authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-02-05 10:50:09+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-04 06:08:09+02:00
log156ab8750056c3ff440af0937806d8cdb2623816
tree26956c58e4d169279885ab94d479f8b9f4285872
parent7ab01c9a42fa0262d67d9ff1a0ecde24fb7031e7
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

libcxx: Update to Clang 20.

See: * https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc/77319 * https://discourse.llvm.org/t/rfc-project-hand-in-hand-llvm-libc-libc-code-sharing/77701 We're dropping support for C++03 for Zig due to the first change; it would be insane to ship 1018 duplicate header files just for this outdated use case. As a result of the second change, I had to bring in a subset of the headers from llvm-libc since libc++ now depends on these. Hopefully we can continue to get away with not copying the entirety of llvm-libc.

1001 files changed, 36835 insertions(+), 19964 deletions(-)

lib/libcxx/include/__algorithm/adjacent_find.h+11-9
...@@ -11,9 +11,9 @@...@@ -11,9 +11,9 @@
11#define _LIBCPP___ALGORITHM_ADJACENT_FIND_H11#define _LIBCPP___ALGORITHM_ADJACENT_FIND_H
1212
13#include <__algorithm/comp.h>13#include <__algorithm/comp.h>
14#include <__algorithm/iterator_operations.h>
15#include <__config>14#include <__config>
16#include <__iterator/iterator_traits.h>15#include <__functional/identity.h>
16#include <__type_traits/invoke.h>
17#include <__utility/move.h>17#include <__utility/move.h>
1818
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -25,14 +25,15 @@ _LIBCPP_PUSH_MACROS...@@ -25,14 +25,15 @@ _LIBCPP_PUSH_MACROS
2525
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28template <class _Iter, class _Sent, class _BinaryPredicate>28template <class _Iter, class _Sent, class _Pred, class _Proj>
29_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter29[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
30__adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {30__adjacent_find(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
31 if (__first == __last)31 if (__first == __last)
32 return __first;32 return __first;
33
33 _Iter __i = __first;34 _Iter __i = __first;
34 while (++__i != __last) {35 while (++__i != __last) {
35 if (__pred(*__first, *__i))36 if (std::__invoke(__pred, std::__invoke(__proj, *__first), std::__invoke(__proj, *__i)))
36 return __first;37 return __first;
37 __first = __i;38 __first = __i;
38 }39 }
...@@ -40,13 +41,14 @@ __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {...@@ -40,13 +41,14 @@ __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
40}41}
4142
42template <class _ForwardIterator, class _BinaryPredicate>43template <class _ForwardIterator, class _BinaryPredicate>
43_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator44[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
44adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {45adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
45 return std::__adjacent_find(std::move(__first), std::move(__last), __pred);46 __identity __proj;
47 return std::__adjacent_find(std::move(__first), std::move(__last), __pred, __proj);
46}48}
4749
48template <class _ForwardIterator>50template <class _ForwardIterator>
49_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator51[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
50adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {52adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
51 return std::adjacent_find(std::move(__first), std::move(__last), __equal_to());53 return std::adjacent_find(std::move(__first), std::move(__last), __equal_to());
52}54}
lib/libcxx/include/__algorithm/all_of.h+15-5
...@@ -11,6 +11,8 @@...@@ -11,6 +11,8 @@
11#define _LIBCPP___ALGORITHM_ALL_OF_H11#define _LIBCPP___ALGORITHM_ALL_OF_H
1212
13#include <__config>13#include <__config>
14#include <__functional/identity.h>
15#include <__type_traits/invoke.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
...@@ -18,15 +20,23 @@...@@ -18,15 +20,23 @@
1820
19_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2022
21template <class _InputIterator, class _Predicate>23template <class _Iter, class _Sent, class _Proj, class _Pred>
22_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
23all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {25__all_of(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
24 for (; __first != __last; ++__first)26 for (; __first != __last; ++__first) {
25 if (!__pred(*__first))27 if (!std::__invoke(__pred, std::__invoke(__proj, *__first)))
26 return false;28 return false;
29 }
27 return true;30 return true;
28}31}
2932
33template <class _InputIterator, class _Predicate>
34[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
35all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
36 __identity __proj;
37 return std::__all_of(__first, __last, __pred, __proj);
38}
39
30_LIBCPP_END_NAMESPACE_STD40_LIBCPP_END_NAMESPACE_STD
3141
32#endif // _LIBCPP___ALGORITHM_ALL_OF_H42#endif // _LIBCPP___ALGORITHM_ALL_OF_H
lib/libcxx/include/__algorithm/any_of.h+15-5
...@@ -11,6 +11,8 @@...@@ -11,6 +11,8 @@
11#define _LIBCPP___ALGORITHM_ANY_OF_H11#define _LIBCPP___ALGORITHM_ANY_OF_H
1212
13#include <__config>13#include <__config>
14#include <__functional/identity.h>
15#include <__type_traits/invoke.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
...@@ -18,15 +20,23 @@...@@ -18,15 +20,23 @@
1820
19_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2022
21template <class _InputIterator, class _Predicate>23template <class _Iter, class _Sent, class _Proj, class _Pred>
22_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
23any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {25__any_of(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
24 for (; __first != __last; ++__first)26 for (; __first != __last; ++__first) {
25 if (__pred(*__first))27 if (std::__invoke(__pred, std::__invoke(__proj, *__first)))
26 return true;28 return true;
29 }
27 return false;30 return false;
28}31}
2932
33template <class _InputIterator, class _Predicate>
34[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
35any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
36 __identity __proj;
37 return std::__any_of(__first, __last, __pred, __proj);
38}
39
30_LIBCPP_END_NAMESPACE_STD40_LIBCPP_END_NAMESPACE_STD
3141
32#endif // _LIBCPP___ALGORITHM_ANY_OF_H42#endif // _LIBCPP___ALGORITHM_ANY_OF_H
lib/libcxx/include/__algorithm/binary_search.h+2-3
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/lower_bound.h>14#include <__algorithm/lower_bound.h>
15#include <__config>15#include <__config>
16#include <__iterator/iterator_traits.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
...@@ -22,14 +21,14 @@...@@ -22,14 +21,14 @@
22_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _ForwardIterator, class _Tp, class _Compare>23template <class _ForwardIterator, class _Tp, class _Compare>
25_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool24[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
26binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {25binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
27 __first = std::lower_bound<_ForwardIterator, _Tp, __comp_ref_type<_Compare> >(__first, __last, __value, __comp);26 __first = std::lower_bound<_ForwardIterator, _Tp, __comp_ref_type<_Compare> >(__first, __last, __value, __comp);
28 return __first != __last && !__comp(__value, *__first);27 return __first != __last && !__comp(__value, *__first);
29}28}
3029
31template <class _ForwardIterator, class _Tp>30template <class _ForwardIterator, class _Tp>
32_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool31[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
33binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {32binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
34 return std::binary_search(__first, __last, __value, __less<>());33 return std::binary_search(__first, __last, __value, __less<>());
35}34}
lib/libcxx/include/__algorithm/comp.h+4
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/desugars_to.h>13#include <__type_traits/desugars_to.h>
14#include <__type_traits/is_integral.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
...@@ -44,6 +45,9 @@ struct __less<void, void> {...@@ -44,6 +45,9 @@ struct __less<void, void> {
44template <class _Tp>45template <class _Tp>
45inline const bool __desugars_to_v<__less_tag, __less<>, _Tp, _Tp> = true;46inline const bool __desugars_to_v<__less_tag, __less<>, _Tp, _Tp> = true;
4647
48template <class _Tp>
49inline const bool __desugars_to_v<__totally_ordered_less_tag, __less<>, _Tp, _Tp> = is_integral<_Tp>::value;
50
47_LIBCPP_END_NAMESPACE_STD51_LIBCPP_END_NAMESPACE_STD
4852
49#endif // _LIBCPP___ALGORITHM_COMP_H53#endif // _LIBCPP___ALGORITHM_COMP_H
lib/libcxx/include/__algorithm/comp_ref_type.h+2-2
...@@ -56,10 +56,10 @@ struct __debug_less {...@@ -56,10 +56,10 @@ struct __debug_less {
56// Pass the comparator by lvalue reference. Or in the debug mode, using a debugging wrapper that stores a reference.56// Pass the comparator by lvalue reference. Or in the debug mode, using a debugging wrapper that stores a reference.
57#if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG57#if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
58template <class _Comp>58template <class _Comp>
59using __comp_ref_type = __debug_less<_Comp>;59using __comp_ref_type _LIBCPP_NODEBUG = __debug_less<_Comp>;
60#else60#else
61template <class _Comp>61template <class _Comp>
62using __comp_ref_type = _Comp&;62using __comp_ref_type _LIBCPP_NODEBUG = _Comp&;
63#endif63#endif
6464
65_LIBCPP_END_NAMESPACE_STD65_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/copy.h+9-10
...@@ -11,11 +11,12 @@...@@ -11,11 +11,12 @@
1111
12#include <__algorithm/copy_move_common.h>12#include <__algorithm/copy_move_common.h>
13#include <__algorithm/for_each_segment.h>13#include <__algorithm/for_each_segment.h>
14#include <__algorithm/iterator_operations.h>
15#include <__algorithm/min.h>14#include <__algorithm/min.h>
16#include <__config>15#include <__config>
16#include <__iterator/iterator_traits.h>
17#include <__iterator/segmented_iterator.h>17#include <__iterator/segmented_iterator.h>
18#include <__type_traits/common_type.h>18#include <__type_traits/common_type.h>
19#include <__type_traits/enable_if.h>
19#include <__utility/move.h>20#include <__utility/move.h>
20#include <__utility/pair.h>21#include <__utility/pair.h>
2122
...@@ -28,10 +29,9 @@ _LIBCPP_PUSH_MACROS...@@ -28,10 +29,9 @@ _LIBCPP_PUSH_MACROS
2829
29_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3031
31template <class, class _InIter, class _Sent, class _OutIter>32template <class _InIter, class _Sent, class _OutIter>
32inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter);33inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter);
3334
34template <class _AlgPolicy>
35struct __copy_impl {35struct __copy_impl {
36 template <class _InIter, class _Sent, class _OutIter>36 template <class _InIter, class _Sent, class _OutIter>
37 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>37 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
...@@ -47,7 +47,7 @@ struct __copy_impl {...@@ -47,7 +47,7 @@ struct __copy_impl {
4747
48 template <class _InIter, class _OutIter>48 template <class _InIter, class _OutIter>
49 struct _CopySegment {49 struct _CopySegment {
50 using _Traits = __segmented_iterator_traits<_InIter>;50 using _Traits _LIBCPP_NODEBUG = __segmented_iterator_traits<_InIter>;
5151
52 _OutIter& __result_;52 _OutIter& __result_;
5353
...@@ -56,7 +56,7 @@ struct __copy_impl {...@@ -56,7 +56,7 @@ struct __copy_impl {
5656
57 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void57 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
58 operator()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) {58 operator()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) {
59 __result_ = std::__copy<_AlgPolicy>(__lfirst, __llast, std::move(__result_)).second;59 __result_ = std::__copy(__lfirst, __llast, std::move(__result_)).second;
60 }60 }
61 };61 };
6262
...@@ -85,7 +85,7 @@ struct __copy_impl {...@@ -85,7 +85,7 @@ struct __copy_impl {
85 while (true) {85 while (true) {
86 auto __local_last = _Traits::__end(__segment_iterator);86 auto __local_last = _Traits::__end(__segment_iterator);
87 auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);87 auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
88 auto __iters = std::__copy<_AlgPolicy>(__first, __first + __size, __local_first);88 auto __iters = std::__copy(__first, __first + __size, __local_first);
89 __first = std::move(__iters.first);89 __first = std::move(__iters.first);
9090
91 if (__first == __last)91 if (__first == __last)
...@@ -103,17 +103,16 @@ struct __copy_impl {...@@ -103,17 +103,16 @@ struct __copy_impl {
103 }103 }
104};104};
105105
106template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>106template <class _InIter, class _Sent, class _OutIter>
107pair<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14107pair<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
108__copy(_InIter __first, _Sent __last, _OutIter __result) {108__copy(_InIter __first, _Sent __last, _OutIter __result) {
109 return std::__copy_move_unwrap_iters<__copy_impl<_AlgPolicy> >(109 return std::__copy_move_unwrap_iters<__copy_impl>(std::move(__first), std::move(__last), std::move(__result));
110 std::move(__first), std::move(__last), std::move(__result));
111}110}
112111
113template <class _InputIterator, class _OutputIterator>112template <class _InputIterator, class _OutputIterator>
114inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator113inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
115copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {114copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
116 return std::__copy<_ClassicAlgPolicy>(__first, __last, __result).second;115 return std::__copy(__first, __last, __result).second;
117}116}
118117
119_LIBCPP_END_NAMESPACE_STD118_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/copy_backward.h+2
...@@ -13,8 +13,10 @@...@@ -13,8 +13,10 @@
13#include <__algorithm/iterator_operations.h>13#include <__algorithm/iterator_operations.h>
14#include <__algorithm/min.h>14#include <__algorithm/min.h>
15#include <__config>15#include <__config>
16#include <__iterator/iterator_traits.h>
16#include <__iterator/segmented_iterator.h>17#include <__iterator/segmented_iterator.h>
17#include <__type_traits/common_type.h>18#include <__type_traits/common_type.h>
19#include <__type_traits/enable_if.h>
18#include <__type_traits/is_constructible.h>20#include <__type_traits/is_constructible.h>
19#include <__utility/move.h>21#include <__utility/move.h>
20#include <__utility/pair.h>22#include <__utility/pair.h>
lib/libcxx/include/__algorithm/copy_if.h+21-5
...@@ -10,25 +10,41 @@...@@ -10,25 +10,41 @@
10#define _LIBCPP___ALGORITHM_COPY_IF_H10#define _LIBCPP___ALGORITHM_COPY_IF_H
1111
12#include <__config>12#include <__config>
13#include <__functional/identity.h>
14#include <__type_traits/invoke.h>
15#include <__utility/move.h>
16#include <__utility/pair.h>
1317
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header19# pragma GCC system_header
16#endif20#endif
1721
22_LIBCPP_PUSH_MACROS
23#include <__undef_macros>
24
18_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
1926
20template <class _InputIterator, class _OutputIterator, class _Predicate>27template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred>
21inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
22copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) {29__copy_if(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) {
23 for (; __first != __last; ++__first) {30 for (; __first != __last; ++__first) {
24 if (__pred(*__first)) {31 if (std::__invoke(__pred, std::__invoke(__proj, *__first))) {
25 *__result = *__first;32 *__result = *__first;
26 ++__result;33 ++__result;
27 }34 }
28 }35 }
29 return __result;36 return std::make_pair(std::move(__first), std::move(__result));
37}
38
39template <class _InputIterator, class _OutputIterator, class _Predicate>
40inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
41copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) {
42 __identity __proj;
43 return std::__copy_if(__first, __last, __result, __pred, __proj).second;
30}44}
3145
32_LIBCPP_END_NAMESPACE_STD46_LIBCPP_END_NAMESPACE_STD
3347
48_LIBCPP_POP_MACROS
49
34#endif // _LIBCPP___ALGORITHM_COPY_IF_H50#endif // _LIBCPP___ALGORITHM_COPY_IF_H
lib/libcxx/include/__algorithm/copy_move_common.h+1-2
...@@ -9,10 +9,10 @@...@@ -9,10 +9,10 @@
9#ifndef _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H9#ifndef _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H
10#define _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H10#define _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H
1111
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/unwrap_iter.h>12#include <__algorithm/unwrap_iter.h>
14#include <__algorithm/unwrap_range.h>13#include <__algorithm/unwrap_range.h>
15#include <__config>14#include <__config>
15#include <__cstddef/size_t.h>
16#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
17#include <__memory/pointer_traits.h>17#include <__memory/pointer_traits.h>
18#include <__string/constexpr_c_functions.h>18#include <__string/constexpr_c_functions.h>
...@@ -24,7 +24,6 @@...@@ -24,7 +24,6 @@
24#include <__type_traits/is_volatile.h>24#include <__type_traits/is_volatile.h>
25#include <__utility/move.h>25#include <__utility/move.h>
26#include <__utility/pair.h>26#include <__utility/pair.h>
27#include <cstddef>
2827
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header29# pragma GCC system_header
lib/libcxx/include/__algorithm/count.h+8-5
...@@ -16,9 +16,10 @@...@@ -16,9 +16,10 @@
16#include <__bit/popcount.h>16#include <__bit/popcount.h>
17#include <__config>17#include <__config>
18#include <__functional/identity.h>18#include <__functional/identity.h>
19#include <__functional/invoke.h>
20#include <__fwd/bit_reference.h>19#include <__fwd/bit_reference.h>
21#include <__iterator/iterator_traits.h>20#include <__iterator/iterator_traits.h>
21#include <__type_traits/enable_if.h>
22#include <__type_traits/invoke.h>
2223
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header25# pragma GCC system_header
...@@ -43,7 +44,7 @@ __count(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {...@@ -43,7 +44,7 @@ __count(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
43// __bit_iterator implementation44// __bit_iterator implementation
44template <bool _ToCount, class _Cp, bool _IsConst>45template <bool _ToCount, class _Cp, bool _IsConst>
45_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bit_iterator<_Cp, _IsConst>::difference_type46_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bit_iterator<_Cp, _IsConst>::difference_type
46__count_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) {47__count_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_type_traits<_Cp>::size_type __n) {
47 using _It = __bit_iterator<_Cp, _IsConst>;48 using _It = __bit_iterator<_Cp, _IsConst>;
48 using __storage_type = typename _It::__storage_type;49 using __storage_type = typename _It::__storage_type;
49 using difference_type = typename _It::difference_type;50 using difference_type = typename _It::difference_type;
...@@ -74,12 +75,14 @@ template <class, class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t...@@ -74,12 +75,14 @@ template <class, class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t
74_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<__bit_iterator<_Cp, _IsConst> >75_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<__bit_iterator<_Cp, _IsConst> >
75__count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) {76__count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) {
76 if (__value)77 if (__value)
77 return std::__count_bool<true>(__first, static_cast<typename _Cp::size_type>(__last - __first));78 return std::__count_bool<true>(
78 return std::__count_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first));79 __first, static_cast<typename __size_difference_type_traits<_Cp>::size_type>(__last - __first));
80 return std::__count_bool<false>(
81 __first, static_cast<typename __size_difference_type_traits<_Cp>::size_type>(__last - __first));
79}82}
8083
81template <class _InputIterator, class _Tp>84template <class _InputIterator, class _Tp>
82_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator>85[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator>
83count(_InputIterator __first, _InputIterator __last, const _Tp& __value) {86count(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
84 __identity __proj;87 __identity __proj;
85 return std::__count<_ClassicAlgPolicy>(__first, __last, __value, __proj);88 return std::__count<_ClassicAlgPolicy>(__first, __last, __value, __proj);
lib/libcxx/include/__algorithm/count_if.h+17-6
...@@ -10,8 +10,11 @@...@@ -10,8 +10,11 @@
10#ifndef _LIBCPP___ALGORITHM_COUNT_IF_H10#ifndef _LIBCPP___ALGORITHM_COUNT_IF_H
11#define _LIBCPP___ALGORITHM_COUNT_IF_H11#define _LIBCPP___ALGORITHM_COUNT_IF_H
1212
13#include <__algorithm/iterator_operations.h>
13#include <__config>14#include <__config>
15#include <__functional/identity.h>
14#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
17#include <__type_traits/invoke.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
...@@ -19,15 +22,23 @@...@@ -19,15 +22,23 @@
1922
20_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2124
25template <class _AlgPolicy, class _Iter, class _Sent, class _Proj, class _Pred>
26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __policy_iter_diff_t<_AlgPolicy, _Iter>
27__count_if(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
28 __policy_iter_diff_t<_AlgPolicy, _Iter> __counter(0);
29 for (; __first != __last; ++__first) {
30 if (std::__invoke(__pred, std::__invoke(__proj, *__first)))
31 ++__counter;
32 }
33 return __counter;
34}
35
22template <class _InputIterator, class _Predicate>36template <class _InputIterator, class _Predicate>
23_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX2037[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
24typename iterator_traits<_InputIterator>::difference_type38typename iterator_traits<_InputIterator>::difference_type
25count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {39count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
26 typename iterator_traits<_InputIterator>::difference_type __r(0);40 __identity __proj;
27 for (; __first != __last; ++__first)41 return std::__count_if<_ClassicAlgPolicy>(__first, __last, __pred, __proj);
28 if (__pred(*__first))
29 ++__r;
30 return __r;
31}42}
3243
33_LIBCPP_END_NAMESPACE_STD44_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/equal.h+9-10
...@@ -14,13 +14,12 @@...@@ -14,13 +14,12 @@
14#include <__algorithm/unwrap_iter.h>14#include <__algorithm/unwrap_iter.h>
15#include <__config>15#include <__config>
16#include <__functional/identity.h>16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__iterator/distance.h>17#include <__iterator/distance.h>
19#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
20#include <__string/constexpr_c_functions.h>19#include <__string/constexpr_c_functions.h>
21#include <__type_traits/desugars_to.h>20#include <__type_traits/desugars_to.h>
22#include <__type_traits/enable_if.h>21#include <__type_traits/enable_if.h>
23#include <__type_traits/is_constant_evaluated.h>22#include <__type_traits/invoke.h>
24#include <__type_traits/is_equality_comparable.h>23#include <__type_traits/is_equality_comparable.h>
25#include <__type_traits/is_volatile.h>24#include <__type_traits/is_volatile.h>
26#include <__utility/move.h>25#include <__utility/move.h>
...@@ -35,7 +34,7 @@ _LIBCPP_PUSH_MACROS...@@ -35,7 +34,7 @@ _LIBCPP_PUSH_MACROS
35_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3635
37template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>36template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
38_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl(37[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl(
39 _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate& __pred) {38 _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate& __pred) {
40 for (; __first1 != __last1; ++__first1, (void)++__first2)39 for (; __first1 != __last1; ++__first1, (void)++__first2)
41 if (!__pred(*__first1, *__first2))40 if (!__pred(*__first1, *__first2))
...@@ -49,20 +48,20 @@ template <class _Tp,...@@ -49,20 +48,20 @@ template <class _Tp,
49 __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, _Tp, _Up> && !is_volatile<_Tp>::value &&48 __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, _Tp, _Up> && !is_volatile<_Tp>::value &&
50 !is_volatile<_Up>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,49 !is_volatile<_Up>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
51 int> = 0>50 int> = 0>
52_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool51[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
53__equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _BinaryPredicate&) {52__equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _BinaryPredicate&) {
54 return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));53 return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));
55}54}
5655
57template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>56template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
58_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool57[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
59equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {58equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
60 return std::__equal_iter_impl(59 return std::__equal_iter_impl(
61 std::__unwrap_iter(__first1), std::__unwrap_iter(__last1), std::__unwrap_iter(__first2), __pred);60 std::__unwrap_iter(__first1), std::__unwrap_iter(__last1), std::__unwrap_iter(__first2), __pred);
62}61}
6362
64template <class _InputIterator1, class _InputIterator2>63template <class _InputIterator1, class _InputIterator2>
65_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool64[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
66equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {65equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
67 return std::equal(__first1, __last1, __first2, __equal_to());66 return std::equal(__first1, __last1, __first2, __equal_to());
68}67}
...@@ -70,7 +69,7 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first...@@ -70,7 +69,7 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
70#if _LIBCPP_STD_VER >= 1469#if _LIBCPP_STD_VER >= 14
7170
72template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>71template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
73_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl(72[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl(
74 _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __comp, _Proj1& __proj1, _Proj2& __proj2) {73 _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __comp, _Proj1& __proj1, _Proj2& __proj2) {
75 while (__first1 != __last1 && __first2 != __last2) {74 while (__first1 != __last1 && __first2 != __last2) {
76 if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))75 if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
...@@ -90,13 +89,13 @@ template <class _Tp,...@@ -90,13 +89,13 @@ template <class _Tp,
90 __is_identity<_Proj2>::value && !is_volatile<_Tp>::value && !is_volatile<_Up>::value &&89 __is_identity<_Proj2>::value && !is_volatile<_Tp>::value && !is_volatile<_Up>::value &&
91 __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,90 __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
92 int> = 0>91 int> = 0>
93_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool92[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
94__equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, _Proj2&) {93__equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, _Proj2&) {
95 return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));94 return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));
96}95}
9796
98template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>97template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
99_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool98[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
100equal(_InputIterator1 __first1,99equal(_InputIterator1 __first1,
101 _InputIterator1 __last1,100 _InputIterator1 __last1,
102 _InputIterator2 __first2,101 _InputIterator2 __first2,
...@@ -119,7 +118,7 @@ equal(_InputIterator1 __first1,...@@ -119,7 +118,7 @@ equal(_InputIterator1 __first1,
119}118}
120119
121template <class _InputIterator1, class _InputIterator2>120template <class _InputIterator1, class _InputIterator2>
122_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool121[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
123equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {122equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
124 return std::equal(__first1, __last1, __first2, __last2, __equal_to());123 return std::equal(__first1, __last1, __first2, __last2, __equal_to());
125}124}
lib/libcxx/include/__algorithm/equal_range.h+4-8
...@@ -17,11 +17,7 @@...@@ -17,11 +17,7 @@
17#include <__algorithm/upper_bound.h>17#include <__algorithm/upper_bound.h>
18#include <__config>18#include <__config>
19#include <__functional/identity.h>19#include <__functional/identity.h>
20#include <__functional/invoke.h>20#include <__type_traits/invoke.h>
21#include <__iterator/advance.h>
22#include <__iterator/distance.h>
23#include <__iterator/iterator_traits.h>
24#include <__iterator/next.h>
25#include <__type_traits/is_callable.h>21#include <__type_traits/is_callable.h>
26#include <__type_traits/is_constructible.h>22#include <__type_traits/is_constructible.h>
27#include <__utility/move.h>23#include <__utility/move.h>
...@@ -60,9 +56,9 @@ __equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp...@@ -60,9 +56,9 @@ __equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp
60}56}
6157
62template <class _ForwardIterator, class _Tp, class _Compare>58template <class _ForwardIterator, class _Tp, class _Compare>
63_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>59[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>
64equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {60equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
65 static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, "The comparator has to be callable");61 static_assert(__is_callable<_Compare&, decltype(*__first), const _Tp&>::value, "The comparator has to be callable");
66 static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible");62 static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible");
67 return std::__equal_range<_ClassicAlgPolicy>(63 return std::__equal_range<_ClassicAlgPolicy>(
68 std::move(__first),64 std::move(__first),
...@@ -73,7 +69,7 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu...@@ -73,7 +69,7 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
73}69}
7470
75template <class _ForwardIterator, class _Tp>71template <class _ForwardIterator, class _Tp>
76_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>72[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>
77equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {73equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
78 return std::equal_range(std::move(__first), std::move(__last), __value, __less<>());74 return std::equal_range(std::move(__first), std::move(__last), __value, __less<>());
79}75}
lib/libcxx/include/__algorithm/fill_n.h+1-2
...@@ -12,7 +12,6 @@...@@ -12,7 +12,6 @@
12#include <__algorithm/min.h>12#include <__algorithm/min.h>
13#include <__config>13#include <__config>
14#include <__fwd/bit_reference.h>14#include <__fwd/bit_reference.h>
15#include <__iterator/iterator_traits.h>
16#include <__memory/pointer_traits.h>15#include <__memory/pointer_traits.h>
17#include <__utility/convert_to_integral.h>16#include <__utility/convert_to_integral.h>
1817
...@@ -33,7 +32,7 @@ __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value);...@@ -33,7 +32,7 @@ __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value);
3332
34template <bool _FillVal, class _Cp>33template <bool _FillVal, class _Cp>
35_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void34_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
36__fill_n_bool(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) {35__fill_n_bool(__bit_iterator<_Cp, false> __first, typename __size_difference_type_traits<_Cp>::size_type __n) {
37 using _It = __bit_iterator<_Cp, false>;36 using _It = __bit_iterator<_Cp, false>;
38 using __storage_type = typename _It::__storage_type;37 using __storage_type = typename _It::__storage_type;
3938
lib/libcxx/include/__algorithm/find.h+12-9
...@@ -17,17 +17,18 @@...@@ -17,17 +17,18 @@
17#include <__bit/invert_if.h>17#include <__bit/invert_if.h>
18#include <__config>18#include <__config>
19#include <__functional/identity.h>19#include <__functional/identity.h>
20#include <__functional/invoke.h>
21#include <__fwd/bit_reference.h>20#include <__fwd/bit_reference.h>
22#include <__iterator/segmented_iterator.h>21#include <__iterator/segmented_iterator.h>
23#include <__string/constexpr_c_functions.h>22#include <__string/constexpr_c_functions.h>
23#include <__type_traits/enable_if.h>
24#include <__type_traits/invoke.h>
25#include <__type_traits/is_equality_comparable.h>
24#include <__type_traits/is_integral.h>26#include <__type_traits/is_integral.h>
25#include <__type_traits/is_same.h>
26#include <__type_traits/is_signed.h>27#include <__type_traits/is_signed.h>
27#include <__utility/move.h>28#include <__utility/move.h>
28#include <limits>29#include <limits>
2930
30#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS31#if _LIBCPP_HAS_WIDE_CHARACTERS
31# include <cwchar>32# include <cwchar>
32#endif33#endif
3334
...@@ -63,7 +64,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _T...@@ -63,7 +64,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _T
63 return __last;64 return __last;
64}65}
6566
66#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS67#if _LIBCPP_HAS_WIDE_CHARACTERS
67template <class _Tp,68template <class _Tp,
68 class _Up,69 class _Up,
69 class _Proj,70 class _Proj,
...@@ -75,7 +76,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _T...@@ -75,7 +76,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _T
75 return __ret;76 return __ret;
76 return __last;77 return __last;
77}78}
78#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS79#endif // _LIBCPP_HAS_WIDE_CHARACTERS
7980
80// TODO: This should also be possible to get right with different signedness81// TODO: This should also be possible to get right with different signedness
81// cast integral types to allow vectorization82// cast integral types to allow vectorization
...@@ -96,7 +97,7 @@ __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj& __proj) {...@@ -96,7 +97,7 @@ __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj& __proj) {
96// __bit_iterator implementation97// __bit_iterator implementation
97template <bool _ToFind, class _Cp, bool _IsConst>98template <bool _ToFind, class _Cp, bool _IsConst>
98_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, _IsConst>99_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, _IsConst>
99__find_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) {100__find_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_type_traits<_Cp>::size_type __n) {
100 using _It = __bit_iterator<_Cp, _IsConst>;101 using _It = __bit_iterator<_Cp, _IsConst>;
101 using __storage_type = typename _It::__storage_type;102 using __storage_type = typename _It::__storage_type;
102103
...@@ -134,8 +135,10 @@ template <class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t<__is_i...@@ -134,8 +135,10 @@ template <class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t<__is_i
134inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, _IsConst>135inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, _IsConst>
135__find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) {136__find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) {
136 if (static_cast<bool>(__value))137 if (static_cast<bool>(__value))
137 return std::__find_bool<true>(__first, static_cast<typename _Cp::size_type>(__last - __first));138 return std::__find_bool<true>(
138 return std::__find_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first));139 __first, static_cast<typename __size_difference_type_traits<_Cp>::size_type>(__last - __first));
140 return std::__find_bool<false>(
141 __first, static_cast<typename __size_difference_type_traits<_Cp>::size_type>(__last - __first));
139}142}
140143
141// segmented iterator implementation144// segmented iterator implementation
...@@ -167,7 +170,7 @@ struct __find_segment {...@@ -167,7 +170,7 @@ struct __find_segment {
167170
168// public API171// public API
169template <class _InputIterator, class _Tp>172template <class _InputIterator, class _Tp>
170_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator173[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
171find(_InputIterator __first, _InputIterator __last, const _Tp& __value) {174find(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
172 __identity __proj;175 __identity __proj;
173 return std::__rewrap_iter(176 return std::__rewrap_iter(
lib/libcxx/include/__algorithm/find_end.h+4-111
...@@ -12,14 +12,10 @@...@@ -12,14 +12,10 @@
1212
13#include <__algorithm/comp.h>13#include <__algorithm/comp.h>
14#include <__algorithm/iterator_operations.h>14#include <__algorithm/iterator_operations.h>
15#include <__algorithm/search.h>
16#include <__config>15#include <__config>
17#include <__functional/identity.h>16#include <__functional/identity.h>
18#include <__functional/invoke.h>
19#include <__iterator/advance.h>
20#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
21#include <__iterator/next.h>18#include <__type_traits/invoke.h>
22#include <__iterator/reverse_iterator.h>
23#include <__utility/pair.h>19#include <__utility/pair.h>
2420
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -80,111 +76,8 @@ _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1>...@@ -80,111 +76,8 @@ _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1>
80 }76 }
81}77}
8278
83template < class _IterOps,
84 class _Pred,
85 class _Iter1,
86 class _Sent1,
87 class _Iter2,
88 class _Sent2,
89 class _Proj1,
90 class _Proj2>
91_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter1 __find_end(
92 _Iter1 __first1,
93 _Sent1 __sent1,
94 _Iter2 __first2,
95 _Sent2 __sent2,
96 _Pred& __pred,
97 _Proj1& __proj1,
98 _Proj2& __proj2,
99 bidirectional_iterator_tag,
100 bidirectional_iterator_tag) {
101 auto __last1 = _IterOps::next(__first1, __sent1);
102 auto __last2 = _IterOps::next(__first2, __sent2);
103 // modeled after search algorithm (in reverse)
104 if (__first2 == __last2)
105 return __last1; // Everything matches an empty sequence
106 _Iter1 __l1 = __last1;
107 _Iter2 __l2 = __last2;
108 --__l2;
109 while (true) {
110 // Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks
111 while (true) {
112 if (__first1 == __l1) // return __last1 if no element matches *__first2
113 return __last1;
114 if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2)))
115 break;
116 }
117 // *__l1 matches *__l2, now match elements before here
118 _Iter1 __m1 = __l1;
119 _Iter2 __m2 = __l2;
120 while (true) {
121 if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern)
122 return __m1;
123 if (__m1 == __first1) // Otherwise if source exhaused, pattern not found
124 return __last1;
125
126 // if there is a mismatch, restart with a new __l1
127 if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(__proj2, *--__m2))) {
128 break;
129 } // else there is a match, check next elements
130 }
131 }
132}
133
134template < class _AlgPolicy,
135 class _Pred,
136 class _Iter1,
137 class _Sent1,
138 class _Iter2,
139 class _Sent2,
140 class _Proj1,
141 class _Proj2>
142_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter1 __find_end(
143 _Iter1 __first1,
144 _Sent1 __sent1,
145 _Iter2 __first2,
146 _Sent2 __sent2,
147 _Pred& __pred,
148 _Proj1& __proj1,
149 _Proj2& __proj2,
150 random_access_iterator_tag,
151 random_access_iterator_tag) {
152 typedef typename iterator_traits<_Iter1>::difference_type _D1;
153 auto __last1 = _IterOps<_AlgPolicy>::next(__first1, __sent1);
154 auto __last2 = _IterOps<_AlgPolicy>::next(__first2, __sent2);
155 // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
156 auto __len2 = __last2 - __first2;
157 if (__len2 == 0)
158 return __last1;
159 auto __len1 = __last1 - __first1;
160 if (__len1 < __len2)
161 return __last1;
162 const _Iter1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here
163 _Iter1 __l1 = __last1;
164 _Iter2 __l2 = __last2;
165 --__l2;
166 while (true) {
167 while (true) {
168 if (__s == __l1)
169 return __last1;
170 if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2)))
171 break;
172 }
173 _Iter1 __m1 = __l1;
174 _Iter2 __m2 = __l2;
175 while (true) {
176 if (__m2 == __first2)
177 return __m1;
178 // no need to check range on __m1 because __s guarantees we have enough source
179 if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(*--__m2))) {
180 break;
181 }
182 }
183 }
184}
185
186template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>79template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
187_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_end_classic(80[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_end_classic(
188 _ForwardIterator1 __first1,81 _ForwardIterator1 __first1,
189 _ForwardIterator1 __last1,82 _ForwardIterator1 __last1,
190 _ForwardIterator2 __first2,83 _ForwardIterator2 __first2,
...@@ -205,7 +98,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Fo...@@ -205,7 +98,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Fo
205}98}
20699
207template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>100template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
208_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_end(101[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_end(
209 _ForwardIterator1 __first1,102 _ForwardIterator1 __first1,
210 _ForwardIterator1 __last1,103 _ForwardIterator1 __last1,
211 _ForwardIterator2 __first2,104 _ForwardIterator2 __first2,
...@@ -215,7 +108,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Fo...@@ -215,7 +108,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Fo
215}108}
216109
217template <class _ForwardIterator1, class _ForwardIterator2>110template <class _ForwardIterator1, class _ForwardIterator2>
218_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1111[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
219find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {112find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
220 return std::find_end(__first1, __last1, __first2, __last2, __equal_to());113 return std::find_end(__first1, __last1, __first2, __last2, __equal_to());
221}114}
lib/libcxx/include/__algorithm/find_first_of.h+2-3
...@@ -12,7 +12,6 @@...@@ -12,7 +12,6 @@
1212
13#include <__algorithm/comp.h>13#include <__algorithm/comp.h>
14#include <__config>14#include <__config>
15#include <__iterator/iterator_traits.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
...@@ -35,7 +34,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_fir...@@ -35,7 +34,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_fir
35}34}
3635
37template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>36template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
38_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of(37[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of(
39 _ForwardIterator1 __first1,38 _ForwardIterator1 __first1,
40 _ForwardIterator1 __last1,39 _ForwardIterator1 __last1,
41 _ForwardIterator2 __first2,40 _ForwardIterator2 __first2,
...@@ -45,7 +44,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Fo...@@ -45,7 +44,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Fo
45}44}
4645
47template <class _ForwardIterator1, class _ForwardIterator2>46template <class _ForwardIterator1, class _ForwardIterator2>
48_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of(47[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of(
49 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {48 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
50 return std::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to());49 return std::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to());
51}50}
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 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator22[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _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 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator22[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _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/fold.h deleted-128
...@@ -1,128 +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___ALGORITHM_FOLD_H
11#define _LIBCPP___ALGORITHM_FOLD_H
12
13#include <__concepts/assignable.h>
14#include <__concepts/convertible_to.h>
15#include <__concepts/invocable.h>
16#include <__concepts/movable.h>
17#include <__config>
18#include <__functional/invoke.h>
19#include <__functional/reference_wrapper.h>
20#include <__iterator/concepts.h>
21#include <__iterator/iterator_traits.h>
22#include <__iterator/next.h>
23#include <__ranges/access.h>
24#include <__ranges/concepts.h>
25#include <__ranges/dangling.h>
26#include <__type_traits/decay.h>
27#include <__type_traits/invoke.h>
28#include <__utility/forward.h>
29#include <__utility/move.h>
30
31#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
32# pragma GCC system_header
33#endif
34
35_LIBCPP_PUSH_MACROS
36#include <__undef_macros>
37
38_LIBCPP_BEGIN_NAMESPACE_STD
39
40#if _LIBCPP_STD_VER >= 23
41
42namespace ranges {
43template <class _Ip, class _Tp>
44struct in_value_result {
45 _LIBCPP_NO_UNIQUE_ADDRESS _Ip in;
46 _LIBCPP_NO_UNIQUE_ADDRESS _Tp value;
47
48 template <class _I2, class _T2>
49 requires convertible_to<const _Ip&, _I2> && convertible_to<const _Tp&, _T2>
50 _LIBCPP_HIDE_FROM_ABI constexpr operator in_value_result<_I2, _T2>() const& {
51 return {in, value};
52 }
53
54 template <class _I2, class _T2>
55 requires convertible_to<_Ip, _I2> && convertible_to<_Tp, _T2>
56 _LIBCPP_HIDE_FROM_ABI constexpr operator in_value_result<_I2, _T2>() && {
57 return {std::move(in), std::move(value)};
58 }
59};
60
61template <class _Ip, class _Tp>
62using fold_left_with_iter_result = in_value_result<_Ip, _Tp>;
63
64template <class _Fp, class _Tp, class _Ip, class _Rp, class _Up = decay_t<_Rp>>
65concept __indirectly_binary_left_foldable_impl =
66 convertible_to<_Rp, _Up> && //
67 movable<_Tp> && //
68 movable<_Up> && //
69 convertible_to<_Tp, _Up> && //
70 invocable<_Fp&, _Up, iter_reference_t<_Ip>> && //
71 assignable_from<_Up&, invoke_result_t<_Fp&, _Up, iter_reference_t<_Ip>>>;
72
73template <class _Fp, class _Tp, class _Ip>
74concept __indirectly_binary_left_foldable =
75 copy_constructible<_Fp> && //
76 invocable<_Fp&, _Tp, iter_reference_t<_Ip>> && //
77 __indirectly_binary_left_foldable_impl<_Fp, _Tp, _Ip, invoke_result_t<_Fp&, _Tp, iter_reference_t<_Ip>>>;
78
79struct __fold_left_with_iter {
80 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp>
81 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) {
82 using _Up = decay_t<invoke_result_t<_Fp&, _Tp, iter_reference_t<_Ip>>>;
83
84 if (__first == __last) {
85 return fold_left_with_iter_result<_Ip, _Up>{std::move(__first), _Up(std::move(__init))};
86 }
87
88 _Up __result = std::invoke(__f, std::move(__init), *__first);
89 for (++__first; __first != __last; ++__first) {
90 __result = std::invoke(__f, std::move(__result), *__first);
91 }
92
93 return fold_left_with_iter_result<_Ip, _Up>{std::move(__first), std::move(__result)};
94 }
95
96 template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp>
97 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) {
98 auto __result = operator()(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f));
99
100 using _Up = decay_t<invoke_result_t<_Fp&, _Tp, range_reference_t<_Rp>>>;
101 return fold_left_with_iter_result<borrowed_iterator_t<_Rp>, _Up>{std::move(__result.in), std::move(__result.value)};
102 }
103};
104
105inline constexpr auto fold_left_with_iter = __fold_left_with_iter();
106
107struct __fold_left {
108 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp>
109 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) {
110 return fold_left_with_iter(std::move(__first), std::move(__last), std::move(__init), std::ref(__f)).value;
111 }
112
113 template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp>
114 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) {
115 return fold_left_with_iter(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f)).value;
116 }
117};
118
119inline constexpr auto fold_left = __fold_left();
120} // namespace ranges
121
122#endif // _LIBCPP_STD_VER >= 23
123
124_LIBCPP_END_NAMESPACE_STD
125
126_LIBCPP_POP_MACROS
127
128#endif // _LIBCPP___ALGORITHM_FOLD_H
lib/libcxx/include/__algorithm/for_each.h-1
...@@ -14,7 +14,6 @@...@@ -14,7 +14,6 @@
14#include <__config>14#include <__config>
15#include <__iterator/segmented_iterator.h>15#include <__iterator/segmented_iterator.h>
16#include <__ranges/movable_box.h>16#include <__ranges/movable_box.h>
17#include <__type_traits/enable_if.h>
18#include <__utility/in_place.h>17#include <__utility/in_place.h>
19#include <__utility/move.h>18#include <__utility/move.h>
2019
lib/libcxx/include/__algorithm/includes.h+4-5
...@@ -13,8 +13,7 @@...@@ -13,8 +13,7 @@
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__config>14#include <__config>
15#include <__functional/identity.h>15#include <__functional/identity.h>
16#include <__functional/invoke.h>16#include <__type_traits/invoke.h>
17#include <__iterator/iterator_traits.h>
18#include <__type_traits/is_callable.h>17#include <__type_traits/is_callable.h>
19#include <__utility/move.h>18#include <__utility/move.h>
2019
...@@ -47,14 +46,14 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __includes(...@@ -47,14 +46,14 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __includes(
47}46}
4847
49template <class _InputIterator1, class _InputIterator2, class _Compare>48template <class _InputIterator1, class _InputIterator2, class _Compare>
50_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool49[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
51includes(_InputIterator1 __first1,50includes(_InputIterator1 __first1,
52 _InputIterator1 __last1,51 _InputIterator1 __last1,
53 _InputIterator2 __first2,52 _InputIterator2 __first2,
54 _InputIterator2 __last2,53 _InputIterator2 __last2,
55 _Compare __comp) {54 _Compare __comp) {
56 static_assert(55 static_assert(
57 __is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value, "Comparator has to be callable");56 __is_callable<_Compare&, decltype(*__first1), decltype(*__first2)>::value, "The comparator has to be callable");
5857
59 return std::__includes(58 return std::__includes(
60 std::move(__first1),59 std::move(__first1),
...@@ -67,7 +66,7 @@ includes(_InputIterator1 __first1,...@@ -67,7 +66,7 @@ includes(_InputIterator1 __first1,
67}66}
6867
69template <class _InputIterator1, class _InputIterator2>68template <class _InputIterator1, class _InputIterator2>
70_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool69[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
71includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {70includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
72 return std::includes(std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __less<>());71 return std::includes(std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __less<>());
73}72}
lib/libcxx/include/__algorithm/inplace_merge.h+22-20
...@@ -18,16 +18,15 @@...@@ -18,16 +18,15 @@
18#include <__algorithm/rotate.h>18#include <__algorithm/rotate.h>
19#include <__algorithm/upper_bound.h>19#include <__algorithm/upper_bound.h>
20#include <__config>20#include <__config>
21#include <__cstddef/ptrdiff_t.h>
21#include <__functional/identity.h>22#include <__functional/identity.h>
22#include <__iterator/advance.h>
23#include <__iterator/distance.h>
24#include <__iterator/iterator_traits.h>23#include <__iterator/iterator_traits.h>
25#include <__iterator/reverse_iterator.h>24#include <__iterator/reverse_iterator.h>
26#include <__memory/destruct_n.h>25#include <__memory/destruct_n.h>
27#include <__memory/temporary_buffer.h>
28#include <__memory/unique_ptr.h>26#include <__memory/unique_ptr.h>
27#include <__memory/unique_temporary_buffer.h>
28#include <__utility/move.h>
29#include <__utility/pair.h>29#include <__utility/pair.h>
30#include <new>
3130
32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)31#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
33# pragma GCC system_header32# pragma GCC system_header
...@@ -45,17 +44,17 @@ private:...@@ -45,17 +44,17 @@ private:
45 _Predicate __p_;44 _Predicate __p_;
4645
47public:46public:
48 _LIBCPP_HIDE_FROM_ABI __invert() {}47 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __invert() {}
4948
50 _LIBCPP_HIDE_FROM_ABI explicit __invert(_Predicate __p) : __p_(__p) {}49 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __invert(_Predicate __p) : __p_(__p) {}
5150
52 template <class _T1>51 template <class _T1>
53 _LIBCPP_HIDE_FROM_ABI bool operator()(const _T1& __x) {52 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _T1& __x) {
54 return !__p_(__x);53 return !__p_(__x);
55 }54 }
5655
57 template <class _T1, class _T2>56 template <class _T1, class _T2>
58 _LIBCPP_HIDE_FROM_ABI bool operator()(const _T1& __x, const _T2& __y) {57 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _T1& __x, const _T2& __y) {
59 return __p_(__y, __x);58 return __p_(__y, __x);
60 }59 }
61};60};
...@@ -67,7 +66,7 @@ template <class _AlgPolicy,...@@ -67,7 +66,7 @@ template <class _AlgPolicy,
67 class _InputIterator2,66 class _InputIterator2,
68 class _Sent2,67 class _Sent2,
69 class _OutputIterator>68 class _OutputIterator>
70_LIBCPP_HIDE_FROM_ABI void __half_inplace_merge(69_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __half_inplace_merge(
71 _InputIterator1 __first1,70 _InputIterator1 __first1,
72 _Sent1 __last1,71 _Sent1 __last1,
73 _InputIterator2 __first2,72 _InputIterator2 __first2,
...@@ -92,7 +91,7 @@ _LIBCPP_HIDE_FROM_ABI void __half_inplace_merge(...@@ -92,7 +91,7 @@ _LIBCPP_HIDE_FROM_ABI void __half_inplace_merge(
92}91}
9392
94template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>93template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
95_LIBCPP_HIDE_FROM_ABI void __buffered_inplace_merge(94_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __buffered_inplace_merge(
96 _BidirectionalIterator __first,95 _BidirectionalIterator __first,
97 _BidirectionalIterator __middle,96 _BidirectionalIterator __middle,
98 _BidirectionalIterator __last,97 _BidirectionalIterator __last,
...@@ -123,7 +122,7 @@ _LIBCPP_HIDE_FROM_ABI void __buffered_inplace_merge(...@@ -123,7 +122,7 @@ _LIBCPP_HIDE_FROM_ABI void __buffered_inplace_merge(
123}122}
124123
125template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>124template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
126void __inplace_merge(125_LIBCPP_CONSTEXPR_SINCE_CXX26 void __inplace_merge(
127 _BidirectionalIterator __first,126 _BidirectionalIterator __first,
128 _BidirectionalIterator __middle,127 _BidirectionalIterator __middle,
129 _BidirectionalIterator __last,128 _BidirectionalIterator __last,
...@@ -208,16 +207,19 @@ _LIBCPP_HIDE_FROM_ABI void __inplace_merge(...@@ -208,16 +207,19 @@ _LIBCPP_HIDE_FROM_ABI void __inplace_merge(
208 _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare&& __comp) {207 _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare&& __comp) {
209 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;208 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
210 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;209 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
211 difference_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle);210 difference_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle);
212 difference_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last);211 difference_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last);
213 difference_type __buf_size = std::min(__len1, __len2);212 difference_type __buf_size = std::min(__len1, __len2);
214 // TODO: Remove the use of std::get_temporary_buffer213 __unique_temporary_buffer<value_type> __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__buf_size);
215 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
216 pair<value_type*, ptrdiff_t> __buf = std::get_temporary_buffer<value_type>(__buf_size);
217 _LIBCPP_SUPPRESS_DEPRECATED_POP
218 unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);
219 return std::__inplace_merge<_AlgPolicy>(214 return std::__inplace_merge<_AlgPolicy>(
220 std::move(__first), std::move(__middle), std::move(__last), __comp, __len1, __len2, __buf.first, __buf.second);215 std::move(__first),
216 std::move(__middle),
217 std::move(__last),
218 __comp,
219 __len1,
220 __len2,
221 __unique_buf.get(),
222 __unique_buf.get_deleter().__count_);
221}223}
222224
223template <class _BidirectionalIterator, class _Compare>225template <class _BidirectionalIterator, class _Compare>
lib/libcxx/include/__algorithm/is_heap.h+2-3
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/is_heap_until.h>14#include <__algorithm/is_heap_until.h>
15#include <__config>15#include <__config>
16#include <__iterator/iterator_traits.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
...@@ -22,13 +21,13 @@...@@ -22,13 +21,13 @@
22_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _RandomAccessIterator, class _Compare>23template <class _RandomAccessIterator, class _Compare>
25_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool24[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
26is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {25is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
27 return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)) == __last;26 return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)) == __last;
28}27}
2928
30template <class _RandomAccessIterator>29template <class _RandomAccessIterator>
31_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool30[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
32is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {31is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
33 return std::is_heap(__first, __last, __less<>());32 return std::is_heap(__first, __last, __less<>());
34}33}
lib/libcxx/include/__algorithm/is_heap_until.h+2-2
...@@ -46,13 +46,13 @@ __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co...@@ -46,13 +46,13 @@ __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
46}46}
4747
48template <class _RandomAccessIterator, class _Compare>48template <class _RandomAccessIterator, class _Compare>
49_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator49[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
50is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {50is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
51 return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp));51 return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp));
52}52}
5353
54template <class _RandomAccessIterator>54template <class _RandomAccessIterator>
55_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator55[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
56is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) {56is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) {
57 return std::__is_heap_until(__first, __last, __less<>());57 return std::__is_heap_until(__first, __last, __less<>());
58}58}
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 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool21[[__nodiscard__]] _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 for (; __first != __last; ++__first)23 for (; __first != __last; ++__first)
24 if (!__pred(*__first))24 if (!__pred(*__first))
lib/libcxx/include/__algorithm/is_permutation.h+12-11
...@@ -14,12 +14,13 @@...@@ -14,12 +14,13 @@
14#include <__algorithm/iterator_operations.h>14#include <__algorithm/iterator_operations.h>
15#include <__config>15#include <__config>
16#include <__functional/identity.h>16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__iterator/concepts.h>17#include <__iterator/concepts.h>
19#include <__iterator/distance.h>18#include <__iterator/distance.h>
20#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
21#include <__iterator/next.h>20#include <__type_traits/enable_if.h>
21#include <__type_traits/invoke.h>
22#include <__type_traits/is_callable.h>22#include <__type_traits/is_callable.h>
23#include <__type_traits/is_same.h>
23#include <__utility/move.h>24#include <__utility/move.h>
2425
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -113,7 +114,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation_impl(...@@ -113,7 +114,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation_impl(
113114
114// 2+1 iterators, predicate. Not used by range algorithms.115// 2+1 iterators, predicate. Not used by range algorithms.
115template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _BinaryPredicate>116template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _BinaryPredicate>
116_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation(117[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation(
117 _ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _BinaryPredicate&& __pred) {118 _ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _BinaryPredicate&& __pred) {
118 // Shorten sequences as much as possible by lopping of any equal prefix.119 // Shorten sequences as much as possible by lopping of any equal prefix.
119 for (; __first1 != __last1; ++__first1, (void)++__first2) {120 for (; __first1 != __last1; ++__first1, (void)++__first2) {
...@@ -247,17 +248,17 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation(...@@ -247,17 +248,17 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation(
247248
248// 2+1 iterators, predicate249// 2+1 iterators, predicate
249template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>250template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
250_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(251[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
251 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) {252 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) {
252 static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,253 static_assert(__is_callable<_BinaryPredicate&, decltype(*__first1), decltype(*__first2)>::value,
253 "The predicate has to be callable");254 "The comparator has to be callable");
254255
255 return std::__is_permutation<_ClassicAlgPolicy>(std::move(__first1), std::move(__last1), std::move(__first2), __pred);256 return std::__is_permutation<_ClassicAlgPolicy>(std::move(__first1), std::move(__last1), std::move(__first2), __pred);
256}257}
257258
258// 2+1 iterators259// 2+1 iterators
259template <class _ForwardIterator1, class _ForwardIterator2>260template <class _ForwardIterator1, class _ForwardIterator2>
260_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool261[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
261is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {262is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
262 return std::is_permutation(__first1, __last1, __first2, __equal_to());263 return std::is_permutation(__first1, __last1, __first2, __equal_to());
263}264}
...@@ -266,7 +267,7 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt...@@ -266,7 +267,7 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt
266267
267// 2+2 iterators268// 2+2 iterators
268template <class _ForwardIterator1, class _ForwardIterator2>269template <class _ForwardIterator1, class _ForwardIterator2>
269_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(270[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
270 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {271 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
271 return std::__is_permutation<_ClassicAlgPolicy>(272 return std::__is_permutation<_ClassicAlgPolicy>(
272 std::move(__first1),273 std::move(__first1),
...@@ -280,14 +281,14 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 boo...@@ -280,14 +281,14 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 boo
280281
281// 2+2 iterators, predicate282// 2+2 iterators, predicate
282template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>283template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
283_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(284[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
284 _ForwardIterator1 __first1,285 _ForwardIterator1 __first1,
285 _ForwardIterator1 __last1,286 _ForwardIterator1 __last1,
286 _ForwardIterator2 __first2,287 _ForwardIterator2 __first2,
287 _ForwardIterator2 __last2,288 _ForwardIterator2 __last2,
288 _BinaryPredicate __pred) {289 _BinaryPredicate __pred) {
289 static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,290 static_assert(__is_callable<_BinaryPredicate&, decltype(*__first1), decltype(*__first2)>::value,
290 "The predicate has to be callable");291 "The comparator has to be callable");
291292
292 return std::__is_permutation<_ClassicAlgPolicy>(293 return std::__is_permutation<_ClassicAlgPolicy>(
293 std::move(__first1),294 std::move(__first1),
lib/libcxx/include/__algorithm/is_sorted.h+2-3
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/is_sorted_until.h>14#include <__algorithm/is_sorted_until.h>
15#include <__config>15#include <__config>
16#include <__iterator/iterator_traits.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
...@@ -22,13 +21,13 @@...@@ -22,13 +21,13 @@
22_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _ForwardIterator, class _Compare>23template <class _ForwardIterator, class _Compare>
25_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool24[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
26is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {25is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
27 return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp) == __last;26 return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp) == __last;
28}27}
2928
30template <class _ForwardIterator>29template <class _ForwardIterator>
31_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool30[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
32is_sorted(_ForwardIterator __first, _ForwardIterator __last) {31is_sorted(_ForwardIterator __first, _ForwardIterator __last) {
33 return std::is_sorted(__first, __last, __less<>());32 return std::is_sorted(__first, __last, __less<>());
34}33}
lib/libcxx/include/__algorithm/is_sorted_until.h+2-3
...@@ -12,7 +12,6 @@...@@ -12,7 +12,6 @@
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 <__config>14#include <__config>
15#include <__iterator/iterator_traits.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
...@@ -35,13 +34,13 @@ __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __...@@ -35,13 +34,13 @@ __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __
35}34}
3635
37template <class _ForwardIterator, class _Compare>36template <class _ForwardIterator, class _Compare>
38_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator37[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
39is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {38is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
40 return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp);39 return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp);
41}40}
4241
43template <class _ForwardIterator>42template <class _ForwardIterator>
44_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator43[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
45is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) {44is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) {
46 return std::is_sorted_until(__first, __last, __less<>());45 return std::is_sorted_until(__first, __last, __less<>());
47}46}
lib/libcxx/include/__algorithm/iterator_operations.h+11-8
...@@ -48,13 +48,13 @@ struct _RangeAlgPolicy {};...@@ -48,13 +48,13 @@ struct _RangeAlgPolicy {};
48template <>48template <>
49struct _IterOps<_RangeAlgPolicy> {49struct _IterOps<_RangeAlgPolicy> {
50 template <class _Iter>50 template <class _Iter>
51 using __value_type = iter_value_t<_Iter>;51 using __value_type _LIBCPP_NODEBUG = iter_value_t<_Iter>;
5252
53 template <class _Iter>53 template <class _Iter>
54 using __iterator_category = ranges::__iterator_concept<_Iter>;54 using __iterator_category _LIBCPP_NODEBUG = ranges::__iterator_concept<_Iter>;
5555
56 template <class _Iter>56 template <class _Iter>
57 using __difference_type = iter_difference_t<_Iter>;57 using __difference_type _LIBCPP_NODEBUG = iter_difference_t<_Iter>;
5858
59 static constexpr auto advance = ranges::advance;59 static constexpr auto advance = ranges::advance;
60 static constexpr auto distance = ranges::distance;60 static constexpr auto distance = ranges::distance;
...@@ -72,13 +72,13 @@ struct _ClassicAlgPolicy {};...@@ -72,13 +72,13 @@ struct _ClassicAlgPolicy {};
72template <>72template <>
73struct _IterOps<_ClassicAlgPolicy> {73struct _IterOps<_ClassicAlgPolicy> {
74 template <class _Iter>74 template <class _Iter>
75 using __value_type = typename iterator_traits<_Iter>::value_type;75 using __value_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::value_type;
7676
77 template <class _Iter>77 template <class _Iter>
78 using __iterator_category = typename iterator_traits<_Iter>::iterator_category;78 using __iterator_category _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::iterator_category;
7979
80 template <class _Iter>80 template <class _Iter>
81 using __difference_type = typename iterator_traits<_Iter>::difference_type;81 using __difference_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::difference_type;
8282
83 // advance83 // advance
84 template <class _Iter, class _Distance>84 template <class _Iter, class _Distance>
...@@ -94,10 +94,10 @@ struct _IterOps<_ClassicAlgPolicy> {...@@ -94,10 +94,10 @@ struct _IterOps<_ClassicAlgPolicy> {
94 }94 }
9595
96 template <class _Iter>96 template <class _Iter>
97 using __deref_t = decltype(*std::declval<_Iter&>());97 using __deref_t _LIBCPP_NODEBUG = decltype(*std::declval<_Iter&>());
9898
99 template <class _Iter>99 template <class _Iter>
100 using __move_t = decltype(std::move(*std::declval<_Iter&>()));100 using __move_t _LIBCPP_NODEBUG = decltype(std::move(*std::declval<_Iter&>()));
101101
102 template <class _Iter>102 template <class _Iter>
103 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static void __validate_iter_reference() {103 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static void __validate_iter_reference() {
...@@ -216,6 +216,9 @@ private:...@@ -216,6 +216,9 @@ private:
216 }216 }
217};217};
218218
219template <class _AlgPolicy, class _Iter>
220using __policy_iter_diff_t _LIBCPP_NODEBUG = typename _IterOps<_AlgPolicy>::template __difference_type<_Iter>;
221
219_LIBCPP_END_NAMESPACE_STD222_LIBCPP_END_NAMESPACE_STD
220223
221_LIBCPP_POP_MACROS224_LIBCPP_POP_MACROS
lib/libcxx/include/__algorithm/lexicographical_compare.h+85-13
...@@ -10,48 +10,120 @@...@@ -10,48 +10,120 @@
10#define _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H10#define _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/min.h>
14#include <__algorithm/mismatch.h>
15#include <__algorithm/simd_utils.h>
16#include <__algorithm/unwrap_iter.h>
14#include <__config>17#include <__config>
18#include <__functional/identity.h>
15#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
20#include <__string/constexpr_c_functions.h>
21#include <__type_traits/desugars_to.h>
22#include <__type_traits/enable_if.h>
23#include <__type_traits/invoke.h>
24#include <__type_traits/is_equality_comparable.h>
25#include <__type_traits/is_integral.h>
26#include <__type_traits/is_trivially_lexicographically_comparable.h>
27#include <__type_traits/is_volatile.h>
28
29#if _LIBCPP_HAS_WIDE_CHARACTERS
30# include <cwchar>
31#endif
1632
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)33#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header34# pragma GCC system_header
19#endif35#endif
2036
37_LIBCPP_PUSH_MACROS
38#include <__undef_macros>
39
21_LIBCPP_BEGIN_NAMESPACE_STD40_LIBCPP_BEGIN_NAMESPACE_STD
2241
23template <class _Compare, class _InputIterator1, class _InputIterator2>42template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Comp>
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __lexicographical_compare(43_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __lexicographical_compare(
25 _InputIterator1 __first1,44 _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Comp& __comp, _Proj1& __proj1, _Proj2& __proj2) {
26 _InputIterator1 __last1,45 while (__first2 != __last2) {
27 _InputIterator2 __first2,46 if (__first1 == __last1 ||
28 _InputIterator2 __last2,47 std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
29 _Compare __comp) {
30 for (; __first2 != __last2; ++__first1, (void)++__first2) {
31 if (__first1 == __last1 || __comp(*__first1, *__first2))
32 return true;48 return true;
33 if (__comp(*__first2, *__first1))49 if (std::__invoke(__comp, std::__invoke(__proj2, *__first2), std::__invoke(__proj1, *__first1)))
34 return false;50 return false;
51 ++__first1;
52 ++__first2;
35 }53 }
36 return false;54 return false;
37}55}
3856
57#if _LIBCPP_STD_VER >= 14
58
59// If the comparison operation is equivalent to < and that is a total order, we know that we can use equality comparison
60// on that type instead to extract some information. Furthermore, if equality comparison on that type is trivial, the
61// user can't observe that we're calling it. So instead of using the user-provided total order, we use std::mismatch,
62// which uses equality comparison (and is vertorized). Additionally, if the type is trivially lexicographically
63// comparable, we can go one step further and use std::memcmp directly instead of calling std::mismatch.
64template <class _Tp,
65 class _Proj1,
66 class _Proj2,
67 class _Comp,
68 __enable_if_t<__desugars_to_v<__totally_ordered_less_tag, _Comp, _Tp, _Tp> && !is_volatile<_Tp>::value &&
69 __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value &&
70 __is_identity<_Proj1>::value && __is_identity<_Proj2>::value,
71 int> = 0>
72_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
73__lexicographical_compare(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Comp&, _Proj1&, _Proj2&) {
74 if constexpr (__is_trivially_lexicographically_comparable_v<_Tp, _Tp>) {
75 auto __res =
76 std::__constexpr_memcmp(__first1, __first2, __element_count(std::min(__last1 - __first1, __last2 - __first2)));
77 if (__res == 0)
78 return __last1 - __first1 < __last2 - __first2;
79 return __res < 0;
80 }
81# if _LIBCPP_HAS_WIDE_CHARACTERS
82 else if constexpr (is_same<__remove_cv_t<_Tp>, wchar_t>::value) {
83 auto __res = std::__constexpr_wmemcmp(__first1, __first2, std::min(__last1 - __first1, __last2 - __first2));
84 if (__res == 0)
85 return __last1 - __first1 < __last2 - __first2;
86 return __res < 0;
87 }
88# endif // _LIBCPP_HAS_WIDE_CHARACTERS
89 else {
90 auto __res = std::mismatch(__first1, __last1, __first2, __last2);
91 if (__res.second == __last2)
92 return false;
93 if (__res.first == __last1)
94 return true;
95 return *__res.first < *__res.second;
96 }
97}
98
99#endif // _LIBCPP_STD_VER >= 14
100
39template <class _InputIterator1, class _InputIterator2, class _Compare>101template <class _InputIterator1, class _InputIterator2, class _Compare>
40_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare(102[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare(
41 _InputIterator1 __first1,103 _InputIterator1 __first1,
42 _InputIterator1 __last1,104 _InputIterator1 __last1,
43 _InputIterator2 __first2,105 _InputIterator2 __first2,
44 _InputIterator2 __last2,106 _InputIterator2 __last2,
45 _Compare __comp) {107 _Compare __comp) {
46 return std::__lexicographical_compare<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __comp);108 __identity __proj;
109 return std::__lexicographical_compare(
110 std::__unwrap_iter(__first1),
111 std::__unwrap_iter(__last1),
112 std::__unwrap_iter(__first2),
113 std::__unwrap_iter(__last2),
114 __comp,
115 __proj,
116 __proj);
47}117}
48118
49template <class _InputIterator1, class _InputIterator2>119template <class _InputIterator1, class _InputIterator2>
50_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare(120[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare(
51 _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {121 _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
52 return std::lexicographical_compare(__first1, __last1, __first2, __last2, __less<>());122 return std::lexicographical_compare(__first1, __last1, __first2, __last2, __less<>());
53}123}
54124
55_LIBCPP_END_NAMESPACE_STD125_LIBCPP_END_NAMESPACE_STD
56126
127_LIBCPP_POP_MACROS
128
57#endif // _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H129#endif // _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H
lib/libcxx/include/__algorithm/lower_bound.h+7-8
...@@ -14,12 +14,11 @@...@@ -14,12 +14,11 @@
14#include <__algorithm/iterator_operations.h>14#include <__algorithm/iterator_operations.h>
15#include <__config>15#include <__config>
16#include <__functional/identity.h>16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__iterator/advance.h>17#include <__iterator/advance.h>
19#include <__iterator/distance.h>18#include <__iterator/distance.h>
20#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
20#include <__type_traits/invoke.h>
21#include <__type_traits/is_callable.h>21#include <__type_traits/is_callable.h>
22#include <__type_traits/remove_reference.h>
2322
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header24# pragma GCC system_header
...@@ -28,7 +27,7 @@...@@ -28,7 +27,7 @@
28_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2928
30template <class _AlgPolicy, class _Iter, class _Type, class _Proj, class _Comp>29template <class _AlgPolicy, class _Iter, class _Type, class _Proj, class _Comp>
31_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter __lower_bound_bisecting(30[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter __lower_bound_bisecting(
32 _Iter __first,31 _Iter __first,
33 const _Type& __value,32 const _Type& __value,
34 typename iterator_traits<_Iter>::difference_type __len,33 typename iterator_traits<_Iter>::difference_type __len,
...@@ -58,7 +57,7 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter __lo...@@ -58,7 +57,7 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter __lo
58// whereas the one-sided version will yield O(n) operations on both counts, with a \Omega(log(n)) bound on the number of57// whereas the one-sided version will yield O(n) operations on both counts, with a \Omega(log(n)) bound on the number of
59// comparisons.58// comparisons.
60template <class _AlgPolicy, class _ForwardIterator, class _Sent, class _Type, class _Proj, class _Comp>59template <class _AlgPolicy, class _ForwardIterator, class _Sent, class _Type, class _Proj, class _Comp>
61_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator60[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
62__lower_bound_onesided(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {61__lower_bound_onesided(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
63 // step = 0, ensuring we can always short-circuit when distance is 1 later on62 // step = 0, ensuring we can always short-circuit when distance is 1 later on
64 if (__first == __last || !std::__invoke(__comp, std::__invoke(__proj, *__first), __value))63 if (__first == __last || !std::__invoke(__comp, std::__invoke(__proj, *__first), __value))
...@@ -84,22 +83,22 @@ __lower_bound_onesided(_ForwardIterator __first, _Sent __last, const _Type& __va...@@ -84,22 +83,22 @@ __lower_bound_onesided(_ForwardIterator __first, _Sent __last, const _Type& __va
84}83}
8584
86template <class _AlgPolicy, class _ForwardIterator, class _Sent, class _Type, class _Proj, class _Comp>85template <class _AlgPolicy, class _ForwardIterator, class _Sent, class _Type, class _Proj, class _Comp>
87_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator86[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
88__lower_bound(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {87__lower_bound(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
89 const auto __dist = _IterOps<_AlgPolicy>::distance(__first, __last);88 const auto __dist = _IterOps<_AlgPolicy>::distance(__first, __last);
90 return std::__lower_bound_bisecting<_AlgPolicy>(__first, __value, __dist, __comp, __proj);89 return std::__lower_bound_bisecting<_AlgPolicy>(__first, __value, __dist, __comp, __proj);
91}90}
9291
93template <class _ForwardIterator, class _Tp, class _Compare>92template <class _ForwardIterator, class _Tp, class _Compare>
94_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator93[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
95lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {94lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
96 static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, "The comparator has to be callable");95 static_assert(__is_callable<_Compare&, decltype(*__first), const _Tp&>::value, "The comparator has to be callable");
97 auto __proj = std::__identity();96 auto __proj = std::__identity();
98 return std::__lower_bound<_ClassicAlgPolicy>(__first, __last, __value, __comp, __proj);97 return std::__lower_bound<_ClassicAlgPolicy>(__first, __last, __value, __comp, __proj);
99}98}
10099
101template <class _ForwardIterator, class _Tp>100template <class _ForwardIterator, class _Tp>
102_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator101[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
103lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {102lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
104 return std::lower_bound(__first, __last, __value, __less<>());103 return std::lower_bound(__first, __last, __value, __less<>());
105}104}
lib/libcxx/include/__algorithm/make_projected.h+7-9
...@@ -9,15 +9,13 @@...@@ -9,15 +9,13 @@
9#ifndef _LIBCPP___ALGORITHM_MAKE_PROJECTED_H9#ifndef _LIBCPP___ALGORITHM_MAKE_PROJECTED_H
10#define _LIBCPP___ALGORITHM_MAKE_PROJECTED_H10#define _LIBCPP___ALGORITHM_MAKE_PROJECTED_H
1111
12#include <__concepts/same_as.h>
13#include <__config>12#include <__config>
14#include <__functional/identity.h>13#include <__functional/identity.h>
15#include <__functional/invoke.h>14#include <__functional/invoke.h>
16#include <__type_traits/decay.h>15#include <__type_traits/decay.h>
17#include <__type_traits/enable_if.h>16#include <__type_traits/enable_if.h>
18#include <__type_traits/integral_constant.h>17#include <__type_traits/invoke.h>
19#include <__type_traits/is_member_pointer.h>18#include <__type_traits/is_member_pointer.h>
20#include <__type_traits/is_same.h>
21#include <__utility/declval.h>19#include <__utility/declval.h>
22#include <__utility/forward.h>20#include <__utility/forward.h>
2321
...@@ -36,16 +34,16 @@ struct _ProjectedPred {...@@ -36,16 +34,16 @@ struct _ProjectedPred {
36 : __pred(__pred_arg), __proj(__proj_arg) {}34 : __pred(__pred_arg), __proj(__proj_arg) {}
3735
38 template <class _Tp>36 template <class _Tp>
39 typename __invoke_of<_Pred&, decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>()))>::type37 __invoke_result_t<_Pred&, decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>()))> _LIBCPP_CONSTEXPR
40 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI38 _LIBCPP_HIDE_FROM_ABI
41 operator()(_Tp&& __v) const {39 operator()(_Tp&& __v) const {
42 return std::__invoke(__pred, std::__invoke(__proj, std::forward<_Tp>(__v)));40 return std::__invoke(__pred, std::__invoke(__proj, std::forward<_Tp>(__v)));
43 }41 }
4442
45 template <class _T1, class _T2>43 template <class _T1, class _T2>
46 typename __invoke_of<_Pred&,44 __invoke_result_t<_Pred&,
47 decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())),45 decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())),
48 decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>()))>::type _LIBCPP_CONSTEXPR46 decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>()))> _LIBCPP_CONSTEXPR
49 _LIBCPP_HIDE_FROM_ABI47 _LIBCPP_HIDE_FROM_ABI
50 operator()(_T1&& __lhs, _T2&& __rhs) const {48 operator()(_T1&& __lhs, _T2&& __rhs) const {
51 return std::__invoke(49 return std::__invoke(
lib/libcxx/include/__algorithm/max.h+4-4
...@@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS...@@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _Tp, class _Compare>27template <class _Tp, class _Compare>
28_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&28[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&
29max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) {29max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) {
30 return __comp(__a, __b) ? __b : __a;30 return __comp(__a, __b) ? __b : __a;
31}31}
3232
33template <class _Tp>33template <class _Tp>
34_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&34[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&
35max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) {35max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) {
36 return std::max(__a, __b, __less<>());36 return std::max(__a, __b, __less<>());
37}37}
...@@ -39,13 +39,13 @@ max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b)...@@ -39,13 +39,13 @@ max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b)
39#ifndef _LIBCPP_CXX03_LANG39#ifndef _LIBCPP_CXX03_LANG
4040
41template <class _Tp, class _Compare>41template <class _Tp, class _Compare>
42_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp42[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp
43max(initializer_list<_Tp> __t, _Compare __comp) {43max(initializer_list<_Tp> __t, _Compare __comp) {
44 return *std::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);44 return *std::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
45}45}
4646
47template <class _Tp>47template <class _Tp>
48_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t) {48[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t) {
49 return *std::max_element(__t.begin(), __t.end(), __less<>());49 return *std::max_element(__t.begin(), __t.end(), __less<>());
50}50}
5151
lib/libcxx/include/__algorithm/max_element.h+5-2
...@@ -13,6 +13,7 @@...@@ -13,6 +13,7 @@
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__config>14#include <__config>
15#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
16#include <__type_traits/is_callable.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
...@@ -35,13 +36,15 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp...@@ -35,13 +36,15 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp
35}36}
3637
37template <class _ForwardIterator, class _Compare>38template <class _ForwardIterator, class _Compare>
38_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator39[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
39max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {40max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
41 static_assert(
42 __is_callable<_Compare&, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable");
40 return std::__max_element<__comp_ref_type<_Compare> >(__first, __last, __comp);43 return std::__max_element<__comp_ref_type<_Compare> >(__first, __last, __comp);
41}44}
4245
43template <class _ForwardIterator>46template <class _ForwardIterator>
44_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator47[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
45max_element(_ForwardIterator __first, _ForwardIterator __last) {48max_element(_ForwardIterator __first, _ForwardIterator __last) {
46 return std::max_element(__first, __last, __less<>());49 return std::max_element(__first, __last, __less<>());
47}50}
lib/libcxx/include/__algorithm/merge.h-1
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
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 <__config>15#include <__config>
16#include <__iterator/iterator_traits.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
lib/libcxx/include/__algorithm/min.h+4-4
...@@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS...@@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _Tp, class _Compare>27template <class _Tp, class _Compare>
28_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&28[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&
29min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) {29min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) {
30 return __comp(__b, __a) ? __b : __a;30 return __comp(__b, __a) ? __b : __a;
31}31}
3232
33template <class _Tp>33template <class _Tp>
34_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&34[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&
35min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) {35min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) {
36 return std::min(__a, __b, __less<>());36 return std::min(__a, __b, __less<>());
37}37}
...@@ -39,13 +39,13 @@ min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b)...@@ -39,13 +39,13 @@ min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b)
39#ifndef _LIBCPP_CXX03_LANG39#ifndef _LIBCPP_CXX03_LANG
4040
41template <class _Tp, class _Compare>41template <class _Tp, class _Compare>
42_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp42[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp
43min(initializer_list<_Tp> __t, _Compare __comp) {43min(initializer_list<_Tp> __t, _Compare __comp) {
44 return *std::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);44 return *std::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
45}45}
4646
47template <class _Tp>47template <class _Tp>
48_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp min(initializer_list<_Tp> __t) {48[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp min(initializer_list<_Tp> __t) {
49 return *std::min_element(__t.begin(), __t.end(), __less<>());49 return *std::min_element(__t.begin(), __t.end(), __less<>());
50}50}
5151
lib/libcxx/include/__algorithm/min_element.h+4-4
...@@ -13,8 +13,8 @@...@@ -13,8 +13,8 @@
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__config>14#include <__config>
15#include <__functional/identity.h>15#include <__functional/identity.h>
16#include <__functional/invoke.h>
17#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
17#include <__type_traits/invoke.h>
18#include <__type_traits/is_callable.h>18#include <__type_traits/is_callable.h>
19#include <__utility/move.h>19#include <__utility/move.h>
2020
...@@ -48,18 +48,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter __min_element(_Iter __...@@ -48,18 +48,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter __min_element(_Iter __
48}48}
4949
50template <class _ForwardIterator, class _Compare>50template <class _ForwardIterator, class _Compare>
51_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator51[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
52min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {52min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
53 static_assert(53 static_assert(
54 __has_forward_iterator_category<_ForwardIterator>::value, "std::min_element requires a ForwardIterator");54 __has_forward_iterator_category<_ForwardIterator>::value, "std::min_element requires a ForwardIterator");
55 static_assert(55 static_assert(
56 __is_callable<_Compare, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable");56 __is_callable<_Compare&, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable");
5757
58 return std::__min_element<__comp_ref_type<_Compare> >(std::move(__first), std::move(__last), __comp);58 return std::__min_element<__comp_ref_type<_Compare> >(std::move(__first), std::move(__last), __comp);
59}59}
6060
61template <class _ForwardIterator>61template <class _ForwardIterator>
62_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator62[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
63min_element(_ForwardIterator __first, _ForwardIterator __last) {63min_element(_ForwardIterator __first, _ForwardIterator __last) {
64 return std::min_element(__first, __last, __less<>());64 return std::min_element(__first, __last, __less<>());
65}65}
lib/libcxx/include/__algorithm/minmax.h+5-5
...@@ -24,13 +24,13 @@...@@ -24,13 +24,13 @@
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
26template <class _Tp, class _Compare>26template <class _Tp, class _Compare>
27_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&>27[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&>
28minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) {28minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) {
29 return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a) : pair<const _Tp&, const _Tp&>(__a, __b);29 return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a) : pair<const _Tp&, const _Tp&>(__a, __b);
30}30}
3131
32template <class _Tp>32template <class _Tp>
33_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&>33[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&>
34minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) {34minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) {
35 return std::minmax(__a, __b, __less<>());35 return std::minmax(__a, __b, __less<>());
36}36}
...@@ -38,16 +38,16 @@ minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __...@@ -38,16 +38,16 @@ minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __
38#ifndef _LIBCPP_CXX03_LANG38#ifndef _LIBCPP_CXX03_LANG
3939
40template <class _Tp, class _Compare>40template <class _Tp, class _Compare>
41_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp>41[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp>
42minmax(initializer_list<_Tp> __t, _Compare __comp) {42minmax(initializer_list<_Tp> __t, _Compare __comp) {
43 static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable");43 static_assert(__is_callable<_Compare&, _Tp, _Tp>::value, "The comparator has to be callable");
44 __identity __proj;44 __identity __proj;
45 auto __ret = std::__minmax_element_impl(__t.begin(), __t.end(), __comp, __proj);45 auto __ret = std::__minmax_element_impl(__t.begin(), __t.end(), __comp, __proj);
46 return pair<_Tp, _Tp>(*__ret.first, *__ret.second);46 return pair<_Tp, _Tp>(*__ret.first, *__ret.second);
47}47}
4848
49template <class _Tp>49template <class _Tp>
50_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp>50[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp>
51minmax(initializer_list<_Tp> __t) {51minmax(initializer_list<_Tp> __t) {
52 return std::minmax(__t, __less<>());52 return std::minmax(__t, __less<>());
53}53}
lib/libcxx/include/__algorithm/minmax_element.h+4-4
...@@ -12,8 +12,8 @@...@@ -12,8 +12,8 @@
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__config>13#include <__config>
14#include <__functional/identity.h>14#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
16#include <__type_traits/invoke.h>
17#include <__type_traits/is_callable.h>17#include <__type_traits/is_callable.h>
18#include <__utility/pair.h>18#include <__utility/pair.h>
1919
...@@ -79,18 +79,18 @@ __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj)...@@ -79,18 +79,18 @@ __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj)
79}79}
8080
81template <class _ForwardIterator, class _Compare>81template <class _ForwardIterator, class _Compare>
82_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator>82[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator>
83minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {83minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
84 static_assert(84 static_assert(
85 __has_forward_iterator_category<_ForwardIterator>::value, "std::minmax_element requires a ForwardIterator");85 __has_forward_iterator_category<_ForwardIterator>::value, "std::minmax_element requires a ForwardIterator");
86 static_assert(86 static_assert(
87 __is_callable<_Compare, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable");87 __is_callable<_Compare&, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable");
88 auto __proj = __identity();88 auto __proj = __identity();
89 return std::__minmax_element_impl(__first, __last, __comp, __proj);89 return std::__minmax_element_impl(__first, __last, __comp, __proj);
90}90}
9191
92template <class _ForwardIterator>92template <class _ForwardIterator>
93_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator>93[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator>
94minmax_element(_ForwardIterator __first, _ForwardIterator __last) {94minmax_element(_ForwardIterator __first, _ForwardIterator __last) {
95 return std::minmax_element(__first, __last, __less<>());95 return std::minmax_element(__first, __last, __less<>());
96}96}
lib/libcxx/include/__algorithm/mismatch.h+14-13
...@@ -15,17 +15,18 @@...@@ -15,17 +15,18 @@
15#include <__algorithm/simd_utils.h>15#include <__algorithm/simd_utils.h>
16#include <__algorithm/unwrap_iter.h>16#include <__algorithm/unwrap_iter.h>
17#include <__config>17#include <__config>
18#include <__cstddef/size_t.h>
18#include <__functional/identity.h>19#include <__functional/identity.h>
19#include <__iterator/aliasing_iterator.h>20#include <__iterator/aliasing_iterator.h>
21#include <__iterator/iterator_traits.h>
20#include <__type_traits/desugars_to.h>22#include <__type_traits/desugars_to.h>
23#include <__type_traits/enable_if.h>
21#include <__type_traits/invoke.h>24#include <__type_traits/invoke.h>
22#include <__type_traits/is_constant_evaluated.h>25#include <__type_traits/is_constant_evaluated.h>
23#include <__type_traits/is_equality_comparable.h>26#include <__type_traits/is_equality_comparable.h>
24#include <__type_traits/is_integral.h>27#include <__type_traits/is_integral.h>
25#include <__utility/move.h>28#include <__utility/move.h>
26#include <__utility/pair.h>29#include <__utility/pair.h>
27#include <__utility/unreachable.h>
28#include <cstddef>
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
...@@ -37,7 +38,7 @@ _LIBCPP_PUSH_MACROS...@@ -37,7 +38,7 @@ _LIBCPP_PUSH_MACROS
37_LIBCPP_BEGIN_NAMESPACE_STD38_LIBCPP_BEGIN_NAMESPACE_STD
3839
39template <class _Iter1, class _Sent1, class _Iter2, class _Pred, class _Proj1, class _Proj2>40template <class _Iter1, class _Sent1, class _Iter2, class _Pred, class _Proj1, class _Proj2>
40_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2>41[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2>
41__mismatch_loop(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {42__mismatch_loop(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
42 while (__first1 != __last1) {43 while (__first1 != __last1) {
43 if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))44 if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
...@@ -49,7 +50,7 @@ __mismatch_loop(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred,...@@ -49,7 +50,7 @@ __mismatch_loop(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred,
49}50}
5051
51template <class _Iter1, class _Sent1, class _Iter2, class _Pred, class _Proj1, class _Proj2>52template <class _Iter1, class _Sent1, class _Iter2, class _Pred, class _Proj1, class _Proj2>
52_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2>53[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2>
53__mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {54__mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
54 return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj1, __proj2);55 return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj1, __proj2);
55}56}
...@@ -57,7 +58,7 @@ __mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Pro...@@ -57,7 +58,7 @@ __mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Pro
57#if _LIBCPP_VECTORIZE_ALGORITHMS58#if _LIBCPP_VECTORIZE_ALGORITHMS
5859
59template <class _Iter>60template <class _Iter>
60_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter, _Iter>61[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter, _Iter>
61__mismatch_vectorized(_Iter __first1, _Iter __last1, _Iter __first2) {62__mismatch_vectorized(_Iter __first1, _Iter __last1, _Iter __first2) {
62 using __value_type = __iter_value_type<_Iter>;63 using __value_type = __iter_value_type<_Iter>;
63 constexpr size_t __unroll_count = 4;64 constexpr size_t __unroll_count = 4;
...@@ -124,7 +125,7 @@ template <class _Tp,...@@ -124,7 +125,7 @@ template <class _Tp,
124 __enable_if_t<is_integral<_Tp>::value && __desugars_to_v<__equal_tag, _Pred, _Tp, _Tp> &&125 __enable_if_t<is_integral<_Tp>::value && __desugars_to_v<__equal_tag, _Pred, _Tp, _Tp> &&
125 __is_identity<_Proj1>::value && __is_identity<_Proj2>::value,126 __is_identity<_Proj1>::value && __is_identity<_Proj2>::value,
126 int> = 0>127 int> = 0>
127_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*>128[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*>
128__mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred&, _Proj1&, _Proj2&) {129__mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred&, _Proj1&, _Proj2&) {
129 return std::__mismatch_vectorized(__first1, __last1, __first2);130 return std::__mismatch_vectorized(__first1, __last1, __first2);
130}131}
...@@ -137,7 +138,7 @@ template <class _Tp,...@@ -137,7 +138,7 @@ template <class _Tp,
137 __is_identity<_Proj1>::value && __is_identity<_Proj2>::value &&138 __is_identity<_Proj1>::value && __is_identity<_Proj2>::value &&
138 __can_map_to_integer_v<_Tp> && __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value,139 __can_map_to_integer_v<_Tp> && __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value,
139 int> = 0>140 int> = 0>
140_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*>141[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*>
141__mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {142__mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
142 if (__libcpp_is_constant_evaluated()) {143 if (__libcpp_is_constant_evaluated()) {
143 return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj1, __proj2);144 return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj1, __proj2);
...@@ -150,7 +151,7 @@ __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred& __pred, _Proj1& __...@@ -150,7 +151,7 @@ __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred& __pred, _Proj1& __
150#endif // _LIBCPP_VECTORIZE_ALGORITHMS151#endif // _LIBCPP_VECTORIZE_ALGORITHMS
151152
152template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>153template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
153_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>154[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
154mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {155mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
155 __identity __proj;156 __identity __proj;
156 auto __res = std::__mismatch(157 auto __res = std::__mismatch(
...@@ -159,14 +160,14 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi...@@ -159,14 +160,14 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi
159}160}
160161
161template <class _InputIterator1, class _InputIterator2>162template <class _InputIterator1, class _InputIterator2>
162_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>163[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
163mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {164mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
164 return std::mismatch(__first1, __last1, __first2, __equal_to());165 return std::mismatch(__first1, __last1, __first2, __equal_to());
165}166}
166167
167#if _LIBCPP_STD_VER >= 14168#if _LIBCPP_STD_VER >= 14
168template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>169template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
169_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> __mismatch(170[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> __mismatch(
170 _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {171 _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
171 while (__first1 != __last1 && __first2 != __last2) {172 while (__first1 != __last1 && __first2 != __last2) {
172 if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))173 if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
...@@ -178,14 +179,14 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter...@@ -178,14 +179,14 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter
178}179}
179180
180template <class _Tp, class _Pred, class _Proj1, class _Proj2>181template <class _Tp, class _Pred, class _Proj1, class _Proj2>
181_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*>182[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*>
182__mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {183__mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
183 auto __len = std::min(__last1 - __first1, __last2 - __first2);184 auto __len = std::min(__last1 - __first1, __last2 - __first2);
184 return std::__mismatch(__first1, __first1 + __len, __first2, __pred, __proj1, __proj2);185 return std::__mismatch(__first1, __first1 + __len, __first2, __pred, __proj1, __proj2);
185}186}
186187
187template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>188template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
188_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>189[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
189mismatch(_InputIterator1 __first1,190mismatch(_InputIterator1 __first1,
190 _InputIterator1 __last1,191 _InputIterator1 __last1,
191 _InputIterator2 __first2,192 _InputIterator2 __first2,
...@@ -204,7 +205,7 @@ mismatch(_InputIterator1 __first1,...@@ -204,7 +205,7 @@ mismatch(_InputIterator1 __first1,
204}205}
205206
206template <class _InputIterator1, class _InputIterator2>207template <class _InputIterator1, class _InputIterator2>
207_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>208[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
208mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {209mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
209 return std::mismatch(__first1, __last1, __first2, __last2, __equal_to());210 return std::mismatch(__first1, __last1, __first2, __last2, __equal_to());
210}211}
lib/libcxx/include/__algorithm/move.h+3-1
...@@ -14,8 +14,10 @@...@@ -14,8 +14,10 @@
14#include <__algorithm/iterator_operations.h>14#include <__algorithm/iterator_operations.h>
15#include <__algorithm/min.h>15#include <__algorithm/min.h>
16#include <__config>16#include <__config>
17#include <__iterator/iterator_traits.h>
17#include <__iterator/segmented_iterator.h>18#include <__iterator/segmented_iterator.h>
18#include <__type_traits/common_type.h>19#include <__type_traits/common_type.h>
20#include <__type_traits/enable_if.h>
19#include <__type_traits/is_constructible.h>21#include <__type_traits/is_constructible.h>
20#include <__utility/move.h>22#include <__utility/move.h>
21#include <__utility/pair.h>23#include <__utility/pair.h>
...@@ -48,7 +50,7 @@ struct __move_impl {...@@ -48,7 +50,7 @@ struct __move_impl {
4850
49 template <class _InIter, class _OutIter>51 template <class _InIter, class _OutIter>
50 struct _MoveSegment {52 struct _MoveSegment {
51 using _Traits = __segmented_iterator_traits<_InIter>;53 using _Traits _LIBCPP_NODEBUG = __segmented_iterator_traits<_InIter>;
5254
53 _OutIter& __result_;55 _OutIter& __result_;
5456
lib/libcxx/include/__algorithm/move_backward.h+2
...@@ -13,8 +13,10 @@...@@ -13,8 +13,10 @@
13#include <__algorithm/iterator_operations.h>13#include <__algorithm/iterator_operations.h>
14#include <__algorithm/min.h>14#include <__algorithm/min.h>
15#include <__config>15#include <__config>
16#include <__iterator/iterator_traits.h>
16#include <__iterator/segmented_iterator.h>17#include <__iterator/segmented_iterator.h>
17#include <__type_traits/common_type.h>18#include <__type_traits/common_type.h>
19#include <__type_traits/enable_if.h>
18#include <__type_traits/is_constructible.h>20#include <__type_traits/is_constructible.h>
19#include <__utility/move.h>21#include <__utility/move.h>
20#include <__utility/pair.h>22#include <__utility/pair.h>
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 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool22[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _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/partial_sort_copy.h+3-3
...@@ -18,8 +18,8 @@...@@ -18,8 +18,8 @@
18#include <__algorithm/sort_heap.h>18#include <__algorithm/sort_heap.h>
19#include <__config>19#include <__config>
20#include <__functional/identity.h>20#include <__functional/identity.h>
21#include <__functional/invoke.h>
22#include <__iterator/iterator_traits.h>21#include <__iterator/iterator_traits.h>
22#include <__type_traits/invoke.h>
23#include <__type_traits/is_callable.h>23#include <__type_traits/is_callable.h>
24#include <__utility/move.h>24#include <__utility/move.h>
25#include <__utility/pair.h>25#include <__utility/pair.h>
...@@ -76,8 +76,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator...@@ -76,8 +76,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
76 _RandomAccessIterator __result_first,76 _RandomAccessIterator __result_first,
77 _RandomAccessIterator __result_last,77 _RandomAccessIterator __result_last,
78 _Compare __comp) {78 _Compare __comp) {
79 static_assert(79 static_assert(__is_callable<_Compare&, decltype(*__first), decltype(*__result_first)>::value,
80 __is_callable<_Compare, decltype(*__first), decltype(*__result_first)>::value, "Comparator has to be callable");80 "The comparator has to be callable");
8181
82 auto __result = std::__partial_sort_copy<_ClassicAlgPolicy>(82 auto __result = std::__partial_sort_copy<_ClassicAlgPolicy>(
83 __first,83 __first,
lib/libcxx/include/__algorithm/partition.h+2-1
...@@ -12,6 +12,7 @@...@@ -12,6 +12,7 @@
12#include <__algorithm/iterator_operations.h>12#include <__algorithm/iterator_operations.h>
13#include <__config>13#include <__config>
14#include <__iterator/iterator_traits.h>14#include <__iterator/iterator_traits.h>
15#include <__type_traits/remove_cvref.h>
15#include <__utility/move.h>16#include <__utility/move.h>
16#include <__utility/pair.h>17#include <__utility/pair.h>
1718
...@@ -29,7 +30,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _Forw...@@ -29,7 +30,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _Forw
29__partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred, forward_iterator_tag) {30__partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred, forward_iterator_tag) {
30 while (true) {31 while (true) {
31 if (__first == __last)32 if (__first == __last)
32 return std::make_pair(std::move(__first), std::move(__first));33 return std::make_pair(__first, __first);
33 if (!__pred(*__first))34 if (!__pred(*__first))
34 break;35 break;
35 ++__first;36 ++__first;
lib/libcxx/include/__algorithm/pstl.h+3-3
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_PUSH_MACROS18_LIBCPP_PUSH_MACROS
19#include <__undef_macros>19#include <__undef_macros>
2020
21#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 1721#if _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
2222
23# include <__functional/operations.h>23# include <__functional/operations.h>
24# include <__iterator/cpp17_iterator_concepts.h>24# include <__iterator/cpp17_iterator_concepts.h>
...@@ -352,7 +352,7 @@ template <class _ExecutionPolicy,...@@ -352,7 +352,7 @@ template <class _ExecutionPolicy,
352 class _Predicate,352 class _Predicate,
353 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,353 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
354 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>354 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
355_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool355[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
356is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {356is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
357 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "is_partitioned requires ForwardIterators");357 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "is_partitioned requires ForwardIterators");
358 using _Implementation = __pstl::__dispatch<__pstl::__is_partitioned, __pstl::__current_configuration, _RawPolicy>;358 using _Implementation = __pstl::__dispatch<__pstl::__is_partitioned, __pstl::__current_configuration, _RawPolicy>;
...@@ -656,7 +656,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(...@@ -656,7 +656,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(
656656
657_LIBCPP_END_NAMESPACE_STD657_LIBCPP_END_NAMESPACE_STD
658658
659#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17659#endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
660660
661_LIBCPP_POP_MACROS661_LIBCPP_POP_MACROS
662662
lib/libcxx/include/__algorithm/radix_sort.h created+332
...@@ -0,0 +1,332 @@
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___ALGORITHM_RADIX_SORT_H
11#define _LIBCPP___ALGORITHM_RADIX_SORT_H
12
13// This is an implementation of classic LSD radix sort algorithm, running in linear time and using `O(max(N, M))`
14// additional memory, where `N` is size of an input range, `M` - maximum value of
15// a radix of the sorted integer type. Type of the radix and its maximum value are determined at compile time
16// based on type returned by function `__radix`. The default radix is uint8.
17
18// The algorithm is equivalent to several consecutive calls of counting sort for each
19// radix of the sorted numbers from low to high byte.
20// The algorithm uses a temporary buffer of size equal to size of the input range. Each `i`-th pass
21// of the algorithm sorts values by `i`-th radix and moves values to the temporary buffer (for each even `i`, counted
22// from zero), or moves them back to the initial range (for each odd `i`). If there is only one radix in sorted integers
23// (e.g. int8), the sorted values are placed to the buffer, and then moved back to the initial range.
24
25// The implementation also has several optimizations:
26// - the counters for the counting sort are calculated in one pass for all radices;
27// - if all values of a radix are the same, we do not sort that radix, and just move items to the buffer;
28// - if two consecutive radices satisfies condition above, we do nothing for these two radices.
29
30#include <__algorithm/for_each.h>
31#include <__algorithm/move.h>
32#include <__bit/bit_log2.h>
33#include <__bit/countl.h>
34#include <__config>
35#include <__functional/identity.h>
36#include <__iterator/distance.h>
37#include <__iterator/iterator_traits.h>
38#include <__iterator/move_iterator.h>
39#include <__iterator/next.h>
40#include <__iterator/reverse_iterator.h>
41#include <__numeric/partial_sum.h>
42#include <__type_traits/decay.h>
43#include <__type_traits/enable_if.h>
44#include <__type_traits/invoke.h>
45#include <__type_traits/is_assignable.h>
46#include <__type_traits/is_integral.h>
47#include <__type_traits/is_unsigned.h>
48#include <__type_traits/make_unsigned.h>
49#include <__utility/forward.h>
50#include <__utility/integer_sequence.h>
51#include <__utility/move.h>
52#include <__utility/pair.h>
53#include <climits>
54#include <cstdint>
55#include <initializer_list>
56#include <limits>
57
58#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
59# pragma GCC system_header
60#endif
61
62_LIBCPP_PUSH_MACROS
63#include <__undef_macros>
64
65_LIBCPP_BEGIN_NAMESPACE_STD
66
67#if _LIBCPP_STD_VER >= 14
68
69template <class _InputIterator, class _OutputIterator>
70_LIBCPP_HIDE_FROM_ABI pair<_OutputIterator, __iter_value_type<_InputIterator>>
71__partial_sum_max(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
72 if (__first == __last)
73 return {__result, 0};
74
75 auto __max = *__first;
76 __iter_value_type<_InputIterator> __sum = *__first;
77 *__result = __sum;
78
79 while (++__first != __last) {
80 if (__max < *__first) {
81 __max = *__first;
82 }
83 __sum = std::move(__sum) + *__first;
84 *++__result = __sum;
85 }
86 return {++__result, __max};
87}
88
89template <class _Value, class _Map, class _Radix>
90struct __radix_sort_traits {
91 using __image_type _LIBCPP_NODEBUG = decay_t<__invoke_result_t<_Map, _Value>>;
92 static_assert(is_unsigned<__image_type>::value);
93
94 using __radix_type _LIBCPP_NODEBUG = decay_t<__invoke_result_t<_Radix, __image_type>>;
95 static_assert(is_integral<__radix_type>::value);
96
97 static constexpr auto __radix_value_range = numeric_limits<__radix_type>::max() + 1;
98 static constexpr auto __radix_size = std::__bit_log2<uint64_t>(__radix_value_range);
99 static constexpr auto __radix_count = sizeof(__image_type) * CHAR_BIT / __radix_size;
100};
101
102template <class _Value, class _Map>
103struct __counting_sort_traits {
104 using __image_type _LIBCPP_NODEBUG = decay_t<__invoke_result_t<_Map, _Value>>;
105 static_assert(is_unsigned<__image_type>::value);
106
107 static constexpr const auto __value_range = numeric_limits<__image_type>::max() + 1;
108 static constexpr auto __radix_size = std::__bit_log2<uint64_t>(__value_range);
109};
110
111template <class _Radix, class _Integer>
112_LIBCPP_HIDE_FROM_ABI auto __nth_radix(size_t __radix_number, _Radix __radix, _Integer __n) {
113 static_assert(is_unsigned<_Integer>::value);
114 using __traits = __counting_sort_traits<_Integer, _Radix>;
115
116 return __radix(static_cast<_Integer>(__n >> __traits::__radix_size * __radix_number));
117}
118
119template <class _ForwardIterator, class _Map, class _RandomAccessIterator>
120_LIBCPP_HIDE_FROM_ABI void
121__collect(_ForwardIterator __first, _ForwardIterator __last, _Map __map, _RandomAccessIterator __counters) {
122 using __value_type = __iter_value_type<_ForwardIterator>;
123 using __traits = __counting_sort_traits<__value_type, _Map>;
124
125 std::for_each(__first, __last, [&__counters, &__map](const auto& __preimage) { ++__counters[__map(__preimage)]; });
126
127 const auto __counters_end = __counters + __traits::__value_range;
128 std::partial_sum(__counters, __counters_end, __counters);
129}
130
131template <class _ForwardIterator, class _RandomAccessIterator1, class _Map, class _RandomAccessIterator2>
132_LIBCPP_HIDE_FROM_ABI void
133__dispose(_ForwardIterator __first,
134 _ForwardIterator __last,
135 _RandomAccessIterator1 __result,
136 _Map __map,
137 _RandomAccessIterator2 __counters) {
138 std::for_each(__first, __last, [&__result, &__counters, &__map](auto&& __preimage) {
139 auto __index = __counters[__map(__preimage)]++;
140 __result[__index] = std::move(__preimage);
141 });
142}
143
144template <class _ForwardIterator,
145 class _Map,
146 class _Radix,
147 class _RandomAccessIterator1,
148 class _RandomAccessIterator2,
149 size_t... _Radices>
150_LIBCPP_HIDE_FROM_ABI bool __collect_impl(
151 _ForwardIterator __first,
152 _ForwardIterator __last,
153 _Map __map,
154 _Radix __radix,
155 _RandomAccessIterator1 __counters,
156 _RandomAccessIterator2 __maximums,
157 index_sequence<_Radices...>) {
158 using __value_type = __iter_value_type<_ForwardIterator>;
159 constexpr auto __radix_value_range = __radix_sort_traits<__value_type, _Map, _Radix>::__radix_value_range;
160
161 auto __previous = numeric_limits<__invoke_result_t<_Map, __value_type>>::min();
162 auto __is_sorted = true;
163 std::for_each(__first, __last, [&__counters, &__map, &__radix, &__previous, &__is_sorted](const auto& __value) {
164 auto __current = __map(__value);
165 __is_sorted &= (__current >= __previous);
166 __previous = __current;
167
168 (++__counters[_Radices][std::__nth_radix(_Radices, __radix, __current)], ...);
169 });
170
171 ((__maximums[_Radices] =
172 std::__partial_sum_max(__counters[_Radices], __counters[_Radices] + __radix_value_range, __counters[_Radices])
173 .second),
174 ...);
175
176 return __is_sorted;
177}
178
179template <class _ForwardIterator, class _Map, class _Radix, class _RandomAccessIterator1, class _RandomAccessIterator2>
180_LIBCPP_HIDE_FROM_ABI bool
181__collect(_ForwardIterator __first,
182 _ForwardIterator __last,
183 _Map __map,
184 _Radix __radix,
185 _RandomAccessIterator1 __counters,
186 _RandomAccessIterator2 __maximums) {
187 using __value_type = __iter_value_type<_ForwardIterator>;
188 constexpr auto __radix_count = __radix_sort_traits<__value_type, _Map, _Radix>::__radix_count;
189 return std::__collect_impl(
190 __first, __last, __map, __radix, __counters, __maximums, make_index_sequence<__radix_count>());
191}
192
193template <class _BidirectionalIterator, class _RandomAccessIterator1, class _Map, class _RandomAccessIterator2>
194_LIBCPP_HIDE_FROM_ABI void __dispose_backward(
195 _BidirectionalIterator __first,
196 _BidirectionalIterator __last,
197 _RandomAccessIterator1 __result,
198 _Map __map,
199 _RandomAccessIterator2 __counters) {
200 std::for_each(std::make_reverse_iterator(__last),
201 std::make_reverse_iterator(__first),
202 [&__result, &__counters, &__map](auto&& __preimage) {
203 auto __index = --__counters[__map(__preimage)];
204 __result[__index] = std::move(__preimage);
205 });
206}
207
208template <class _ForwardIterator, class _RandomAccessIterator, class _Map>
209_LIBCPP_HIDE_FROM_ABI _RandomAccessIterator
210__counting_sort_impl(_ForwardIterator __first, _ForwardIterator __last, _RandomAccessIterator __result, _Map __map) {
211 using __value_type = __iter_value_type<_ForwardIterator>;
212 using __traits = __counting_sort_traits<__value_type, _Map>;
213
214 __iter_diff_t<_RandomAccessIterator> __counters[__traits::__value_range + 1] = {0};
215
216 std::__collect(__first, __last, __map, std::next(std::begin(__counters)));
217 std::__dispose(__first, __last, __result, __map, std::begin(__counters));
218
219 return __result + __counters[__traits::__value_range];
220}
221
222template <class _RandomAccessIterator1,
223 class _RandomAccessIterator2,
224 class _Map,
225 class _Radix,
226 enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count == 1,
227 int> = 0>
228_LIBCPP_HIDE_FROM_ABI void __radix_sort_impl(
229 _RandomAccessIterator1 __first,
230 _RandomAccessIterator1 __last,
231 _RandomAccessIterator2 __buffer,
232 _Map __map,
233 _Radix __radix) {
234 auto __buffer_end = std::__counting_sort_impl(__first, __last, __buffer, [&__map, &__radix](const auto& __value) {
235 return __radix(__map(__value));
236 });
237
238 std::move(__buffer, __buffer_end, __first);
239}
240
241template <
242 class _RandomAccessIterator1,
243 class _RandomAccessIterator2,
244 class _Map,
245 class _Radix,
246 enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count % 2 == 0,
247 int> = 0 >
248_LIBCPP_HIDE_FROM_ABI void __radix_sort_impl(
249 _RandomAccessIterator1 __first,
250 _RandomAccessIterator1 __last,
251 _RandomAccessIterator2 __buffer_begin,
252 _Map __map,
253 _Radix __radix) {
254 using __value_type = __iter_value_type<_RandomAccessIterator1>;
255 using __traits = __radix_sort_traits<__value_type, _Map, _Radix>;
256
257 __iter_diff_t<_RandomAccessIterator1> __counters[__traits::__radix_count][__traits::__radix_value_range] = {{0}};
258 __iter_diff_t<_RandomAccessIterator1> __maximums[__traits::__radix_count] = {0};
259 const auto __is_sorted = std::__collect(__first, __last, __map, __radix, __counters, __maximums);
260 if (!__is_sorted) {
261 const auto __range_size = std::distance(__first, __last);
262 auto __buffer_end = __buffer_begin + __range_size;
263 for (size_t __radix_number = 0; __radix_number < __traits::__radix_count; __radix_number += 2) {
264 const auto __n0th_is_single = __maximums[__radix_number] == __range_size;
265 const auto __n1th_is_single = __maximums[__radix_number + 1] == __range_size;
266
267 if (__n0th_is_single && __n1th_is_single) {
268 continue;
269 }
270
271 if (__n0th_is_single) {
272 std::move(__first, __last, __buffer_begin);
273 } else {
274 auto __n0th = [__radix_number, &__map, &__radix](const auto& __v) {
275 return std::__nth_radix(__radix_number, __radix, __map(__v));
276 };
277 std::__dispose_backward(__first, __last, __buffer_begin, __n0th, __counters[__radix_number]);
278 }
279
280 if (__n1th_is_single) {
281 std::move(__buffer_begin, __buffer_end, __first);
282 } else {
283 auto __n1th = [__radix_number, &__map, &__radix](const auto& __v) {
284 return std::__nth_radix(__radix_number + 1, __radix, __map(__v));
285 };
286 std::__dispose_backward(__buffer_begin, __buffer_end, __first, __n1th, __counters[__radix_number + 1]);
287 }
288 }
289 }
290}
291
292_LIBCPP_HIDE_FROM_ABI constexpr auto __shift_to_unsigned(bool __b) { return __b; }
293
294template <class _Ip>
295_LIBCPP_HIDE_FROM_ABI constexpr auto __shift_to_unsigned(_Ip __n) {
296 constexpr const auto __min_value = numeric_limits<_Ip>::min();
297 return static_cast<make_unsigned_t<_Ip> >(__n ^ __min_value);
298}
299
300struct __low_byte_fn {
301 template <class _Ip>
302 _LIBCPP_HIDE_FROM_ABI constexpr uint8_t operator()(_Ip __integer) const {
303 static_assert(is_unsigned<_Ip>::value);
304
305 return static_cast<uint8_t>(__integer & 0xff);
306 }
307};
308
309template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _Map, class _Radix>
310_LIBCPP_HIDE_FROM_ABI void
311__radix_sort(_RandomAccessIterator1 __first,
312 _RandomAccessIterator1 __last,
313 _RandomAccessIterator2 __buffer,
314 _Map __map,
315 _Radix __radix) {
316 auto __map_to_unsigned = [__map = std::move(__map)](const auto& __x) { return std::__shift_to_unsigned(__map(__x)); };
317 std::__radix_sort_impl(__first, __last, __buffer, __map_to_unsigned, __radix);
318}
319
320template <class _RandomAccessIterator1, class _RandomAccessIterator2>
321_LIBCPP_HIDE_FROM_ABI void
322__radix_sort(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _RandomAccessIterator2 __buffer) {
323 std::__radix_sort(__first, __last, __buffer, __identity{}, __low_byte_fn{});
324}
325
326#endif // _LIBCPP_STD_VER >= 14
327
328_LIBCPP_END_NAMESPACE_STD
329
330_LIBCPP_POP_MACROS
331
332#endif // _LIBCPP___ALGORITHM_RADIX_SORT_H
lib/libcxx/include/__algorithm/ranges_adjacent_find.h+5-22
...@@ -9,9 +9,9 @@...@@ -9,9 +9,9 @@
9#ifndef _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H9#ifndef _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H
10#define _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H10#define _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H
1111
12#include <__algorithm/adjacent_find.h>
12#include <__config>13#include <__config>
13#include <__functional/identity.h>14#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__functional/ranges_operations.h>15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
17#include <__iterator/projected.h>17#include <__iterator/projected.h>
...@@ -32,30 +32,14 @@ _LIBCPP_PUSH_MACROS...@@ -32,30 +32,14 @@ _LIBCPP_PUSH_MACROS
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
34namespace ranges {34namespace ranges {
35namespace __adjacent_find {35struct __adjacent_find {
36struct __fn {
37 template <class _Iter, class _Sent, class _Proj, class _Pred>
38 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
39 __adjacent_find_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
40 if (__first == __last)
41 return __first;
42
43 auto __i = __first;
44 while (++__i != __last) {
45 if (std::invoke(__pred, std::invoke(__proj, *__first), std::invoke(__proj, *__i)))
46 return __first;
47 __first = __i;
48 }
49 return __i;
50 }
51
52 template <forward_iterator _Iter,36 template <forward_iterator _Iter,
53 sentinel_for<_Iter> _Sent,37 sentinel_for<_Iter> _Sent,
54 class _Proj = identity,38 class _Proj = identity,
55 indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to>39 indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to>
56 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter40 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter
57 operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {41 operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
58 return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj);42 return std::__adjacent_find(std::move(__first), std::move(__last), __pred, __proj);
59 }43 }
6044
61 template <forward_range _Range,45 template <forward_range _Range,
...@@ -64,13 +48,12 @@ struct __fn {...@@ -64,13 +48,12 @@ struct __fn {
64 _Pred = ranges::equal_to>48 _Pred = ranges::equal_to>
65 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>49 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
66 operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const {50 operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const {
67 return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);51 return std::__adjacent_find(ranges::begin(__range), ranges::end(__range), __pred, __proj);
68 }52 }
69};53};
70} // namespace __adjacent_find
7154
72inline namespace __cpo {55inline namespace __cpo {
73inline constexpr auto adjacent_find = __adjacent_find::__fn{};56inline constexpr auto adjacent_find = __adjacent_find{};
74} // namespace __cpo57} // namespace __cpo
75} // namespace ranges58} // namespace ranges
7659
lib/libcxx/include/__algorithm/ranges_all_of.h+5-15
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
9#ifndef _LIBCPP___ALGORITHM_RANGES_ALL_OF_H9#ifndef _LIBCPP___ALGORITHM_RANGES_ALL_OF_H
10#define _LIBCPP___ALGORITHM_RANGES_ALL_OF_H10#define _LIBCPP___ALGORITHM_RANGES_ALL_OF_H
1111
12#include <__algorithm/all_of.h>
12#include <__config>13#include <__config>
13#include <__functional/identity.h>14#include <__functional/identity.h>
14#include <__functional/invoke.h>15#include <__functional/invoke.h>
...@@ -30,24 +31,14 @@ _LIBCPP_PUSH_MACROS...@@ -30,24 +31,14 @@ _LIBCPP_PUSH_MACROS
30_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3132
32namespace ranges {33namespace ranges {
33namespace __all_of {34struct __all_of {
34struct __fn {
35 template <class _Iter, class _Sent, class _Proj, class _Pred>
36 _LIBCPP_HIDE_FROM_ABI constexpr static bool __all_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
37 for (; __first != __last; ++__first) {
38 if (!std::invoke(__pred, std::invoke(__proj, *__first)))
39 return false;
40 }
41 return true;
42 }
43
44 template <input_iterator _Iter,35 template <input_iterator _Iter,
45 sentinel_for<_Iter> _Sent,36 sentinel_for<_Iter> _Sent,
46 class _Proj = identity,37 class _Proj = identity,
47 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>38 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
48 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool39 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
49 operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {40 operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
50 return __all_of_impl(std::move(__first), std::move(__last), __pred, __proj);41 return std::__all_of(std::move(__first), std::move(__last), __pred, __proj);
51 }42 }
5243
53 template <input_range _Range,44 template <input_range _Range,
...@@ -55,13 +46,12 @@ struct __fn {...@@ -55,13 +46,12 @@ struct __fn {
55 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>46 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
56 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool47 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
57 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {48 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
58 return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);49 return std::__all_of(ranges::begin(__range), ranges::end(__range), __pred, __proj);
59 }50 }
60};51};
61} // namespace __all_of
6252
63inline namespace __cpo {53inline namespace __cpo {
64inline constexpr auto all_of = __all_of::__fn{};54inline constexpr auto all_of = __all_of{};
65} // namespace __cpo55} // namespace __cpo
66} // namespace ranges56} // namespace ranges
6757
lib/libcxx/include/__algorithm/ranges_any_of.h+5-16
...@@ -9,9 +9,9 @@...@@ -9,9 +9,9 @@
9#ifndef _LIBCPP___ALGORITHM_RANGES_ANY_OF_H9#ifndef _LIBCPP___ALGORITHM_RANGES_ANY_OF_H
10#define _LIBCPP___ALGORITHM_RANGES_ANY_OF_H10#define _LIBCPP___ALGORITHM_RANGES_ANY_OF_H
1111
12#include <__algorithm/any_of.h>
12#include <__config>13#include <__config>
13#include <__functional/identity.h>14#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__iterator/concepts.h>15#include <__iterator/concepts.h>
16#include <__iterator/projected.h>16#include <__iterator/projected.h>
17#include <__ranges/access.h>17#include <__ranges/access.h>
...@@ -30,24 +30,14 @@ _LIBCPP_PUSH_MACROS...@@ -30,24 +30,14 @@ _LIBCPP_PUSH_MACROS
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
32namespace ranges {32namespace ranges {
33namespace __any_of {33struct __any_of {
34struct __fn {
35 template <class _Iter, class _Sent, class _Proj, class _Pred>
36 _LIBCPP_HIDE_FROM_ABI constexpr static bool __any_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
37 for (; __first != __last; ++__first) {
38 if (std::invoke(__pred, std::invoke(__proj, *__first)))
39 return true;
40 }
41 return false;
42 }
43
44 template <input_iterator _Iter,34 template <input_iterator _Iter,
45 sentinel_for<_Iter> _Sent,35 sentinel_for<_Iter> _Sent,
46 class _Proj = identity,36 class _Proj = identity,
47 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>37 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
48 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool38 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
49 operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {39 operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
50 return __any_of_impl(std::move(__first), std::move(__last), __pred, __proj);40 return std::__any_of(std::move(__first), std::move(__last), __pred, __proj);
51 }41 }
5242
53 template <input_range _Range,43 template <input_range _Range,
...@@ -55,13 +45,12 @@ struct __fn {...@@ -55,13 +45,12 @@ struct __fn {
55 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>45 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
56 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool46 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
57 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {47 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
58 return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);48 return std::__any_of(ranges::begin(__range), ranges::end(__range), __pred, __proj);
59 }49 }
60};50};
61} // namespace __any_of
6251
63inline namespace __cpo {52inline namespace __cpo {
64inline constexpr auto any_of = __any_of::__fn{};53inline constexpr auto any_of = __any_of{};
65} // namespace __cpo54} // namespace __cpo
66} // namespace ranges55} // namespace ranges
6756
lib/libcxx/include/__algorithm/ranges_binary_search.h+2-4
...@@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS...@@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
34namespace ranges {34namespace ranges {
35namespace __binary_search {35struct __binary_search {
36struct __fn {
37 template <forward_iterator _Iter,36 template <forward_iterator _Iter,
38 sentinel_for<_Iter> _Sent,37 sentinel_for<_Iter> _Sent,
39 class _Type,38 class _Type,
...@@ -57,10 +56,9 @@ struct __fn {...@@ -57,10 +56,9 @@ struct __fn {
57 return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__ret));56 return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__ret));
58 }57 }
59};58};
60} // namespace __binary_search
6159
62inline namespace __cpo {60inline namespace __cpo {
63inline constexpr auto binary_search = __binary_search::__fn{};61inline constexpr auto binary_search = __binary_search{};
64} // namespace __cpo62} // namespace __cpo
65} // namespace ranges63} // namespace ranges
6664
lib/libcxx/include/__algorithm/ranges_clamp.h+2-4
...@@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS...@@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
32namespace ranges {32namespace ranges {
33namespace __clamp {33struct __clamp {
34struct __fn {
35 template <class _Type,34 template <class _Type,
36 class _Proj = identity,35 class _Proj = identity,
37 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>36 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
...@@ -50,10 +49,9 @@ struct __fn {...@@ -50,10 +49,9 @@ struct __fn {
50 return __value;49 return __value;
51 }50 }
52};51};
53} // namespace __clamp
5452
55inline namespace __cpo {53inline namespace __cpo {
56inline constexpr auto clamp = __clamp::__fn{};54inline constexpr auto clamp = __clamp{};
57} // namespace __cpo55} // namespace __cpo
58} // namespace ranges56} // namespace ranges
5957
lib/libcxx/include/__algorithm/ranges_contains.h+2-4
...@@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS...@@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS
33_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3434
35namespace ranges {35namespace ranges {
36namespace __contains {36struct __contains {
37struct __fn {
38 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>37 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
39 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>38 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
40 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static39 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static
...@@ -50,10 +49,9 @@ struct __fn {...@@ -50,10 +49,9 @@ struct __fn {
50 ranges::end(__range);49 ranges::end(__range);
51 }50 }
52};51};
53} // namespace __contains
5452
55inline namespace __cpo {53inline namespace __cpo {
56inline constexpr auto contains = __contains::__fn{};54inline constexpr auto contains = __contains{};
57} // namespace __cpo55} // namespace __cpo
58} // namespace ranges56} // namespace ranges
5957
lib/libcxx/include/__algorithm/ranges_contains_subrange.h+2-4
...@@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS...@@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS
35_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3636
37namespace ranges {37namespace ranges {
38namespace __contains_subrange {38struct __contains_subrange {
39struct __fn {
40 template <forward_iterator _Iter1,39 template <forward_iterator _Iter1,
41 sentinel_for<_Iter1> _Sent1,40 sentinel_for<_Iter1> _Sent1,
42 forward_iterator _Iter2,41 forward_iterator _Iter2,
...@@ -81,10 +80,9 @@ struct __fn {...@@ -81,10 +80,9 @@ struct __fn {
81 return __ret.empty() == false;80 return __ret.empty() == false;
82 }81 }
83};82};
84} // namespace __contains_subrange
8583
86inline namespace __cpo {84inline namespace __cpo {
87inline constexpr auto contains_subrange = __contains_subrange::__fn{};85inline constexpr auto contains_subrange = __contains_subrange{};
88} // namespace __cpo86} // namespace __cpo
89} // namespace ranges87} // namespace ranges
9088
lib/libcxx/include/__algorithm/ranges_copy.h+4-7
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
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>
15#include <__config>14#include <__config>
16#include <__functional/identity.h>15#include <__functional/identity.h>
17#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
...@@ -37,13 +36,12 @@ namespace ranges {...@@ -37,13 +36,12 @@ namespace ranges {
37template <class _InIter, class _OutIter>36template <class _InIter, class _OutIter>
38using copy_result = in_out_result<_InIter, _OutIter>;37using copy_result = in_out_result<_InIter, _OutIter>;
3938
40namespace __copy {39struct __copy {
41struct __fn {
42 template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>40 template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
43 requires indirectly_copyable<_InIter, _OutIter>41 requires indirectly_copyable<_InIter, _OutIter>
44 _LIBCPP_HIDE_FROM_ABI constexpr copy_result<_InIter, _OutIter>42 _LIBCPP_HIDE_FROM_ABI constexpr copy_result<_InIter, _OutIter>
45 operator()(_InIter __first, _Sent __last, _OutIter __result) const {43 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
46 auto __ret = std::__copy<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));44 auto __ret = std::__copy(std::move(__first), std::move(__last), std::move(__result));
47 return {std::move(__ret.first), std::move(__ret.second)};45 return {std::move(__ret.first), std::move(__ret.second)};
48 }46 }
4947
...@@ -51,14 +49,13 @@ struct __fn {...@@ -51,14 +49,13 @@ struct __fn {
51 requires indirectly_copyable<iterator_t<_Range>, _OutIter>49 requires indirectly_copyable<iterator_t<_Range>, _OutIter>
52 _LIBCPP_HIDE_FROM_ABI constexpr copy_result<borrowed_iterator_t<_Range>, _OutIter>50 _LIBCPP_HIDE_FROM_ABI constexpr copy_result<borrowed_iterator_t<_Range>, _OutIter>
53 operator()(_Range&& __r, _OutIter __result) const {51 operator()(_Range&& __r, _OutIter __result) const {
54 auto __ret = std::__copy<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), std::move(__result));52 auto __ret = std::__copy(ranges::begin(__r), ranges::end(__r), std::move(__result));
55 return {std::move(__ret.first), std::move(__ret.second)};53 return {std::move(__ret.first), std::move(__ret.second)};
56 }54 }
57};55};
58} // namespace __copy
5956
60inline namespace __cpo {57inline namespace __cpo {
61inline constexpr auto copy = __copy::__fn{};58inline constexpr auto copy = __copy{};
62} // namespace __cpo59} // namespace __cpo
63} // namespace ranges60} // namespace ranges
6461
lib/libcxx/include/__algorithm/ranges_copy_backward.h+2-4
...@@ -35,8 +35,7 @@ namespace ranges {...@@ -35,8 +35,7 @@ namespace ranges {
35template <class _Ip, class _Op>35template <class _Ip, class _Op>
36using copy_backward_result = in_out_result<_Ip, _Op>;36using copy_backward_result = in_out_result<_Ip, _Op>;
3737
38namespace __copy_backward {38struct __copy_backward {
39struct __fn {
40 template <bidirectional_iterator _InIter1, sentinel_for<_InIter1> _Sent1, bidirectional_iterator _InIter2>39 template <bidirectional_iterator _InIter1, sentinel_for<_InIter1> _Sent1, bidirectional_iterator _InIter2>
41 requires indirectly_copyable<_InIter1, _InIter2>40 requires indirectly_copyable<_InIter1, _InIter2>
42 _LIBCPP_HIDE_FROM_ABI constexpr copy_backward_result<_InIter1, _InIter2>41 _LIBCPP_HIDE_FROM_ABI constexpr copy_backward_result<_InIter1, _InIter2>
...@@ -53,10 +52,9 @@ struct __fn {...@@ -53,10 +52,9 @@ struct __fn {
53 return {std::move(__ret.first), std::move(__ret.second)};52 return {std::move(__ret.first), std::move(__ret.second)};
54 }53 }
55};54};
56} // namespace __copy_backward
5755
58inline namespace __cpo {56inline namespace __cpo {
59inline constexpr auto copy_backward = __copy_backward::__fn{};57inline constexpr auto copy_backward = __copy_backward{};
60} // namespace __cpo58} // namespace __cpo
61} // namespace ranges59} // namespace ranges
6260
lib/libcxx/include/__algorithm/ranges_copy_if.h+7-18
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
9#ifndef _LIBCPP___ALGORITHM_RANGES_COPY_IF_H9#ifndef _LIBCPP___ALGORITHM_RANGES_COPY_IF_H
10#define _LIBCPP___ALGORITHM_RANGES_COPY_IF_H10#define _LIBCPP___ALGORITHM_RANGES_COPY_IF_H
1111
12#include <__algorithm/copy_if.h>
12#include <__algorithm/in_out_result.h>13#include <__algorithm/in_out_result.h>
13#include <__config>14#include <__config>
14#include <__functional/identity.h>15#include <__functional/identity.h>
...@@ -36,20 +37,7 @@ namespace ranges {...@@ -36,20 +37,7 @@ namespace ranges {
36template <class _Ip, class _Op>37template <class _Ip, class _Op>
37using copy_if_result = in_out_result<_Ip, _Op>;38using copy_if_result = in_out_result<_Ip, _Op>;
3839
39namespace __copy_if {40struct __copy_if {
40struct __fn {
41 template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred>
42 _LIBCPP_HIDE_FROM_ABI static constexpr copy_if_result<_InIter, _OutIter>
43 __copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) {
44 for (; __first != __last; ++__first) {
45 if (std::invoke(__pred, std::invoke(__proj, *__first))) {
46 *__result = *__first;
47 ++__result;
48 }
49 }
50 return {std::move(__first), std::move(__result)};
51 }
52
53 template <input_iterator _Iter,41 template <input_iterator _Iter,
54 sentinel_for<_Iter> _Sent,42 sentinel_for<_Iter> _Sent,
55 weakly_incrementable _OutIter,43 weakly_incrementable _OutIter,
...@@ -58,7 +46,8 @@ struct __fn {...@@ -58,7 +46,8 @@ struct __fn {
58 requires indirectly_copyable<_Iter, _OutIter>46 requires indirectly_copyable<_Iter, _OutIter>
59 _LIBCPP_HIDE_FROM_ABI constexpr copy_if_result<_Iter, _OutIter>47 _LIBCPP_HIDE_FROM_ABI constexpr copy_if_result<_Iter, _OutIter>
60 operator()(_Iter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {48 operator()(_Iter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
61 return __copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj);49 auto __res = std::__copy_if(std::move(__first), std::move(__last), std::move(__result), __pred, __proj);
50 return {std::move(__res.first), std::move(__res.second)};
62 }51 }
6352
64 template <input_range _Range,53 template <input_range _Range,
...@@ -68,13 +57,13 @@ struct __fn {...@@ -68,13 +57,13 @@ struct __fn {
68 requires indirectly_copyable<iterator_t<_Range>, _OutIter>57 requires indirectly_copyable<iterator_t<_Range>, _OutIter>
69 _LIBCPP_HIDE_FROM_ABI constexpr copy_if_result<borrowed_iterator_t<_Range>, _OutIter>58 _LIBCPP_HIDE_FROM_ABI constexpr copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
70 operator()(_Range&& __r, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {59 operator()(_Range&& __r, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
71 return __copy_if_impl(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj);60 auto __res = std::__copy_if(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj);
61 return {std::move(__res.first), std::move(__res.second)};
72 }62 }
73};63};
74} // namespace __copy_if
7564
76inline namespace __cpo {65inline namespace __cpo {
77inline constexpr auto copy_if = __copy_if::__fn{};66inline constexpr auto copy_if = __copy_if{};
78} // namespace __cpo67} // namespace __cpo
79} // namespace ranges68} // namespace ranges
8069
lib/libcxx/include/__algorithm/ranges_copy_n.h+4-5
...@@ -37,8 +37,8 @@ namespace ranges {...@@ -37,8 +37,8 @@ namespace ranges {
37template <class _Ip, class _Op>37template <class _Ip, class _Op>
38using copy_n_result = in_out_result<_Ip, _Op>;38using copy_n_result = in_out_result<_Ip, _Op>;
3939
40namespace __copy_n {40// TODO: Merge this with copy_n
41struct __fn {41struct __copy_n {
42 template <class _InIter, class _DiffType, class _OutIter>42 template <class _InIter, class _DiffType, class _OutIter>
43 _LIBCPP_HIDE_FROM_ABI constexpr static copy_n_result<_InIter, _OutIter>43 _LIBCPP_HIDE_FROM_ABI constexpr static copy_n_result<_InIter, _OutIter>
44 __go(_InIter __first, _DiffType __n, _OutIter __result) {44 __go(_InIter __first, _DiffType __n, _OutIter __result) {
...@@ -54,7 +54,7 @@ struct __fn {...@@ -54,7 +54,7 @@ struct __fn {
54 template <random_access_iterator _InIter, class _DiffType, random_access_iterator _OutIter>54 template <random_access_iterator _InIter, class _DiffType, random_access_iterator _OutIter>
55 _LIBCPP_HIDE_FROM_ABI constexpr static copy_n_result<_InIter, _OutIter>55 _LIBCPP_HIDE_FROM_ABI constexpr static copy_n_result<_InIter, _OutIter>
56 __go(_InIter __first, _DiffType __n, _OutIter __result) {56 __go(_InIter __first, _DiffType __n, _OutIter __result) {
57 auto __ret = std::__copy<_RangeAlgPolicy>(__first, __first + __n, __result);57 auto __ret = std::__copy(__first, __first + __n, __result);
58 return {__ret.first, __ret.second};58 return {__ret.first, __ret.second};
59 }59 }
6060
...@@ -65,10 +65,9 @@ struct __fn {...@@ -65,10 +65,9 @@ struct __fn {
65 return __go(std::move(__first), __n, std::move(__result));65 return __go(std::move(__first), __n, std::move(__result));
66 }66 }
67};67};
68} // namespace __copy_n
6968
70inline namespace __cpo {69inline namespace __cpo {
71inline constexpr auto copy_n = __copy_n::__fn{};70inline constexpr auto copy_n = __copy_n{};
72} // namespace __cpo71} // namespace __cpo
73} // namespace ranges72} // namespace ranges
7473
lib/libcxx/include/__algorithm/ranges_count.h+2-4
...@@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS...@@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS
34_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3535
36namespace ranges {36namespace ranges {
37namespace __count {37struct __count {
38struct __fn {
39 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>38 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
40 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>39 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
41 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>40 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>
...@@ -50,10 +49,9 @@ struct __fn {...@@ -50,10 +49,9 @@ struct __fn {
50 return std::__count<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __proj);49 return std::__count<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __proj);
51 }50 }
52};51};
53} // namespace __count
5452
55inline namespace __cpo {53inline namespace __cpo {
56inline constexpr auto count = __count::__fn{};54inline constexpr auto count = __count{};
57} // namespace __cpo55} // namespace __cpo
58} // namespace ranges56} // namespace ranges
5957
lib/libcxx/include/__algorithm/ranges_count_if.h+6-18
...@@ -9,9 +9,10 @@...@@ -9,9 +9,10 @@
9#ifndef _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H9#ifndef _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H
10#define _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H10#define _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H
1111
12#include <__algorithm/count_if.h>
13#include <__algorithm/iterator_operations.h>
12#include <__config>14#include <__config>
13#include <__functional/identity.h>15#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__functional/ranges_operations.h>16#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>17#include <__iterator/concepts.h>
17#include <__iterator/incrementable_traits.h>18#include <__iterator/incrementable_traits.h>
...@@ -33,26 +34,14 @@ _LIBCPP_PUSH_MACROS...@@ -33,26 +34,14 @@ _LIBCPP_PUSH_MACROS
33_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3435
35namespace ranges {36namespace ranges {
36template <class _Iter, class _Sent, class _Proj, class _Pred>37struct __count_if {
37_LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>
38__count_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
39 iter_difference_t<_Iter> __counter(0);
40 for (; __first != __last; ++__first) {
41 if (std::invoke(__pred, std::invoke(__proj, *__first)))
42 ++__counter;
43 }
44 return __counter;
45}
46
47namespace __count_if {
48struct __fn {
49 template <input_iterator _Iter,38 template <input_iterator _Iter,
50 sentinel_for<_Iter> _Sent,39 sentinel_for<_Iter> _Sent,
51 class _Proj = identity,40 class _Proj = identity,
52 indirect_unary_predicate<projected<_Iter, _Proj>> _Predicate>41 indirect_unary_predicate<projected<_Iter, _Proj>> _Predicate>
53 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>42 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>
54 operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const {43 operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const {
55 return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);44 return std::__count_if<_RangeAlgPolicy>(std::move(__first), std::move(__last), __pred, __proj);
56 }45 }
5746
58 template <input_range _Range,47 template <input_range _Range,
...@@ -60,13 +49,12 @@ struct __fn {...@@ -60,13 +49,12 @@ struct __fn {
60 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Predicate>49 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Predicate>
61 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range>50 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range>
62 operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const {51 operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const {
63 return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);52 return std::__count_if<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __pred, __proj);
64 }53 }
65};54};
66} // namespace __count_if
6755
68inline namespace __cpo {56inline namespace __cpo {
69inline constexpr auto count_if = __count_if::__fn{};57inline constexpr auto count_if = __count_if{};
70} // namespace __cpo58} // namespace __cpo
71} // namespace ranges59} // namespace ranges
7260
lib/libcxx/include/__algorithm/ranges_ends_with.h+3-4
...@@ -22,6 +22,7 @@...@@ -22,6 +22,7 @@
22#include <__iterator/reverse_iterator.h>22#include <__iterator/reverse_iterator.h>
23#include <__ranges/access.h>23#include <__ranges/access.h>
24#include <__ranges/concepts.h>24#include <__ranges/concepts.h>
25#include <__ranges/size.h>
25#include <__utility/move.h>26#include <__utility/move.h>
2627
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -36,8 +37,7 @@ _LIBCPP_PUSH_MACROS...@@ -36,8 +37,7 @@ _LIBCPP_PUSH_MACROS
36_LIBCPP_BEGIN_NAMESPACE_STD37_LIBCPP_BEGIN_NAMESPACE_STD
3738
38namespace ranges {39namespace ranges {
39namespace __ends_with {40struct __ends_with {
40struct __fn {
41 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>41 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
42 _LIBCPP_HIDE_FROM_ABI static constexpr bool __ends_with_fn_impl_bidirectional(42 _LIBCPP_HIDE_FROM_ABI static constexpr bool __ends_with_fn_impl_bidirectional(
43 _Iter1 __first1,43 _Iter1 __first1,
...@@ -185,10 +185,9 @@ struct __fn {...@@ -185,10 +185,9 @@ struct __fn {
185 }185 }
186 }186 }
187};187};
188} // namespace __ends_with
189188
190inline namespace __cpo {189inline namespace __cpo {
191inline constexpr auto ends_with = __ends_with::__fn{};190inline constexpr auto ends_with = __ends_with{};
192} // namespace __cpo191} // namespace __cpo
193} // namespace ranges192} // namespace ranges
194193
lib/libcxx/include/__algorithm/ranges_equal.h+2-4
...@@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS...@@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS
34_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3535
36namespace ranges {36namespace ranges {
37namespace __equal {37struct __equal {
38struct __fn {
39 template <input_iterator _Iter1,38 template <input_iterator _Iter1,
40 sentinel_for<_Iter1> _Sent1,39 sentinel_for<_Iter1> _Sent1,
41 input_iterator _Iter2,40 input_iterator _Iter2,
...@@ -93,10 +92,9 @@ struct __fn {...@@ -93,10 +92,9 @@ struct __fn {
93 return false;92 return false;
94 }93 }
95};94};
96} // namespace __equal
9795
98inline namespace __cpo {96inline namespace __cpo {
99inline constexpr auto equal = __equal::__fn{};97inline constexpr auto equal = __equal{};
100} // namespace __cpo98} // namespace __cpo
101} // namespace ranges99} // namespace ranges
102100
lib/libcxx/include/__algorithm/ranges_equal_range.h+2-6
...@@ -38,9 +38,7 @@ _LIBCPP_PUSH_MACROS...@@ -38,9 +38,7 @@ _LIBCPP_PUSH_MACROS
38_LIBCPP_BEGIN_NAMESPACE_STD38_LIBCPP_BEGIN_NAMESPACE_STD
3939
40namespace ranges {40namespace ranges {
41namespace __equal_range {41struct __equal_range {
42
43struct __fn {
44 template <forward_iterator _Iter,42 template <forward_iterator _Iter,
45 sentinel_for<_Iter> _Sent,43 sentinel_for<_Iter> _Sent,
46 class _Tp,44 class _Tp,
...@@ -64,10 +62,8 @@ struct __fn {...@@ -64,10 +62,8 @@ struct __fn {
64 }62 }
65};63};
6664
67} // namespace __equal_range
68
69inline namespace __cpo {65inline namespace __cpo {
70inline constexpr auto equal_range = __equal_range::__fn{};66inline constexpr auto equal_range = __equal_range{};
71} // namespace __cpo67} // namespace __cpo
72} // namespace ranges68} // namespace ranges
7369
lib/libcxx/include/__algorithm/ranges_fill.h+2-4
...@@ -28,8 +28,7 @@ _LIBCPP_PUSH_MACROS...@@ -28,8 +28,7 @@ _LIBCPP_PUSH_MACROS
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
30namespace ranges {30namespace ranges {
31namespace __fill {31struct __fill {
32struct __fn {
33 template <class _Type, output_iterator<const _Type&> _Iter, sentinel_for<_Iter> _Sent>32 template <class _Type, output_iterator<const _Type&> _Iter, sentinel_for<_Iter> _Sent>
34 _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, const _Type& __value) const {33 _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, const _Type& __value) const {
35 if constexpr (random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>) {34 if constexpr (random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>) {
...@@ -46,10 +45,9 @@ struct __fn {...@@ -46,10 +45,9 @@ struct __fn {
46 return (*this)(ranges::begin(__range), ranges::end(__range), __value);45 return (*this)(ranges::begin(__range), ranges::end(__range), __value);
47 }46 }
48};47};
49} // namespace __fill
5048
51inline namespace __cpo {49inline namespace __cpo {
52inline constexpr auto fill = __fill::__fn{};50inline constexpr auto fill = __fill{};
53} // namespace __cpo51} // namespace __cpo
54} // namespace ranges52} // namespace ranges
5553
lib/libcxx/include/__algorithm/ranges_fill_n.h+5-9
...@@ -9,9 +9,11 @@...@@ -9,9 +9,11 @@
9#ifndef _LIBCPP___ALGORITHM_RANGES_FILL_N_H9#ifndef _LIBCPP___ALGORITHM_RANGES_FILL_N_H
10#define _LIBCPP___ALGORITHM_RANGES_FILL_N_H10#define _LIBCPP___ALGORITHM_RANGES_FILL_N_H
1111
12#include <__algorithm/fill_n.h>
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>
16#include <__utility/move.h>
1517
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header19# pragma GCC system_header
...@@ -25,22 +27,16 @@ _LIBCPP_PUSH_MACROS...@@ -25,22 +27,16 @@ _LIBCPP_PUSH_MACROS
25_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2628
27namespace ranges {29namespace ranges {
28namespace __fill_n {30struct __fill_n {
29struct __fn {
30 template <class _Type, output_iterator<const _Type&> _Iter>31 template <class _Type, output_iterator<const _Type&> _Iter>
31 _LIBCPP_HIDE_FROM_ABI constexpr _Iter32 _LIBCPP_HIDE_FROM_ABI constexpr _Iter
32 operator()(_Iter __first, iter_difference_t<_Iter> __n, const _Type& __value) const {33 operator()(_Iter __first, iter_difference_t<_Iter> __n, const _Type& __value) const {
33 for (; __n != 0; --__n) {34 return std::__fill_n(std::move(__first), __n, __value);
34 *__first = __value;
35 ++__first;
36 }
37 return __first;
38 }35 }
39};36};
40} // namespace __fill_n
4137
42inline namespace __cpo {38inline namespace __cpo {
43inline constexpr auto fill_n = __fill_n::__fn{};39inline constexpr auto fill_n = __fill_n{};
44} // namespace __cpo40} // namespace __cpo
45} // namespace ranges41} // namespace ranges
4642
lib/libcxx/include/__algorithm/ranges_find.h+2-4
...@@ -36,8 +36,7 @@ _LIBCPP_PUSH_MACROS...@@ -36,8 +36,7 @@ _LIBCPP_PUSH_MACROS
36_LIBCPP_BEGIN_NAMESPACE_STD36_LIBCPP_BEGIN_NAMESPACE_STD
3737
38namespace ranges {38namespace ranges {
39namespace __find {39struct __find {
40struct __fn {
41 template <class _Iter, class _Sent, class _Tp, class _Proj>40 template <class _Iter, class _Sent, class _Tp, class _Proj>
42 _LIBCPP_HIDE_FROM_ABI static constexpr _Iter41 _LIBCPP_HIDE_FROM_ABI static constexpr _Iter
43 __find_unwrap(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {42 __find_unwrap(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
...@@ -64,10 +63,9 @@ struct __fn {...@@ -64,10 +63,9 @@ struct __fn {
64 return __find_unwrap(ranges::begin(__r), ranges::end(__r), __value, __proj);63 return __find_unwrap(ranges::begin(__r), ranges::end(__r), __value, __proj);
65 }64 }
66};65};
67} // namespace __find
6866
69inline namespace __cpo {67inline namespace __cpo {
70inline constexpr auto find = __find::__fn{};68inline constexpr auto find = __find{};
71} // namespace __cpo69} // namespace __cpo
72} // namespace ranges70} // namespace ranges
7371
lib/libcxx/include/__algorithm/ranges_find_end.h+2-4
...@@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS...@@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS
35_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3636
37namespace ranges {37namespace ranges {
38namespace __find_end {38struct __find_end {
39struct __fn {
40 template <forward_iterator _Iter1,39 template <forward_iterator _Iter1,
41 sentinel_for<_Iter1> _Sent1,40 sentinel_for<_Iter1> _Sent1,
42 forward_iterator _Iter2,41 forward_iterator _Iter2,
...@@ -87,10 +86,9 @@ struct __fn {...@@ -87,10 +86,9 @@ struct __fn {
87 return {__ret.first, __ret.second};86 return {__ret.first, __ret.second};
88 }87 }
89};88};
90} // namespace __find_end
9189
92inline namespace __cpo {90inline namespace __cpo {
93inline constexpr auto find_end = __find_end::__fn{};91inline constexpr auto find_end = __find_end{};
94} // namespace __cpo92} // namespace __cpo
95} // namespace ranges93} // namespace ranges
9694
lib/libcxx/include/__algorithm/ranges_find_first_of.h+2-4
...@@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS...@@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
34namespace ranges {34namespace ranges {
35namespace __find_first_of {35struct __find_first_of {
36struct __fn {
37 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>36 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
38 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter1 __find_first_of_impl(37 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter1 __find_first_of_impl(
39 _Iter1 __first1,38 _Iter1 __first1,
...@@ -90,10 +89,9 @@ struct __fn {...@@ -90,10 +89,9 @@ struct __fn {
90 __proj2);89 __proj2);
91 }90 }
92};91};
93} // namespace __find_first_of
9492
95inline namespace __cpo {93inline namespace __cpo {
96inline constexpr auto find_first_of = __find_first_of::__fn{};94inline constexpr auto find_first_of = __find_first_of{};
97} // namespace __cpo95} // namespace __cpo
98} // namespace ranges96} // namespace ranges
9997
lib/libcxx/include/__algorithm/ranges_find_if.h+2-4
...@@ -42,8 +42,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Ip __find_if_impl(_Ip __first, _Sp __last, _Pre...@@ -42,8 +42,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Ip __find_if_impl(_Ip __first, _Sp __last, _Pre
42 return __first;42 return __first;
43}43}
4444
45namespace __find_if {45struct __find_if {
46struct __fn {
47 template <input_iterator _Ip,46 template <input_iterator _Ip,
48 sentinel_for<_Ip> _Sp,47 sentinel_for<_Ip> _Sp,
49 class _Proj = identity,48 class _Proj = identity,
...@@ -59,10 +58,9 @@ struct __fn {...@@ -59,10 +58,9 @@ struct __fn {
59 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);58 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
60 }59 }
61};60};
62} // namespace __find_if
6361
64inline namespace __cpo {62inline namespace __cpo {
65inline constexpr auto find_if = __find_if::__fn{};63inline constexpr auto find_if = __find_if{};
66} // namespace __cpo64} // namespace __cpo
67} // namespace ranges65} // namespace ranges
6866
lib/libcxx/include/__algorithm/ranges_find_if_not.h+2-4
...@@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS...@@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS
34_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3535
36namespace ranges {36namespace ranges {
37namespace __find_if_not {37struct __find_if_not {
38struct __fn {
39 template <input_iterator _Ip,38 template <input_iterator _Ip,
40 sentinel_for<_Ip> _Sp,39 sentinel_for<_Ip> _Sp,
41 class _Proj = identity,40 class _Proj = identity,
...@@ -53,10 +52,9 @@ struct __fn {...@@ -53,10 +52,9 @@ struct __fn {
53 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj);52 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj);
54 }53 }
55};54};
56} // namespace __find_if_not
5755
58inline namespace __cpo {56inline namespace __cpo {
59inline constexpr auto find_if_not = __find_if_not::__fn{};57inline constexpr auto find_if_not = __find_if_not{};
60} // namespace __cpo58} // namespace __cpo
61} // namespace ranges59} // namespace ranges
6260
lib/libcxx/include/__algorithm/ranges_find_last.h+7-12
...@@ -21,6 +21,7 @@...@@ -21,6 +21,7 @@
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/forward.h>
24#include <__utility/move.h>25#include <__utility/move.h>
2526
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -72,8 +73,7 @@ __find_last_impl(_Iter __first, _Sent __last, _Pred __pred, _Proj& __proj) {...@@ -72,8 +73,7 @@ __find_last_impl(_Iter __first, _Sent __last, _Pred __pred, _Proj& __proj) {
72 }73 }
73}74}
7475
75namespace __find_last {76struct __find_last {
76struct __fn {
77 template <class _Type>77 template <class _Type>
78 struct __op {78 struct __op {
79 const _Type& __value;79 const _Type& __value;
...@@ -97,10 +97,8 @@ struct __fn {...@@ -97,10 +97,8 @@ struct __fn {
97 return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Type>{__value}, __proj);97 return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Type>{__value}, __proj);
98 }98 }
99};99};
100} // namespace __find_last
101100
102namespace __find_last_if {101struct __find_last_if {
103struct __fn {
104 template <class _Pred>102 template <class _Pred>
105 struct __op {103 struct __op {
106 _Pred& __pred;104 _Pred& __pred;
...@@ -127,10 +125,8 @@ struct __fn {...@@ -127,10 +125,8 @@ struct __fn {
127 return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj);125 return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj);
128 }126 }
129};127};
130} // namespace __find_last_if
131128
132namespace __find_last_if_not {129struct __find_last_if_not {
133struct __fn {
134 template <class _Pred>130 template <class _Pred>
135 struct __op {131 struct __op {
136 _Pred& __pred;132 _Pred& __pred;
...@@ -157,12 +153,11 @@ struct __fn {...@@ -157,12 +153,11 @@ struct __fn {
157 return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj);153 return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj);
158 }154 }
159};155};
160} // namespace __find_last_if_not
161156
162inline namespace __cpo {157inline namespace __cpo {
163inline constexpr auto find_last = __find_last::__fn{};158inline constexpr auto find_last = __find_last{};
164inline constexpr auto find_last_if = __find_last_if::__fn{};159inline constexpr auto find_last_if = __find_last_if{};
165inline constexpr auto find_last_if_not = __find_last_if_not::__fn{};160inline constexpr auto find_last_if_not = __find_last_if_not{};
166} // namespace __cpo161} // namespace __cpo
167} // namespace ranges162} // namespace ranges
168163
lib/libcxx/include/__algorithm/ranges_fold.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___ALGORITHM_RANGES_FOLD_H
11#define _LIBCPP___ALGORITHM_RANGES_FOLD_H
12
13#include <__concepts/assignable.h>
14#include <__concepts/constructible.h>
15#include <__concepts/convertible_to.h>
16#include <__concepts/invocable.h>
17#include <__concepts/movable.h>
18#include <__config>
19#include <__functional/invoke.h>
20#include <__functional/reference_wrapper.h>
21#include <__iterator/concepts.h>
22#include <__iterator/iterator_traits.h>
23#include <__iterator/next.h>
24#include <__ranges/access.h>
25#include <__ranges/concepts.h>
26#include <__ranges/dangling.h>
27#include <__type_traits/decay.h>
28#include <__type_traits/invoke.h>
29#include <__utility/forward.h>
30#include <__utility/move.h>
31
32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
33# pragma GCC system_header
34#endif
35
36_LIBCPP_PUSH_MACROS
37#include <__undef_macros>
38
39_LIBCPP_BEGIN_NAMESPACE_STD
40
41#if _LIBCPP_STD_VER >= 23
42
43namespace ranges {
44template <class _Ip, class _Tp>
45struct in_value_result {
46 _LIBCPP_NO_UNIQUE_ADDRESS _Ip in;
47 _LIBCPP_NO_UNIQUE_ADDRESS _Tp value;
48
49 template <class _I2, class _T2>
50 requires convertible_to<const _Ip&, _I2> && convertible_to<const _Tp&, _T2>
51 _LIBCPP_HIDE_FROM_ABI constexpr operator in_value_result<_I2, _T2>() const& {
52 return {in, value};
53 }
54
55 template <class _I2, class _T2>
56 requires convertible_to<_Ip, _I2> && convertible_to<_Tp, _T2>
57 _LIBCPP_HIDE_FROM_ABI constexpr operator in_value_result<_I2, _T2>() && {
58 return {std::move(in), std::move(value)};
59 }
60};
61
62template <class _Ip, class _Tp>
63using fold_left_with_iter_result = in_value_result<_Ip, _Tp>;
64
65template <class _Fp, class _Tp, class _Ip, class _Rp, class _Up = decay_t<_Rp>>
66concept __indirectly_binary_left_foldable_impl =
67 convertible_to<_Rp, _Up> && //
68 movable<_Tp> && //
69 movable<_Up> && //
70 convertible_to<_Tp, _Up> && //
71 invocable<_Fp&, _Up, iter_reference_t<_Ip>> && //
72 assignable_from<_Up&, invoke_result_t<_Fp&, _Up, iter_reference_t<_Ip>>>;
73
74template <class _Fp, class _Tp, class _Ip>
75concept __indirectly_binary_left_foldable =
76 copy_constructible<_Fp> && //
77 invocable<_Fp&, _Tp, iter_reference_t<_Ip>> && //
78 __indirectly_binary_left_foldable_impl<_Fp, _Tp, _Ip, invoke_result_t<_Fp&, _Tp, iter_reference_t<_Ip>>>;
79
80struct __fold_left_with_iter {
81 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp>
82 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) {
83 using _Up = decay_t<invoke_result_t<_Fp&, _Tp, iter_reference_t<_Ip>>>;
84
85 if (__first == __last) {
86 return fold_left_with_iter_result<_Ip, _Up>{std::move(__first), _Up(std::move(__init))};
87 }
88
89 _Up __result = std::invoke(__f, std::move(__init), *__first);
90 for (++__first; __first != __last; ++__first) {
91 __result = std::invoke(__f, std::move(__result), *__first);
92 }
93
94 return fold_left_with_iter_result<_Ip, _Up>{std::move(__first), std::move(__result)};
95 }
96
97 template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp>
98 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) {
99 auto __result = operator()(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f));
100
101 using _Up = decay_t<invoke_result_t<_Fp&, _Tp, range_reference_t<_Rp>>>;
102 return fold_left_with_iter_result<borrowed_iterator_t<_Rp>, _Up>{std::move(__result.in), std::move(__result.value)};
103 }
104};
105
106inline constexpr auto fold_left_with_iter = __fold_left_with_iter();
107
108struct __fold_left {
109 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp>
110 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) {
111 return fold_left_with_iter(std::move(__first), std::move(__last), std::move(__init), std::ref(__f)).value;
112 }
113
114 template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp>
115 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) {
116 return fold_left_with_iter(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f)).value;
117 }
118};
119
120inline constexpr auto fold_left = __fold_left();
121} // namespace ranges
122
123#endif // _LIBCPP_STD_VER >= 23
124
125_LIBCPP_END_NAMESPACE_STD
126
127_LIBCPP_POP_MACROS
128
129#endif // _LIBCPP___ALGORITHM_RANGES_FOLD_H
lib/libcxx/include/__algorithm/ranges_for_each.h+2-4
...@@ -36,8 +36,7 @@ namespace ranges {...@@ -36,8 +36,7 @@ namespace ranges {
36template <class _Iter, class _Func>36template <class _Iter, class _Func>
37using for_each_result = in_fun_result<_Iter, _Func>;37using for_each_result = in_fun_result<_Iter, _Func>;
3838
39namespace __for_each {39struct __for_each {
40struct __fn {
41private:40private:
42 template <class _Iter, class _Sent, class _Proj, class _Func>41 template <class _Iter, class _Sent, class _Proj, class _Func>
43 _LIBCPP_HIDE_FROM_ABI constexpr static for_each_result<_Iter, _Func>42 _LIBCPP_HIDE_FROM_ABI constexpr static for_each_result<_Iter, _Func>
...@@ -65,10 +64,9 @@ public:...@@ -65,10 +64,9 @@ public:
65 return __for_each_impl(ranges::begin(__range), ranges::end(__range), __func, __proj);64 return __for_each_impl(ranges::begin(__range), ranges::end(__range), __func, __proj);
66 }65 }
67};66};
68} // namespace __for_each
6967
70inline namespace __cpo {68inline namespace __cpo {
71inline constexpr auto for_each = __for_each::__fn{};69inline constexpr auto for_each = __for_each{};
72} // namespace __cpo70} // namespace __cpo
73} // namespace ranges71} // namespace ranges
7472
lib/libcxx/include/__algorithm/ranges_for_each_n.h+2-4
...@@ -36,8 +36,7 @@ namespace ranges {...@@ -36,8 +36,7 @@ namespace ranges {
36template <class _Iter, class _Func>36template <class _Iter, class _Func>
37using for_each_n_result = in_fun_result<_Iter, _Func>;37using for_each_n_result = in_fun_result<_Iter, _Func>;
3838
39namespace __for_each_n {39struct __for_each_n {
40struct __fn {
41 template <input_iterator _Iter, class _Proj = identity, indirectly_unary_invocable<projected<_Iter, _Proj>> _Func>40 template <input_iterator _Iter, class _Proj = identity, indirectly_unary_invocable<projected<_Iter, _Proj>> _Func>
42 _LIBCPP_HIDE_FROM_ABI constexpr for_each_n_result<_Iter, _Func>41 _LIBCPP_HIDE_FROM_ABI constexpr for_each_n_result<_Iter, _Func>
43 operator()(_Iter __first, iter_difference_t<_Iter> __count, _Func __func, _Proj __proj = {}) const {42 operator()(_Iter __first, iter_difference_t<_Iter> __count, _Func __func, _Proj __proj = {}) const {
...@@ -48,10 +47,9 @@ struct __fn {...@@ -48,10 +47,9 @@ struct __fn {
48 return {std::move(__first), std::move(__func)};47 return {std::move(__first), std::move(__func)};
49 }48 }
50};49};
51} // namespace __for_each_n
5250
53inline namespace __cpo {51inline namespace __cpo {
54inline constexpr auto for_each_n = __for_each_n::__fn{};52inline constexpr auto for_each_n = __for_each_n{};
55} // namespace __cpo53} // namespace __cpo
56} // namespace ranges54} // namespace ranges
5755
lib/libcxx/include/__algorithm/ranges_generate.h+3-7
...@@ -12,12 +12,12 @@...@@ -12,12 +12,12 @@
12#include <__concepts/constructible.h>12#include <__concepts/constructible.h>
13#include <__concepts/invocable.h>13#include <__concepts/invocable.h>
14#include <__config>14#include <__config>
15#include <__functional/invoke.h>
16#include <__iterator/concepts.h>15#include <__iterator/concepts.h>
17#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.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>
20#include <__type_traits/invoke.h>
21#include <__utility/move.h>21#include <__utility/move.h>
2222
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -32,9 +32,7 @@ _LIBCPP_PUSH_MACROS...@@ -32,9 +32,7 @@ _LIBCPP_PUSH_MACROS
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
34namespace ranges {34namespace ranges {
35namespace __generate {35struct __generate {
36
37struct __fn {
38 template <class _OutIter, class _Sent, class _Func>36 template <class _OutIter, class _Sent, class _Func>
39 _LIBCPP_HIDE_FROM_ABI constexpr static _OutIter __generate_fn_impl(_OutIter __first, _Sent __last, _Func& __gen) {37 _LIBCPP_HIDE_FROM_ABI constexpr static _OutIter __generate_fn_impl(_OutIter __first, _Sent __last, _Func& __gen) {
40 for (; __first != __last; ++__first) {38 for (; __first != __last; ++__first) {
...@@ -57,10 +55,8 @@ struct __fn {...@@ -57,10 +55,8 @@ struct __fn {
57 }55 }
58};56};
5957
60} // namespace __generate
61
62inline namespace __cpo {58inline namespace __cpo {
63inline constexpr auto generate = __generate::__fn{};59inline constexpr auto generate = __generate{};
64} // namespace __cpo60} // namespace __cpo
65} // namespace ranges61} // namespace ranges
6662
lib/libcxx/include/__algorithm/ranges_generate_n.h+3-7
...@@ -13,12 +13,12 @@...@@ -13,12 +13,12 @@
13#include <__concepts/invocable.h>13#include <__concepts/invocable.h>
14#include <__config>14#include <__config>
15#include <__functional/identity.h>15#include <__functional/identity.h>
16#include <__functional/invoke.h>
17#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
18#include <__iterator/incrementable_traits.h>17#include <__iterator/incrementable_traits.h>
19#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
20#include <__ranges/access.h>19#include <__ranges/access.h>
21#include <__ranges/concepts.h>20#include <__ranges/concepts.h>
21#include <__type_traits/invoke.h>
22#include <__utility/move.h>22#include <__utility/move.h>
2323
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -33,9 +33,7 @@ _LIBCPP_PUSH_MACROS...@@ -33,9 +33,7 @@ _LIBCPP_PUSH_MACROS
33_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3434
35namespace ranges {35namespace ranges {
36namespace __generate_n {36struct __generate_n {
37
38struct __fn {
39 template <input_or_output_iterator _OutIter, copy_constructible _Func>37 template <input_or_output_iterator _OutIter, copy_constructible _Func>
40 requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>>38 requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>>
41 _LIBCPP_HIDE_FROM_ABI constexpr _OutIter39 _LIBCPP_HIDE_FROM_ABI constexpr _OutIter
...@@ -49,10 +47,8 @@ struct __fn {...@@ -49,10 +47,8 @@ struct __fn {
49 }47 }
50};48};
5149
52} // namespace __generate_n
53
54inline namespace __cpo {50inline namespace __cpo {
55inline constexpr auto generate_n = __generate_n::__fn{};51inline constexpr auto generate_n = __generate_n{};
56} // namespace __cpo52} // namespace __cpo
57} // namespace ranges53} // namespace ranges
5854
lib/libcxx/include/__algorithm/ranges_includes.h+2-6
...@@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS...@@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS
35_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3636
37namespace ranges {37namespace ranges {
38namespace __includes {38struct __includes {
39
40struct __fn {
41 template <input_iterator _Iter1,39 template <input_iterator _Iter1,
42 sentinel_for<_Iter1> _Sent1,40 sentinel_for<_Iter1> _Sent1,
43 input_iterator _Iter2,41 input_iterator _Iter2,
...@@ -82,10 +80,8 @@ struct __fn {...@@ -82,10 +80,8 @@ struct __fn {
82 }80 }
83};81};
8482
85} // namespace __includes
86
87inline namespace __cpo {83inline namespace __cpo {
88inline constexpr auto includes = __includes::__fn{};84inline constexpr auto includes = __includes{};
89} // namespace __cpo85} // namespace __cpo
90} // namespace ranges86} // namespace ranges
9187
lib/libcxx/include/__algorithm/ranges_inplace_merge.h+2-6
...@@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS...@@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS
39_LIBCPP_BEGIN_NAMESPACE_STD39_LIBCPP_BEGIN_NAMESPACE_STD
4040
41namespace ranges {41namespace ranges {
42namespace __inplace_merge {42struct __inplace_merge {
43
44struct __fn {
45 template <class _Iter, class _Sent, class _Comp, class _Proj>43 template <class _Iter, class _Sent, class _Comp, class _Proj>
46 _LIBCPP_HIDE_FROM_ABI static constexpr auto44 _LIBCPP_HIDE_FROM_ABI static constexpr auto
47 __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) {45 __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) {
...@@ -68,10 +66,8 @@ struct __fn {...@@ -68,10 +66,8 @@ struct __fn {
68 }66 }
69};67};
7068
71} // namespace __inplace_merge
72
73inline namespace __cpo {69inline namespace __cpo {
74inline constexpr auto inplace_merge = __inplace_merge::__fn{};70inline constexpr auto inplace_merge = __inplace_merge{};
75} // namespace __cpo71} // namespace __cpo
76} // namespace ranges72} // namespace ranges
7773
lib/libcxx/include/__algorithm/ranges_is_heap.h+2-6
...@@ -34,9 +34,7 @@ _LIBCPP_PUSH_MACROS...@@ -34,9 +34,7 @@ _LIBCPP_PUSH_MACROS
34_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3535
36namespace ranges {36namespace ranges {
37namespace __is_heap {37struct __is_heap {
38
39struct __fn {
40 template <class _Iter, class _Sent, class _Proj, class _Comp>38 template <class _Iter, class _Sent, class _Proj, class _Comp>
41 _LIBCPP_HIDE_FROM_ABI constexpr static bool39 _LIBCPP_HIDE_FROM_ABI constexpr static bool
42 __is_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {40 __is_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
...@@ -65,10 +63,8 @@ struct __fn {...@@ -65,10 +63,8 @@ struct __fn {
65 }63 }
66};64};
6765
68} // namespace __is_heap
69
70inline namespace __cpo {66inline namespace __cpo {
71inline constexpr auto is_heap = __is_heap::__fn{};67inline constexpr auto is_heap = __is_heap{};
72} // namespace __cpo68} // namespace __cpo
73} // namespace ranges69} // namespace ranges
7470
lib/libcxx/include/__algorithm/ranges_is_heap_until.h+2-6
...@@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS...@@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS
35_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3636
37namespace ranges {37namespace ranges {
38namespace __is_heap_until {38struct __is_heap_until {
39
40struct __fn {
41 template <class _Iter, class _Sent, class _Proj, class _Comp>39 template <class _Iter, class _Sent, class _Proj, class _Comp>
42 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter40 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
43 __is_heap_until_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {41 __is_heap_until_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
...@@ -65,10 +63,8 @@ struct __fn {...@@ -65,10 +63,8 @@ struct __fn {
65 }63 }
66};64};
6765
68} // namespace __is_heap_until
69
70inline namespace __cpo {66inline namespace __cpo {
71inline constexpr auto is_heap_until = __is_heap_until::__fn{};67inline constexpr auto is_heap_until = __is_heap_until{};
72} // namespace __cpo68} // namespace __cpo
73} // namespace ranges69} // namespace ranges
7470
lib/libcxx/include/__algorithm/ranges_is_partitioned.h+2-4
...@@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS...@@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
33namespace ranges {33namespace ranges {
34namespace __is_partitioned {34struct __is_partitioned {
35struct __fn {
36 template <class _Iter, class _Sent, class _Proj, class _Pred>35 template <class _Iter, class _Sent, class _Proj, class _Pred>
37 _LIBCPP_HIDE_FROM_ABI constexpr static bool36 _LIBCPP_HIDE_FROM_ABI constexpr static bool
38 __is_partitioned_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {37 __is_partitioned_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
...@@ -70,10 +69,9 @@ struct __fn {...@@ -70,10 +69,9 @@ struct __fn {
70 return __is_partitioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);69 return __is_partitioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
71 }70 }
72};71};
73} // namespace __is_partitioned
7472
75inline namespace __cpo {73inline namespace __cpo {
76inline constexpr auto is_partitioned = __is_partitioned::__fn{};74inline constexpr auto is_partitioned = __is_partitioned{};
77} // namespace __cpo75} // namespace __cpo
78} // namespace ranges76} // namespace ranges
7977
lib/libcxx/include/__algorithm/ranges_is_permutation.h+2-4
...@@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS...@@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS
33_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3434
35namespace ranges {35namespace ranges {
36namespace __is_permutation {36struct __is_permutation {
37struct __fn {
38 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Pred>37 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Pred>
39 _LIBCPP_HIDE_FROM_ABI constexpr static bool __is_permutation_func_impl(38 _LIBCPP_HIDE_FROM_ABI constexpr static bool __is_permutation_func_impl(
40 _Iter1 __first1,39 _Iter1 __first1,
...@@ -91,10 +90,9 @@ struct __fn {...@@ -91,10 +90,9 @@ struct __fn {
91 __proj2);90 __proj2);
92 }91 }
93};92};
94} // namespace __is_permutation
9593
96inline namespace __cpo {94inline namespace __cpo {
97inline constexpr auto is_permutation = __is_permutation::__fn{};95inline constexpr auto is_permutation = __is_permutation{};
98} // namespace __cpo96} // namespace __cpo
99} // namespace ranges97} // namespace ranges
10098
lib/libcxx/include/__algorithm/ranges_is_sorted.h+2-4
...@@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS...@@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
33namespace ranges {33namespace ranges {
34namespace __is_sorted {34struct __is_sorted {
35struct __fn {
36 template <forward_iterator _Iter,35 template <forward_iterator _Iter,
37 sentinel_for<_Iter> _Sent,36 sentinel_for<_Iter> _Sent,
38 class _Proj = identity,37 class _Proj = identity,
...@@ -51,10 +50,9 @@ struct __fn {...@@ -51,10 +50,9 @@ struct __fn {
51 return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last;50 return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last;
52 }51 }
53};52};
54} // namespace __is_sorted
5553
56inline namespace __cpo {54inline namespace __cpo {
57inline constexpr auto is_sorted = __is_sorted::__fn{};55inline constexpr auto is_sorted = __is_sorted{};
58} // namespace __cpo56} // namespace __cpo
59} // namespace ranges57} // namespace ranges
6058
lib/libcxx/include/__algorithm/ranges_is_sorted_until.h+2-4
...@@ -47,8 +47,7 @@ __is_sorted_until_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj...@@ -47,8 +47,7 @@ __is_sorted_until_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj
47 return __i;47 return __i;
48}48}
4949
50namespace __is_sorted_until {50struct __is_sorted_until {
51struct __fn {
52 template <forward_iterator _Iter,51 template <forward_iterator _Iter,
53 sentinel_for<_Iter> _Sent,52 sentinel_for<_Iter> _Sent,
54 class _Proj = identity,53 class _Proj = identity,
...@@ -66,10 +65,9 @@ struct __fn {...@@ -66,10 +65,9 @@ struct __fn {
66 return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);65 return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
67 }66 }
68};67};
69} // namespace __is_sorted_until
7068
71inline namespace __cpo {69inline namespace __cpo {
72inline constexpr auto is_sorted_until = __is_sorted_until::__fn{};70inline constexpr auto is_sorted_until = __is_sorted_until{};
73} // namespace __cpo71} // namespace __cpo
74} // namespace ranges72} // namespace ranges
7573
lib/libcxx/include/__algorithm/ranges_iterator_concept.h+1-1
...@@ -44,7 +44,7 @@ consteval auto __get_iterator_concept() {...@@ -44,7 +44,7 @@ consteval auto __get_iterator_concept() {
44}44}
4545
46template <class _Iter>46template <class _Iter>
47using __iterator_concept = decltype(__get_iterator_concept<_Iter>());47using __iterator_concept _LIBCPP_NODEBUG = decltype(__get_iterator_concept<_Iter>());
4848
49} // namespace ranges49} // namespace ranges
50_LIBCPP_END_NAMESPACE_STD50_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/ranges_lexicographical_compare.h+17-16
...@@ -9,6 +9,8 @@...@@ -9,6 +9,8 @@
9#ifndef _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H9#ifndef _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H
10#define _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H10#define _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H
1111
12#include <__algorithm/lexicographical_compare.h>
13#include <__algorithm/unwrap_range.h>
12#include <__config>14#include <__config>
13#include <__functional/identity.h>15#include <__functional/identity.h>
14#include <__functional/invoke.h>16#include <__functional/invoke.h>
...@@ -31,10 +33,9 @@ _LIBCPP_PUSH_MACROS...@@ -31,10 +33,9 @@ _LIBCPP_PUSH_MACROS
31_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3234
33namespace ranges {35namespace ranges {
34namespace __lexicographical_compare {36struct __lexicographical_compare {
35struct __fn {
36 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Comp>37 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Comp>
37 _LIBCPP_HIDE_FROM_ABI constexpr static bool __lexicographical_compare_impl(38 static _LIBCPP_HIDE_FROM_ABI constexpr bool __lexicographical_compare_unwrap(
38 _Iter1 __first1,39 _Iter1 __first1,
39 _Sent1 __last1,40 _Sent1 __last1,
40 _Iter2 __first2,41 _Iter2 __first2,
...@@ -42,15 +43,16 @@ struct __fn {...@@ -42,15 +43,16 @@ struct __fn {
42 _Comp& __comp,43 _Comp& __comp,
43 _Proj1& __proj1,44 _Proj1& __proj1,
44 _Proj2& __proj2) {45 _Proj2& __proj2) {
45 while (__first2 != __last2) {46 auto [__first1_un, __last1_un] = std::__unwrap_range(std::move(__first1), std::move(__last1));
46 if (__first1 == __last1 || std::invoke(__comp, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2)))47 auto [__first2_un, __last2_un] = std::__unwrap_range(std::move(__first2), std::move(__last2));
47 return true;48 return std::__lexicographical_compare(
48 if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1)))49 std::move(__first1_un),
49 return false;50 std::move(__last1_un),
50 ++__first1;51 std::move(__first2_un),
51 ++__first2;52 std::move(__last2_un),
52 }53 __comp,
53 return false;54 __proj1,
55 __proj2);
54 }56 }
5557
56 template <input_iterator _Iter1,58 template <input_iterator _Iter1,
...@@ -68,7 +70,7 @@ struct __fn {...@@ -68,7 +70,7 @@ struct __fn {
68 _Comp __comp = {},70 _Comp __comp = {},
69 _Proj1 __proj1 = {},71 _Proj1 __proj1 = {},
70 _Proj2 __proj2 = {}) const {72 _Proj2 __proj2 = {}) const {
71 return __lexicographical_compare_impl(73 return __lexicographical_compare_unwrap(
72 std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __comp, __proj1, __proj2);74 std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __comp, __proj1, __proj2);
73 }75 }
7476
...@@ -80,7 +82,7 @@ struct __fn {...@@ -80,7 +82,7 @@ struct __fn {
80 _Comp = ranges::less>82 _Comp = ranges::less>
81 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(83 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
82 _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {84 _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
83 return __lexicographical_compare_impl(85 return __lexicographical_compare_unwrap(
84 ranges::begin(__range1),86 ranges::begin(__range1),
85 ranges::end(__range1),87 ranges::end(__range1),
86 ranges::begin(__range2),88 ranges::begin(__range2),
...@@ -90,10 +92,9 @@ struct __fn {...@@ -90,10 +92,9 @@ struct __fn {
90 __proj2);92 __proj2);
91 }93 }
92};94};
93} // namespace __lexicographical_compare
9495
95inline namespace __cpo {96inline namespace __cpo {
96inline constexpr auto lexicographical_compare = __lexicographical_compare::__fn{};97inline constexpr auto lexicographical_compare = __lexicographical_compare{};
97} // namespace __cpo98} // namespace __cpo
98} // namespace ranges99} // namespace ranges
99100
lib/libcxx/include/__algorithm/ranges_lower_bound.h+2-4
...@@ -36,8 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -36,8 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3636
37namespace ranges {37namespace ranges {
3838
39namespace __lower_bound {39struct __lower_bound {
40struct __fn {
41 template <forward_iterator _Iter,40 template <forward_iterator _Iter,
42 sentinel_for<_Iter> _Sent,41 sentinel_for<_Iter> _Sent,
43 class _Type,42 class _Type,
...@@ -57,10 +56,9 @@ struct __fn {...@@ -57,10 +56,9 @@ struct __fn {
57 return std::__lower_bound<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __comp, __proj);56 return std::__lower_bound<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __comp, __proj);
58 }57 }
59};58};
60} // namespace __lower_bound
6159
62inline namespace __cpo {60inline namespace __cpo {
63inline constexpr auto lower_bound = __lower_bound::__fn{};61inline constexpr auto lower_bound = __lower_bound{};
64} // namespace __cpo62} // namespace __cpo
65} // namespace ranges63} // namespace ranges
6664
lib/libcxx/include/__algorithm/ranges_make_heap.h+2-6
...@@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS...@@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS
40_LIBCPP_BEGIN_NAMESPACE_STD40_LIBCPP_BEGIN_NAMESPACE_STD
4141
42namespace ranges {42namespace ranges {
43namespace __make_heap {43struct __make_heap {
44
45struct __fn {
46 template <class _Iter, class _Sent, class _Comp, class _Proj>44 template <class _Iter, class _Sent, class _Comp, class _Proj>
47 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter45 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
48 __make_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {46 __make_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
...@@ -69,10 +67,8 @@ struct __fn {...@@ -69,10 +67,8 @@ struct __fn {
69 }67 }
70};68};
7169
72} // namespace __make_heap
73
74inline namespace __cpo {70inline namespace __cpo {
75inline constexpr auto make_heap = __make_heap::__fn{};71inline constexpr auto make_heap = __make_heap{};
76} // namespace __cpo72} // namespace __cpo
77} // namespace ranges73} // namespace ranges
7874
lib/libcxx/include/__algorithm/ranges_max.h+2-4
...@@ -36,8 +36,7 @@ _LIBCPP_PUSH_MACROS...@@ -36,8 +36,7 @@ _LIBCPP_PUSH_MACROS
36_LIBCPP_BEGIN_NAMESPACE_STD36_LIBCPP_BEGIN_NAMESPACE_STD
3737
38namespace ranges {38namespace ranges {
39namespace __max {39struct __max {
40struct __fn {
41 template <class _Tp,40 template <class _Tp,
42 class _Proj = identity,41 class _Proj = identity,
43 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>42 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
...@@ -87,10 +86,9 @@ struct __fn {...@@ -87,10 +86,9 @@ struct __fn {
87 }86 }
88 }87 }
89};88};
90} // namespace __max
9189
92inline namespace __cpo {90inline namespace __cpo {
93inline constexpr auto max = __max::__fn{};91inline constexpr auto max = __max{};
94} // namespace __cpo92} // namespace __cpo
95} // namespace ranges93} // namespace ranges
9694
lib/libcxx/include/__algorithm/ranges_max_element.h+2-4
...@@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS...@@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
34namespace ranges {34namespace ranges {
35namespace __max_element {35struct __max_element {
36struct __fn {
37 template <forward_iterator _Ip,36 template <forward_iterator _Ip,
38 sentinel_for<_Ip> _Sp,37 sentinel_for<_Ip> _Sp,
39 class _Proj = identity,38 class _Proj = identity,
...@@ -53,10 +52,9 @@ struct __fn {...@@ -53,10 +52,9 @@ struct __fn {
53 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);52 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);
54 }53 }
55};54};
56} // namespace __max_element
5755
58inline namespace __cpo {56inline namespace __cpo {
59inline constexpr auto max_element = __max_element::__fn{};57inline constexpr auto max_element = __max_element{};
60} // namespace __cpo58} // namespace __cpo
61} // namespace ranges59} // namespace ranges
6260
lib/libcxx/include/__algorithm/ranges_merge.h+35-39
...@@ -39,42 +39,7 @@ namespace ranges {...@@ -39,42 +39,7 @@ namespace ranges {
39template <class _InIter1, class _InIter2, class _OutIter>39template <class _InIter1, class _InIter2, class _OutIter>
40using merge_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;40using merge_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;
4141
42namespace __merge {42struct __merge {
43
44template < class _InIter1,
45 class _Sent1,
46 class _InIter2,
47 class _Sent2,
48 class _OutIter,
49 class _Comp,
50 class _Proj1,
51 class _Proj2>
52_LIBCPP_HIDE_FROM_ABI constexpr merge_result<__remove_cvref_t<_InIter1>,
53 __remove_cvref_t<_InIter2>,
54 __remove_cvref_t<_OutIter>>
55__merge_impl(_InIter1&& __first1,
56 _Sent1&& __last1,
57 _InIter2&& __first2,
58 _Sent2&& __last2,
59 _OutIter&& __result,
60 _Comp&& __comp,
61 _Proj1&& __proj1,
62 _Proj2&& __proj2) {
63 for (; __first1 != __last1 && __first2 != __last2; ++__result) {
64 if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) {
65 *__result = *__first2;
66 ++__first2;
67 } else {
68 *__result = *__first1;
69 ++__first1;
70 }
71 }
72 auto __ret1 = ranges::copy(std::move(__first1), std::move(__last1), std::move(__result));
73 auto __ret2 = ranges::copy(std::move(__first2), std::move(__last2), std::move(__ret1.out));
74 return {std::move(__ret1.in), std::move(__ret2.in), std::move(__ret2.out)};
75}
76
77struct __fn {
78 template <input_iterator _InIter1,43 template <input_iterator _InIter1,
79 sentinel_for<_InIter1> _Sent1,44 sentinel_for<_InIter1> _Sent1,
80 input_iterator _InIter2,45 input_iterator _InIter2,
...@@ -120,12 +85,43 @@ struct __fn {...@@ -120,12 +85,43 @@ struct __fn {
120 __proj1,85 __proj1,
121 __proj2);86 __proj2);
122 }87 }
123};
12488
125} // namespace __merge89 template < class _InIter1,
90 class _Sent1,
91 class _InIter2,
92 class _Sent2,
93 class _OutIter,
94 class _Comp,
95 class _Proj1,
96 class _Proj2>
97 _LIBCPP_HIDE_FROM_ABI static constexpr merge_result<__remove_cvref_t<_InIter1>,
98 __remove_cvref_t<_InIter2>,
99 __remove_cvref_t<_OutIter>>
100 __merge_impl(_InIter1&& __first1,
101 _Sent1&& __last1,
102 _InIter2&& __first2,
103 _Sent2&& __last2,
104 _OutIter&& __result,
105 _Comp&& __comp,
106 _Proj1&& __proj1,
107 _Proj2&& __proj2) {
108 for (; __first1 != __last1 && __first2 != __last2; ++__result) {
109 if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) {
110 *__result = *__first2;
111 ++__first2;
112 } else {
113 *__result = *__first1;
114 ++__first1;
115 }
116 }
117 auto __ret1 = ranges::copy(std::move(__first1), std::move(__last1), std::move(__result));
118 auto __ret2 = ranges::copy(std::move(__first2), std::move(__last2), std::move(__ret1.out));
119 return {std::move(__ret1.in), std::move(__ret2.in), std::move(__ret2.out)};
120 }
121};
126122
127inline namespace __cpo {123inline namespace __cpo {
128inline constexpr auto merge = __merge::__fn{};124inline constexpr auto merge = __merge{};
129} // namespace __cpo125} // namespace __cpo
130} // namespace ranges126} // namespace ranges
131127
lib/libcxx/include/__algorithm/ranges_min.h+2-4
...@@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS...@@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS
35_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3636
37namespace ranges {37namespace ranges {
38namespace __min {38struct __min {
39struct __fn {
40 template <class _Tp,39 template <class _Tp,
41 class _Proj = identity,40 class _Proj = identity,
42 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>41 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
...@@ -79,10 +78,9 @@ struct __fn {...@@ -79,10 +78,9 @@ struct __fn {
79 }78 }
80 }79 }
81};80};
82} // namespace __min
8381
84inline namespace __cpo {82inline namespace __cpo {
85inline constexpr auto min = __min::__fn{};83inline constexpr auto min = __min{};
86} // namespace __cpo84} // namespace __cpo
87} // namespace ranges85} // namespace ranges
8886
lib/libcxx/include/__algorithm/ranges_min_element.h+2-4
...@@ -46,8 +46,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Ip __min_element_impl(_Ip __first, _Sp __last,...@@ -46,8 +46,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Ip __min_element_impl(_Ip __first, _Sp __last,
46 return __first;46 return __first;
47}47}
4848
49namespace __min_element {49struct __min_element {
50struct __fn {
51 template <forward_iterator _Ip,50 template <forward_iterator _Ip,
52 sentinel_for<_Ip> _Sp,51 sentinel_for<_Ip> _Sp,
53 class _Proj = identity,52 class _Proj = identity,
...@@ -65,10 +64,9 @@ struct __fn {...@@ -65,10 +64,9 @@ struct __fn {
65 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);64 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
66 }65 }
67};66};
68} // namespace __min_element
6967
70inline namespace __cpo {68inline namespace __cpo {
71inline constexpr auto min_element = __min_element::__fn{};69inline constexpr auto min_element = __min_element{};
72} // namespace __cpo70} // namespace __cpo
73} // namespace ranges71} // namespace ranges
7472
lib/libcxx/include/__algorithm/ranges_minmax.h+3-4
...@@ -24,6 +24,7 @@...@@ -24,6 +24,7 @@
24#include <__ranges/access.h>24#include <__ranges/access.h>
25#include <__ranges/concepts.h>25#include <__ranges/concepts.h>
26#include <__type_traits/desugars_to.h>26#include <__type_traits/desugars_to.h>
27#include <__type_traits/is_integral.h>
27#include <__type_traits/is_reference.h>28#include <__type_traits/is_reference.h>
28#include <__type_traits/is_trivially_copyable.h>29#include <__type_traits/is_trivially_copyable.h>
29#include <__type_traits/remove_cvref.h>30#include <__type_traits/remove_cvref.h>
...@@ -47,8 +48,7 @@ namespace ranges {...@@ -47,8 +48,7 @@ namespace ranges {
47template <class _T1>48template <class _T1>
48using minmax_result = min_max_result<_T1>;49using minmax_result = min_max_result<_T1>;
4950
50namespace __minmax {51struct __minmax {
51struct __fn {
52 template <class _Type,52 template <class _Type,
53 class _Proj = identity,53 class _Proj = identity,
54 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>54 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
...@@ -159,10 +159,9 @@ struct __fn {...@@ -159,10 +159,9 @@ struct __fn {
159 }159 }
160 }160 }
161};161};
162} // namespace __minmax
163162
164inline namespace __cpo {163inline namespace __cpo {
165inline constexpr auto minmax = __minmax::__fn{};164inline constexpr auto minmax = __minmax{};
166} // namespace __cpo165} // namespace __cpo
167} // namespace ranges166} // namespace ranges
168167
lib/libcxx/include/__algorithm/ranges_minmax_element.h+2-4
...@@ -40,8 +40,7 @@ namespace ranges {...@@ -40,8 +40,7 @@ namespace ranges {
40template <class _T1>40template <class _T1>
41using minmax_element_result = min_max_result<_T1>;41using minmax_element_result = min_max_result<_T1>;
4242
43namespace __minmax_element {43struct __minmax_element {
44struct __fn {
45 template <forward_iterator _Ip,44 template <forward_iterator _Ip,
46 sentinel_for<_Ip> _Sp,45 sentinel_for<_Ip> _Sp,
47 class _Proj = identity,46 class _Proj = identity,
...@@ -61,10 +60,9 @@ struct __fn {...@@ -61,10 +60,9 @@ struct __fn {
61 return {__ret.first, __ret.second};60 return {__ret.first, __ret.second};
62 }61 }
63};62};
64} // namespace __minmax_element
6563
66inline namespace __cpo {64inline namespace __cpo {
67inline constexpr auto minmax_element = __minmax_element::__fn{};65inline constexpr auto minmax_element = __minmax_element{};
68} // namespace __cpo66} // namespace __cpo
6967
70} // namespace ranges68} // namespace ranges
lib/libcxx/include/__algorithm/ranges_mismatch.h+2-4
...@@ -39,8 +39,7 @@ namespace ranges {...@@ -39,8 +39,7 @@ namespace ranges {
39template <class _I1, class _I2>39template <class _I1, class _I2>
40using mismatch_result = in_in_result<_I1, _I2>;40using mismatch_result = in_in_result<_I1, _I2>;
4141
42namespace __mismatch {42struct __mismatch {
43struct __fn {
44 template <class _I1, class _S1, class _I2, class _S2, class _Pred, class _Proj1, class _Proj2>43 template <class _I1, class _S1, class _I2, class _S2, class _Pred, class _Proj1, class _Proj2>
45 static _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2>44 static _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2>
46 __go(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {45 __go(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
...@@ -84,10 +83,9 @@ struct __fn {...@@ -84,10 +83,9 @@ struct __fn {
84 ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2), __pred, __proj1, __proj2);83 ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2), __pred, __proj1, __proj2);
85 }84 }
86};85};
87} // namespace __mismatch
8886
89inline namespace __cpo {87inline namespace __cpo {
90constexpr inline auto mismatch = __mismatch::__fn{};88constexpr inline auto mismatch = __mismatch{};
91} // namespace __cpo89} // namespace __cpo
92} // namespace ranges90} // namespace ranges
9391
lib/libcxx/include/__algorithm/ranges_move.h+2-4
...@@ -35,8 +35,7 @@ namespace ranges {...@@ -35,8 +35,7 @@ namespace ranges {
35template <class _InIter, class _OutIter>35template <class _InIter, class _OutIter>
36using move_result = in_out_result<_InIter, _OutIter>;36using move_result = in_out_result<_InIter, _OutIter>;
3737
38namespace __move {38struct __move {
39struct __fn {
40 template <class _InIter, class _Sent, class _OutIter>39 template <class _InIter, class _Sent, class _OutIter>
41 _LIBCPP_HIDE_FROM_ABI constexpr static move_result<_InIter, _OutIter>40 _LIBCPP_HIDE_FROM_ABI constexpr static move_result<_InIter, _OutIter>
42 __move_impl(_InIter __first, _Sent __last, _OutIter __result) {41 __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
...@@ -58,10 +57,9 @@ struct __fn {...@@ -58,10 +57,9 @@ struct __fn {
58 return __move_impl(ranges::begin(__range), ranges::end(__range), std::move(__result));57 return __move_impl(ranges::begin(__range), ranges::end(__range), std::move(__result));
59 }58 }
60};59};
61} // namespace __move
6260
63inline namespace __cpo {61inline namespace __cpo {
64inline constexpr auto move = __move::__fn{};62inline constexpr auto move = __move{};
65} // namespace __cpo63} // namespace __cpo
66} // namespace ranges64} // namespace ranges
6765
lib/libcxx/include/__algorithm/ranges_move_backward.h+2-4
...@@ -37,8 +37,7 @@ namespace ranges {...@@ -37,8 +37,7 @@ namespace ranges {
37template <class _InIter, class _OutIter>37template <class _InIter, class _OutIter>
38using move_backward_result = in_out_result<_InIter, _OutIter>;38using move_backward_result = in_out_result<_InIter, _OutIter>;
3939
40namespace __move_backward {40struct __move_backward {
41struct __fn {
42 template <class _InIter, class _Sent, class _OutIter>41 template <class _InIter, class _Sent, class _OutIter>
43 _LIBCPP_HIDE_FROM_ABI constexpr static move_backward_result<_InIter, _OutIter>42 _LIBCPP_HIDE_FROM_ABI constexpr static move_backward_result<_InIter, _OutIter>
44 __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) {43 __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) {
...@@ -60,10 +59,9 @@ struct __fn {...@@ -60,10 +59,9 @@ struct __fn {
60 return __move_backward_impl(ranges::begin(__range), ranges::end(__range), std::move(__result));59 return __move_backward_impl(ranges::begin(__range), ranges::end(__range), std::move(__result));
61 }60 }
62};61};
63} // namespace __move_backward
6462
65inline namespace __cpo {63inline namespace __cpo {
66inline constexpr auto move_backward = __move_backward::__fn{};64inline constexpr auto move_backward = __move_backward{};
67} // namespace __cpo65} // namespace __cpo
68} // namespace ranges66} // namespace ranges
6967
lib/libcxx/include/__algorithm/ranges_next_permutation.h+2-6
...@@ -40,9 +40,7 @@ namespace ranges {...@@ -40,9 +40,7 @@ namespace ranges {
40template <class _InIter>40template <class _InIter>
41using next_permutation_result = in_found_result<_InIter>;41using next_permutation_result = in_found_result<_InIter>;
4242
43namespace __next_permutation {43struct __next_permutation {
44
45struct __fn {
46 template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>44 template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
47 requires sortable<_Iter, _Comp, _Proj>45 requires sortable<_Iter, _Comp, _Proj>
48 _LIBCPP_HIDE_FROM_ABI constexpr next_permutation_result<_Iter>46 _LIBCPP_HIDE_FROM_ABI constexpr next_permutation_result<_Iter>
...@@ -62,10 +60,8 @@ struct __fn {...@@ -62,10 +60,8 @@ struct __fn {
62 }60 }
63};61};
6462
65} // namespace __next_permutation
66
67inline namespace __cpo {63inline namespace __cpo {
68constexpr inline auto next_permutation = __next_permutation::__fn{};64constexpr inline auto next_permutation = __next_permutation{};
69} // namespace __cpo65} // namespace __cpo
70} // namespace ranges66} // namespace ranges
7167
lib/libcxx/include/__algorithm/ranges_none_of.h+2-4
...@@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS...@@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
32namespace ranges {32namespace ranges {
33namespace __none_of {33struct __none_of {
34struct __fn {
35 template <class _Iter, class _Sent, class _Proj, class _Pred>34 template <class _Iter, class _Sent, class _Proj, class _Pred>
36 _LIBCPP_HIDE_FROM_ABI constexpr static bool35 _LIBCPP_HIDE_FROM_ABI constexpr static bool
37 __none_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {36 __none_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
...@@ -59,10 +58,9 @@ struct __fn {...@@ -59,10 +58,9 @@ struct __fn {
59 return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);58 return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
60 }59 }
61};60};
62} // namespace __none_of
6361
64inline namespace __cpo {62inline namespace __cpo {
65inline constexpr auto none_of = __none_of::__fn{};63inline constexpr auto none_of = __none_of{};
66} // namespace __cpo64} // namespace __cpo
67} // namespace ranges65} // namespace ranges
6866
lib/libcxx/include/__algorithm/ranges_nth_element.h+2-6
...@@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS...@@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS
39_LIBCPP_BEGIN_NAMESPACE_STD39_LIBCPP_BEGIN_NAMESPACE_STD
4040
41namespace ranges {41namespace ranges {
42namespace __nth_element {42struct __nth_element {
43
44struct __fn {
45 template <class _Iter, class _Sent, class _Comp, class _Proj>43 template <class _Iter, class _Sent, class _Comp, class _Proj>
46 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter44 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
47 __nth_element_fn_impl(_Iter __first, _Iter __nth, _Sent __last, _Comp& __comp, _Proj& __proj) {45 __nth_element_fn_impl(_Iter __first, _Iter __nth, _Sent __last, _Comp& __comp, _Proj& __proj) {
...@@ -68,10 +66,8 @@ struct __fn {...@@ -68,10 +66,8 @@ struct __fn {
68 }66 }
69};67};
7068
71} // namespace __nth_element
72
73inline namespace __cpo {69inline namespace __cpo {
74inline constexpr auto nth_element = __nth_element::__fn{};70inline constexpr auto nth_element = __nth_element{};
75} // namespace __cpo71} // namespace __cpo
76} // namespace ranges72} // namespace ranges
7773
lib/libcxx/include/__algorithm/ranges_partial_sort.h+2-6
...@@ -41,9 +41,7 @@ _LIBCPP_PUSH_MACROS...@@ -41,9 +41,7 @@ _LIBCPP_PUSH_MACROS
41_LIBCPP_BEGIN_NAMESPACE_STD41_LIBCPP_BEGIN_NAMESPACE_STD
4242
43namespace ranges {43namespace ranges {
44namespace __partial_sort {44struct __partial_sort {
45
46struct __fn {
47 template <class _Iter, class _Sent, class _Comp, class _Proj>45 template <class _Iter, class _Sent, class _Comp, class _Proj>
48 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter46 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
49 __partial_sort_fn_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp& __comp, _Proj& __proj) {47 __partial_sort_fn_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp& __comp, _Proj& __proj) {
...@@ -66,10 +64,8 @@ struct __fn {...@@ -66,10 +64,8 @@ struct __fn {
66 }64 }
67};65};
6866
69} // namespace __partial_sort
70
71inline namespace __cpo {67inline namespace __cpo {
72inline constexpr auto partial_sort = __partial_sort::__fn{};68inline constexpr auto partial_sort = __partial_sort{};
73} // namespace __cpo69} // namespace __cpo
74} // namespace ranges70} // namespace ranges
7571
lib/libcxx/include/__algorithm/ranges_partial_sort_copy.h+2-6
...@@ -42,9 +42,7 @@ namespace ranges {...@@ -42,9 +42,7 @@ namespace ranges {
42template <class _InIter, class _OutIter>42template <class _InIter, class _OutIter>
43using partial_sort_copy_result = in_out_result<_InIter, _OutIter>;43using partial_sort_copy_result = in_out_result<_InIter, _OutIter>;
4444
45namespace __partial_sort_copy {45struct __partial_sort_copy {
46
47struct __fn {
48 template <input_iterator _Iter1,46 template <input_iterator _Iter1,
49 sentinel_for<_Iter1> _Sent1,47 sentinel_for<_Iter1> _Sent1,
50 random_access_iterator _Iter2,48 random_access_iterator _Iter2,
...@@ -98,10 +96,8 @@ struct __fn {...@@ -98,10 +96,8 @@ struct __fn {
98 }96 }
99};97};
10098
101} // namespace __partial_sort_copy
102
103inline namespace __cpo {99inline namespace __cpo {
104inline constexpr auto partial_sort_copy = __partial_sort_copy::__fn{};100inline constexpr auto partial_sort_copy = __partial_sort_copy{};
105} // namespace __cpo101} // namespace __cpo
106} // namespace ranges102} // namespace ranges
107103
lib/libcxx/include/__algorithm/ranges_partition.h+3-6
...@@ -24,6 +24,7 @@...@@ -24,6 +24,7 @@
24#include <__ranges/access.h>24#include <__ranges/access.h>
25#include <__ranges/concepts.h>25#include <__ranges/concepts.h>
26#include <__ranges/subrange.h>26#include <__ranges/subrange.h>
27#include <__type_traits/remove_cvref.h>
27#include <__utility/forward.h>28#include <__utility/forward.h>
28#include <__utility/move.h>29#include <__utility/move.h>
29#include <__utility/pair.h>30#include <__utility/pair.h>
...@@ -40,9 +41,7 @@ _LIBCPP_PUSH_MACROS...@@ -40,9 +41,7 @@ _LIBCPP_PUSH_MACROS
40_LIBCPP_BEGIN_NAMESPACE_STD41_LIBCPP_BEGIN_NAMESPACE_STD
4142
42namespace ranges {43namespace ranges {
43namespace __partition {44struct __partition {
44
45struct __fn {
46 template <class _Iter, class _Sent, class _Proj, class _Pred>45 template <class _Iter, class _Sent, class _Proj, class _Pred>
47 _LIBCPP_HIDE_FROM_ABI static constexpr subrange<__remove_cvref_t<_Iter>>46 _LIBCPP_HIDE_FROM_ABI static constexpr subrange<__remove_cvref_t<_Iter>>
48 __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {47 __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
...@@ -72,10 +71,8 @@ struct __fn {...@@ -72,10 +71,8 @@ struct __fn {
72 }71 }
73};72};
7473
75} // namespace __partition
76
77inline namespace __cpo {74inline namespace __cpo {
78inline constexpr auto partition = __partition::__fn{};75inline constexpr auto partition = __partition{};
79} // namespace __cpo76} // namespace __cpo
80} // namespace ranges77} // namespace ranges
8178
lib/libcxx/include/__algorithm/ranges_partition_copy.h+2-6
...@@ -38,9 +38,7 @@ namespace ranges {...@@ -38,9 +38,7 @@ namespace ranges {
38template <class _InIter, class _OutIter1, class _OutIter2>38template <class _InIter, class _OutIter1, class _OutIter2>
39using partition_copy_result = in_out_out_result<_InIter, _OutIter1, _OutIter2>;39using partition_copy_result = in_out_out_result<_InIter, _OutIter1, _OutIter2>;
4040
41namespace __partition_copy {41struct __partition_copy {
42
43struct __fn {
44 // TODO(ranges): delegate to the classic algorithm.42 // TODO(ranges): delegate to the classic algorithm.
45 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>
46 _LIBCPP_HIDE_FROM_ABI constexpr static partition_copy_result<__remove_cvref_t<_InIter>,44 _LIBCPP_HIDE_FROM_ABI constexpr static partition_copy_result<__remove_cvref_t<_InIter>,
...@@ -94,10 +92,8 @@ struct __fn {...@@ -94,10 +92,8 @@ struct __fn {
94 }92 }
95};93};
9694
97} // namespace __partition_copy
98
99inline namespace __cpo {95inline namespace __cpo {
100inline constexpr auto partition_copy = __partition_copy::__fn{};96inline constexpr auto partition_copy = __partition_copy{};
101} // namespace __cpo97} // namespace __cpo
102} // namespace ranges98} // namespace ranges
10399
lib/libcxx/include/__algorithm/ranges_partition_point.h+2-6
...@@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS...@@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS
35_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3636
37namespace ranges {37namespace ranges {
38namespace __partition_point {38struct __partition_point {
39
40struct __fn {
41 // TODO(ranges): delegate to the classic algorithm.39 // TODO(ranges): delegate to the classic algorithm.
42 template <class _Iter, class _Sent, class _Proj, class _Pred>40 template <class _Iter, class _Sent, class _Proj, class _Pred>
43 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter41 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
...@@ -77,10 +75,8 @@ struct __fn {...@@ -77,10 +75,8 @@ struct __fn {
77 }75 }
78};76};
7977
80} // namespace __partition_point
81
82inline namespace __cpo {78inline namespace __cpo {
83inline constexpr auto partition_point = __partition_point::__fn{};79inline constexpr auto partition_point = __partition_point{};
84} // namespace __cpo80} // namespace __cpo
85} // namespace ranges81} // namespace ranges
8682
lib/libcxx/include/__algorithm/ranges_pop_heap.h+2-6
...@@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS...@@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS
40_LIBCPP_BEGIN_NAMESPACE_STD40_LIBCPP_BEGIN_NAMESPACE_STD
4141
42namespace ranges {42namespace ranges {
43namespace __pop_heap {43struct __pop_heap {
44
45struct __fn {
46 template <class _Iter, class _Sent, class _Comp, class _Proj>44 template <class _Iter, class _Sent, class _Comp, class _Proj>
47 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter45 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
48 __pop_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {46 __pop_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
...@@ -70,10 +68,8 @@ struct __fn {...@@ -70,10 +68,8 @@ struct __fn {
70 }68 }
71};69};
7270
73} // namespace __pop_heap
74
75inline namespace __cpo {71inline namespace __cpo {
76inline constexpr auto pop_heap = __pop_heap::__fn{};72inline constexpr auto pop_heap = __pop_heap{};
77} // namespace __cpo73} // namespace __cpo
78} // namespace ranges74} // namespace ranges
7975
lib/libcxx/include/__algorithm/ranges_prev_permutation.h+2-6
...@@ -40,9 +40,7 @@ namespace ranges {...@@ -40,9 +40,7 @@ namespace ranges {
40template <class _InIter>40template <class _InIter>
41using prev_permutation_result = in_found_result<_InIter>;41using prev_permutation_result = in_found_result<_InIter>;
4242
43namespace __prev_permutation {43struct __prev_permutation {
44
45struct __fn {
46 template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>44 template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
47 requires sortable<_Iter, _Comp, _Proj>45 requires sortable<_Iter, _Comp, _Proj>
48 _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<_Iter>46 _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<_Iter>
...@@ -62,10 +60,8 @@ struct __fn {...@@ -62,10 +60,8 @@ struct __fn {
62 }60 }
63};61};
6462
65} // namespace __prev_permutation
66
67inline namespace __cpo {63inline namespace __cpo {
68constexpr inline auto prev_permutation = __prev_permutation::__fn{};64constexpr inline auto prev_permutation = __prev_permutation{};
69} // namespace __cpo65} // namespace __cpo
70} // namespace ranges66} // namespace ranges
7167
lib/libcxx/include/__algorithm/ranges_push_heap.h+2-6
...@@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS...@@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS
40_LIBCPP_BEGIN_NAMESPACE_STD40_LIBCPP_BEGIN_NAMESPACE_STD
4141
42namespace ranges {42namespace ranges {
43namespace __push_heap {43struct __push_heap {
44
45struct __fn {
46 template <class _Iter, class _Sent, class _Comp, class _Proj>44 template <class _Iter, class _Sent, class _Comp, class _Proj>
47 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter45 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
48 __push_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {46 __push_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
...@@ -69,10 +67,8 @@ struct __fn {...@@ -69,10 +67,8 @@ struct __fn {
69 }67 }
70};68};
7169
72} // namespace __push_heap
73
74inline namespace __cpo {70inline namespace __cpo {
75inline constexpr auto push_heap = __push_heap::__fn{};71inline constexpr auto push_heap = __push_heap{};
76} // namespace __cpo72} // namespace __cpo
77} // namespace ranges73} // namespace ranges
7874
lib/libcxx/include/__algorithm/ranges_remove.h+2-4
...@@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS...@@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS
33_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3434
35namespace ranges {35namespace ranges {
36namespace __remove {36struct __remove {
37struct __fn {
38 template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>37 template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
39 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>38 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
40 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>39 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
...@@ -52,10 +51,9 @@ struct __fn {...@@ -52,10 +51,9 @@ struct __fn {
52 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);51 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
53 }52 }
54};53};
55} // namespace __remove
5654
57inline namespace __cpo {55inline namespace __cpo {
58inline constexpr auto remove = __remove::__fn{};56inline constexpr auto remove = __remove{};
59} // namespace __cpo57} // namespace __cpo
60} // namespace ranges58} // namespace ranges
6159
lib/libcxx/include/__algorithm/ranges_remove_copy.h+2-6
...@@ -38,9 +38,7 @@ namespace ranges {...@@ -38,9 +38,7 @@ namespace ranges {
38template <class _InIter, class _OutIter>38template <class _InIter, class _OutIter>
39using remove_copy_result = in_out_result<_InIter, _OutIter>;39using remove_copy_result = in_out_result<_InIter, _OutIter>;
4040
41namespace __remove_copy {41struct __remove_copy {
42
43struct __fn {
44 template <input_iterator _InIter,42 template <input_iterator _InIter,
45 sentinel_for<_InIter> _Sent,43 sentinel_for<_InIter> _Sent,
46 weakly_incrementable _OutIter,44 weakly_incrementable _OutIter,
...@@ -65,10 +63,8 @@ struct __fn {...@@ -65,10 +63,8 @@ struct __fn {
65 }63 }
66};64};
6765
68} // namespace __remove_copy
69
70inline namespace __cpo {66inline namespace __cpo {
71inline constexpr auto remove_copy = __remove_copy::__fn{};67inline constexpr auto remove_copy = __remove_copy{};
72} // namespace __cpo68} // namespace __cpo
73} // namespace ranges69} // namespace ranges
7470
lib/libcxx/include/__algorithm/ranges_remove_copy_if.h+2-6
...@@ -53,9 +53,7 @@ __remove_copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& _...@@ -53,9 +53,7 @@ __remove_copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& _
53 return {std::move(__first), std::move(__result)};53 return {std::move(__first), std::move(__result)};
54}54}
5555
56namespace __remove_copy_if {56struct __remove_copy_if {
57
58struct __fn {
59 template <input_iterator _InIter,57 template <input_iterator _InIter,
60 sentinel_for<_InIter> _Sent,58 sentinel_for<_InIter> _Sent,
61 weakly_incrementable _OutIter,59 weakly_incrementable _OutIter,
...@@ -79,10 +77,8 @@ struct __fn {...@@ -79,10 +77,8 @@ struct __fn {
79 }77 }
80};78};
8179
82} // namespace __remove_copy_if
83
84inline namespace __cpo {80inline namespace __cpo {
85inline constexpr auto remove_copy_if = __remove_copy_if::__fn{};81inline constexpr auto remove_copy_if = __remove_copy_if{};
86} // namespace __cpo82} // namespace __cpo
87} // namespace ranges83} // namespace ranges
8884
lib/libcxx/include/__algorithm/ranges_remove_if.h+2-4
...@@ -53,8 +53,7 @@ __remove_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {...@@ -53,8 +53,7 @@ __remove_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
53 return {__new_end, __i};53 return {__new_end, __i};
54}54}
5555
56namespace __remove_if {56struct __remove_if {
57struct __fn {
58 template <permutable _Iter,57 template <permutable _Iter,
59 sentinel_for<_Iter> _Sent,58 sentinel_for<_Iter> _Sent,
60 class _Proj = identity,59 class _Proj = identity,
...@@ -73,10 +72,9 @@ struct __fn {...@@ -73,10 +72,9 @@ struct __fn {
73 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);72 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
74 }73 }
75};74};
76} // namespace __remove_if
7775
78inline namespace __cpo {76inline namespace __cpo {
79inline constexpr auto remove_if = __remove_if::__fn{};77inline constexpr auto remove_if = __remove_if{};
80} // namespace __cpo78} // namespace __cpo
81} // namespace ranges79} // namespace ranges
8280
lib/libcxx/include/__algorithm/ranges_replace.h+2-4
...@@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS...@@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
34namespace ranges {34namespace ranges {
35namespace __replace {35struct __replace {
36struct __fn {
37 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type1, class _Type2, class _Proj = identity>36 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type1, class _Type2, class _Proj = identity>
38 requires indirectly_writable<_Iter, const _Type2&> &&37 requires indirectly_writable<_Iter, const _Type2&> &&
39 indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type1*>38 indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type1*>
...@@ -52,10 +51,9 @@ struct __fn {...@@ -52,10 +51,9 @@ struct __fn {
52 return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj);51 return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj);
53 }52 }
54};53};
55} // namespace __replace
5654
57inline namespace __cpo {55inline namespace __cpo {
58inline constexpr auto replace = __replace::__fn{};56inline constexpr auto replace = __replace{};
59} // namespace __cpo57} // namespace __cpo
60} // namespace ranges58} // namespace ranges
6159
lib/libcxx/include/__algorithm/ranges_replace_copy.h+2-6
...@@ -38,9 +38,7 @@ namespace ranges {...@@ -38,9 +38,7 @@ namespace ranges {
38template <class _InIter, class _OutIter>38template <class _InIter, class _OutIter>
39using replace_copy_result = in_out_result<_InIter, _OutIter>;39using replace_copy_result = in_out_result<_InIter, _OutIter>;
4040
41namespace __replace_copy {41struct __replace_copy {
42
43struct __fn {
44 template <input_iterator _InIter,42 template <input_iterator _InIter,
45 sentinel_for<_InIter> _Sent,43 sentinel_for<_InIter> _Sent,
46 class _OldType,44 class _OldType,
...@@ -77,10 +75,8 @@ struct __fn {...@@ -77,10 +75,8 @@ struct __fn {
77 }75 }
78};76};
7977
80} // namespace __replace_copy
81
82inline namespace __cpo {78inline namespace __cpo {
83inline constexpr auto replace_copy = __replace_copy::__fn{};79inline constexpr auto replace_copy = __replace_copy{};
84} // namespace __cpo80} // namespace __cpo
85} // namespace ranges81} // namespace ranges
8682
lib/libcxx/include/__algorithm/ranges_replace_copy_if.h+2-6
...@@ -52,9 +52,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<_InIter, _OutIter> __repl...@@ -52,9 +52,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<_InIter, _OutIter> __repl
52 return {std::move(__first), std::move(__result)};52 return {std::move(__first), std::move(__result)};
53}53}
5454
55namespace __replace_copy_if {55struct __replace_copy_if {
56
57struct __fn {
58 template <input_iterator _InIter,56 template <input_iterator _InIter,
59 sentinel_for<_InIter> _Sent,57 sentinel_for<_InIter> _Sent,
60 class _Type,58 class _Type,
...@@ -82,10 +80,8 @@ struct __fn {...@@ -82,10 +80,8 @@ struct __fn {
82 }80 }
83};81};
8482
85} // namespace __replace_copy_if
86
87inline namespace __cpo {83inline namespace __cpo {
88inline constexpr auto replace_copy_if = __replace_copy_if::__fn{};84inline constexpr auto replace_copy_if = __replace_copy_if{};
89} // namespace __cpo85} // namespace __cpo
90} // namespace ranges86} // namespace ranges
9187
lib/libcxx/include/__algorithm/ranges_replace_if.h+2-4
...@@ -42,8 +42,7 @@ __replace_if_impl(_Iter __first, _Sent __last, _Pred& __pred, const _Type& __new...@@ -42,8 +42,7 @@ __replace_if_impl(_Iter __first, _Sent __last, _Pred& __pred, const _Type& __new
42 return __first;42 return __first;
43}43}
4444
45namespace __replace_if {45struct __replace_if {
46struct __fn {
47 template <input_iterator _Iter,46 template <input_iterator _Iter,
48 sentinel_for<_Iter> _Sent,47 sentinel_for<_Iter> _Sent,
49 class _Type,48 class _Type,
...@@ -65,10 +64,9 @@ struct __fn {...@@ -65,10 +64,9 @@ struct __fn {
65 return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj);64 return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj);
66 }65 }
67};66};
68} // namespace __replace_if
6967
70inline namespace __cpo {68inline namespace __cpo {
71inline constexpr auto replace_if = __replace_if::__fn{};69inline constexpr auto replace_if = __replace_if{};
72} // namespace __cpo70} // namespace __cpo
73} // namespace ranges71} // namespace ranges
7472
lib/libcxx/include/__algorithm/ranges_reverse.h+2-4
...@@ -27,8 +27,7 @@...@@ -27,8 +27,7 @@
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2828
29namespace ranges {29namespace ranges {
30namespace __reverse {30struct __reverse {
31struct __fn {
32 template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent>31 template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent>
33 requires permutable<_Iter>32 requires permutable<_Iter>
34 _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last) const {33 _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last) const {
...@@ -65,10 +64,9 @@ struct __fn {...@@ -65,10 +64,9 @@ struct __fn {
65 return (*this)(ranges::begin(__range), ranges::end(__range));64 return (*this)(ranges::begin(__range), ranges::end(__range));
66 }65 }
67};66};
68} // namespace __reverse
6967
70inline namespace __cpo {68inline namespace __cpo {
71inline constexpr auto reverse = __reverse::__fn{};69inline constexpr auto reverse = __reverse{};
72} // namespace __cpo70} // namespace __cpo
73} // namespace ranges71} // namespace ranges
7472
lib/libcxx/include/__algorithm/ranges_reverse_copy.h+2-4
...@@ -37,8 +37,7 @@ namespace ranges {...@@ -37,8 +37,7 @@ namespace ranges {
37template <class _InIter, class _OutIter>37template <class _InIter, class _OutIter>
38using reverse_copy_result = in_out_result<_InIter, _OutIter>;38using reverse_copy_result = in_out_result<_InIter, _OutIter>;
3939
40namespace __reverse_copy {40struct __reverse_copy {
41struct __fn {
42 template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>41 template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
43 requires indirectly_copyable<_InIter, _OutIter>42 requires indirectly_copyable<_InIter, _OutIter>
44 _LIBCPP_HIDE_FROM_ABI constexpr reverse_copy_result<_InIter, _OutIter>43 _LIBCPP_HIDE_FROM_ABI constexpr reverse_copy_result<_InIter, _OutIter>
...@@ -54,10 +53,9 @@ struct __fn {...@@ -54,10 +53,9 @@ struct __fn {
54 return {ranges::next(ranges::begin(__range), ranges::end(__range)), std::move(__ret.out)};53 return {ranges::next(ranges::begin(__range), ranges::end(__range)), std::move(__ret.out)};
55 }54 }
56};55};
57} // namespace __reverse_copy
5856
59inline namespace __cpo {57inline namespace __cpo {
60inline constexpr auto reverse_copy = __reverse_copy::__fn{};58inline constexpr auto reverse_copy = __reverse_copy{};
61} // namespace __cpo59} // namespace __cpo
62} // namespace ranges60} // namespace ranges
6361
lib/libcxx/include/__algorithm/ranges_rotate.h+2-6
...@@ -33,9 +33,7 @@ _LIBCPP_PUSH_MACROS...@@ -33,9 +33,7 @@ _LIBCPP_PUSH_MACROS
33_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3434
35namespace ranges {35namespace ranges {
36namespace __rotate {36struct __rotate {
37
38struct __fn {
39 template <class _Iter, class _Sent>37 template <class _Iter, class _Sent>
40 _LIBCPP_HIDE_FROM_ABI constexpr static subrange<_Iter> __rotate_fn_impl(_Iter __first, _Iter __middle, _Sent __last) {38 _LIBCPP_HIDE_FROM_ABI constexpr static subrange<_Iter> __rotate_fn_impl(_Iter __first, _Iter __middle, _Sent __last) {
41 auto __ret = std::__rotate<_RangeAlgPolicy>(std::move(__first), std::move(__middle), std::move(__last));39 auto __ret = std::__rotate<_RangeAlgPolicy>(std::move(__first), std::move(__middle), std::move(__last));
...@@ -55,10 +53,8 @@ struct __fn {...@@ -55,10 +53,8 @@ struct __fn {
55 }53 }
56};54};
5755
58} // namespace __rotate
59
60inline namespace __cpo {56inline namespace __cpo {
61inline constexpr auto rotate = __rotate::__fn{};57inline constexpr auto rotate = __rotate{};
62} // namespace __cpo58} // namespace __cpo
63} // namespace ranges59} // namespace ranges
6460
lib/libcxx/include/__algorithm/ranges_rotate_copy.h+2-4
...@@ -34,8 +34,7 @@ namespace ranges {...@@ -34,8 +34,7 @@ namespace ranges {
34template <class _InIter, class _OutIter>34template <class _InIter, class _OutIter>
35using rotate_copy_result = in_out_result<_InIter, _OutIter>;35using rotate_copy_result = in_out_result<_InIter, _OutIter>;
3636
37namespace __rotate_copy {37struct __rotate_copy {
38struct __fn {
39 template <forward_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>38 template <forward_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
40 requires indirectly_copyable<_InIter, _OutIter>39 requires indirectly_copyable<_InIter, _OutIter>
41 _LIBCPP_HIDE_FROM_ABI constexpr rotate_copy_result<_InIter, _OutIter>40 _LIBCPP_HIDE_FROM_ABI constexpr rotate_copy_result<_InIter, _OutIter>
...@@ -52,10 +51,9 @@ struct __fn {...@@ -52,10 +51,9 @@ struct __fn {
52 return (*this)(ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__result));51 return (*this)(ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__result));
53 }52 }
54};53};
55} // namespace __rotate_copy
5654
57inline namespace __cpo {55inline namespace __cpo {
58inline constexpr auto rotate_copy = __rotate_copy::__fn{};56inline constexpr auto rotate_copy = __rotate_copy{};
59} // namespace __cpo57} // namespace __cpo
60} // namespace ranges58} // namespace ranges
6159
lib/libcxx/include/__algorithm/ranges_sample.h+2-6
...@@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS...@@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS
35_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3636
37namespace ranges {37namespace ranges {
38namespace __sample {38struct __sample {
39
40struct __fn {
41 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, weakly_incrementable _OutIter, class _Gen>39 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, weakly_incrementable _OutIter, class _Gen>
42 requires(forward_iterator<_Iter> || random_access_iterator<_OutIter>) && indirectly_copyable<_Iter, _OutIter> &&40 requires(forward_iterator<_Iter> || random_access_iterator<_OutIter>) && indirectly_copyable<_Iter, _OutIter> &&
43 uniform_random_bit_generator<remove_reference_t<_Gen>>41 uniform_random_bit_generator<remove_reference_t<_Gen>>
...@@ -58,10 +56,8 @@ struct __fn {...@@ -58,10 +56,8 @@ struct __fn {
58 }56 }
59};57};
6058
61} // namespace __sample
62
63inline namespace __cpo {59inline namespace __cpo {
64inline constexpr auto sample = __sample::__fn{};60inline constexpr auto sample = __sample{};
65} // namespace __cpo61} // namespace __cpo
66} // namespace ranges62} // namespace ranges
6763
lib/libcxx/include/__algorithm/ranges_search.h+2-4
...@@ -33,8 +33,7 @@...@@ -33,8 +33,7 @@
33_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3434
35namespace ranges {35namespace ranges {
36namespace __search {36struct __search {
37struct __fn {
38 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>37 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
39 _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_impl(38 _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_impl(
40 _Iter1 __first1,39 _Iter1 __first1,
...@@ -120,10 +119,9 @@ struct __fn {...@@ -120,10 +119,9 @@ struct __fn {
120 __proj2);119 __proj2);
121 }120 }
122};121};
123} // namespace __search
124122
125inline namespace __cpo {123inline namespace __cpo {
126inline constexpr auto search = __search::__fn{};124inline constexpr auto search = __search{};
127} // namespace __cpo125} // namespace __cpo
128} // namespace ranges126} // namespace ranges
129127
lib/libcxx/include/__algorithm/ranges_search_n.h+2-4
...@@ -39,8 +39,7 @@ _LIBCPP_PUSH_MACROS...@@ -39,8 +39,7 @@ _LIBCPP_PUSH_MACROS
39_LIBCPP_BEGIN_NAMESPACE_STD39_LIBCPP_BEGIN_NAMESPACE_STD
4040
41namespace ranges {41namespace ranges {
42namespace __search_n {42struct __search_n {
43struct __fn {
44 template <class _Iter1, class _Sent1, class _SizeT, class _Type, class _Pred, class _Proj>43 template <class _Iter1, class _Sent1, class _SizeT, class _Type, class _Pred, class _Proj>
45 _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_n_impl(44 _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_n_impl(
46 _Iter1 __first, _Sent1 __last, _SizeT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) {45 _Iter1 __first, _Sent1 __last, _SizeT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) {
...@@ -100,10 +99,9 @@ struct __fn {...@@ -100,10 +99,9 @@ struct __fn {
100 return __ranges_search_n_impl(ranges::begin(__range), ranges::end(__range), __count, __value, __pred, __proj);99 return __ranges_search_n_impl(ranges::begin(__range), ranges::end(__range), __count, __value, __pred, __proj);
101 }100 }
102};101};
103} // namespace __search_n
104102
105inline namespace __cpo {103inline namespace __cpo {
106inline constexpr auto search_n = __search_n::__fn{};104inline constexpr auto search_n = __search_n{};
107} // namespace __cpo105} // namespace __cpo
108} // namespace ranges106} // namespace ranges
109107
lib/libcxx/include/__algorithm/ranges_set_difference.h+4-9
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
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>
14#include <__algorithm/make_projected.h>13#include <__algorithm/make_projected.h>
15#include <__algorithm/set_difference.h>14#include <__algorithm/set_difference.h>
16#include <__config>15#include <__config>
...@@ -42,9 +41,7 @@ namespace ranges {...@@ -42,9 +41,7 @@ namespace ranges {
42template <class _InIter, class _OutIter>41template <class _InIter, class _OutIter>
43using set_difference_result = in_out_result<_InIter, _OutIter>;42using set_difference_result = in_out_result<_InIter, _OutIter>;
4443
45namespace __set_difference {44struct __set_difference {
46
47struct __fn {
48 template <input_iterator _InIter1,45 template <input_iterator _InIter1,
49 sentinel_for<_InIter1> _Sent1,46 sentinel_for<_InIter1> _Sent1,
50 input_iterator _InIter2,47 input_iterator _InIter2,
...@@ -63,7 +60,7 @@ struct __fn {...@@ -63,7 +60,7 @@ struct __fn {
63 _Comp __comp = {},60 _Comp __comp = {},
64 _Proj1 __proj1 = {},61 _Proj1 __proj1 = {},
65 _Proj2 __proj2 = {}) const {62 _Proj2 __proj2 = {}) const {
66 auto __ret = std::__set_difference<_RangeAlgPolicy>(63 auto __ret = std::__set_difference(
67 __first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2));64 __first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2));
68 return {std::move(__ret.first), std::move(__ret.second)};65 return {std::move(__ret.first), std::move(__ret.second)};
69 }66 }
...@@ -82,7 +79,7 @@ struct __fn {...@@ -82,7 +79,7 @@ struct __fn {
82 _Comp __comp = {},79 _Comp __comp = {},
83 _Proj1 __proj1 = {},80 _Proj1 __proj1 = {},
84 _Proj2 __proj2 = {}) const {81 _Proj2 __proj2 = {}) const {
85 auto __ret = std::__set_difference<_RangeAlgPolicy>(82 auto __ret = std::__set_difference(
86 ranges::begin(__range1),83 ranges::begin(__range1),
87 ranges::end(__range1),84 ranges::end(__range1),
88 ranges::begin(__range2),85 ranges::begin(__range2),
...@@ -93,10 +90,8 @@ struct __fn {...@@ -93,10 +90,8 @@ struct __fn {
93 }90 }
94};91};
9592
96} // namespace __set_difference
97
98inline namespace __cpo {93inline namespace __cpo {
99inline constexpr auto set_difference = __set_difference::__fn{};94inline constexpr auto set_difference = __set_difference{};
100} // namespace __cpo95} // namespace __cpo
101} // namespace ranges96} // namespace ranges
10297
lib/libcxx/include/__algorithm/ranges_set_intersection.h+2-6
...@@ -40,9 +40,7 @@ namespace ranges {...@@ -40,9 +40,7 @@ namespace ranges {
40template <class _InIter1, class _InIter2, class _OutIter>40template <class _InIter1, class _InIter2, class _OutIter>
41using set_intersection_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;41using set_intersection_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;
4242
43namespace __set_intersection {43struct __set_intersection {
44
45struct __fn {
46 template <input_iterator _InIter1,44 template <input_iterator _InIter1,
47 sentinel_for<_InIter1> _Sent1,45 sentinel_for<_InIter1> _Sent1,
48 input_iterator _InIter2,46 input_iterator _InIter2,
...@@ -98,10 +96,8 @@ struct __fn {...@@ -98,10 +96,8 @@ struct __fn {
98 }96 }
99};97};
10098
101} // namespace __set_intersection
102
103inline namespace __cpo {99inline namespace __cpo {
104inline constexpr auto set_intersection = __set_intersection::__fn{};100inline constexpr auto set_intersection = __set_intersection{};
105} // namespace __cpo101} // namespace __cpo
106} // namespace ranges102} // namespace ranges
107103
lib/libcxx/include/__algorithm/ranges_set_symmetric_difference.h+4-9
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
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>
14#include <__algorithm/make_projected.h>13#include <__algorithm/make_projected.h>
15#include <__algorithm/set_symmetric_difference.h>14#include <__algorithm/set_symmetric_difference.h>
16#include <__config>15#include <__config>
...@@ -40,9 +39,7 @@ namespace ranges {...@@ -40,9 +39,7 @@ namespace ranges {
40template <class _InIter1, class _InIter2, class _OutIter>39template <class _InIter1, class _InIter2, class _OutIter>
41using set_symmetric_difference_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;40using set_symmetric_difference_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;
4241
43namespace __set_symmetric_difference {42struct __set_symmetric_difference {
44
45struct __fn {
46 template <input_iterator _InIter1,43 template <input_iterator _InIter1,
47 sentinel_for<_InIter1> _Sent1,44 sentinel_for<_InIter1> _Sent1,
48 input_iterator _InIter2,45 input_iterator _InIter2,
...@@ -61,7 +58,7 @@ struct __fn {...@@ -61,7 +58,7 @@ struct __fn {
61 _Comp __comp = {},58 _Comp __comp = {},
62 _Proj1 __proj1 = {},59 _Proj1 __proj1 = {},
63 _Proj2 __proj2 = {}) const {60 _Proj2 __proj2 = {}) const {
64 auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>(61 auto __ret = std::__set_symmetric_difference(
65 std::move(__first1),62 std::move(__first1),
66 std::move(__last1),63 std::move(__last1),
67 std::move(__first2),64 std::move(__first2),
...@@ -87,7 +84,7 @@ struct __fn {...@@ -87,7 +84,7 @@ struct __fn {
87 _Comp __comp = {},84 _Comp __comp = {},
88 _Proj1 __proj1 = {},85 _Proj1 __proj1 = {},
89 _Proj2 __proj2 = {}) const {86 _Proj2 __proj2 = {}) const {
90 auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>(87 auto __ret = std::__set_symmetric_difference(
91 ranges::begin(__range1),88 ranges::begin(__range1),
92 ranges::end(__range1),89 ranges::end(__range1),
93 ranges::begin(__range2),90 ranges::begin(__range2),
...@@ -98,10 +95,8 @@ struct __fn {...@@ -98,10 +95,8 @@ struct __fn {
98 }95 }
99};96};
10097
101} // namespace __set_symmetric_difference
102
103inline namespace __cpo {98inline namespace __cpo {
104inline constexpr auto set_symmetric_difference = __set_symmetric_difference::__fn{};99inline constexpr auto set_symmetric_difference = __set_symmetric_difference{};
105} // namespace __cpo100} // namespace __cpo
106} // namespace ranges101} // namespace ranges
107102
lib/libcxx/include/__algorithm/ranges_set_union.h+4-9
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
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>
14#include <__algorithm/make_projected.h>13#include <__algorithm/make_projected.h>
15#include <__algorithm/set_union.h>14#include <__algorithm/set_union.h>
16#include <__config>15#include <__config>
...@@ -43,9 +42,7 @@ namespace ranges {...@@ -43,9 +42,7 @@ namespace ranges {
43template <class _InIter1, class _InIter2, class _OutIter>42template <class _InIter1, class _InIter2, class _OutIter>
44using set_union_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;43using set_union_result = in_in_out_result<_InIter1, _InIter2, _OutIter>;
4544
46namespace __set_union {45struct __set_union {
47
48struct __fn {
49 template <input_iterator _InIter1,46 template <input_iterator _InIter1,
50 sentinel_for<_InIter1> _Sent1,47 sentinel_for<_InIter1> _Sent1,
51 input_iterator _InIter2,48 input_iterator _InIter2,
...@@ -64,7 +61,7 @@ struct __fn {...@@ -64,7 +61,7 @@ struct __fn {
64 _Comp __comp = {},61 _Comp __comp = {},
65 _Proj1 __proj1 = {},62 _Proj1 __proj1 = {},
66 _Proj2 __proj2 = {}) const {63 _Proj2 __proj2 = {}) const {
67 auto __ret = std::__set_union<_RangeAlgPolicy>(64 auto __ret = std::__set_union(
68 std::move(__first1),65 std::move(__first1),
69 std::move(__last1),66 std::move(__last1),
70 std::move(__first2),67 std::move(__first2),
...@@ -88,7 +85,7 @@ struct __fn {...@@ -88,7 +85,7 @@ struct __fn {
88 _Comp __comp = {},85 _Comp __comp = {},
89 _Proj1 __proj1 = {},86 _Proj1 __proj1 = {},
90 _Proj2 __proj2 = {}) const {87 _Proj2 __proj2 = {}) const {
91 auto __ret = std::__set_union<_RangeAlgPolicy>(88 auto __ret = std::__set_union(
92 ranges::begin(__range1),89 ranges::begin(__range1),
93 ranges::end(__range1),90 ranges::end(__range1),
94 ranges::begin(__range2),91 ranges::begin(__range2),
...@@ -99,10 +96,8 @@ struct __fn {...@@ -99,10 +96,8 @@ struct __fn {
99 }96 }
100};97};
10198
102} // namespace __set_union
103
104inline namespace __cpo {99inline namespace __cpo {
105inline constexpr auto set_union = __set_union::__fn{};100inline constexpr auto set_union = __set_union{};
106} // namespace __cpo101} // namespace __cpo
107} // namespace ranges102} // namespace ranges
108103
lib/libcxx/include/__algorithm/ranges_shuffle.h+2-6
...@@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS...@@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS
39_LIBCPP_BEGIN_NAMESPACE_STD39_LIBCPP_BEGIN_NAMESPACE_STD
4040
41namespace ranges {41namespace ranges {
42namespace __shuffle {42struct __shuffle {
43
44struct __fn {
45 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Gen>43 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Gen>
46 requires permutable<_Iter> && uniform_random_bit_generator<remove_reference_t<_Gen>>44 requires permutable<_Iter> && uniform_random_bit_generator<remove_reference_t<_Gen>>
47 _LIBCPP_HIDE_FROM_ABI _Iter operator()(_Iter __first, _Sent __last, _Gen&& __gen) const {45 _LIBCPP_HIDE_FROM_ABI _Iter operator()(_Iter __first, _Sent __last, _Gen&& __gen) const {
...@@ -56,10 +54,8 @@ struct __fn {...@@ -56,10 +54,8 @@ struct __fn {
56 }54 }
57};55};
5856
59} // namespace __shuffle
60
61inline namespace __cpo {57inline namespace __cpo {
62inline constexpr auto shuffle = __shuffle::__fn{};58inline constexpr auto shuffle = __shuffle{};
63} // namespace __cpo59} // namespace __cpo
64} // namespace ranges60} // namespace ranges
6561
lib/libcxx/include/__algorithm/ranges_sort.h+2-6
...@@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS...@@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS
39_LIBCPP_BEGIN_NAMESPACE_STD39_LIBCPP_BEGIN_NAMESPACE_STD
4040
41namespace ranges {41namespace ranges {
42namespace __sort {42struct __sort {
43
44struct __fn {
45 template <class _Iter, class _Sent, class _Comp, class _Proj>43 template <class _Iter, class _Sent, class _Comp, class _Proj>
46 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter44 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
47 __sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {45 __sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
...@@ -68,10 +66,8 @@ struct __fn {...@@ -68,10 +66,8 @@ struct __fn {
68 }66 }
69};67};
7068
71} // namespace __sort
72
73inline namespace __cpo {69inline namespace __cpo {
74inline constexpr auto sort = __sort::__fn{};70inline constexpr auto sort = __sort{};
75} // namespace __cpo71} // namespace __cpo
76} // namespace ranges72} // namespace ranges
7773
lib/libcxx/include/__algorithm/ranges_sort_heap.h+2-6
...@@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS...@@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS
40_LIBCPP_BEGIN_NAMESPACE_STD40_LIBCPP_BEGIN_NAMESPACE_STD
4141
42namespace ranges {42namespace ranges {
43namespace __sort_heap {43struct __sort_heap {
44
45struct __fn {
46 template <class _Iter, class _Sent, class _Comp, class _Proj>44 template <class _Iter, class _Sent, class _Comp, class _Proj>
47 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter45 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
48 __sort_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {46 __sort_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
...@@ -69,10 +67,8 @@ struct __fn {...@@ -69,10 +67,8 @@ struct __fn {
69 }67 }
70};68};
7169
72} // namespace __sort_heap
73
74inline namespace __cpo {70inline namespace __cpo {
75inline constexpr auto sort_heap = __sort_heap::__fn{};71inline constexpr auto sort_heap = __sort_heap{};
76} // namespace __cpo72} // namespace __cpo
77} // namespace ranges73} // namespace ranges
7874
lib/libcxx/include/__algorithm/ranges_stable_partition.h+2-6
...@@ -42,9 +42,7 @@ _LIBCPP_PUSH_MACROS...@@ -42,9 +42,7 @@ _LIBCPP_PUSH_MACROS
42_LIBCPP_BEGIN_NAMESPACE_STD42_LIBCPP_BEGIN_NAMESPACE_STD
4343
44namespace ranges {44namespace ranges {
45namespace __stable_partition {45struct __stable_partition {
46
47struct __fn {
48 template <class _Iter, class _Sent, class _Proj, class _Pred>46 template <class _Iter, class _Sent, class _Proj, class _Pred>
49 _LIBCPP_HIDE_FROM_ABI static subrange<__remove_cvref_t<_Iter>>47 _LIBCPP_HIDE_FROM_ABI static subrange<__remove_cvref_t<_Iter>>
50 __stable_partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {48 __stable_partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
...@@ -76,10 +74,8 @@ struct __fn {...@@ -76,10 +74,8 @@ struct __fn {
76 }74 }
77};75};
7876
79} // namespace __stable_partition
80
81inline namespace __cpo {77inline namespace __cpo {
82inline constexpr auto stable_partition = __stable_partition::__fn{};78inline constexpr auto stable_partition = __stable_partition{};
83} // namespace __cpo79} // namespace __cpo
84} // namespace ranges80} // namespace ranges
8581
lib/libcxx/include/__algorithm/ranges_stable_sort.h+2-6
...@@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS...@@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS
39_LIBCPP_BEGIN_NAMESPACE_STD39_LIBCPP_BEGIN_NAMESPACE_STD
4040
41namespace ranges {41namespace ranges {
42namespace __stable_sort {42struct __stable_sort {
43
44struct __fn {
45 template <class _Iter, class _Sent, class _Comp, class _Proj>43 template <class _Iter, class _Sent, class _Comp, class _Proj>
46 _LIBCPP_HIDE_FROM_ABI static _Iter __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {44 _LIBCPP_HIDE_FROM_ABI static _Iter __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
47 auto __last_iter = ranges::next(__first, __last);45 auto __last_iter = ranges::next(__first, __last);
...@@ -66,10 +64,8 @@ struct __fn {...@@ -66,10 +64,8 @@ struct __fn {
66 }64 }
67};65};
6866
69} // namespace __stable_sort
70
71inline namespace __cpo {67inline namespace __cpo {
72inline constexpr auto stable_sort = __stable_sort::__fn{};68inline constexpr auto stable_sort = __stable_sort{};
73} // namespace __cpo69} // namespace __cpo
74} // namespace ranges70} // namespace ranges
7571
lib/libcxx/include/__algorithm/ranges_starts_with.h+4-6
...@@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS...@@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
34namespace ranges {34namespace ranges {
35namespace __starts_with {35struct __starts_with {
36struct __fn {
37 template <input_iterator _Iter1,36 template <input_iterator _Iter1,
38 sentinel_for<_Iter1> _Sent1,37 sentinel_for<_Iter1> _Sent1,
39 input_iterator _Iter2,38 input_iterator _Iter2,
...@@ -50,7 +49,7 @@ struct __fn {...@@ -50,7 +49,7 @@ struct __fn {
50 _Pred __pred = {},49 _Pred __pred = {},
51 _Proj1 __proj1 = {},50 _Proj1 __proj1 = {},
52 _Proj2 __proj2 = {}) {51 _Proj2 __proj2 = {}) {
53 return __mismatch::__fn::__go(52 return __mismatch::__go(
54 std::move(__first1),53 std::move(__first1),
55 std::move(__last1),54 std::move(__last1),
56 std::move(__first2),55 std::move(__first2),
...@@ -69,7 +68,7 @@ struct __fn {...@@ -69,7 +68,7 @@ struct __fn {
69 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>68 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
70 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool69 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool
71 operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) {70 operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) {
72 return __mismatch::__fn::__go(71 return __mismatch::__go(
73 ranges::begin(__range1),72 ranges::begin(__range1),
74 ranges::end(__range1),73 ranges::end(__range1),
75 ranges::begin(__range2),74 ranges::begin(__range2),
...@@ -80,9 +79,8 @@ struct __fn {...@@ -80,9 +79,8 @@ struct __fn {
80 .in2 == ranges::end(__range2);79 .in2 == ranges::end(__range2);
81 }80 }
82};81};
83} // namespace __starts_with
84inline namespace __cpo {82inline namespace __cpo {
85inline constexpr auto starts_with = __starts_with::__fn{};83inline constexpr auto starts_with = __starts_with{};
86} // namespace __cpo84} // namespace __cpo
87} // namespace ranges85} // namespace ranges
8886
lib/libcxx/include/__algorithm/ranges_swap_ranges.h+2-4
...@@ -36,8 +36,7 @@ namespace ranges {...@@ -36,8 +36,7 @@ namespace ranges {
36template <class _I1, class _I2>36template <class _I1, class _I2>
37using swap_ranges_result = in_in_result<_I1, _I2>;37using swap_ranges_result = in_in_result<_I1, _I2>;
3838
39namespace __swap_ranges {39struct __swap_ranges {
40struct __fn {
41 template <input_iterator _I1, sentinel_for<_I1> _S1, input_iterator _I2, sentinel_for<_I2> _S2>40 template <input_iterator _I1, sentinel_for<_I1> _S1, input_iterator _I2, sentinel_for<_I2> _S2>
42 requires indirectly_swappable<_I1, _I2>41 requires indirectly_swappable<_I1, _I2>
43 _LIBCPP_HIDE_FROM_ABI constexpr swap_ranges_result<_I1, _I2>42 _LIBCPP_HIDE_FROM_ABI constexpr swap_ranges_result<_I1, _I2>
...@@ -54,10 +53,9 @@ struct __fn {...@@ -54,10 +53,9 @@ struct __fn {
54 return operator()(ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2));53 return operator()(ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2));
55 }54 }
56};55};
57} // namespace __swap_ranges
5856
59inline namespace __cpo {57inline namespace __cpo {
60inline constexpr auto swap_ranges = __swap_ranges::__fn{};58inline constexpr auto swap_ranges = __swap_ranges{};
61} // namespace __cpo59} // namespace __cpo
62} // namespace ranges60} // namespace ranges
6361
lib/libcxx/include/__algorithm/ranges_transform.h+2-4
...@@ -41,8 +41,7 @@ using unary_transform_result = in_out_result<_Ip, _Op>;...@@ -41,8 +41,7 @@ using unary_transform_result = in_out_result<_Ip, _Op>;
41template <class _I1, class _I2, class _O1>41template <class _I1, class _I2, class _O1>
42using binary_transform_result = in_in_out_result<_I1, _I2, _O1>;42using binary_transform_result = in_in_out_result<_I1, _I2, _O1>;
4343
44namespace __transform {44struct __transform {
45struct __fn {
46private:45private:
47 template <class _InIter, class _Sent, class _OutIter, class _Func, class _Proj>46 template <class _InIter, class _Sent, class _OutIter, class _Func, class _Proj>
48 _LIBCPP_HIDE_FROM_ABI static constexpr unary_transform_result<_InIter, _OutIter>47 _LIBCPP_HIDE_FROM_ABI static constexpr unary_transform_result<_InIter, _OutIter>
...@@ -161,10 +160,9 @@ public:...@@ -161,10 +160,9 @@ public:
161 __projection2);160 __projection2);
162 }161 }
163};162};
164} // namespace __transform
165163
166inline namespace __cpo {164inline namespace __cpo {
167inline constexpr auto transform = __transform::__fn{};165inline constexpr auto transform = __transform{};
168} // namespace __cpo166} // namespace __cpo
169} // namespace ranges167} // namespace ranges
170168
lib/libcxx/include/__algorithm/ranges_unique.h+2-6
...@@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS...@@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS
40_LIBCPP_BEGIN_NAMESPACE_STD40_LIBCPP_BEGIN_NAMESPACE_STD
4141
42namespace ranges {42namespace ranges {
43namespace __unique {43struct __unique {
44
45struct __fn {
46 template <permutable _Iter,44 template <permutable _Iter,
47 sentinel_for<_Iter> _Sent,45 sentinel_for<_Iter> _Sent,
48 class _Proj = identity,46 class _Proj = identity,
...@@ -66,10 +64,8 @@ struct __fn {...@@ -66,10 +64,8 @@ struct __fn {
66 }64 }
67};65};
6866
69} // namespace __unique
70
71inline namespace __cpo {67inline namespace __cpo {
72inline constexpr auto unique = __unique::__fn{};68inline constexpr auto unique = __unique{};
73} // namespace __cpo69} // namespace __cpo
74} // namespace ranges70} // namespace ranges
7571
lib/libcxx/include/__algorithm/ranges_unique_copy.h+3-7
...@@ -44,12 +44,10 @@ namespace ranges {...@@ -44,12 +44,10 @@ namespace ranges {
44template <class _InIter, class _OutIter>44template <class _InIter, class _OutIter>
45using unique_copy_result = in_out_result<_InIter, _OutIter>;45using unique_copy_result = in_out_result<_InIter, _OutIter>;
4646
47namespace __unique_copy {
48
49template <class _InIter, class _OutIter>47template <class _InIter, class _OutIter>
50concept __can_reread_from_output = (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>);48concept __can_reread_from_output = (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>);
5149
52struct __fn {50struct __unique_copy {
53 template <class _InIter, class _OutIter>51 template <class _InIter, class _OutIter>
54 static consteval auto __get_algo_tag() {52 static consteval auto __get_algo_tag() {
55 if constexpr (forward_iterator<_InIter>) {53 if constexpr (forward_iterator<_InIter>) {
...@@ -62,7 +60,7 @@ struct __fn {...@@ -62,7 +60,7 @@ struct __fn {
62 }60 }
6361
64 template <class _InIter, class _OutIter>62 template <class _InIter, class _OutIter>
65 using __algo_tag_t = decltype(__get_algo_tag<_InIter, _OutIter>());63 using __algo_tag_t _LIBCPP_NODEBUG = decltype(__get_algo_tag<_InIter, _OutIter>());
6664
67 template <input_iterator _InIter,65 template <input_iterator _InIter,
68 sentinel_for<_InIter> _Sent,66 sentinel_for<_InIter> _Sent,
...@@ -104,10 +102,8 @@ struct __fn {...@@ -104,10 +102,8 @@ struct __fn {
104 }102 }
105};103};
106104
107} // namespace __unique_copy
108
109inline namespace __cpo {105inline namespace __cpo {
110inline constexpr auto unique_copy = __unique_copy::__fn{};106inline constexpr auto unique_copy = __unique_copy{};
111} // namespace __cpo107} // namespace __cpo
112} // namespace ranges108} // namespace ranges
113109
lib/libcxx/include/__algorithm/ranges_upper_bound.h+2-4
...@@ -30,8 +30,7 @@...@@ -30,8 +30,7 @@
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
32namespace ranges {32namespace ranges {
33namespace __upper_bound {33struct __upper_bound {
34struct __fn {
35 template <forward_iterator _Iter,34 template <forward_iterator _Iter,
36 sentinel_for<_Iter> _Sent,35 sentinel_for<_Iter> _Sent,
37 class _Type,36 class _Type,
...@@ -60,10 +59,9 @@ struct __fn {...@@ -60,10 +59,9 @@ struct __fn {
60 ranges::begin(__r), ranges::end(__r), __value, __comp_lhs_rhs_swapped, __proj);59 ranges::begin(__r), ranges::end(__r), __value, __comp_lhs_rhs_swapped, __proj);
61 }60 }
62};61};
63} // namespace __upper_bound
6462
65inline namespace __cpo {63inline namespace __cpo {
66inline constexpr auto upper_bound = __upper_bound::__fn{};64inline constexpr auto upper_bound = __upper_bound{};
67} // namespace __cpo65} // namespace __cpo
68} // namespace ranges66} // namespace ranges
6967
lib/libcxx/include/__algorithm/remove.h+1-1
...@@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS...@@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
26template <class _ForwardIterator, class _Tp>26template <class _ForwardIterator, class _Tp>
27_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator27[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
28remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {28remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
29 __first = std::find(__first, __last, __value);29 __first = std::find(__first, __last, __value);
30 if (__first != __last) {30 if (__first != __last) {
lib/libcxx/include/__algorithm/remove_if.h+1-1
...@@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS...@@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25template <class _ForwardIterator, class _Predicate>25template <class _ForwardIterator, class _Predicate>
26_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator26[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
27remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {27remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
28 __first = std::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred);28 __first = std::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred);
29 if (__first != __last) {29 if (__first != __last) {
lib/libcxx/include/__algorithm/search.h+5-5
...@@ -14,11 +14,11 @@...@@ -14,11 +14,11 @@
14#include <__algorithm/iterator_operations.h>14#include <__algorithm/iterator_operations.h>
15#include <__config>15#include <__config>
16#include <__functional/identity.h>16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__iterator/advance.h>17#include <__iterator/advance.h>
19#include <__iterator/concepts.h>18#include <__iterator/concepts.h>
20#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
21#include <__type_traits/enable_if.h>20#include <__type_traits/enable_if.h>
21#include <__type_traits/invoke.h>
22#include <__type_traits/is_callable.h>22#include <__type_traits/is_callable.h>
23#include <__utility/pair.h>23#include <__utility/pair.h>
2424
...@@ -160,20 +160,20 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __searc...@@ -160,20 +160,20 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __searc
160}160}
161161
162template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>162template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
163_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1163[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
164search(_ForwardIterator1 __first1,164search(_ForwardIterator1 __first1,
165 _ForwardIterator1 __last1,165 _ForwardIterator1 __last1,
166 _ForwardIterator2 __first2,166 _ForwardIterator2 __first2,
167 _ForwardIterator2 __last2,167 _ForwardIterator2 __last2,
168 _BinaryPredicate __pred) {168 _BinaryPredicate __pred) {
169 static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,169 static_assert(__is_callable<_BinaryPredicate&, decltype(*__first1), decltype(*__first2)>::value,
170 "BinaryPredicate has to be callable");170 "The comparator has to be callable");
171 auto __proj = __identity();171 auto __proj = __identity();
172 return std::__search_impl(__first1, __last1, __first2, __last2, __pred, __proj, __proj).first;172 return std::__search_impl(__first1, __last1, __first2, __last2, __pred, __proj, __proj).first;
173}173}
174174
175template <class _ForwardIterator1, class _ForwardIterator2>175template <class _ForwardIterator1, class _ForwardIterator2>
176_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1176[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
177search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {177search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
178 return std::search(__first1, __last1, __first2, __last2, __equal_to());178 return std::search(__first1, __last1, __first2, __last2, __equal_to());
179}179}
lib/libcxx/include/__algorithm/search_n.h+5-4
...@@ -14,12 +14,13 @@...@@ -14,12 +14,13 @@
14#include <__algorithm/iterator_operations.h>14#include <__algorithm/iterator_operations.h>
15#include <__config>15#include <__config>
16#include <__functional/identity.h>16#include <__functional/identity.h>
17#include <__functional/invoke.h>
18#include <__iterator/advance.h>17#include <__iterator/advance.h>
19#include <__iterator/concepts.h>18#include <__iterator/concepts.h>
20#include <__iterator/distance.h>19#include <__iterator/distance.h>
21#include <__iterator/iterator_traits.h>20#include <__iterator/iterator_traits.h>
22#include <__ranges/concepts.h>21#include <__ranges/concepts.h>
22#include <__type_traits/enable_if.h>
23#include <__type_traits/invoke.h>
23#include <__type_traits/is_callable.h>24#include <__type_traits/is_callable.h>
24#include <__utility/convert_to_integral.h>25#include <__utility/convert_to_integral.h>
25#include <__utility/pair.h>26#include <__utility/pair.h>
...@@ -136,16 +137,16 @@ __search_n_impl(_Iter1 __first, _Sent1 __last, _DiffT __count, const _Type& __va...@@ -136,16 +137,16 @@ __search_n_impl(_Iter1 __first, _Sent1 __last, _DiffT __count, const _Type& __va
136}137}
137138
138template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>139template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
139_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator search_n(140[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator search_n(
140 _ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value, _BinaryPredicate __pred) {141 _ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value, _BinaryPredicate __pred) {
141 static_assert(142 static_assert(
142 __is_callable<_BinaryPredicate, decltype(*__first), const _Tp&>::value, "BinaryPredicate has to be callable");143 __is_callable<_BinaryPredicate&, decltype(*__first), const _Tp&>::value, "The comparator has to be callable");
143 auto __proj = __identity();144 auto __proj = __identity();
144 return std::__search_n_impl(__first, __last, std::__convert_to_integral(__count), __value, __pred, __proj).first;145 return std::__search_n_impl(__first, __last, std::__convert_to_integral(__count), __value, __pred, __proj).first;
145}146}
146147
147template <class _ForwardIterator, class _Size, class _Tp>148template <class _ForwardIterator, class _Size, class _Tp>
148_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator149[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
149search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) {150search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) {
150 return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to());151 return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to());
151}152}
lib/libcxx/include/__algorithm/set_difference.h+4-7
...@@ -12,10 +12,8 @@...@@ -12,10 +12,8 @@
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>
16#include <__config>15#include <__config>
17#include <__functional/identity.h>16#include <__functional/identity.h>
18#include <__functional/invoke.h>
19#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
20#include <__type_traits/remove_cvref.h>18#include <__type_traits/remove_cvref.h>
21#include <__utility/move.h>19#include <__utility/move.h>
...@@ -30,7 +28,7 @@ _LIBCPP_PUSH_MACROS...@@ -30,7 +28,7 @@ _LIBCPP_PUSH_MACROS
3028
31_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3230
33template <class _AlgPolicy, class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>31template <class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
34_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__remove_cvref_t<_InIter1>, __remove_cvref_t<_OutIter> >32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__remove_cvref_t<_InIter1>, __remove_cvref_t<_OutIter> >
35__set_difference(33__set_difference(
36 _InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) {34 _InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) {
...@@ -46,7 +44,7 @@ __set_difference(...@@ -46,7 +44,7 @@ __set_difference(
46 ++__first2;44 ++__first2;
47 }45 }
48 }46 }
49 return std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result));47 return std::__copy(std::move(__first1), std::move(__last1), std::move(__result));
50}48}
5149
52template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>50template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
...@@ -57,8 +55,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_d...@@ -57,8 +55,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_d
57 _InputIterator2 __last2,55 _InputIterator2 __last2,
58 _OutputIterator __result,56 _OutputIterator __result,
59 _Compare __comp) {57 _Compare __comp) {
60 return std::__set_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(58 return std::__set_difference<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __result, __comp)
61 __first1, __last1, __first2, __last2, __result, __comp)
62 .second;59 .second;
63}60}
6461
...@@ -69,7 +66,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_d...@@ -69,7 +66,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_d
69 _InputIterator2 __first2,66 _InputIterator2 __first2,
70 _InputIterator2 __last2,67 _InputIterator2 __last2,
71 _OutputIterator __result) {68 _OutputIterator __result) {
72 return std::__set_difference<_ClassicAlgPolicy>(__first1, __last1, __first2, __last2, __result, __less<>()).second;69 return std::__set_difference(__first1, __last1, __first2, __last2, __result, __less<>()).second;
73}70}
7471
75_LIBCPP_END_NAMESPACE_STD72_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/set_intersection.h+4-3
...@@ -19,6 +19,7 @@...@@ -19,6 +19,7 @@
19#include <__iterator/next.h>19#include <__iterator/next.h>
20#include <__type_traits/is_same.h>20#include <__type_traits/is_same.h>
21#include <__utility/exchange.h>21#include <__utility/exchange.h>
22#include <__utility/forward.h>
22#include <__utility/move.h>23#include <__utility/move.h>
23#include <__utility/swap.h>24#include <__utility/swap.h>
2425
...@@ -84,7 +85,7 @@ template <class _AlgPolicy,...@@ -84,7 +85,7 @@ template <class _AlgPolicy,
84 class _InForwardIter2,85 class _InForwardIter2,
85 class _Sent2,86 class _Sent2,
86 class _OutIter>87 class _OutIter>
87_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI88[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI
88_LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InForwardIter1, _InForwardIter2, _OutIter>89_LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InForwardIter1, _InForwardIter2, _OutIter>
89__set_intersection(90__set_intersection(
90 _InForwardIter1 __first1,91 _InForwardIter1 __first1,
...@@ -129,7 +130,7 @@ template <class _AlgPolicy,...@@ -129,7 +130,7 @@ template <class _AlgPolicy,
129 class _InInputIter2,130 class _InInputIter2,
130 class _Sent2,131 class _Sent2,
131 class _OutIter>132 class _OutIter>
132_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI133[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI
133_LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InInputIter1, _InInputIter2, _OutIter>134_LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InInputIter1, _InInputIter2, _OutIter>
134__set_intersection(135__set_intersection(
135 _InInputIter1 __first1,136 _InInputIter1 __first1,
...@@ -160,7 +161,7 @@ __set_intersection(...@@ -160,7 +161,7 @@ __set_intersection(
160}161}
161162
162template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>163template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
163_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI164[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI
164_LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InIter1, _InIter2, _OutIter>165_LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InIter1, _InIter2, _OutIter>
165__set_intersection(166__set_intersection(
166 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {167 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
lib/libcxx/include/__algorithm/set_symmetric_difference.h+4-5
...@@ -12,7 +12,6 @@...@@ -12,7 +12,6 @@
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>
16#include <__config>15#include <__config>
17#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
18#include <__utility/move.h>17#include <__utility/move.h>
...@@ -39,13 +38,13 @@ struct __set_symmetric_difference_result {...@@ -39,13 +38,13 @@ struct __set_symmetric_difference_result {
39 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}38 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
40};39};
4140
42template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>41template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
43_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>
44__set_symmetric_difference(43__set_symmetric_difference(
45 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {44 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
46 while (__first1 != __last1) {45 while (__first1 != __last1) {
47 if (__first2 == __last2) {46 if (__first2 == __last2) {
48 auto __ret1 = std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result));47 auto __ret1 = std::__copy(std::move(__first1), std::move(__last1), std::move(__result));
49 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(48 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
50 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));49 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
51 }50 }
...@@ -63,7 +62,7 @@ __set_symmetric_difference(...@@ -63,7 +62,7 @@ __set_symmetric_difference(
63 ++__first2;62 ++__first2;
64 }63 }
65 }64 }
66 auto __ret2 = std::__copy<_AlgPolicy>(std::move(__first2), std::move(__last2), std::move(__result));65 auto __ret2 = std::__copy(std::move(__first2), std::move(__last2), std::move(__result));
67 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(66 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
68 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));67 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
69}68}
...@@ -76,7 +75,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_symmetri...@@ -76,7 +75,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_symmetri
76 _InputIterator2 __last2,75 _InputIterator2 __last2,
77 _OutputIterator __result,76 _OutputIterator __result,
78 _Compare __comp) {77 _Compare __comp) {
79 return std::__set_symmetric_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(78 return std::__set_symmetric_difference<__comp_ref_type<_Compare> >(
80 std::move(__first1),79 std::move(__first1),
81 std::move(__last1),80 std::move(__last1),
82 std::move(__first2),81 std::move(__first2),
lib/libcxx/include/__algorithm/set_union.h+4-5
...@@ -12,7 +12,6 @@...@@ -12,7 +12,6 @@
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>
16#include <__config>15#include <__config>
17#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
18#include <__utility/move.h>17#include <__utility/move.h>
...@@ -39,12 +38,12 @@ struct __set_union_result {...@@ -39,12 +38,12 @@ struct __set_union_result {
39 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}38 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
40};39};
4140
42template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>41template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
43_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1, _InIter2, _OutIter> __set_union(42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1, _InIter2, _OutIter> __set_union(
44 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {43 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
45 for (; __first1 != __last1; ++__result) {44 for (; __first1 != __last1; ++__result) {
46 if (__first2 == __last2) {45 if (__first2 == __last2) {
47 auto __ret1 = std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result));46 auto __ret1 = std::__copy(std::move(__first1), std::move(__last1), std::move(__result));
48 return __set_union_result<_InIter1, _InIter2, _OutIter>(47 return __set_union_result<_InIter1, _InIter2, _OutIter>(
49 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));48 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
50 }49 }
...@@ -59,7 +58,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1,...@@ -59,7 +58,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1,
59 ++__first1;58 ++__first1;
60 }59 }
61 }60 }
62 auto __ret2 = std::__copy<_AlgPolicy>(std::move(__first2), std::move(__last2), std::move(__result));61 auto __ret2 = std::__copy(std::move(__first2), std::move(__last2), std::move(__result));
63 return __set_union_result<_InIter1, _InIter2, _OutIter>(62 return __set_union_result<_InIter1, _InIter2, _OutIter>(
64 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));63 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
65}64}
...@@ -72,7 +71,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_union(...@@ -72,7 +71,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_union(
72 _InputIterator2 __last2,71 _InputIterator2 __last2,
73 _OutputIterator __result,72 _OutputIterator __result,
74 _Compare __comp) {73 _Compare __comp) {
75 return std::__set_union<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(74 return std::__set_union<__comp_ref_type<_Compare> >(
76 std::move(__first1),75 std::move(__first1),
77 std::move(__last1),76 std::move(__last1),
78 std::move(__first2),77 std::move(__first2),
lib/libcxx/include/__algorithm/shuffle.h+1-1
...@@ -11,12 +11,12 @@...@@ -11,12 +11,12 @@
1111
12#include <__algorithm/iterator_operations.h>12#include <__algorithm/iterator_operations.h>
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
14#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
15#include <__random/uniform_int_distribution.h>16#include <__random/uniform_int_distribution.h>
16#include <__utility/forward.h>17#include <__utility/forward.h>
17#include <__utility/move.h>18#include <__utility/move.h>
18#include <__utility/swap.h>19#include <__utility/swap.h>
19#include <cstddef>
20#include <cstdint>20#include <cstdint>
2121
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__algorithm/simd_utils.h+8-8
...@@ -14,10 +14,10 @@...@@ -14,10 +14,10 @@
14#include <__bit/countl.h>14#include <__bit/countl.h>
15#include <__bit/countr.h>15#include <__bit/countr.h>
16#include <__config>16#include <__config>
17#include <__cstddef/size_t.h>
17#include <__type_traits/is_arithmetic.h>18#include <__type_traits/is_arithmetic.h>
18#include <__type_traits/is_same.h>19#include <__type_traits/is_same.h>
19#include <__utility/integer_sequence.h>20#include <__utility/integer_sequence.h>
20#include <cstddef>
21#include <cstdint>21#include <cstdint>
2222
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -70,7 +70,7 @@ struct __get_as_integer_type_impl<8> {...@@ -70,7 +70,7 @@ struct __get_as_integer_type_impl<8> {
70};70};
7171
72template <class _Tp>72template <class _Tp>
73using __get_as_integer_type_t = typename __get_as_integer_type_impl<sizeof(_Tp)>::type;73using __get_as_integer_type_t _LIBCPP_NODEBUG = typename __get_as_integer_type_impl<sizeof(_Tp)>::type;
7474
75// This isn't specialized for 64 byte vectors on purpose. They have the potential to significantly reduce performance75// This isn't specialized for 64 byte vectors on purpose. They have the potential to significantly reduce performance
76// in mixed simd/non-simd workloads and don't provide any performance improvement for currently vectorized algorithms76// in mixed simd/non-simd workloads and don't provide any performance improvement for currently vectorized algorithms
...@@ -90,7 +90,7 @@ inline constexpr size_t __native_vector_size = 1;...@@ -90,7 +90,7 @@ inline constexpr size_t __native_vector_size = 1;
90# endif90# endif
9191
92template <class _ArithmeticT, size_t _Np>92template <class _ArithmeticT, size_t _Np>
93using __simd_vector __attribute__((__ext_vector_type__(_Np))) = _ArithmeticT;93using __simd_vector __attribute__((__ext_vector_type__(_Np))) _LIBCPP_NODEBUG = _ArithmeticT;
9494
95template <class _VecT>95template <class _VecT>
96inline constexpr size_t __simd_vector_size_v = []<bool _False = false>() -> size_t {96inline constexpr size_t __simd_vector_size_v = []<bool _False = false>() -> size_t {
...@@ -106,23 +106,23 @@ _LIBCPP_HIDE_FROM_ABI _Tp __simd_vector_underlying_type_impl(__simd_vector<_Tp,...@@ -106,23 +106,23 @@ _LIBCPP_HIDE_FROM_ABI _Tp __simd_vector_underlying_type_impl(__simd_vector<_Tp,
106}106}
107107
108template <class _VecT>108template <class _VecT>
109using __simd_vector_underlying_type_t = decltype(std::__simd_vector_underlying_type_impl(_VecT{}));109using __simd_vector_underlying_type_t _LIBCPP_NODEBUG = decltype(std::__simd_vector_underlying_type_impl(_VecT{}));
110110
111// This isn't inlined without always_inline when loading chars.111// This isn't inlined without always_inline when loading chars.
112template <class _VecT, class _Iter>112template <class _VecT, class _Iter>
113_LIBCPP_NODISCARD _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _VecT __load_vector(_Iter __iter) noexcept {113[[__nodiscard__]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _VecT __load_vector(_Iter __iter) noexcept {
114 return [=]<size_t... _Indices>(index_sequence<_Indices...>) _LIBCPP_ALWAYS_INLINE noexcept {114 return [=]<size_t... _Indices>(index_sequence<_Indices...>) _LIBCPP_ALWAYS_INLINE noexcept {
115 return _VecT{__iter[_Indices]...};115 return _VecT{__iter[_Indices]...};
116 }(make_index_sequence<__simd_vector_size_v<_VecT>>{});116 }(make_index_sequence<__simd_vector_size_v<_VecT>>{});
117}117}
118118
119template <class _Tp, size_t _Np>119template <class _Tp, size_t _Np>
120_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool __all_of(__simd_vector<_Tp, _Np> __vec) noexcept {120[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool __all_of(__simd_vector<_Tp, _Np> __vec) noexcept {
121 return __builtin_reduce_and(__builtin_convertvector(__vec, __simd_vector<bool, _Np>));121 return __builtin_reduce_and(__builtin_convertvector(__vec, __simd_vector<bool, _Np>));
122}122}
123123
124template <class _Tp, size_t _Np>124template <class _Tp, size_t _Np>
125_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_Tp, _Np> __vec) noexcept {125[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_Tp, _Np> __vec) noexcept {
126 using __mask_vec = __simd_vector<bool, _Np>;126 using __mask_vec = __simd_vector<bool, _Np>;
127127
128 // This has MSan disabled du to https://github.com/llvm/llvm-project/issues/85876128 // This has MSan disabled du to https://github.com/llvm/llvm-project/issues/85876
...@@ -151,7 +151,7 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_T...@@ -151,7 +151,7 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_T
151}151}
152152
153template <class _Tp, size_t _Np>153template <class _Tp, size_t _Np>
154_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI size_t __find_first_not_set(__simd_vector<_Tp, _Np> __vec) noexcept {154[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t __find_first_not_set(__simd_vector<_Tp, _Np> __vec) noexcept {
155 return std::__find_first_set(~__vec);155 return std::__find_first_set(~__vec);
156}156}
157157
lib/libcxx/include/__algorithm/sort.h+128-170
...@@ -27,9 +27,14 @@...@@ -27,9 +27,14 @@
27#include <__functional/ranges_operations.h>27#include <__functional/ranges_operations.h>
28#include <__iterator/iterator_traits.h>28#include <__iterator/iterator_traits.h>
29#include <__type_traits/conditional.h>29#include <__type_traits/conditional.h>
30#include <__type_traits/desugars_to.h>
30#include <__type_traits/disjunction.h>31#include <__type_traits/disjunction.h>
32#include <__type_traits/enable_if.h>
31#include <__type_traits/is_arithmetic.h>33#include <__type_traits/is_arithmetic.h>
32#include <__type_traits/is_constant_evaluated.h>34#include <__type_traits/is_constant_evaluated.h>
35#include <__type_traits/is_same.h>
36#include <__type_traits/is_trivially_copyable.h>
37#include <__type_traits/remove_cvref.h>
33#include <__utility/move.h>38#include <__utility/move.h>
34#include <__utility/pair.h>39#include <__utility/pair.h>
35#include <climits>40#include <climits>
...@@ -44,110 +49,11 @@ _LIBCPP_PUSH_MACROS...@@ -44,110 +49,11 @@ _LIBCPP_PUSH_MACROS
4449
45_LIBCPP_BEGIN_NAMESPACE_STD50_LIBCPP_BEGIN_NAMESPACE_STD
4651
47// stable, 2-3 compares, 0-2 swaps
48
49template <class _AlgPolicy, class _Compare, class _ForwardIterator>
50_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 unsigned
51__sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z, _Compare __c) {
52 using _Ops = _IterOps<_AlgPolicy>;
53
54 unsigned __r = 0;
55 if (!__c(*__y, *__x)) // if x <= y
56 {
57 if (!__c(*__z, *__y)) // if y <= z
58 return __r; // x <= y && y <= z
59 // x <= y && y > z
60 _Ops::iter_swap(__y, __z); // x <= z && y < z
61 __r = 1;
62 if (__c(*__y, *__x)) // if x > y
63 {
64 _Ops::iter_swap(__x, __y); // x < y && y <= z
65 __r = 2;
66 }
67 return __r; // x <= y && y < z
68 }
69 if (__c(*__z, *__y)) // x > y, if y > z
70 {
71 _Ops::iter_swap(__x, __z); // x < y && y < z
72 __r = 1;
73 return __r;
74 }
75 _Ops::iter_swap(__x, __y); // x > y && y <= z
76 __r = 1; // x < y && x <= z
77 if (__c(*__z, *__y)) // if y > z
78 {
79 _Ops::iter_swap(__y, __z); // x <= y && y < z
80 __r = 2;
81 }
82 return __r;
83} // x <= y && y <= z
84
85// stable, 3-6 compares, 0-5 swaps
86
87template <class _AlgPolicy, class _Compare, class _ForwardIterator>
88_LIBCPP_HIDE_FROM_ABI void
89__sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, _Compare __c) {
90 using _Ops = _IterOps<_AlgPolicy>;
91 std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);
92 if (__c(*__x4, *__x3)) {
93 _Ops::iter_swap(__x3, __x4);
94 if (__c(*__x3, *__x2)) {
95 _Ops::iter_swap(__x2, __x3);
96 if (__c(*__x2, *__x1)) {
97 _Ops::iter_swap(__x1, __x2);
98 }
99 }
100 }
101}
102
103// stable, 4-10 compares, 0-9 swaps
104
105template <class _AlgPolicy, class _Comp, class _ForwardIterator>
106_LIBCPP_HIDE_FROM_ABI void
107__sort5(_ForwardIterator __x1,
108 _ForwardIterator __x2,
109 _ForwardIterator __x3,
110 _ForwardIterator __x4,
111 _ForwardIterator __x5,
112 _Comp __comp) {
113 using _Ops = _IterOps<_AlgPolicy>;
114
115 std::__sort4<_AlgPolicy, _Comp>(__x1, __x2, __x3, __x4, __comp);
116 if (__comp(*__x5, *__x4)) {
117 _Ops::iter_swap(__x4, __x5);
118 if (__comp(*__x4, *__x3)) {
119 _Ops::iter_swap(__x3, __x4);
120 if (__comp(*__x3, *__x2)) {
121 _Ops::iter_swap(__x2, __x3);
122 if (__comp(*__x2, *__x1)) {
123 _Ops::iter_swap(__x1, __x2);
124 }
125 }
126 }
127 }
128}
129
130// The comparator being simple is a prerequisite for using the branchless optimization.
131template <class _Tp>
132struct __is_simple_comparator : false_type {};
133template <>
134struct __is_simple_comparator<__less<>&> : true_type {};
135template <class _Tp>
136struct __is_simple_comparator<less<_Tp>&> : true_type {};
137template <class _Tp>
138struct __is_simple_comparator<greater<_Tp>&> : true_type {};
139#if _LIBCPP_STD_VER >= 20
140template <>
141struct __is_simple_comparator<ranges::less&> : true_type {};
142template <>
143struct __is_simple_comparator<ranges::greater&> : true_type {};
144#endif
145
146template <class _Compare, class _Iter, class _Tp = typename iterator_traits<_Iter>::value_type>52template <class _Compare, class _Iter, class _Tp = typename iterator_traits<_Iter>::value_type>
147using __use_branchless_sort =53inline const bool __use_branchless_sort =
148 integral_constant<bool,54 __libcpp_is_contiguous_iterator<_Iter>::value && __is_cheap_to_copy<_Tp> && is_arithmetic<_Tp>::value &&
149 __libcpp_is_contiguous_iterator<_Iter>::value && sizeof(_Tp) <= sizeof(void*) &&55 (__desugars_to_v<__less_tag, __remove_cvref_t<_Compare>, _Tp, _Tp> ||
150 is_arithmetic<_Tp>::value && __is_simple_comparator<_Compare>::value>;56 __desugars_to_v<__greater_tag, __remove_cvref_t<_Compare>, _Tp, _Tp>);
15157
152namespace __detail {58namespace __detail {
15359
...@@ -158,59 +64,88 @@ enum { __block_size = sizeof(uint64_t) * 8 };...@@ -158,59 +64,88 @@ enum { __block_size = sizeof(uint64_t) * 8 };
15864
159// Ensures that __c(*__x, *__y) is true by swapping *__x and *__y if necessary.65// Ensures that __c(*__x, *__y) is true by swapping *__x and *__y if necessary.
160template <class _Compare, class _RandomAccessIterator>66template <class _Compare, class _RandomAccessIterator>
161inline _LIBCPP_HIDE_FROM_ABI void __cond_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _Compare __c) {67inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
68__cond_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _Compare __c) {
162 // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`).69 // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`).
163 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;70 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
164 bool __r = __c(*__x, *__y);71 bool __r = __c(*__x, *__y);
165 value_type __tmp = __r ? *__x : *__y;72 value_type __tmp = __r ? *__x : *__y;
166 *__y = __r ? *__y : *__x;73 *__y = __r ? *__y : *__x;
167 *__x = __tmp;74 *__x = __tmp;
75 return !__r;
168}76}
16977
170// Ensures that *__x, *__y and *__z are ordered according to the comparator __c,78// Ensures that *__x, *__y and *__z are ordered according to the comparator __c,
171// under the assumption that *__y and *__z are already ordered.79// under the assumption that *__y and *__z are already ordered.
172template <class _Compare, class _RandomAccessIterator>80template <class _Compare, class _RandomAccessIterator>
173inline _LIBCPP_HIDE_FROM_ABI void81inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
174__partially_sorted_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _RandomAccessIterator __z, _Compare __c) {82__partially_sorted_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _RandomAccessIterator __z, _Compare __c) {
175 // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`).83 // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`).
176 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;84 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
177 bool __r = __c(*__z, *__x);85 bool __r1 = __c(*__z, *__x);
178 value_type __tmp = __r ? *__z : *__x;86 value_type __tmp = __r1 ? *__z : *__x;
179 *__z = __r ? *__x : *__z;87 *__z = __r1 ? *__x : *__z;
180 __r = __c(__tmp, *__y);88 bool __r2 = __c(__tmp, *__y);
181 *__x = __r ? *__x : *__y;89 *__x = __r2 ? *__x : *__y;
182 *__y = __r ? *__y : __tmp;90 *__y = __r2 ? *__y : __tmp;
91 return !__r1 || !__r2;
183}92}
18493
94// stable, 2-3 compares, 0-2 swaps
95
185template <class,96template <class,
186 class _Compare,97 class _Compare,
187 class _RandomAccessIterator,98 class _RandomAccessIterator,
188 __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>99 __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0>
189inline _LIBCPP_HIDE_FROM_ABI void __sort3_maybe_branchless(100inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
190 _RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, _Compare __c) {101__sort3(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, _Compare __c) {
191 std::__cond_swap<_Compare>(__x2, __x3, __c);102 bool __swapped1 = std::__cond_swap<_Compare>(__x2, __x3, __c);
192 std::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c);103 bool __swapped2 = std::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c);
104 return __swapped1 || __swapped2;
193}105}
194106
195template <class _AlgPolicy,107template <class _AlgPolicy,
196 class _Compare,108 class _Compare,
197 class _RandomAccessIterator,109 class _RandomAccessIterator,
198 __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>110 __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0>
199inline _LIBCPP_HIDE_FROM_ABI void __sort3_maybe_branchless(111inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
200 _RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, _Compare __c) {112__sort3(_RandomAccessIterator __x, _RandomAccessIterator __y, _RandomAccessIterator __z, _Compare __c) {
201 std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);113 using _Ops = _IterOps<_AlgPolicy>;
202}114
115 if (!__c(*__y, *__x)) // if x <= y
116 {
117 if (!__c(*__z, *__y)) // if y <= z
118 return false; // x <= y && y <= z
119 // x <= y && y > z
120 _Ops::iter_swap(__y, __z); // x <= z && y < z
121 if (__c(*__y, *__x)) // if x > y
122 _Ops::iter_swap(__x, __y); // x < y && y <= z
123 return true; // x <= y && y < z
124 }
125 if (__c(*__z, *__y)) // x > y, if y > z
126 {
127 _Ops::iter_swap(__x, __z); // x < y && y < z
128 return true;
129 }
130 _Ops::iter_swap(__x, __y); // x > y && y <= z
131 // x < y && x <= z
132 if (__c(*__z, *__y)) // if y > z
133 _Ops::iter_swap(__y, __z); // x <= y && y < z
134 return true;
135} // x <= y && y <= z
136
137// stable, 3-6 compares, 0-5 swaps
203138
204template <class,139template <class,
205 class _Compare,140 class _Compare,
206 class _RandomAccessIterator,141 class _RandomAccessIterator,
207 __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>142 __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0>
208inline _LIBCPP_HIDE_FROM_ABI void __sort4_maybe_branchless(143inline _LIBCPP_HIDE_FROM_ABI void
209 _RandomAccessIterator __x1,144__sort4(_RandomAccessIterator __x1,
210 _RandomAccessIterator __x2,145 _RandomAccessIterator __x2,
211 _RandomAccessIterator __x3,146 _RandomAccessIterator __x3,
212 _RandomAccessIterator __x4,147 _RandomAccessIterator __x4,
213 _Compare __c) {148 _Compare __c) {
214 std::__cond_swap<_Compare>(__x1, __x3, __c);149 std::__cond_swap<_Compare>(__x1, __x3, __c);
215 std::__cond_swap<_Compare>(__x2, __x4, __c);150 std::__cond_swap<_Compare>(__x2, __x4, __c);
216 std::__cond_swap<_Compare>(__x1, __x2, __c);151 std::__cond_swap<_Compare>(__x1, __x2, __c);
...@@ -221,27 +156,39 @@ inline _LIBCPP_HIDE_FROM_ABI void __sort4_maybe_branchless(...@@ -221,27 +156,39 @@ inline _LIBCPP_HIDE_FROM_ABI void __sort4_maybe_branchless(
221template <class _AlgPolicy,156template <class _AlgPolicy,
222 class _Compare,157 class _Compare,
223 class _RandomAccessIterator,158 class _RandomAccessIterator,
224 __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>159 __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0>
225inline _LIBCPP_HIDE_FROM_ABI void __sort4_maybe_branchless(160inline _LIBCPP_HIDE_FROM_ABI void
226 _RandomAccessIterator __x1,161__sort4(_RandomAccessIterator __x1,
227 _RandomAccessIterator __x2,162 _RandomAccessIterator __x2,
228 _RandomAccessIterator __x3,163 _RandomAccessIterator __x3,
229 _RandomAccessIterator __x4,164 _RandomAccessIterator __x4,
230 _Compare __c) {165 _Compare __c) {
231 std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c);166 using _Ops = _IterOps<_AlgPolicy>;
167 std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);
168 if (__c(*__x4, *__x3)) {
169 _Ops::iter_swap(__x3, __x4);
170 if (__c(*__x3, *__x2)) {
171 _Ops::iter_swap(__x2, __x3);
172 if (__c(*__x2, *__x1)) {
173 _Ops::iter_swap(__x1, __x2);
174 }
175 }
176 }
232}177}
233178
179// stable, 4-10 compares, 0-9 swaps
180
234template <class _AlgPolicy,181template <class _AlgPolicy,
235 class _Compare,182 class _Compare,
236 class _RandomAccessIterator,183 class _RandomAccessIterator,
237 __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>184 __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0>
238inline _LIBCPP_HIDE_FROM_ABI void __sort5_maybe_branchless(185inline _LIBCPP_HIDE_FROM_ABI void
239 _RandomAccessIterator __x1,186__sort5(_RandomAccessIterator __x1,
240 _RandomAccessIterator __x2,187 _RandomAccessIterator __x2,
241 _RandomAccessIterator __x3,188 _RandomAccessIterator __x3,
242 _RandomAccessIterator __x4,189 _RandomAccessIterator __x4,
243 _RandomAccessIterator __x5,190 _RandomAccessIterator __x5,
244 _Compare __c) {191 _Compare __c) {
245 std::__cond_swap<_Compare>(__x1, __x2, __c);192 std::__cond_swap<_Compare>(__x1, __x2, __c);
246 std::__cond_swap<_Compare>(__x4, __x5, __c);193 std::__cond_swap<_Compare>(__x4, __x5, __c);
247 std::__partially_sorted_swap<_Compare>(__x3, __x4, __x5, __c);194 std::__partially_sorted_swap<_Compare>(__x3, __x4, __x5, __c);
...@@ -253,16 +200,29 @@ inline _LIBCPP_HIDE_FROM_ABI void __sort5_maybe_branchless(...@@ -253,16 +200,29 @@ inline _LIBCPP_HIDE_FROM_ABI void __sort5_maybe_branchless(
253template <class _AlgPolicy,200template <class _AlgPolicy,
254 class _Compare,201 class _Compare,
255 class _RandomAccessIterator,202 class _RandomAccessIterator,
256 __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>203 __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0>
257inline _LIBCPP_HIDE_FROM_ABI void __sort5_maybe_branchless(204inline _LIBCPP_HIDE_FROM_ABI void
258 _RandomAccessIterator __x1,205__sort5(_RandomAccessIterator __x1,
259 _RandomAccessIterator __x2,206 _RandomAccessIterator __x2,
260 _RandomAccessIterator __x3,207 _RandomAccessIterator __x3,
261 _RandomAccessIterator __x4,208 _RandomAccessIterator __x4,
262 _RandomAccessIterator __x5,209 _RandomAccessIterator __x5,
263 _Compare __c) {210 _Compare __comp) {
264 std::__sort5<_AlgPolicy, _Compare, _RandomAccessIterator>(211 using _Ops = _IterOps<_AlgPolicy>;
265 std::move(__x1), std::move(__x2), std::move(__x3), std::move(__x4), std::move(__x5), __c);212
213 std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __comp);
214 if (__comp(*__x5, *__x4)) {
215 _Ops::iter_swap(__x4, __x5);
216 if (__comp(*__x4, *__x3)) {
217 _Ops::iter_swap(__x3, __x4);
218 if (__comp(*__x3, *__x2)) {
219 _Ops::iter_swap(__x2, __x3);
220 if (__comp(*__x2, *__x1)) {
221 _Ops::iter_swap(__x1, __x2);
222 }
223 }
224 }
225 }
266}226}
267227
268// Assumes size > 0228// Assumes size > 0
...@@ -280,7 +240,7 @@ __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last,...@@ -280,7 +240,7 @@ __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last,
280// Sort the iterator range [__first, __last) using the comparator __comp using240// Sort the iterator range [__first, __last) using the comparator __comp using
281// the insertion sort algorithm.241// the insertion sort algorithm.
282template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>242template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
283_LIBCPP_HIDE_FROM_ABI void243_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
284__insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) {244__insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) {
285 using _Ops = _IterOps<_AlgPolicy>;245 using _Ops = _IterOps<_AlgPolicy>;
286246
...@@ -352,14 +312,14 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator...@@ -352,14 +312,14 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator
352 _Ops::iter_swap(__first, __last);312 _Ops::iter_swap(__first, __last);
353 return true;313 return true;
354 case 3:314 case 3:
355 std::__sort3_maybe_branchless<_AlgPolicy, _Comp>(__first, __first + difference_type(1), --__last, __comp);315 std::__sort3<_AlgPolicy, _Comp>(__first, __first + difference_type(1), --__last, __comp);
356 return true;316 return true;
357 case 4:317 case 4:
358 std::__sort4_maybe_branchless<_AlgPolicy, _Comp>(318 std::__sort4<_AlgPolicy, _Comp>(
359 __first, __first + difference_type(1), __first + difference_type(2), --__last, __comp);319 __first, __first + difference_type(1), __first + difference_type(2), --__last, __comp);
360 return true;320 return true;
361 case 5:321 case 5:
362 std::__sort5_maybe_branchless<_AlgPolicy, _Comp>(322 std::__sort5<_AlgPolicy, _Comp>(
363 __first,323 __first,
364 __first + difference_type(1),324 __first + difference_type(1),
365 __first + difference_type(2),325 __first + difference_type(2),
...@@ -370,7 +330,7 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator...@@ -370,7 +330,7 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator
370 }330 }
371 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;331 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
372 _RandomAccessIterator __j = __first + difference_type(2);332 _RandomAccessIterator __j = __first + difference_type(2);
373 std::__sort3_maybe_branchless<_AlgPolicy, _Comp>(__first, __first + difference_type(1), __j, __comp);333 std::__sort3<_AlgPolicy, _Comp>(__first, __first + difference_type(1), __j, __comp);
374 const unsigned __limit = 8;334 const unsigned __limit = 8;
375 unsigned __count = 0;335 unsigned __count = 0;
376 for (_RandomAccessIterator __i = __j + difference_type(1); __i != __last; ++__i) {336 for (_RandomAccessIterator __i = __j + difference_type(1); __i != __last; ++__i) {
...@@ -777,14 +737,14 @@ void __introsort(_RandomAccessIterator __first,...@@ -777,14 +737,14 @@ void __introsort(_RandomAccessIterator __first,
777 _Ops::iter_swap(__first, __last);737 _Ops::iter_swap(__first, __last);
778 return;738 return;
779 case 3:739 case 3:
780 std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);740 std::__sort3<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);
781 return;741 return;
782 case 4:742 case 4:
783 std::__sort4_maybe_branchless<_AlgPolicy, _Compare>(743 std::__sort4<_AlgPolicy, _Compare>(
784 __first, __first + difference_type(1), __first + difference_type(2), --__last, __comp);744 __first, __first + difference_type(1), __first + difference_type(2), --__last, __comp);
785 return;745 return;
786 case 5:746 case 5:
787 std::__sort5_maybe_branchless<_AlgPolicy, _Compare>(747 std::__sort5<_AlgPolicy, _Compare>(
788 __first,748 __first,
789 __first + difference_type(1),749 __first + difference_type(1),
790 __first + difference_type(2),750 __first + difference_type(2),
...@@ -891,7 +851,7 @@ template <class _Comp, class _RandomAccessIterator>...@@ -891,7 +851,7 @@ template <class _Comp, class _RandomAccessIterator>
891void __sort(_RandomAccessIterator, _RandomAccessIterator, _Comp);851void __sort(_RandomAccessIterator, _RandomAccessIterator, _Comp);
892852
893extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<char>&, char*>(char*, char*, __less<char>&);853extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
894#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS854#if _LIBCPP_HAS_WIDE_CHARACTERS
895extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);855extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
896#endif856#endif
897extern template _LIBCPP_EXPORTED_FROM_ABI void857extern template _LIBCPP_EXPORTED_FROM_ABI void
...@@ -925,20 +885,18 @@ __sort_dispatch(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co...@@ -925,20 +885,18 @@ __sort_dispatch(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
925 // Only use bitset partitioning for arithmetic types. We should also check885 // Only use bitset partitioning for arithmetic types. We should also check
926 // that the default comparator is in use so that we are sure that there are no886 // that the default comparator is in use so that we are sure that there are no
927 // branches in the comparator.887 // branches in the comparator.
928 std::__introsort<_AlgPolicy,888 std::__introsort<_AlgPolicy, _Comp&, _RandomAccessIterator, __use_branchless_sort<_Comp, _RandomAccessIterator> >(
929 _Comp&,889 __first, __last, __comp, __depth_limit);
930 _RandomAccessIterator,
931 __use_branchless_sort<_Comp, _RandomAccessIterator>::value>(__first, __last, __comp, __depth_limit);
932}890}
933891
934template <class _Type, class... _Options>892template <class _Type, class... _Options>
935using __is_any_of = _Or<is_same<_Type, _Options>...>;893using __is_any_of _LIBCPP_NODEBUG = _Or<is_same<_Type, _Options>...>;
936894
937template <class _Type>895template <class _Type>
938using __sort_is_specialized_in_library = __is_any_of<896using __sort_is_specialized_in_library _LIBCPP_NODEBUG = __is_any_of<
939 _Type,897 _Type,
940 char,898 char,
941#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS899#if _LIBCPP_HAS_WIDE_CHARACTERS
942 wchar_t,900 wchar_t,
943#endif901#endif
944 signed char,902 signed char,
lib/libcxx/include/__algorithm/stable_partition.h+11-14
...@@ -12,15 +12,16 @@...@@ -12,15 +12,16 @@
12#include <__algorithm/iterator_operations.h>12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/rotate.h>13#include <__algorithm/rotate.h>
14#include <__config>14#include <__config>
15#include <__cstddef/ptrdiff_t.h>
15#include <__iterator/advance.h>16#include <__iterator/advance.h>
16#include <__iterator/distance.h>17#include <__iterator/distance.h>
17#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
18#include <__memory/destruct_n.h>19#include <__memory/destruct_n.h>
19#include <__memory/temporary_buffer.h>
20#include <__memory/unique_ptr.h>20#include <__memory/unique_ptr.h>
21#include <__memory/unique_temporary_buffer.h>
22#include <__type_traits/remove_cvref.h>
21#include <__utility/move.h>23#include <__utility/move.h>
22#include <__utility/pair.h>24#include <__utility/pair.h>
23#include <new>
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
...@@ -132,14 +133,12 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred...@@ -132,14 +133,12 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred
132 // We now have a reduced range [__first, __last)133 // We now have a reduced range [__first, __last)
133 // *__first is known to be false134 // *__first is known to be false
134 difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last);135 difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last);
136 __unique_temporary_buffer<value_type> __unique_buf;
135 pair<value_type*, ptrdiff_t> __p(0, 0);137 pair<value_type*, ptrdiff_t> __p(0, 0);
136 unique_ptr<value_type, __return_temporary_buffer> __h;
137 if (__len >= __alloc_limit) {138 if (__len >= __alloc_limit) {
138 // TODO: Remove the use of std::get_temporary_buffer139 __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__len);
139 _LIBCPP_SUPPRESS_DEPRECATED_PUSH140 __p.first = __unique_buf.get();
140 __p = std::get_temporary_buffer<value_type>(__len);141 __p.second = __unique_buf.get_deleter().__count_;
141 _LIBCPP_SUPPRESS_DEPRECATED_POP
142 __h.reset(__p.first);
143 }142 }
144 return std::__stable_partition_impl<_AlgPolicy, _Predicate&>(143 return std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
145 std::move(__first), std::move(__last), __pred, __len, __p, forward_iterator_tag());144 std::move(__first), std::move(__last), __pred, __len, __p, forward_iterator_tag());
...@@ -272,14 +271,12 @@ _LIBCPP_HIDE_FROM_ABI _BidirectionalIterator __stable_partition_impl(...@@ -272,14 +271,12 @@ _LIBCPP_HIDE_FROM_ABI _BidirectionalIterator __stable_partition_impl(
272 // *__last is known to be true271 // *__last is known to be true
273 // __len >= 2272 // __len >= 2
274 difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last) + 1;273 difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last) + 1;
274 __unique_temporary_buffer<value_type> __unique_buf;
275 pair<value_type*, ptrdiff_t> __p(0, 0);275 pair<value_type*, ptrdiff_t> __p(0, 0);
276 unique_ptr<value_type, __return_temporary_buffer> __h;
277 if (__len >= __alloc_limit) {276 if (__len >= __alloc_limit) {
278 // TODO: Remove the use of std::get_temporary_buffer277 __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__len);
279 _LIBCPP_SUPPRESS_DEPRECATED_PUSH278 __p.first = __unique_buf.get();
280 __p = std::get_temporary_buffer<value_type>(__len);279 __p.second = __unique_buf.get_deleter().__count_;
281 _LIBCPP_SUPPRESS_DEPRECATED_POP
282 __h.reset(__p.first);
283 }280 }
284 return std::__stable_partition_impl<_AlgPolicy, _Predicate&>(281 return std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
285 std::move(__first), std::move(__last), __pred, __len, __p, bidirectional_iterator_tag());282 std::move(__first), std::move(__last), __pred, __len, __p, bidirectional_iterator_tag());
lib/libcxx/include/__algorithm/stable_sort.h+90-44
...@@ -13,17 +13,24 @@...@@ -13,17 +13,24 @@
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/inplace_merge.h>14#include <__algorithm/inplace_merge.h>
15#include <__algorithm/iterator_operations.h>15#include <__algorithm/iterator_operations.h>
16#include <__algorithm/radix_sort.h>
16#include <__algorithm/sort.h>17#include <__algorithm/sort.h>
17#include <__config>18#include <__config>
19#include <__cstddef/ptrdiff_t.h>
18#include <__debug_utils/strict_weak_ordering_check.h>20#include <__debug_utils/strict_weak_ordering_check.h>
19#include <__iterator/iterator_traits.h>21#include <__iterator/iterator_traits.h>
22#include <__memory/construct_at.h>
20#include <__memory/destruct_n.h>23#include <__memory/destruct_n.h>
21#include <__memory/temporary_buffer.h>
22#include <__memory/unique_ptr.h>24#include <__memory/unique_ptr.h>
25#include <__memory/unique_temporary_buffer.h>
26#include <__type_traits/desugars_to.h>
27#include <__type_traits/enable_if.h>
28#include <__type_traits/is_integral.h>
29#include <__type_traits/is_same.h>
23#include <__type_traits/is_trivially_assignable.h>30#include <__type_traits/is_trivially_assignable.h>
31#include <__type_traits/remove_cvref.h>
24#include <__utility/move.h>32#include <__utility/move.h>
25#include <__utility/pair.h>33#include <__utility/pair.h>
26#include <new>
2734
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)35#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header36# pragma GCC system_header
...@@ -35,7 +42,7 @@ _LIBCPP_PUSH_MACROS...@@ -35,7 +42,7 @@ _LIBCPP_PUSH_MACROS
35_LIBCPP_BEGIN_NAMESPACE_STD42_LIBCPP_BEGIN_NAMESPACE_STD
3643
37template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>44template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
38_LIBCPP_HIDE_FROM_ABI void __insertion_sort_move(45_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __insertion_sort_move(
39 _BidirectionalIterator __first1,46 _BidirectionalIterator __first1,
40 _BidirectionalIterator __last1,47 _BidirectionalIterator __last1,
41 typename iterator_traits<_BidirectionalIterator>::value_type* __first2,48 typename iterator_traits<_BidirectionalIterator>::value_type* __first2,
...@@ -47,19 +54,19 @@ _LIBCPP_HIDE_FROM_ABI void __insertion_sort_move(...@@ -47,19 +54,19 @@ _LIBCPP_HIDE_FROM_ABI void __insertion_sort_move(
47 __destruct_n __d(0);54 __destruct_n __d(0);
48 unique_ptr<value_type, __destruct_n&> __h(__first2, __d);55 unique_ptr<value_type, __destruct_n&> __h(__first2, __d);
49 value_type* __last2 = __first2;56 value_type* __last2 = __first2;
50 ::new ((void*)__last2) value_type(_Ops::__iter_move(__first1));57 std::__construct_at(__last2, _Ops::__iter_move(__first1));
51 __d.template __incr<value_type>();58 __d.template __incr<value_type>();
52 for (++__last2; ++__first1 != __last1; ++__last2) {59 for (++__last2; ++__first1 != __last1; ++__last2) {
53 value_type* __j2 = __last2;60 value_type* __j2 = __last2;
54 value_type* __i2 = __j2;61 value_type* __i2 = __j2;
55 if (__comp(*__first1, *--__i2)) {62 if (__comp(*__first1, *--__i2)) {
56 ::new ((void*)__j2) value_type(std::move(*__i2));63 std::__construct_at(__j2, std::move(*__i2));
57 __d.template __incr<value_type>();64 __d.template __incr<value_type>();
58 for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)65 for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)
59 *__j2 = std::move(*__i2);66 *__j2 = std::move(*__i2);
60 *__j2 = _Ops::__iter_move(__first1);67 *__j2 = _Ops::__iter_move(__first1);
61 } else {68 } else {
62 ::new ((void*)__j2) value_type(_Ops::__iter_move(__first1));69 std::__construct_at(__j2, _Ops::__iter_move(__first1));
63 __d.template __incr<value_type>();70 __d.template __incr<value_type>();
64 }71 }
65 }72 }
...@@ -68,7 +75,7 @@ _LIBCPP_HIDE_FROM_ABI void __insertion_sort_move(...@@ -68,7 +75,7 @@ _LIBCPP_HIDE_FROM_ABI void __insertion_sort_move(
68}75}
6976
70template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2>77template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2>
71_LIBCPP_HIDE_FROM_ABI void __merge_move_construct(78_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __merge_move_construct(
72 _InputIterator1 __first1,79 _InputIterator1 __first1,
73 _InputIterator1 __last1,80 _InputIterator1 __last1,
74 _InputIterator2 __first2,81 _InputIterator2 __first2,
...@@ -83,22 +90,22 @@ _LIBCPP_HIDE_FROM_ABI void __merge_move_construct(...@@ -83,22 +90,22 @@ _LIBCPP_HIDE_FROM_ABI void __merge_move_construct(
83 for (; true; ++__result) {90 for (; true; ++__result) {
84 if (__first1 == __last1) {91 if (__first1 == __last1) {
85 for (; __first2 != __last2; ++__first2, (void)++__result, __d.template __incr<value_type>())92 for (; __first2 != __last2; ++__first2, (void)++__result, __d.template __incr<value_type>())
86 ::new ((void*)__result) value_type(_Ops::__iter_move(__first2));93 std::__construct_at(__result, _Ops::__iter_move(__first2));
87 __h.release();94 __h.release();
88 return;95 return;
89 }96 }
90 if (__first2 == __last2) {97 if (__first2 == __last2) {
91 for (; __first1 != __last1; ++__first1, (void)++__result, __d.template __incr<value_type>())98 for (; __first1 != __last1; ++__first1, (void)++__result, __d.template __incr<value_type>())
92 ::new ((void*)__result) value_type(_Ops::__iter_move(__first1));99 std::__construct_at(__result, _Ops::__iter_move(__first1));
93 __h.release();100 __h.release();
94 return;101 return;
95 }102 }
96 if (__comp(*__first2, *__first1)) {103 if (__comp(*__first2, *__first1)) {
97 ::new ((void*)__result) value_type(_Ops::__iter_move(__first2));104 std::__construct_at(__result, _Ops::__iter_move(__first2));
98 __d.template __incr<value_type>();105 __d.template __incr<value_type>();
99 ++__first2;106 ++__first2;
100 } else {107 } else {
101 ::new ((void*)__result) value_type(_Ops::__iter_move(__first1));108 std::__construct_at(__result, _Ops::__iter_move(__first1));
102 __d.template __incr<value_type>();109 __d.template __incr<value_type>();
103 ++__first1;110 ++__first1;
104 }111 }
...@@ -106,7 +113,7 @@ _LIBCPP_HIDE_FROM_ABI void __merge_move_construct(...@@ -106,7 +113,7 @@ _LIBCPP_HIDE_FROM_ABI void __merge_move_construct(
106}113}
107114
108template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>115template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
109_LIBCPP_HIDE_FROM_ABI void __merge_move_assign(116_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __merge_move_assign(
110 _InputIterator1 __first1,117 _InputIterator1 __first1,
111 _InputIterator1 __last1,118 _InputIterator1 __last1,
112 _InputIterator2 __first2,119 _InputIterator2 __first2,
...@@ -134,19 +141,21 @@ _LIBCPP_HIDE_FROM_ABI void __merge_move_assign(...@@ -134,19 +141,21 @@ _LIBCPP_HIDE_FROM_ABI void __merge_move_assign(
134}141}
135142
136template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>143template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
137void __stable_sort(_RandomAccessIterator __first,144_LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort(
138 _RandomAccessIterator __last,145 _RandomAccessIterator __first,
139 _Compare __comp,146 _RandomAccessIterator __last,
140 typename iterator_traits<_RandomAccessIterator>::difference_type __len,147 _Compare __comp,
141 typename iterator_traits<_RandomAccessIterator>::value_type* __buff,148 typename iterator_traits<_RandomAccessIterator>::difference_type __len,
142 ptrdiff_t __buff_size);149 typename iterator_traits<_RandomAccessIterator>::value_type* __buff,
150 ptrdiff_t __buff_size);
143151
144template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>152template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
145void __stable_sort_move(_RandomAccessIterator __first1,153_LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort_move(
146 _RandomAccessIterator __last1,154 _RandomAccessIterator __first1,
147 _Compare __comp,155 _RandomAccessIterator __last1,
148 typename iterator_traits<_RandomAccessIterator>::difference_type __len,156 _Compare __comp,
149 typename iterator_traits<_RandomAccessIterator>::value_type* __first2) {157 typename iterator_traits<_RandomAccessIterator>::difference_type __len,
158 typename iterator_traits<_RandomAccessIterator>::value_type* __first2) {
150 using _Ops = _IterOps<_AlgPolicy>;159 using _Ops = _IterOps<_AlgPolicy>;
151160
152 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;161 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
...@@ -154,21 +163,21 @@ void __stable_sort_move(_RandomAccessIterator __first1,...@@ -154,21 +163,21 @@ void __stable_sort_move(_RandomAccessIterator __first1,
154 case 0:163 case 0:
155 return;164 return;
156 case 1:165 case 1:
157 ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1));166 std::__construct_at(__first2, _Ops::__iter_move(__first1));
158 return;167 return;
159 case 2:168 case 2:
160 __destruct_n __d(0);169 __destruct_n __d(0);
161 unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);170 unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);
162 if (__comp(*--__last1, *__first1)) {171 if (__comp(*--__last1, *__first1)) {
163 ::new ((void*)__first2) value_type(_Ops::__iter_move(__last1));172 std::__construct_at(__first2, _Ops::__iter_move(__last1));
164 __d.template __incr<value_type>();173 __d.template __incr<value_type>();
165 ++__first2;174 ++__first2;
166 ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1));175 std::__construct_at(__first2, _Ops::__iter_move(__first1));
167 } else {176 } else {
168 ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1));177 std::__construct_at(__first2, _Ops::__iter_move(__first1));
169 __d.template __incr<value_type>();178 __d.template __incr<value_type>();
170 ++__first2;179 ++__first2;
171 ::new ((void*)__first2) value_type(_Ops::__iter_move(__last1));180 std::__construct_at(__first2, _Ops::__iter_move(__last1));
172 }181 }
173 __h2.release();182 __h2.release();
174 return;183 return;
...@@ -189,13 +198,36 @@ struct __stable_sort_switch {...@@ -189,13 +198,36 @@ struct __stable_sort_switch {
189 static const unsigned value = 128 * is_trivially_copy_assignable<_Tp>::value;198 static const unsigned value = 128 * is_trivially_copy_assignable<_Tp>::value;
190};199};
191200
201#if _LIBCPP_STD_VER >= 17
202template <class _Tp>
203_LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_min_bound() {
204 static_assert(is_integral<_Tp>::value);
205 if constexpr (sizeof(_Tp) == 1) {
206 return 1 << 8;
207 }
208
209 return 1 << 10;
210}
211
212template <class _Tp>
213_LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_max_bound() {
214 static_assert(is_integral<_Tp>::value);
215 if constexpr (sizeof(_Tp) >= 8) {
216 return 1 << 15;
217 }
218
219 return 1 << 16;
220}
221#endif // _LIBCPP_STD_VER >= 17
222
192template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>223template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
193void __stable_sort(_RandomAccessIterator __first,224_LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort(
194 _RandomAccessIterator __last,225 _RandomAccessIterator __first,
195 _Compare __comp,226 _RandomAccessIterator __last,
196 typename iterator_traits<_RandomAccessIterator>::difference_type __len,227 _Compare __comp,
197 typename iterator_traits<_RandomAccessIterator>::value_type* __buff,228 typename iterator_traits<_RandomAccessIterator>::difference_type __len,
198 ptrdiff_t __buff_size) {229 typename iterator_traits<_RandomAccessIterator>::value_type* __buff,
230 ptrdiff_t __buff_size) {
199 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;231 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
200 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;232 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
201 switch (__len) {233 switch (__len) {
...@@ -211,6 +243,22 @@ void __stable_sort(_RandomAccessIterator __first,...@@ -211,6 +243,22 @@ void __stable_sort(_RandomAccessIterator __first,
211 std::__insertion_sort<_AlgPolicy, _Compare>(__first, __last, __comp);243 std::__insertion_sort<_AlgPolicy, _Compare>(__first, __last, __comp);
212 return;244 return;
213 }245 }
246
247#if _LIBCPP_STD_VER >= 17
248 constexpr auto __default_comp =
249 __desugars_to_v<__totally_ordered_less_tag, __remove_cvref_t<_Compare>, value_type, value_type >;
250 constexpr auto __integral_value =
251 is_integral_v<value_type > && is_same_v< value_type&, __iter_reference<_RandomAccessIterator>>;
252 constexpr auto __allowed_radix_sort = __default_comp && __integral_value;
253 if constexpr (__allowed_radix_sort) {
254 if (__len <= __buff_size && __len >= static_cast<difference_type>(__radix_sort_min_bound<value_type>()) &&
255 __len <= static_cast<difference_type>(__radix_sort_max_bound<value_type>())) {
256 std::__radix_sort(__first, __last, __buff);
257 return;
258 }
259 }
260#endif // _LIBCPP_STD_VER >= 17
261
214 typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;262 typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
215 _RandomAccessIterator __m = __first + __l2;263 _RandomAccessIterator __m = __first + __l2;
216 if (__len <= __buff_size) {264 if (__len <= __buff_size) {
...@@ -235,20 +283,18 @@ void __stable_sort(_RandomAccessIterator __first,...@@ -235,20 +283,18 @@ void __stable_sort(_RandomAccessIterator __first,
235}283}
236284
237template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>285template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
238inline _LIBCPP_HIDE_FROM_ABI void286_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
239__stable_sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {287__stable_sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {
240 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;288 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
241 using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;289 using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
242290
243 difference_type __len = __last - __first;291 difference_type __len = __last - __first;
292 __unique_temporary_buffer<value_type> __unique_buf;
244 pair<value_type*, ptrdiff_t> __buf(0, 0);293 pair<value_type*, ptrdiff_t> __buf(0, 0);
245 unique_ptr<value_type, __return_temporary_buffer> __h;
246 if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value)) {294 if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value)) {
247 // TODO: Remove the use of std::get_temporary_buffer295 __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__len);
248 _LIBCPP_SUPPRESS_DEPRECATED_PUSH296 __buf.first = __unique_buf.get();
249 __buf = std::get_temporary_buffer<value_type>(__len);297 __buf.second = __unique_buf.get_deleter().__count_;
250 _LIBCPP_SUPPRESS_DEPRECATED_POP
251 __h.reset(__buf.first);
252 }298 }
253299
254 std::__stable_sort<_AlgPolicy, __comp_ref_type<_Compare> >(__first, __last, __comp, __len, __buf.first, __buf.second);300 std::__stable_sort<_AlgPolicy, __comp_ref_type<_Compare> >(__first, __last, __comp, __len, __buf.first, __buf.second);
...@@ -256,18 +302,18 @@ __stable_sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last,...@@ -256,18 +302,18 @@ __stable_sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last,
256}302}
257303
258template <class _RandomAccessIterator, class _Compare>304template <class _RandomAccessIterator, class _Compare>
259inline _LIBCPP_HIDE_FROM_ABI void305_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
260stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {306stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
261 std::__stable_sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);307 std::__stable_sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
262}308}
263309
264template <class _RandomAccessIterator>310template <class _RandomAccessIterator>
265inline _LIBCPP_HIDE_FROM_ABI void stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {311_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
312stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {
266 std::stable_sort(__first, __last, __less<>());313 std::stable_sort(__first, __last, __less<>());
267}314}
268315
269_LIBCPP_END_NAMESPACE_STD316_LIBCPP_END_NAMESPACE_STD
270
271_LIBCPP_POP_MACROS317_LIBCPP_POP_MACROS
272318
273#endif // _LIBCPP___ALGORITHM_STABLE_SORT_H319#endif // _LIBCPP___ALGORITHM_STABLE_SORT_H
lib/libcxx/include/__algorithm/three_way_comp_ref_type.h+2-2
...@@ -61,10 +61,10 @@ struct __debug_three_way_comp {...@@ -61,10 +61,10 @@ struct __debug_three_way_comp {
61// Pass the comparator by lvalue reference. Or in the debug mode, using a debugging wrapper that stores a reference.61// Pass the comparator by lvalue reference. Or in the debug mode, using a debugging wrapper that stores a reference.
62# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG62# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
63template <class _Comp>63template <class _Comp>
64using __three_way_comp_ref_type = __debug_three_way_comp<_Comp>;64using __three_way_comp_ref_type _LIBCPP_NODEBUG = __debug_three_way_comp<_Comp>;
65# else65# else
66template <class _Comp>66template <class _Comp>
67using __three_way_comp_ref_type = _Comp&;67using __three_way_comp_ref_type _LIBCPP_NODEBUG = _Comp&;
68# endif68# endif
6969
70#endif // _LIBCPP_STD_VER >= 2070#endif // _LIBCPP_STD_VER >= 20
lib/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h+1-1
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#define _LIBCPP___ALGORITHM_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H10#define _LIBCPP___ALGORITHM_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H
1111
12#include <__config>12#include <__config>
13#include <__functional/invoke.h>13#include <__type_traits/invoke.h>
14#include <__type_traits/remove_cvref.h>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)
lib/libcxx/include/__algorithm/unique.h+6-4
...@@ -13,6 +13,7 @@...@@ -13,6 +13,7 @@
13#include <__algorithm/comp.h>13#include <__algorithm/comp.h>
14#include <__algorithm/iterator_operations.h>14#include <__algorithm/iterator_operations.h>
15#include <__config>15#include <__config>
16#include <__functional/identity.h>
16#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
17#include <__utility/move.h>18#include <__utility/move.h>
18#include <__utility/pair.h>19#include <__utility/pair.h>
...@@ -29,9 +30,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,9 +30,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
29// unique30// unique
3031
31template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate>32template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate>
32_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter>33[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter>
33__unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {34__unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
34 __first = std::__adjacent_find(__first, __last, __pred);35 __identity __proj;
36 __first = std::__adjacent_find(__first, __last, __pred, __proj);
35 if (__first != __last) {37 if (__first != __last) {
36 // ... a a ? ...38 // ... a a ? ...
37 // f i39 // f i
...@@ -46,13 +48,13 @@ __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {...@@ -46,13 +48,13 @@ __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
46}48}
4749
48template <class _ForwardIterator, class _BinaryPredicate>50template <class _ForwardIterator, class _BinaryPredicate>
49_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator51[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
50unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {52unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
51 return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first;53 return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first;
52}54}
5355
54template <class _ForwardIterator>56template <class _ForwardIterator>
55_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator57[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
56unique(_ForwardIterator __first, _ForwardIterator __last) {58unique(_ForwardIterator __first, _ForwardIterator __last) {
57 return std::unique(__first, __last, __equal_to());59 return std::unique(__first, __last, __equal_to());
58}60}
lib/libcxx/include/__algorithm/unwrap_iter.h+1-1
...@@ -46,7 +46,7 @@ struct __unwrap_iter_impl {...@@ -46,7 +46,7 @@ struct __unwrap_iter_impl {
46// It's a contiguous iterator, so we can use a raw pointer instead46// It's a contiguous iterator, so we can use a raw pointer instead
47template <class _Iter>47template <class _Iter>
48struct __unwrap_iter_impl<_Iter, true> {48struct __unwrap_iter_impl<_Iter, true> {
49 using _ToAddressT = decltype(std::__to_address(std::declval<_Iter>()));49 using _ToAddressT _LIBCPP_NODEBUG = decltype(std::__to_address(std::declval<_Iter>()));
5050
51 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap(_Iter __orig_iter, _ToAddressT __unwrapped_iter) {51 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap(_Iter __orig_iter, _ToAddressT __unwrapped_iter) {
52 return __orig_iter + (__unwrapped_iter - std::__to_address(__orig_iter));52 return __orig_iter + (__unwrapped_iter - std::__to_address(__orig_iter));
lib/libcxx/include/__algorithm/upper_bound.h+5-2
...@@ -18,6 +18,8 @@...@@ -18,6 +18,8 @@
18#include <__iterator/advance.h>18#include <__iterator/advance.h>
19#include <__iterator/distance.h>19#include <__iterator/distance.h>
20#include <__iterator/iterator_traits.h>20#include <__iterator/iterator_traits.h>
21#include <__type_traits/invoke.h>
22#include <__type_traits/is_callable.h>
21#include <__type_traits/is_constructible.h>23#include <__type_traits/is_constructible.h>
22#include <__utility/move.h>24#include <__utility/move.h>
2325
...@@ -48,15 +50,16 @@ __upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp...@@ -48,15 +50,16 @@ __upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp
48}50}
4951
50template <class _ForwardIterator, class _Tp, class _Compare>52template <class _ForwardIterator, class _Tp, class _Compare>
51_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator53[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
52upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {54upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
55 static_assert(__is_callable<_Compare&, const _Tp&, decltype(*__first)>::value, "The comparator has to be callable");
53 static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible");56 static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible");
54 return std::__upper_bound<_ClassicAlgPolicy>(57 return std::__upper_bound<_ClassicAlgPolicy>(
55 std::move(__first), std::move(__last), __value, std::move(__comp), std::__identity());58 std::move(__first), std::move(__last), __value, std::move(__comp), std::__identity());
56}59}
5760
58template <class _ForwardIterator, class _Tp>61template <class _ForwardIterator, class _Tp>
59_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator62[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
60upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {63upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
61 return std::upper_bound(std::move(__first), std::move(__last), __value, __less<>());64 return std::upper_bound(std::move(__first), std::move(__last), __value, __less<>());
62}65}
lib/libcxx/include/__assert+28-28
...@@ -23,10 +23,10 @@...@@ -23,10 +23,10 @@
23 : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": assertion " _LIBCPP_TOSTRING( \23 : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": assertion " _LIBCPP_TOSTRING( \
24 expression) " failed: " message "\n"))24 expression) " failed: " message "\n"))
2525
26// TODO: __builtin_assume can currently inhibit optimizations. Until this has been fixed and we can add26// WARNING: __builtin_assume can currently inhibit optimizations. Only add assumptions with a clear
27// assumptions without a clear optimization intent, disable that to avoid worsening the code generation.27// optimization intent. See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a
28// See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a discussion.28// discussion.
29#if 0 && __has_builtin(__builtin_assume)29#if __has_builtin(__builtin_assume)
30# define _LIBCPP_ASSUME(expression) \30# define _LIBCPP_ASSUME(expression) \
31 (_LIBCPP_DIAGNOSTIC_PUSH _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wassume") \31 (_LIBCPP_DIAGNOSTIC_PUSH _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wassume") \
32 __builtin_assume(static_cast<bool>(expression)) _LIBCPP_DIAGNOSTIC_POP)32 __builtin_assume(static_cast<bool>(expression)) _LIBCPP_DIAGNOSTIC_POP)
...@@ -44,18 +44,18 @@...@@ -44,18 +44,18 @@
44# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message)44# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message)
45// Disabled checks.45// Disabled checks.
46// On most modern platforms, dereferencing a null pointer does not lead to an actual memory access.46// On most modern platforms, dereferencing a null pointer does not lead to an actual memory access.
47# define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSUME(expression)47# define _LIBCPP_ASSERT_NON_NULL(expression, message) ((void)0)
48// Overlapping ranges will make algorithms produce incorrect results but don't directly lead to a security48// Overlapping ranges will make algorithms produce incorrect results but don't directly lead to a security
49// vulnerability.49// vulnerability.
50# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression)50# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) ((void)0)
51# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSUME(expression)51# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) ((void)0)
52# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSUME(expression)52# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) ((void)0)
53# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression)53# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) ((void)0)
54# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSUME(expression)54# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) ((void)0)
55# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSUME(expression)55# define _LIBCPP_ASSERT_PEDANTIC(expression, message) ((void)0)
56# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression)56# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) ((void)0)
57# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)57# define _LIBCPP_ASSERT_INTERNAL(expression, message) ((void)0)
58# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression)58# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) ((void)0)
5959
60// Extensive hardening mode checks.60// Extensive hardening mode checks.
6161
...@@ -73,8 +73,8 @@...@@ -73,8 +73,8 @@
73# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSERT(expression, message)73# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSERT(expression, message)
74# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message)74# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message)
75// Disabled checks.75// Disabled checks.
76# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression)76# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) ((void)0)
77# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)77# define _LIBCPP_ASSERT_INTERNAL(expression, message) ((void)0)
7878
79// Debug hardening mode checks.79// Debug hardening mode checks.
8080
...@@ -99,18 +99,18 @@...@@ -99,18 +99,18 @@
99#else99#else
100100
101// All checks disabled.101// All checks disabled.
102# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSUME(expression)102# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) ((void)0)
103# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSUME(expression)103# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) ((void)0)
104# define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSUME(expression)104# define _LIBCPP_ASSERT_NON_NULL(expression, message) ((void)0)
105# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression)105# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) ((void)0)
106# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSUME(expression)106# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) ((void)0)
107# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSUME(expression)107# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) ((void)0)
108# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression)108# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) ((void)0)
109# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSUME(expression)109# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) ((void)0)
110# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSUME(expression)110# define _LIBCPP_ASSERT_PEDANTIC(expression, message) ((void)0)
111# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression)111# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) ((void)0)
112# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)112# define _LIBCPP_ASSERT_INTERNAL(expression, message) ((void)0)
113# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression)113# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) ((void)0)
114114
115#endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST115#endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
116// clang-format on116// clang-format on
lib/libcxx/include/__assertion_handler+9-3
...@@ -10,8 +10,13 @@...@@ -10,8 +10,13 @@
10#ifndef _LIBCPP___ASSERTION_HANDLER10#ifndef _LIBCPP___ASSERTION_HANDLER
11#define _LIBCPP___ASSERTION_HANDLER11#define _LIBCPP___ASSERTION_HANDLER
1212
13#include <__config>13#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
14#include <__verbose_abort>14# include <__cxx03/__config>
15# include <__cxx03/__verbose_abort>
16#else
17# include <__config>
18# include <__verbose_abort>
19#endif
1520
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header22# pragma GCC system_header
...@@ -26,7 +31,8 @@...@@ -26,7 +31,8 @@
26# if __has_builtin(__builtin_verbose_trap)31# if __has_builtin(__builtin_verbose_trap)
27// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream32// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream
28// version before upstream Clang actually got the builtin.33// version before upstream Clang actually got the builtin.
29# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700034// TODO: Remove once AppleClang supports the two-arguments version of the builtin.
35# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700
30# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message)36# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message)
31# else37# else
32# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message)38# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message)
lib/libcxx/include/__atomic/aliases.h+9-8
...@@ -14,9 +14,10 @@...@@ -14,9 +14,10 @@
14#include <__atomic/contention_t.h>14#include <__atomic/contention_t.h>
15#include <__atomic/is_always_lock_free.h>15#include <__atomic/is_always_lock_free.h>
16#include <__config>16#include <__config>
17#include <__cstddef/ptrdiff_t.h>
18#include <__cstddef/size_t.h>
17#include <__type_traits/conditional.h>19#include <__type_traits/conditional.h>
18#include <__type_traits/make_unsigned.h>20#include <__type_traits/make_unsigned.h>
19#include <cstddef>
20#include <cstdint>21#include <cstdint>
2122
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -37,12 +38,12 @@ using atomic_long = atomic<long>;...@@ -37,12 +38,12 @@ using atomic_long = atomic<long>;
37using atomic_ulong = atomic<unsigned long>;38using atomic_ulong = atomic<unsigned long>;
38using atomic_llong = atomic<long long>;39using atomic_llong = atomic<long long>;
39using atomic_ullong = atomic<unsigned long long>;40using atomic_ullong = atomic<unsigned long long>;
40#ifndef _LIBCPP_HAS_NO_CHAR8_T41#if _LIBCPP_HAS_CHAR8_T
41using atomic_char8_t = atomic<char8_t>;42using atomic_char8_t = atomic<char8_t>;
42#endif43#endif
43using atomic_char16_t = atomic<char16_t>;44using atomic_char16_t = atomic<char16_t>;
44using atomic_char32_t = atomic<char32_t>;45using atomic_char32_t = atomic<char32_t>;
45#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS46#if _LIBCPP_HAS_WIDE_CHARACTERS
46using atomic_wchar_t = atomic<wchar_t>;47using atomic_wchar_t = atomic<wchar_t>;
47#endif48#endif
4849
...@@ -83,19 +84,19 @@ using atomic_uintmax_t = atomic<uintmax_t>;...@@ -83,19 +84,19 @@ using atomic_uintmax_t = atomic<uintmax_t>;
83// C++20 atomic_{signed,unsigned}_lock_free: prefer the contention type most highly, then the largest lock-free type84// C++20 atomic_{signed,unsigned}_lock_free: prefer the contention type most highly, then the largest lock-free type
84#if _LIBCPP_STD_VER >= 2085#if _LIBCPP_STD_VER >= 20
85# if ATOMIC_LLONG_LOCK_FREE == 286# if ATOMIC_LLONG_LOCK_FREE == 2
86using __largest_lock_free_type = long long;87using __largest_lock_free_type _LIBCPP_NODEBUG = long long;
87# elif ATOMIC_INT_LOCK_FREE == 288# elif ATOMIC_INT_LOCK_FREE == 2
88using __largest_lock_free_type = int;89using __largest_lock_free_type _LIBCPP_NODEBUG = int;
89# elif ATOMIC_SHORT_LOCK_FREE == 290# elif ATOMIC_SHORT_LOCK_FREE == 2
90using __largest_lock_free_type = short;91using __largest_lock_free_type _LIBCPP_NODEBUG = short;
91# elif ATOMIC_CHAR_LOCK_FREE == 292# elif ATOMIC_CHAR_LOCK_FREE == 2
92using __largest_lock_free_type = char;93using __largest_lock_free_type _LIBCPP_NODEBUG = char;
93# else94# else
94# define _LIBCPP_NO_LOCK_FREE_TYPES // There are no lockfree types (this can happen on unusual platforms)95# define _LIBCPP_NO_LOCK_FREE_TYPES // There are no lockfree types (this can happen on unusual platforms)
95# endif96# endif
9697
97# ifndef _LIBCPP_NO_LOCK_FREE_TYPES98# ifndef _LIBCPP_NO_LOCK_FREE_TYPES
98using __contention_t_or_largest =99using __contention_t_or_largest _LIBCPP_NODEBUG =
99 __conditional_t<__libcpp_is_always_lock_free<__cxx_contention_t>::__value,100 __conditional_t<__libcpp_is_always_lock_free<__cxx_contention_t>::__value,
100 __cxx_contention_t,101 __cxx_contention_t,
101 __largest_lock_free_type>;102 __largest_lock_free_type>;
lib/libcxx/include/__atomic/atomic.h+222-23
...@@ -9,21 +9,24 @@...@@ -9,21 +9,24 @@
9#ifndef _LIBCPP___ATOMIC_ATOMIC_H9#ifndef _LIBCPP___ATOMIC_ATOMIC_H
10#define _LIBCPP___ATOMIC_ATOMIC_H10#define _LIBCPP___ATOMIC_ATOMIC_H
1111
12#include <__atomic/atomic_base.h>12#include <__atomic/atomic_sync.h>
13#include <__atomic/check_memory_order.h>13#include <__atomic/check_memory_order.h>
14#include <__atomic/cxx_atomic_impl.h>14#include <__atomic/is_always_lock_free.h>
15#include <__atomic/memory_order.h>15#include <__atomic/memory_order.h>
16#include <__atomic/support.h>
16#include <__config>17#include <__config>
17#include <__functional/operations.h>18#include <__cstddef/ptrdiff_t.h>
18#include <__memory/addressof.h>19#include <__memory/addressof.h>
20#include <__type_traits/enable_if.h>
19#include <__type_traits/is_floating_point.h>21#include <__type_traits/is_floating_point.h>
20#include <__type_traits/is_function.h>22#include <__type_traits/is_function.h>
23#include <__type_traits/is_integral.h>
24#include <__type_traits/is_nothrow_constructible.h>
21#include <__type_traits/is_same.h>25#include <__type_traits/is_same.h>
22#include <__type_traits/remove_const.h>26#include <__type_traits/remove_const.h>
23#include <__type_traits/remove_pointer.h>27#include <__type_traits/remove_pointer.h>
24#include <__type_traits/remove_volatile.h>28#include <__type_traits/remove_volatile.h>
25#include <__utility/forward.h>29#include <__utility/forward.h>
26#include <cstddef>
27#include <cstring>30#include <cstring>
2831
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -32,11 +35,202 @@...@@ -32,11 +35,202 @@
3235
33_LIBCPP_BEGIN_NAMESPACE_STD36_LIBCPP_BEGIN_NAMESPACE_STD
3437
38template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
39struct __atomic_base // false
40{
41 mutable __cxx_atomic_impl<_Tp> __a_;
42
43#if _LIBCPP_STD_VER >= 17
44 static constexpr bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value;
45#endif
46
47 _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const volatile _NOEXCEPT {
48 return __cxx_atomic_is_lock_free(sizeof(__cxx_atomic_impl<_Tp>));
49 }
50 _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const _NOEXCEPT {
51 return static_cast<__atomic_base const volatile*>(this)->is_lock_free();
52 }
53 _LIBCPP_HIDE_FROM_ABI void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
54 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) {
55 std::__cxx_atomic_store(std::addressof(__a_), __d, __m);
56 }
57 _LIBCPP_HIDE_FROM_ABI void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
58 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) {
59 std::__cxx_atomic_store(std::addressof(__a_), __d, __m);
60 }
61 _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
62 _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) {
63 return std::__cxx_atomic_load(std::addressof(__a_), __m);
64 }
65 _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
66 _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) {
67 return std::__cxx_atomic_load(std::addressof(__a_), __m);
68 }
69 _LIBCPP_HIDE_FROM_ABI operator _Tp() const volatile _NOEXCEPT { return load(); }
70 _LIBCPP_HIDE_FROM_ABI operator _Tp() const _NOEXCEPT { return load(); }
71 _LIBCPP_HIDE_FROM_ABI _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
72 return std::__cxx_atomic_exchange(std::addressof(__a_), __d, __m);
73 }
74 _LIBCPP_HIDE_FROM_ABI _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
75 return std::__cxx_atomic_exchange(std::addressof(__a_), __d, __m);
76 }
77 _LIBCPP_HIDE_FROM_ABI bool
78 compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) volatile _NOEXCEPT
79 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) {
80 return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __s, __f);
81 }
82 _LIBCPP_HIDE_FROM_ABI bool compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) _NOEXCEPT
83 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) {
84 return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __s, __f);
85 }
86 _LIBCPP_HIDE_FROM_ABI bool
87 compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) volatile _NOEXCEPT
88 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) {
89 return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __s, __f);
90 }
91 _LIBCPP_HIDE_FROM_ABI bool compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) _NOEXCEPT
92 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) {
93 return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __s, __f);
94 }
95 _LIBCPP_HIDE_FROM_ABI bool
96 compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
97 return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __m, __m);
98 }
99 _LIBCPP_HIDE_FROM_ABI bool
100 compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
101 return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __m, __m);
102 }
103 _LIBCPP_HIDE_FROM_ABI bool
104 compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
105 return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __m, __m);
106 }
107 _LIBCPP_HIDE_FROM_ABI bool
108 compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
109 return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __m, __m);
110 }
111
112#if _LIBCPP_STD_VER >= 20
113 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const
114 volatile _NOEXCEPT {
115 std::__atomic_wait(*this, __v, __m);
116 }
117 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
118 wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT {
119 std::__atomic_wait(*this, __v, __m);
120 }
121 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT {
122 std::__atomic_notify_one(*this);
123 }
124 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); }
125 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT {
126 std::__atomic_notify_all(*this);
127 }
128 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); }
129#endif // _LIBCPP_STD_VER >= 20
130
131#if _LIBCPP_STD_VER >= 20
132 _LIBCPP_HIDE_FROM_ABI constexpr __atomic_base() noexcept(is_nothrow_default_constructible_v<_Tp>) : __a_(_Tp()) {}
133#else
134 _LIBCPP_HIDE_FROM_ABI __atomic_base() _NOEXCEPT = default;
135#endif
136
137 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
138
139 __atomic_base(const __atomic_base&) = delete;
140};
141
142// atomic<Integral>
143
144template <class _Tp>
145struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> {
146 using __base _LIBCPP_NODEBUG = __atomic_base<_Tp, false>;
147
148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __atomic_base() _NOEXCEPT = default;
149
150 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
151
152 _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
153 return std::__cxx_atomic_fetch_add(std::addressof(this->__a_), __op, __m);
154 }
155 _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
156 return std::__cxx_atomic_fetch_add(std::addressof(this->__a_), __op, __m);
157 }
158 _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
159 return std::__cxx_atomic_fetch_sub(std::addressof(this->__a_), __op, __m);
160 }
161 _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
162 return std::__cxx_atomic_fetch_sub(std::addressof(this->__a_), __op, __m);
163 }
164 _LIBCPP_HIDE_FROM_ABI _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
165 return std::__cxx_atomic_fetch_and(std::addressof(this->__a_), __op, __m);
166 }
167 _LIBCPP_HIDE_FROM_ABI _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
168 return std::__cxx_atomic_fetch_and(std::addressof(this->__a_), __op, __m);
169 }
170 _LIBCPP_HIDE_FROM_ABI _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
171 return std::__cxx_atomic_fetch_or(std::addressof(this->__a_), __op, __m);
172 }
173 _LIBCPP_HIDE_FROM_ABI _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
174 return std::__cxx_atomic_fetch_or(std::addressof(this->__a_), __op, __m);
175 }
176 _LIBCPP_HIDE_FROM_ABI _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
177 return std::__cxx_atomic_fetch_xor(std::addressof(this->__a_), __op, __m);
178 }
179 _LIBCPP_HIDE_FROM_ABI _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
180 return std::__cxx_atomic_fetch_xor(std::addressof(this->__a_), __op, __m);
181 }
182
183 _LIBCPP_HIDE_FROM_ABI _Tp operator++(int) volatile _NOEXCEPT { return fetch_add(_Tp(1)); }
184 _LIBCPP_HIDE_FROM_ABI _Tp operator++(int) _NOEXCEPT { return fetch_add(_Tp(1)); }
185 _LIBCPP_HIDE_FROM_ABI _Tp operator--(int) volatile _NOEXCEPT { return fetch_sub(_Tp(1)); }
186 _LIBCPP_HIDE_FROM_ABI _Tp operator--(int) _NOEXCEPT { return fetch_sub(_Tp(1)); }
187 _LIBCPP_HIDE_FROM_ABI _Tp operator++() volatile _NOEXCEPT { return fetch_add(_Tp(1)) + _Tp(1); }
188 _LIBCPP_HIDE_FROM_ABI _Tp operator++() _NOEXCEPT { return fetch_add(_Tp(1)) + _Tp(1); }
189 _LIBCPP_HIDE_FROM_ABI _Tp operator--() volatile _NOEXCEPT { return fetch_sub(_Tp(1)) - _Tp(1); }
190 _LIBCPP_HIDE_FROM_ABI _Tp operator--() _NOEXCEPT { return fetch_sub(_Tp(1)) - _Tp(1); }
191 _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __op) volatile _NOEXCEPT { return fetch_add(__op) + __op; }
192 _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __op) _NOEXCEPT { return fetch_add(__op) + __op; }
193 _LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __op) volatile _NOEXCEPT { return fetch_sub(__op) - __op; }
194 _LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __op) _NOEXCEPT { return fetch_sub(__op) - __op; }
195 _LIBCPP_HIDE_FROM_ABI _Tp operator&=(_Tp __op) volatile _NOEXCEPT { return fetch_and(__op) & __op; }
196 _LIBCPP_HIDE_FROM_ABI _Tp operator&=(_Tp __op) _NOEXCEPT { return fetch_and(__op) & __op; }
197 _LIBCPP_HIDE_FROM_ABI _Tp operator|=(_Tp __op) volatile _NOEXCEPT { return fetch_or(__op) | __op; }
198 _LIBCPP_HIDE_FROM_ABI _Tp operator|=(_Tp __op) _NOEXCEPT { return fetch_or(__op) | __op; }
199 _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __op) volatile _NOEXCEPT { return fetch_xor(__op) ^ __op; }
200 _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __op) _NOEXCEPT { return fetch_xor(__op) ^ __op; }
201};
202
203// Here we need _IsIntegral because the default template argument is not enough
204// e.g __atomic_base<int> is __atomic_base<int, true>, which inherits from
205// __atomic_base<int, false> and the caller of the wait function is
206// __atomic_base<int, false>. So specializing __atomic_base<_Tp> does not work
207template <class _Tp, bool _IsIntegral>
208struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > {
209 static _LIBCPP_HIDE_FROM_ABI _Tp __atomic_load(const __atomic_base<_Tp, _IsIntegral>& __a, memory_order __order) {
210 return __a.load(__order);
211 }
212
213 static _LIBCPP_HIDE_FROM_ABI _Tp
214 __atomic_load(const volatile __atomic_base<_Tp, _IsIntegral>& __this, memory_order __order) {
215 return __this.load(__order);
216 }
217
218 static _LIBCPP_HIDE_FROM_ABI const __cxx_atomic_impl<_Tp>*
219 __atomic_contention_address(const __atomic_base<_Tp, _IsIntegral>& __a) {
220 return std::addressof(__a.__a_);
221 }
222
223 static _LIBCPP_HIDE_FROM_ABI const volatile __cxx_atomic_impl<_Tp>*
224 __atomic_contention_address(const volatile __atomic_base<_Tp, _IsIntegral>& __this) {
225 return std::addressof(__this.__a_);
226 }
227};
228
35template <class _Tp>229template <class _Tp>
36struct atomic : public __atomic_base<_Tp> {230struct atomic : public __atomic_base<_Tp> {
37 using __base = __atomic_base<_Tp>;231 using __base _LIBCPP_NODEBUG = __atomic_base<_Tp>;
38 using value_type = _Tp;232 using value_type = _Tp;
39 using difference_type = value_type;233 using difference_type = value_type;
40234
41#if _LIBCPP_STD_VER >= 20235#if _LIBCPP_STD_VER >= 20
42 _LIBCPP_HIDE_FROM_ABI atomic() = default;236 _LIBCPP_HIDE_FROM_ABI atomic() = default;
...@@ -63,9 +257,9 @@ struct atomic : public __atomic_base<_Tp> {...@@ -63,9 +257,9 @@ struct atomic : public __atomic_base<_Tp> {
63257
64template <class _Tp>258template <class _Tp>
65struct atomic<_Tp*> : public __atomic_base<_Tp*> {259struct atomic<_Tp*> : public __atomic_base<_Tp*> {
66 using __base = __atomic_base<_Tp*>;260 using __base _LIBCPP_NODEBUG = __atomic_base<_Tp*>;
67 using value_type = _Tp*;261 using value_type = _Tp*;
68 using difference_type = ptrdiff_t;262 using difference_type = ptrdiff_t;
69263
70 _LIBCPP_HIDE_FROM_ABI atomic() _NOEXCEPT = default;264 _LIBCPP_HIDE_FROM_ABI atomic() _NOEXCEPT = default;
71265
...@@ -121,6 +315,9 @@ struct atomic<_Tp*> : public __atomic_base<_Tp*> {...@@ -121,6 +315,9 @@ struct atomic<_Tp*> : public __atomic_base<_Tp*> {
121 atomic& operator=(const atomic&) volatile = delete;315 atomic& operator=(const atomic&) volatile = delete;
122};316};
123317
318template <class _Tp>
319struct __atomic_waitable_traits<atomic<_Tp> > : __atomic_waitable_traits<__atomic_base<_Tp> > {};
320
124#if _LIBCPP_STD_VER >= 20321#if _LIBCPP_STD_VER >= 20
125template <class _Tp>322template <class _Tp>
126 requires is_floating_point_v<_Tp>323 requires is_floating_point_v<_Tp>
...@@ -178,7 +375,8 @@ private:...@@ -178,7 +375,8 @@ private:
178 auto __builtin_op = [](auto __a, auto __builtin_operand, auto __order) {375 auto __builtin_op = [](auto __a, auto __builtin_operand, auto __order) {
179 return std::__cxx_atomic_fetch_add(__a, __builtin_operand, __order);376 return std::__cxx_atomic_fetch_add(__a, __builtin_operand, __order);
180 };377 };
181 return __rmw_op(std::forward<_This>(__self), __operand, __m, std::plus<>{}, __builtin_op);378 auto __plus = [](auto __a, auto __b) { return __a + __b; };
379 return __rmw_op(std::forward<_This>(__self), __operand, __m, __plus, __builtin_op);
182 }380 }
183381
184 template <class _This>382 template <class _This>
...@@ -186,13 +384,14 @@ private:...@@ -186,13 +384,14 @@ private:
186 auto __builtin_op = [](auto __a, auto __builtin_operand, auto __order) {384 auto __builtin_op = [](auto __a, auto __builtin_operand, auto __order) {
187 return std::__cxx_atomic_fetch_sub(__a, __builtin_operand, __order);385 return std::__cxx_atomic_fetch_sub(__a, __builtin_operand, __order);
188 };386 };
189 return __rmw_op(std::forward<_This>(__self), __operand, __m, std::minus<>{}, __builtin_op);387 auto __minus = [](auto __a, auto __b) { return __a - __b; };
388 return __rmw_op(std::forward<_This>(__self), __operand, __m, __minus, __builtin_op);
190 }389 }
191390
192public:391public:
193 using __base = __atomic_base<_Tp>;392 using __base _LIBCPP_NODEBUG = __atomic_base<_Tp>;
194 using value_type = _Tp;393 using value_type = _Tp;
195 using difference_type = value_type;394 using difference_type = value_type;
196395
197 _LIBCPP_HIDE_FROM_ABI constexpr atomic() noexcept = default;396 _LIBCPP_HIDE_FROM_ABI constexpr atomic() noexcept = default;
198 _LIBCPP_HIDE_FROM_ABI constexpr atomic(_Tp __d) noexcept : __base(__d) {}397 _LIBCPP_HIDE_FROM_ABI constexpr atomic(_Tp __d) noexcept : __base(__d) {}
...@@ -429,6 +628,8 @@ _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_strong_explicit(...@@ -429,6 +628,8 @@ _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_strong_explicit(
429 return __o->compare_exchange_strong(*__e, __d, __s, __f);628 return __o->compare_exchange_strong(*__e, __d, __s, __f);
430}629}
431630
631#if _LIBCPP_STD_VER >= 20
632
432// atomic_wait633// atomic_wait
433634
434template <class _Tp>635template <class _Tp>
...@@ -462,29 +663,27 @@ atomic_wait_explicit(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __...@@ -462,29 +663,27 @@ atomic_wait_explicit(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __
462// atomic_notify_one663// atomic_notify_one
463664
464template <class _Tp>665template <class _Tp>
465_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void666_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT {
466atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT {
467 __o->notify_one();667 __o->notify_one();
468}668}
469template <class _Tp>669template <class _Tp>
470_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void670_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT {
471atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT {
472 __o->notify_one();671 __o->notify_one();
473}672}
474673
475// atomic_notify_all674// atomic_notify_all
476675
477template <class _Tp>676template <class _Tp>
478_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void677_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT {
479atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT {
480 __o->notify_all();678 __o->notify_all();
481}679}
482template <class _Tp>680template <class _Tp>
483_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void681_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT {
484atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT {
485 __o->notify_all();682 __o->notify_all();
486}683}
487684
685#endif // _LIBCPP_STD_VER >= 20
686
488// atomic_fetch_add687// atomic_fetch_add
489688
490template <class _Tp>689template <class _Tp>
lib/libcxx/include/__atomic/atomic_base.h deleted-221
...@@ -1,221 +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___ATOMIC_ATOMIC_BASE_H
10#define _LIBCPP___ATOMIC_ATOMIC_BASE_H
11
12#include <__atomic/atomic_sync.h>
13#include <__atomic/check_memory_order.h>
14#include <__atomic/cxx_atomic_impl.h>
15#include <__atomic/is_always_lock_free.h>
16#include <__atomic/memory_order.h>
17#include <__config>
18#include <__memory/addressof.h>
19#include <__type_traits/is_integral.h>
20#include <__type_traits/is_nothrow_constructible.h>
21#include <__type_traits/is_same.h>
22#include <version>
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26#endif
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
31struct __atomic_base // false
32{
33 mutable __cxx_atomic_impl<_Tp> __a_;
34
35#if _LIBCPP_STD_VER >= 17
36 static constexpr bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value;
37#endif
38
39 _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const volatile _NOEXCEPT {
40 return __cxx_atomic_is_lock_free(sizeof(__cxx_atomic_impl<_Tp>));
41 }
42 _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const _NOEXCEPT {
43 return static_cast<__atomic_base const volatile*>(this)->is_lock_free();
44 }
45 _LIBCPP_HIDE_FROM_ABI void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
46 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) {
47 std::__cxx_atomic_store(std::addressof(__a_), __d, __m);
48 }
49 _LIBCPP_HIDE_FROM_ABI void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
50 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) {
51 std::__cxx_atomic_store(std::addressof(__a_), __d, __m);
52 }
53 _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
54 _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) {
55 return std::__cxx_atomic_load(std::addressof(__a_), __m);
56 }
57 _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
58 _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) {
59 return std::__cxx_atomic_load(std::addressof(__a_), __m);
60 }
61 _LIBCPP_HIDE_FROM_ABI operator _Tp() const volatile _NOEXCEPT { return load(); }
62 _LIBCPP_HIDE_FROM_ABI operator _Tp() const _NOEXCEPT { return load(); }
63 _LIBCPP_HIDE_FROM_ABI _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
64 return std::__cxx_atomic_exchange(std::addressof(__a_), __d, __m);
65 }
66 _LIBCPP_HIDE_FROM_ABI _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
67 return std::__cxx_atomic_exchange(std::addressof(__a_), __d, __m);
68 }
69 _LIBCPP_HIDE_FROM_ABI bool
70 compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) volatile _NOEXCEPT
71 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) {
72 return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __s, __f);
73 }
74 _LIBCPP_HIDE_FROM_ABI bool compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) _NOEXCEPT
75 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) {
76 return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __s, __f);
77 }
78 _LIBCPP_HIDE_FROM_ABI bool
79 compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) volatile _NOEXCEPT
80 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) {
81 return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __s, __f);
82 }
83 _LIBCPP_HIDE_FROM_ABI bool compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) _NOEXCEPT
84 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) {
85 return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __s, __f);
86 }
87 _LIBCPP_HIDE_FROM_ABI bool
88 compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
89 return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __m, __m);
90 }
91 _LIBCPP_HIDE_FROM_ABI bool
92 compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
93 return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __m, __m);
94 }
95 _LIBCPP_HIDE_FROM_ABI bool
96 compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
97 return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __m, __m);
98 }
99 _LIBCPP_HIDE_FROM_ABI bool
100 compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
101 return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __m, __m);
102 }
103
104 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const
105 volatile _NOEXCEPT {
106 std::__atomic_wait(*this, __v, __m);
107 }
108 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
109 wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT {
110 std::__atomic_wait(*this, __v, __m);
111 }
112 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT {
113 std::__atomic_notify_one(*this);
114 }
115 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); }
116 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT {
117 std::__atomic_notify_all(*this);
118 }
119 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); }
120
121#if _LIBCPP_STD_VER >= 20
122 _LIBCPP_HIDE_FROM_ABI constexpr __atomic_base() noexcept(is_nothrow_default_constructible_v<_Tp>) : __a_(_Tp()) {}
123#else
124 _LIBCPP_HIDE_FROM_ABI __atomic_base() _NOEXCEPT = default;
125#endif
126
127 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
128
129 __atomic_base(const __atomic_base&) = delete;
130};
131
132// atomic<Integral>
133
134template <class _Tp>
135struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> {
136 using __base = __atomic_base<_Tp, false>;
137
138 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __atomic_base() _NOEXCEPT = default;
139
140 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
141
142 _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
143 return std::__cxx_atomic_fetch_add(std::addressof(this->__a_), __op, __m);
144 }
145 _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
146 return std::__cxx_atomic_fetch_add(std::addressof(this->__a_), __op, __m);
147 }
148 _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
149 return std::__cxx_atomic_fetch_sub(std::addressof(this->__a_), __op, __m);
150 }
151 _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
152 return std::__cxx_atomic_fetch_sub(std::addressof(this->__a_), __op, __m);
153 }
154 _LIBCPP_HIDE_FROM_ABI _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
155 return std::__cxx_atomic_fetch_and(std::addressof(this->__a_), __op, __m);
156 }
157 _LIBCPP_HIDE_FROM_ABI _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
158 return std::__cxx_atomic_fetch_and(std::addressof(this->__a_), __op, __m);
159 }
160 _LIBCPP_HIDE_FROM_ABI _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
161 return std::__cxx_atomic_fetch_or(std::addressof(this->__a_), __op, __m);
162 }
163 _LIBCPP_HIDE_FROM_ABI _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
164 return std::__cxx_atomic_fetch_or(std::addressof(this->__a_), __op, __m);
165 }
166 _LIBCPP_HIDE_FROM_ABI _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
167 return std::__cxx_atomic_fetch_xor(std::addressof(this->__a_), __op, __m);
168 }
169 _LIBCPP_HIDE_FROM_ABI _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
170 return std::__cxx_atomic_fetch_xor(std::addressof(this->__a_), __op, __m);
171 }
172
173 _LIBCPP_HIDE_FROM_ABI _Tp operator++(int) volatile _NOEXCEPT { return fetch_add(_Tp(1)); }
174 _LIBCPP_HIDE_FROM_ABI _Tp operator++(int) _NOEXCEPT { return fetch_add(_Tp(1)); }
175 _LIBCPP_HIDE_FROM_ABI _Tp operator--(int) volatile _NOEXCEPT { return fetch_sub(_Tp(1)); }
176 _LIBCPP_HIDE_FROM_ABI _Tp operator--(int) _NOEXCEPT { return fetch_sub(_Tp(1)); }
177 _LIBCPP_HIDE_FROM_ABI _Tp operator++() volatile _NOEXCEPT { return fetch_add(_Tp(1)) + _Tp(1); }
178 _LIBCPP_HIDE_FROM_ABI _Tp operator++() _NOEXCEPT { return fetch_add(_Tp(1)) + _Tp(1); }
179 _LIBCPP_HIDE_FROM_ABI _Tp operator--() volatile _NOEXCEPT { return fetch_sub(_Tp(1)) - _Tp(1); }
180 _LIBCPP_HIDE_FROM_ABI _Tp operator--() _NOEXCEPT { return fetch_sub(_Tp(1)) - _Tp(1); }
181 _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __op) volatile _NOEXCEPT { return fetch_add(__op) + __op; }
182 _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __op) _NOEXCEPT { return fetch_add(__op) + __op; }
183 _LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __op) volatile _NOEXCEPT { return fetch_sub(__op) - __op; }
184 _LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __op) _NOEXCEPT { return fetch_sub(__op) - __op; }
185 _LIBCPP_HIDE_FROM_ABI _Tp operator&=(_Tp __op) volatile _NOEXCEPT { return fetch_and(__op) & __op; }
186 _LIBCPP_HIDE_FROM_ABI _Tp operator&=(_Tp __op) _NOEXCEPT { return fetch_and(__op) & __op; }
187 _LIBCPP_HIDE_FROM_ABI _Tp operator|=(_Tp __op) volatile _NOEXCEPT { return fetch_or(__op) | __op; }
188 _LIBCPP_HIDE_FROM_ABI _Tp operator|=(_Tp __op) _NOEXCEPT { return fetch_or(__op) | __op; }
189 _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __op) volatile _NOEXCEPT { return fetch_xor(__op) ^ __op; }
190 _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __op) _NOEXCEPT { return fetch_xor(__op) ^ __op; }
191};
192
193// Here we need _IsIntegral because the default template argument is not enough
194// e.g __atomic_base<int> is __atomic_base<int, true>, which inherits from
195// __atomic_base<int, false> and the caller of the wait function is
196// __atomic_base<int, false>. So specializing __atomic_base<_Tp> does not work
197template <class _Tp, bool _IsIntegral>
198struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > {
199 static _LIBCPP_HIDE_FROM_ABI _Tp __atomic_load(const __atomic_base<_Tp, _IsIntegral>& __a, memory_order __order) {
200 return __a.load(__order);
201 }
202
203 static _LIBCPP_HIDE_FROM_ABI _Tp
204 __atomic_load(const volatile __atomic_base<_Tp, _IsIntegral>& __this, memory_order __order) {
205 return __this.load(__order);
206 }
207
208 static _LIBCPP_HIDE_FROM_ABI const __cxx_atomic_impl<_Tp>*
209 __atomic_contention_address(const __atomic_base<_Tp, _IsIntegral>& __a) {
210 return std::addressof(__a.__a_);
211 }
212
213 static _LIBCPP_HIDE_FROM_ABI const volatile __cxx_atomic_impl<_Tp>*
214 __atomic_contention_address(const volatile __atomic_base<_Tp, _IsIntegral>& __this) {
215 return std::addressof(__this.__a_);
216 }
217};
218
219_LIBCPP_END_NAMESPACE_STD
220
221#endif // _LIBCPP___ATOMIC_ATOMIC_BASE_H
lib/libcxx/include/__atomic/atomic_flag.h+19-21
...@@ -11,8 +11,8 @@...@@ -11,8 +11,8 @@
1111
12#include <__atomic/atomic_sync.h>12#include <__atomic/atomic_sync.h>
13#include <__atomic/contention_t.h>13#include <__atomic/contention_t.h>
14#include <__atomic/cxx_atomic_impl.h>
15#include <__atomic/memory_order.h>14#include <__atomic/memory_order.h>
15#include <__atomic/support.h>
16#include <__chrono/duration.h>16#include <__chrono/duration.h>
17#include <__config>17#include <__config>
18#include <__memory/addressof.h>18#include <__memory/addressof.h>
...@@ -48,26 +48,24 @@ struct atomic_flag {...@@ -48,26 +48,24 @@ struct atomic_flag {
48 __cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m);48 __cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m);
49 }49 }
5050
51 _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void51#if _LIBCPP_STD_VER >= 20
52 wait(bool __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT {52 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(bool __v, memory_order __m = memory_order_seq_cst) const
53 volatile _NOEXCEPT {
53 std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);54 std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);
54 }55 }
55 _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void56 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
56 wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT {57 wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT {
57 std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);58 std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);
58 }59 }
59 _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT {60 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT {
60 std::__atomic_notify_one(*this);
61 }
62 _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT {
63 std::__atomic_notify_one(*this);61 std::__atomic_notify_one(*this);
64 }62 }
63 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); }
65 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT {64 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT {
66 std::__atomic_notify_all(*this);65 std::__atomic_notify_all(*this);
67 }66 }
68 _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT {67 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); }
69 std::__atomic_notify_all(*this);68#endif
70 }
7169
72#if _LIBCPP_STD_VER >= 2070#if _LIBCPP_STD_VER >= 20
73 _LIBCPP_HIDE_FROM_ABI constexpr atomic_flag() _NOEXCEPT : __a_(false) {}71 _LIBCPP_HIDE_FROM_ABI constexpr atomic_flag() _NOEXCEPT : __a_(false) {}
...@@ -144,45 +142,45 @@ inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_clear_explicit(atomic_flag* __o, m...@@ -144,45 +142,45 @@ inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_clear_explicit(atomic_flag* __o, m
144 __o->clear(__m);142 __o->clear(__m);
145}143}
146144
147inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void145#if _LIBCPP_STD_VER >= 20
146inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
148atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT {147atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT {
149 __o->wait(__v);148 __o->wait(__v);
150}149}
151150
152inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void151inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
153atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT {152atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT {
154 __o->wait(__v);153 __o->wait(__v);
155}154}
156155
157inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void156inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
158atomic_flag_wait_explicit(const volatile atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT {157atomic_flag_wait_explicit(const volatile atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT {
159 __o->wait(__v, __m);158 __o->wait(__v, __m);
160}159}
161160
162inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void161inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
163atomic_flag_wait_explicit(const atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT {162atomic_flag_wait_explicit(const atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT {
164 __o->wait(__v, __m);163 __o->wait(__v, __m);
165}164}
166165
167inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void166inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
168atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT {167atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT {
169 __o->notify_one();168 __o->notify_one();
170}169}
171170
172inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void171inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT {
173atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT {
174 __o->notify_one();172 __o->notify_one();
175}173}
176174
177inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void175inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
178atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT {176atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT {
179 __o->notify_all();177 __o->notify_all();
180}178}
181179
182inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void180inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT {
183atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT {
184 __o->notify_all();181 __o->notify_all();
185}182}
183#endif // _LIBCPP_STD_VER >= 20
186184
187_LIBCPP_END_NAMESPACE_STD185_LIBCPP_END_NAMESPACE_STD
188186
lib/libcxx/include/__atomic/atomic_lock_free.h+2-2
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18#if defined(__CLANG_ATOMIC_BOOL_LOCK_FREE)18#if defined(__CLANG_ATOMIC_BOOL_LOCK_FREE)
19# define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE19# define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE
20# define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE20# define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE
21# ifndef _LIBCPP_HAS_NO_CHAR8_T21# if _LIBCPP_HAS_CHAR8_T
22# define ATOMIC_CHAR8_T_LOCK_FREE __CLANG_ATOMIC_CHAR8_T_LOCK_FREE22# define ATOMIC_CHAR8_T_LOCK_FREE __CLANG_ATOMIC_CHAR8_T_LOCK_FREE
23# endif23# endif
24# define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE24# define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE
...@@ -32,7 +32,7 @@...@@ -32,7 +32,7 @@
32#elif defined(__GCC_ATOMIC_BOOL_LOCK_FREE)32#elif defined(__GCC_ATOMIC_BOOL_LOCK_FREE)
33# define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE33# define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
34# define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE34# define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
35# ifndef _LIBCPP_HAS_NO_CHAR8_T35# if _LIBCPP_HAS_CHAR8_T
36# define ATOMIC_CHAR8_T_LOCK_FREE __GCC_ATOMIC_CHAR8_T_LOCK_FREE36# define ATOMIC_CHAR8_T_LOCK_FREE __GCC_ATOMIC_CHAR8_T_LOCK_FREE
37# endif37# endif
38# define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE38# define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
lib/libcxx/include/__atomic/atomic_ref.h+8-6
...@@ -20,14 +20,16 @@...@@ -20,14 +20,16 @@
20#include <__assert>20#include <__assert>
21#include <__atomic/atomic_sync.h>21#include <__atomic/atomic_sync.h>
22#include <__atomic/check_memory_order.h>22#include <__atomic/check_memory_order.h>
23#include <__atomic/memory_order.h>
23#include <__atomic/to_gcc_order.h>24#include <__atomic/to_gcc_order.h>
24#include <__concepts/arithmetic.h>25#include <__concepts/arithmetic.h>
25#include <__concepts/same_as.h>26#include <__concepts/same_as.h>
26#include <__config>27#include <__config>
28#include <__cstddef/byte.h>
29#include <__cstddef/ptrdiff_t.h>
27#include <__memory/addressof.h>30#include <__memory/addressof.h>
28#include <__type_traits/has_unique_object_representation.h>31#include <__type_traits/has_unique_object_representation.h>
29#include <__type_traits/is_trivially_copyable.h>32#include <__type_traits/is_trivially_copyable.h>
30#include <cstddef>
31#include <cstdint>33#include <cstdint>
32#include <cstring>34#include <cstring>
3335
...@@ -219,7 +221,7 @@ public:...@@ -219,7 +221,7 @@ public:
219 _LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { std::__atomic_notify_all(*this); }221 _LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { std::__atomic_notify_all(*this); }
220222
221protected:223protected:
222 typedef _Tp _Aligned_Tp __attribute__((aligned(required_alignment)));224 using _Aligned_Tp [[__gnu__::__aligned__(required_alignment), __gnu__::__nodebug__]] = _Tp;
223 _Aligned_Tp* __ptr_;225 _Aligned_Tp* __ptr_;
224226
225 _LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : __ptr_(std::addressof(__obj)) {}227 _LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : __ptr_(std::addressof(__obj)) {}
...@@ -239,7 +241,7 @@ template <class _Tp>...@@ -239,7 +241,7 @@ template <class _Tp>
239struct atomic_ref : public __atomic_ref_base<_Tp> {241struct atomic_ref : public __atomic_ref_base<_Tp> {
240 static_assert(is_trivially_copyable_v<_Tp>, "std::atomic_ref<T> requires that 'T' be a trivially copyable type");242 static_assert(is_trivially_copyable_v<_Tp>, "std::atomic_ref<T> requires that 'T' be a trivially copyable type");
241243
242 using __base = __atomic_ref_base<_Tp>;244 using __base _LIBCPP_NODEBUG = __atomic_ref_base<_Tp>;
243245
244 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) {246 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) {
245 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(247 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
...@@ -257,7 +259,7 @@ struct atomic_ref : public __atomic_ref_base<_Tp> {...@@ -257,7 +259,7 @@ struct atomic_ref : public __atomic_ref_base<_Tp> {
257template <class _Tp>259template <class _Tp>
258 requires(std::integral<_Tp> && !std::same_as<bool, _Tp>)260 requires(std::integral<_Tp> && !std::same_as<bool, _Tp>)
259struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {261struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {
260 using __base = __atomic_ref_base<_Tp>;262 using __base _LIBCPP_NODEBUG = __atomic_ref_base<_Tp>;
261263
262 using difference_type = __base::value_type;264 using difference_type = __base::value_type;
263265
...@@ -303,7 +305,7 @@ struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {...@@ -303,7 +305,7 @@ struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {
303template <class _Tp>305template <class _Tp>
304 requires std::floating_point<_Tp>306 requires std::floating_point<_Tp>
305struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {307struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {
306 using __base = __atomic_ref_base<_Tp>;308 using __base _LIBCPP_NODEBUG = __atomic_ref_base<_Tp>;
307309
308 using difference_type = __base::value_type;310 using difference_type = __base::value_type;
309311
...@@ -342,7 +344,7 @@ struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {...@@ -342,7 +344,7 @@ struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {
342344
343template <class _Tp>345template <class _Tp>
344struct atomic_ref<_Tp*> : public __atomic_ref_base<_Tp*> {346struct atomic_ref<_Tp*> : public __atomic_ref_base<_Tp*> {
345 using __base = __atomic_ref_base<_Tp*>;347 using __base _LIBCPP_NODEBUG = __atomic_ref_base<_Tp*>;
346348
347 using difference_type = ptrdiff_t;349 using difference_type = ptrdiff_t;
348350
lib/libcxx/include/__atomic/atomic_sync.h+30-40
...@@ -10,14 +10,12 @@...@@ -10,14 +10,12 @@
10#define _LIBCPP___ATOMIC_ATOMIC_SYNC_H10#define _LIBCPP___ATOMIC_ATOMIC_SYNC_H
1111
12#include <__atomic/contention_t.h>12#include <__atomic/contention_t.h>
13#include <__atomic/cxx_atomic_impl.h>
14#include <__atomic/memory_order.h>13#include <__atomic/memory_order.h>
15#include <__atomic/to_gcc_order.h>14#include <__atomic/to_gcc_order.h>
16#include <__chrono/duration.h>15#include <__chrono/duration.h>
17#include <__config>16#include <__config>
18#include <__memory/addressof.h>17#include <__memory/addressof.h>
19#include <__thread/poll_with_backoff.h>18#include <__thread/poll_with_backoff.h>
20#include <__thread/support.h>
21#include <__type_traits/conjunction.h>19#include <__type_traits/conjunction.h>
22#include <__type_traits/decay.h>20#include <__type_traits/decay.h>
23#include <__type_traits/invoke.h>21#include <__type_traits/invoke.h>
...@@ -57,19 +55,8 @@ struct __atomic_waitable< _Tp,...@@ -57,19 +55,8 @@ struct __atomic_waitable< _Tp,
57 decltype(__atomic_waitable_traits<__decay_t<_Tp> >::__atomic_contention_address(55 decltype(__atomic_waitable_traits<__decay_t<_Tp> >::__atomic_contention_address(
58 std::declval<const _Tp&>()))> > : true_type {};56 std::declval<const _Tp&>()))> > : true_type {};
5957
60template <class _AtomicWaitable, class _Poll>58#if _LIBCPP_STD_VER >= 20
61struct __atomic_wait_poll_impl {59# if _LIBCPP_HAS_THREADS
62 const _AtomicWaitable& __a_;
63 _Poll __poll_;
64 memory_order __order_;
65
66 _LIBCPP_HIDE_FROM_ABI bool operator()() const {
67 auto __current_val = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_load(__a_, __order_);
68 return __poll_(__current_val);
69 }
70};
71
72#ifndef _LIBCPP_HAS_NO_THREADS
7360
74_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*) _NOEXCEPT;61_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*) _NOEXCEPT;
75_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*) _NOEXCEPT;62_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*) _NOEXCEPT;
...@@ -93,7 +80,7 @@ struct __atomic_wait_backoff_impl {...@@ -93,7 +80,7 @@ struct __atomic_wait_backoff_impl {
93 _Poll __poll_;80 _Poll __poll_;
94 memory_order __order_;81 memory_order __order_;
9582
96 using __waitable_traits = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >;83 using __waitable_traits _LIBCPP_NODEBUG = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >;
9784
98 _LIBCPP_AVAILABILITY_SYNC85 _LIBCPP_AVAILABILITY_SYNC
99 _LIBCPP_HIDE_FROM_ABI bool86 _LIBCPP_HIDE_FROM_ABI bool
...@@ -120,15 +107,13 @@ struct __atomic_wait_backoff_impl {...@@ -120,15 +107,13 @@ struct __atomic_wait_backoff_impl {
120107
121 _LIBCPP_AVAILABILITY_SYNC108 _LIBCPP_AVAILABILITY_SYNC
122 _LIBCPP_HIDE_FROM_ABI bool operator()(chrono::nanoseconds __elapsed) const {109 _LIBCPP_HIDE_FROM_ABI bool operator()(chrono::nanoseconds __elapsed) const {
123 if (__elapsed > chrono::microseconds(64)) {110 if (__elapsed > chrono::microseconds(4)) {
124 auto __contention_address = __waitable_traits::__atomic_contention_address(__a_);111 auto __contention_address = __waitable_traits::__atomic_contention_address(__a_);
125 __cxx_contention_t __monitor_val;112 __cxx_contention_t __monitor_val;
126 if (__update_monitor_val_and_poll(__contention_address, __monitor_val))113 if (__update_monitor_val_and_poll(__contention_address, __monitor_val))
127 return true;114 return true;
128 std::__libcpp_atomic_wait(__contention_address, __monitor_val);115 std::__libcpp_atomic_wait(__contention_address, __monitor_val);
129 } else if (__elapsed > chrono::microseconds(4))116 } else {
130 __libcpp_thread_yield();
131 else {
132 } // poll117 } // poll
133 return false;118 return false;
134 }119 }
...@@ -144,11 +129,16 @@ struct __atomic_wait_backoff_impl {...@@ -144,11 +129,16 @@ struct __atomic_wait_backoff_impl {
144// value. The predicate function must not return `false` spuriously.129// value. The predicate function must not return `false` spuriously.
145template <class _AtomicWaitable, class _Poll>130template <class _AtomicWaitable, class _Poll>
146_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void131_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
147__atomic_wait_unless(const _AtomicWaitable& __a, _Poll&& __poll, memory_order __order) {132__atomic_wait_unless(const _AtomicWaitable& __a, memory_order __order, _Poll&& __poll) {
148 static_assert(__atomic_waitable<_AtomicWaitable>::value, "");133 static_assert(__atomic_waitable<_AtomicWaitable>::value, "");
149 __atomic_wait_poll_impl<_AtomicWaitable, __decay_t<_Poll> > __poll_impl = {__a, __poll, __order};
150 __atomic_wait_backoff_impl<_AtomicWaitable, __decay_t<_Poll> > __backoff_fn = {__a, __poll, __order};134 __atomic_wait_backoff_impl<_AtomicWaitable, __decay_t<_Poll> > __backoff_fn = {__a, __poll, __order};
151 std::__libcpp_thread_poll_with_backoff(__poll_impl, __backoff_fn);135 std::__libcpp_thread_poll_with_backoff(
136 /* poll */
137 [&]() {
138 auto __current_val = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_load(__a, __order);
139 return __poll(__current_val);
140 },
141 /* backoff */ __backoff_fn);
152}142}
153143
154template <class _AtomicWaitable>144template <class _AtomicWaitable>
...@@ -163,12 +153,17 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _...@@ -163,12 +153,17 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _
163 std::__cxx_atomic_notify_all(__atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_contention_address(__a));153 std::__cxx_atomic_notify_all(__atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_contention_address(__a));
164}154}
165155
166#else // _LIBCPP_HAS_NO_THREADS156# else // _LIBCPP_HAS_THREADS
167157
168template <class _AtomicWaitable, class _Poll>158template <class _AtomicWaitable, class _Poll>
169_LIBCPP_HIDE_FROM_ABI void __atomic_wait_unless(const _AtomicWaitable& __a, _Poll&& __poll, memory_order __order) {159_LIBCPP_HIDE_FROM_ABI void __atomic_wait_unless(const _AtomicWaitable& __a, memory_order __order, _Poll&& __poll) {
170 __atomic_wait_poll_impl<_AtomicWaitable, __decay_t<_Poll> > __poll_fn = {__a, __poll, __order};160 std::__libcpp_thread_poll_with_backoff(
171 std::__libcpp_thread_poll_with_backoff(__poll_fn, __spinning_backoff_policy());161 /* poll */
162 [&]() {
163 auto __current_val = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_load(__a, __order);
164 return __poll(__current_val);
165 },
166 /* backoff */ __spinning_backoff_policy());
172}167}
173168
174template <class _AtomicWaitable>169template <class _AtomicWaitable>
...@@ -177,29 +172,24 @@ _LIBCPP_HIDE_FROM_ABI void __atomic_notify_one(const _AtomicWaitable&) {}...@@ -177,29 +172,24 @@ _LIBCPP_HIDE_FROM_ABI void __atomic_notify_one(const _AtomicWaitable&) {}
177template <class _AtomicWaitable>172template <class _AtomicWaitable>
178_LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _AtomicWaitable&) {}173_LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _AtomicWaitable&) {}
179174
180#endif // _LIBCPP_HAS_NO_THREADS175# endif // _LIBCPP_HAS_THREADS
181176
182template <typename _Tp>177template <typename _Tp>
183_LIBCPP_HIDE_FROM_ABI bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp const& __rhs) {178_LIBCPP_HIDE_FROM_ABI bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp const& __rhs) {
184 return std::memcmp(std::addressof(__lhs), std::addressof(__rhs), sizeof(_Tp)) == 0;179 return std::memcmp(std::addressof(__lhs), std::addressof(__rhs), sizeof(_Tp)) == 0;
185}180}
186181
187template <class _Tp>182template <class _AtomicWaitable, class _Tp>
188struct __atomic_compare_unequal_to {
189 _Tp __val_;
190 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __arg) const {
191 return !std::__cxx_nonatomic_compare_equal(__arg, __val_);
192 }
193};
194
195template <class _AtomicWaitable, class _Up>
196_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void183_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
197__atomic_wait(_AtomicWaitable& __a, _Up __val, memory_order __order) {184__atomic_wait(_AtomicWaitable& __a, _Tp __val, memory_order __order) {
198 static_assert(__atomic_waitable<_AtomicWaitable>::value, "");185 static_assert(__atomic_waitable<_AtomicWaitable>::value, "");
199 __atomic_compare_unequal_to<_Up> __nonatomic_equal = {__val};186 std::__atomic_wait_unless(__a, __order, [&](_Tp const& __current) {
200 std::__atomic_wait_unless(__a, __nonatomic_equal, __order);187 return !std::__cxx_nonatomic_compare_equal(__current, __val);
188 });
201}189}
202190
191#endif // C++20
192
203_LIBCPP_END_NAMESPACE_STD193_LIBCPP_END_NAMESPACE_STD
204194
205#endif // _LIBCPP___ATOMIC_ATOMIC_SYNC_H195#endif // _LIBCPP___ATOMIC_ATOMIC_SYNC_H
lib/libcxx/include/__atomic/contention_t.h+4-4
...@@ -9,7 +9,7 @@...@@ -9,7 +9,7 @@
9#ifndef _LIBCPP___ATOMIC_CONTENTION_T_H9#ifndef _LIBCPP___ATOMIC_CONTENTION_T_H
10#define _LIBCPP___ATOMIC_CONTENTION_T_H10#define _LIBCPP___ATOMIC_CONTENTION_T_H
1111
12#include <__atomic/cxx_atomic_impl.h>12#include <__atomic/support.h>
13#include <__config>13#include <__config>
14#include <cstdint>14#include <cstdint>
1515
...@@ -20,12 +20,12 @@...@@ -20,12 +20,12 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if defined(__linux__) || (defined(_AIX) && !defined(__64BIT__))22#if defined(__linux__) || (defined(_AIX) && !defined(__64BIT__))
23using __cxx_contention_t = int32_t;23using __cxx_contention_t _LIBCPP_NODEBUG = int32_t;
24#else24#else
25using __cxx_contention_t = int64_t;25using __cxx_contention_t _LIBCPP_NODEBUG = int64_t;
26#endif // __linux__ || (_AIX && !__64BIT__)26#endif // __linux__ || (_AIX && !__64BIT__)
2727
28using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;28using __cxx_atomic_contention_t _LIBCPP_NODEBUG = __cxx_atomic_impl<__cxx_contention_t>;
2929
30_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
3131
lib/libcxx/include/__atomic/cxx_atomic_impl.h deleted-510
...@@ -1,510 +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___ATOMIC_CXX_ATOMIC_IMPL_H
10#define _LIBCPP___ATOMIC_CXX_ATOMIC_IMPL_H
11
12#include <__atomic/memory_order.h>
13#include <__atomic/to_gcc_order.h>
14#include <__config>
15#include <__memory/addressof.h>
16#include <__type_traits/is_assignable.h>
17#include <__type_traits/is_trivially_copyable.h>
18#include <__type_traits/remove_const.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 defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
28
29// [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because
30// the default operator= in an object is not volatile, a byte-by-byte copy
31// is required.
32template <typename _Tp, typename _Tv, __enable_if_t<is_assignable<_Tp&, _Tv>::value, int> = 0>
33_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp& __a_value, _Tv const& __val) {
34 __a_value = __val;
35}
36template <typename _Tp, typename _Tv, __enable_if_t<is_assignable<_Tp&, _Tv>::value, int> = 0>
37_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp volatile& __a_value, _Tv volatile const& __val) {
38 volatile char* __to = reinterpret_cast<volatile char*>(std::addressof(__a_value));
39 volatile char* __end = __to + sizeof(_Tp);
40 volatile const char* __from = reinterpret_cast<volatile const char*>(std::addressof(__val));
41 while (__to != __end)
42 *__to++ = *__from++;
43}
44
45template <typename _Tp>
46struct __cxx_atomic_base_impl {
47 _LIBCPP_HIDE_FROM_ABI
48# ifndef _LIBCPP_CXX03_LANG
49 __cxx_atomic_base_impl() _NOEXCEPT = default;
50# else
51 __cxx_atomic_base_impl() _NOEXCEPT : __a_value() {
52 }
53# endif // _LIBCPP_CXX03_LANG
54 _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp value) _NOEXCEPT : __a_value(value) {}
55 _Tp __a_value;
56};
57
58template <typename _Tp>
59_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val) {
60 __cxx_atomic_assign_volatile(__a->__a_value, __val);
61}
62
63template <typename _Tp>
64_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val) {
65 __a->__a_value = __val;
66}
67
68_LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_thread_fence(memory_order __order) {
69 __atomic_thread_fence(__to_gcc_order(__order));
70}
71
72_LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_signal_fence(memory_order __order) {
73 __atomic_signal_fence(__to_gcc_order(__order));
74}
75
76template <typename _Tp>
77_LIBCPP_HIDE_FROM_ABI void
78__cxx_atomic_store(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) {
79 __atomic_store(std::addressof(__a->__a_value), std::addressof(__val), __to_gcc_order(__order));
80}
81
82template <typename _Tp>
83_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) {
84 __atomic_store(std::addressof(__a->__a_value), std::addressof(__val), __to_gcc_order(__order));
85}
86
87template <typename _Tp>
88_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const volatile __cxx_atomic_base_impl<_Tp>* __a, memory_order __order) {
89 _Tp __ret;
90 __atomic_load(std::addressof(__a->__a_value), std::addressof(__ret), __to_gcc_order(__order));
91 return __ret;
92}
93
94template <typename _Tp>
95_LIBCPP_HIDE_FROM_ABI void
96__cxx_atomic_load_inplace(const volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp* __dst, memory_order __order) {
97 __atomic_load(std::addressof(__a->__a_value), __dst, __to_gcc_order(__order));
98}
99
100template <typename _Tp>
101_LIBCPP_HIDE_FROM_ABI void
102__cxx_atomic_load_inplace(const __cxx_atomic_base_impl<_Tp>* __a, _Tp* __dst, memory_order __order) {
103 __atomic_load(std::addressof(__a->__a_value), __dst, __to_gcc_order(__order));
104}
105
106template <typename _Tp>
107_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const __cxx_atomic_base_impl<_Tp>* __a, memory_order __order) {
108 _Tp __ret;
109 __atomic_load(std::addressof(__a->__a_value), std::addressof(__ret), __to_gcc_order(__order));
110 return __ret;
111}
112
113template <typename _Tp>
114_LIBCPP_HIDE_FROM_ABI _Tp
115__cxx_atomic_exchange(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) {
116 _Tp __ret;
117 __atomic_exchange(
118 std::addressof(__a->__a_value), std::addressof(__value), std::addressof(__ret), __to_gcc_order(__order));
119 return __ret;
120}
121
122template <typename _Tp>
123_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) {
124 _Tp __ret;
125 __atomic_exchange(
126 std::addressof(__a->__a_value), std::addressof(__value), std::addressof(__ret), __to_gcc_order(__order));
127 return __ret;
128}
129
130template <typename _Tp>
131_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(
132 volatile __cxx_atomic_base_impl<_Tp>* __a,
133 _Tp* __expected,
134 _Tp __value,
135 memory_order __success,
136 memory_order __failure) {
137 return __atomic_compare_exchange(
138 std::addressof(__a->__a_value),
139 __expected,
140 std::addressof(__value),
141 false,
142 __to_gcc_order(__success),
143 __to_gcc_failure_order(__failure));
144}
145
146template <typename _Tp>
147_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(
148 __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) {
149 return __atomic_compare_exchange(
150 std::addressof(__a->__a_value),
151 __expected,
152 std::addressof(__value),
153 false,
154 __to_gcc_order(__success),
155 __to_gcc_failure_order(__failure));
156}
157
158template <typename _Tp>
159_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(
160 volatile __cxx_atomic_base_impl<_Tp>* __a,
161 _Tp* __expected,
162 _Tp __value,
163 memory_order __success,
164 memory_order __failure) {
165 return __atomic_compare_exchange(
166 std::addressof(__a->__a_value),
167 __expected,
168 std::addressof(__value),
169 true,
170 __to_gcc_order(__success),
171 __to_gcc_failure_order(__failure));
172}
173
174template <typename _Tp>
175_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(
176 __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) {
177 return __atomic_compare_exchange(
178 std::addressof(__a->__a_value),
179 __expected,
180 std::addressof(__value),
181 true,
182 __to_gcc_order(__success),
183 __to_gcc_failure_order(__failure));
184}
185
186template <typename _Tp>
187struct __skip_amt {
188 enum { value = 1 };
189};
190
191template <typename _Tp>
192struct __skip_amt<_Tp*> {
193 enum { value = sizeof(_Tp) };
194};
195
196// FIXME: Haven't figured out what the spec says about using arrays with
197// atomic_fetch_add. Force a failure rather than creating bad behavior.
198template <typename _Tp>
199struct __skip_amt<_Tp[]> {};
200template <typename _Tp, int n>
201struct __skip_amt<_Tp[n]> {};
202
203template <typename _Tp, typename _Td>
204_LIBCPP_HIDE_FROM_ABI _Tp
205__cxx_atomic_fetch_add(volatile __cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) {
206 return __atomic_fetch_add(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order));
207}
208
209template <typename _Tp, typename _Td>
210_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) {
211 return __atomic_fetch_add(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order));
212}
213
214template <typename _Tp, typename _Td>
215_LIBCPP_HIDE_FROM_ABI _Tp
216__cxx_atomic_fetch_sub(volatile __cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) {
217 return __atomic_fetch_sub(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order));
218}
219
220template <typename _Tp, typename _Td>
221_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) {
222 return __atomic_fetch_sub(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order));
223}
224
225template <typename _Tp>
226_LIBCPP_HIDE_FROM_ABI _Tp
227__cxx_atomic_fetch_and(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {
228 return __atomic_fetch_and(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));
229}
230
231template <typename _Tp>
232_LIBCPP_HIDE_FROM_ABI _Tp
233__cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {
234 return __atomic_fetch_and(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));
235}
236
237template <typename _Tp>
238_LIBCPP_HIDE_FROM_ABI _Tp
239__cxx_atomic_fetch_or(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {
240 return __atomic_fetch_or(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));
241}
242
243template <typename _Tp>
244_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {
245 return __atomic_fetch_or(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));
246}
247
248template <typename _Tp>
249_LIBCPP_HIDE_FROM_ABI _Tp
250__cxx_atomic_fetch_xor(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {
251 return __atomic_fetch_xor(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));
252}
253
254template <typename _Tp>
255_LIBCPP_HIDE_FROM_ABI _Tp
256__cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {
257 return __atomic_fetch_xor(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));
258}
259
260# define __cxx_atomic_is_lock_free(__s) __atomic_is_lock_free(__s, 0)
261
262#elif defined(_LIBCPP_HAS_C_ATOMIC_IMP)
263
264template <typename _Tp>
265struct __cxx_atomic_base_impl {
266 _LIBCPP_HIDE_FROM_ABI
267# ifndef _LIBCPP_CXX03_LANG
268 __cxx_atomic_base_impl() _NOEXCEPT = default;
269# else
270 __cxx_atomic_base_impl() _NOEXCEPT : __a_value() {
271 }
272# endif // _LIBCPP_CXX03_LANG
273 _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp __value) _NOEXCEPT : __a_value(__value) {}
274 _LIBCPP_DISABLE_EXTENSION_WARNING _Atomic(_Tp) __a_value;
275};
276
277# define __cxx_atomic_is_lock_free(__s) __c11_atomic_is_lock_free(__s)
278
279_LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_thread_fence(memory_order __order) _NOEXCEPT {
280 __c11_atomic_thread_fence(static_cast<__memory_order_underlying_t>(__order));
281}
282
283_LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_signal_fence(memory_order __order) _NOEXCEPT {
284 __c11_atomic_signal_fence(static_cast<__memory_order_underlying_t>(__order));
285}
286
287template <class _Tp>
288_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val) _NOEXCEPT {
289 __c11_atomic_init(std::addressof(__a->__a_value), __val);
290}
291template <class _Tp>
292_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val) _NOEXCEPT {
293 __c11_atomic_init(std::addressof(__a->__a_value), __val);
294}
295
296template <class _Tp>
297_LIBCPP_HIDE_FROM_ABI void
298__cxx_atomic_store(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val, memory_order __order) _NOEXCEPT {
299 __c11_atomic_store(std::addressof(__a->__a_value), __val, static_cast<__memory_order_underlying_t>(__order));
300}
301template <class _Tp>
302_LIBCPP_HIDE_FROM_ABI void
303__cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) _NOEXCEPT {
304 __c11_atomic_store(std::addressof(__a->__a_value), __val, static_cast<__memory_order_underlying_t>(__order));
305}
306
307template <class _Tp>
308_LIBCPP_HIDE_FROM_ABI _Tp
309__cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const volatile* __a, memory_order __order) _NOEXCEPT {
310 using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;
311 return __c11_atomic_load(
312 const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order));
313}
314template <class _Tp>
315_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const* __a, memory_order __order) _NOEXCEPT {
316 using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;
317 return __c11_atomic_load(
318 const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order));
319}
320
321template <class _Tp>
322_LIBCPP_HIDE_FROM_ABI void
323__cxx_atomic_load_inplace(__cxx_atomic_base_impl<_Tp> const volatile* __a, _Tp* __dst, memory_order __order) _NOEXCEPT {
324 using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;
325 *__dst = __c11_atomic_load(
326 const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order));
327}
328template <class _Tp>
329_LIBCPP_HIDE_FROM_ABI void
330__cxx_atomic_load_inplace(__cxx_atomic_base_impl<_Tp> const* __a, _Tp* __dst, memory_order __order) _NOEXCEPT {
331 using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;
332 *__dst = __c11_atomic_load(
333 const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order));
334}
335
336template <class _Tp>
337_LIBCPP_HIDE_FROM_ABI _Tp
338__cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __value, memory_order __order) _NOEXCEPT {
339 return __c11_atomic_exchange(
340 std::addressof(__a->__a_value), __value, static_cast<__memory_order_underlying_t>(__order));
341}
342template <class _Tp>
343_LIBCPP_HIDE_FROM_ABI _Tp
344__cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) _NOEXCEPT {
345 return __c11_atomic_exchange(
346 std::addressof(__a->__a_value), __value, static_cast<__memory_order_underlying_t>(__order));
347}
348
349_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR memory_order __to_failure_order(memory_order __order) {
350 // Avoid switch statement to make this a constexpr.
351 return __order == memory_order_release
352 ? memory_order_relaxed
353 : (__order == memory_order_acq_rel ? memory_order_acquire : __order);
354}
355
356template <class _Tp>
357_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(
358 __cxx_atomic_base_impl<_Tp> volatile* __a,
359 _Tp* __expected,
360 _Tp __value,
361 memory_order __success,
362 memory_order __failure) _NOEXCEPT {
363 return __c11_atomic_compare_exchange_strong(
364 std::addressof(__a->__a_value),
365 __expected,
366 __value,
367 static_cast<__memory_order_underlying_t>(__success),
368 static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
369}
370template <class _Tp>
371_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(
372 __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure)
373 _NOEXCEPT {
374 return __c11_atomic_compare_exchange_strong(
375 std::addressof(__a->__a_value),
376 __expected,
377 __value,
378 static_cast<__memory_order_underlying_t>(__success),
379 static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
380}
381
382template <class _Tp>
383_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(
384 __cxx_atomic_base_impl<_Tp> volatile* __a,
385 _Tp* __expected,
386 _Tp __value,
387 memory_order __success,
388 memory_order __failure) _NOEXCEPT {
389 return __c11_atomic_compare_exchange_weak(
390 std::addressof(__a->__a_value),
391 __expected,
392 __value,
393 static_cast<__memory_order_underlying_t>(__success),
394 static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
395}
396template <class _Tp>
397_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(
398 __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure)
399 _NOEXCEPT {
400 return __c11_atomic_compare_exchange_weak(
401 std::addressof(__a->__a_value),
402 __expected,
403 __value,
404 static_cast<__memory_order_underlying_t>(__success),
405 static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
406}
407
408template <class _Tp>
409_LIBCPP_HIDE_FROM_ABI _Tp
410__cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
411 return __c11_atomic_fetch_add(
412 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
413}
414template <class _Tp>
415_LIBCPP_HIDE_FROM_ABI _Tp
416__cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
417 return __c11_atomic_fetch_add(
418 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
419}
420
421template <class _Tp>
422_LIBCPP_HIDE_FROM_ABI _Tp*
423__cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
424 return __c11_atomic_fetch_add(
425 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
426}
427template <class _Tp>
428_LIBCPP_HIDE_FROM_ABI _Tp*
429__cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
430 return __c11_atomic_fetch_add(
431 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
432}
433
434template <class _Tp>
435_LIBCPP_HIDE_FROM_ABI _Tp
436__cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
437 return __c11_atomic_fetch_sub(
438 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
439}
440template <class _Tp>
441_LIBCPP_HIDE_FROM_ABI _Tp
442__cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
443 return __c11_atomic_fetch_sub(
444 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
445}
446template <class _Tp>
447_LIBCPP_HIDE_FROM_ABI _Tp*
448__cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
449 return __c11_atomic_fetch_sub(
450 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
451}
452template <class _Tp>
453_LIBCPP_HIDE_FROM_ABI _Tp*
454__cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
455 return __c11_atomic_fetch_sub(
456 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
457}
458
459template <class _Tp>
460_LIBCPP_HIDE_FROM_ABI _Tp
461__cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
462 return __c11_atomic_fetch_and(
463 std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
464}
465template <class _Tp>
466_LIBCPP_HIDE_FROM_ABI _Tp
467__cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
468 return __c11_atomic_fetch_and(
469 std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
470}
471
472template <class _Tp>
473_LIBCPP_HIDE_FROM_ABI _Tp
474__cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
475 return __c11_atomic_fetch_or(
476 std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
477}
478template <class _Tp>
479_LIBCPP_HIDE_FROM_ABI _Tp
480__cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
481 return __c11_atomic_fetch_or(
482 std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
483}
484
485template <class _Tp>
486_LIBCPP_HIDE_FROM_ABI _Tp
487__cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
488 return __c11_atomic_fetch_xor(
489 std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
490}
491template <class _Tp>
492_LIBCPP_HIDE_FROM_ABI _Tp
493__cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
494 return __c11_atomic_fetch_xor(
495 std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
496}
497
498#endif // _LIBCPP_HAS_GCC_ATOMIC_IMP, _LIBCPP_HAS_C_ATOMIC_IMP
499
500template <typename _Tp, typename _Base = __cxx_atomic_base_impl<_Tp> >
501struct __cxx_atomic_impl : public _Base {
502 static_assert(is_trivially_copyable<_Tp>::value, "std::atomic<T> requires that 'T' be a trivially copyable type");
503
504 _LIBCPP_HIDE_FROM_ABI __cxx_atomic_impl() _NOEXCEPT = default;
505 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp __value) _NOEXCEPT : _Base(__value) {}
506};
507
508_LIBCPP_END_NAMESPACE_STD
509
510#endif // _LIBCPP___ATOMIC_CXX_ATOMIC_IMPL_H
lib/libcxx/include/__atomic/fence.h+1-1
...@@ -9,8 +9,8 @@...@@ -9,8 +9,8 @@
9#ifndef _LIBCPP___ATOMIC_FENCE_H9#ifndef _LIBCPP___ATOMIC_FENCE_H
10#define _LIBCPP___ATOMIC_FENCE_H10#define _LIBCPP___ATOMIC_FENCE_H
1111
12#include <__atomic/cxx_atomic_impl.h>
13#include <__atomic/memory_order.h>12#include <__atomic/memory_order.h>
13#include <__atomic/support.h>
14#include <__config>14#include <__config>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__atomic/memory_order.h+1-1
...@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
24// to pin the underlying type in C++20.24// to pin the underlying type in C++20.
25enum __legacy_memory_order { __mo_relaxed, __mo_consume, __mo_acquire, __mo_release, __mo_acq_rel, __mo_seq_cst };25enum __legacy_memory_order { __mo_relaxed, __mo_consume, __mo_acquire, __mo_release, __mo_acq_rel, __mo_seq_cst };
2626
27using __memory_order_underlying_t = underlying_type<__legacy_memory_order>::type;27using __memory_order_underlying_t _LIBCPP_NODEBUG = underlying_type<__legacy_memory_order>::type;
2828
29#if _LIBCPP_STD_VER >= 2029#if _LIBCPP_STD_VER >= 20
3030
lib/libcxx/include/__atomic/support.h created+124
...@@ -0,0 +1,124 @@
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___ATOMIC_SUPPORT_H
10#define _LIBCPP___ATOMIC_SUPPORT_H
11
12#include <__config>
13#include <__type_traits/is_trivially_copyable.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19//
20// This file implements base support for atomics on the platform.
21//
22// The following operations and types must be implemented (where _Atmc
23// is __cxx_atomic_base_impl for readability):
24//
25// clang-format off
26//
27// template <class _Tp>
28// struct __cxx_atomic_base_impl;
29//
30// #define __cxx_atomic_is_lock_free(__size)
31//
32// void __cxx_atomic_thread_fence(memory_order __order) noexcept;
33// void __cxx_atomic_signal_fence(memory_order __order) noexcept;
34//
35// template <class _Tp>
36// void __cxx_atomic_init(_Atmc<_Tp> volatile* __a, _Tp __val) noexcept;
37// template <class _Tp>
38// void __cxx_atomic_init(_Atmc<_Tp>* __a, _Tp __val) noexcept;
39//
40// template <class _Tp>
41// void __cxx_atomic_store(_Atmc<_Tp> volatile* __a, _Tp __val, memory_order __order) noexcept;
42// template <class _Tp>
43// void __cxx_atomic_store(_Atmc<_Tp>* __a, _Tp __val, memory_order __order) noexcept;
44//
45// template <class _Tp>
46// _Tp __cxx_atomic_load(_Atmc<_Tp> const volatile* __a, memory_order __order) noexcept;
47// template <class _Tp>
48// _Tp __cxx_atomic_load(_Atmc<_Tp> const* __a, memory_order __order) noexcept;
49//
50// template <class _Tp>
51// void __cxx_atomic_load_inplace(_Atmc<_Tp> const volatile* __a, _Tp* __dst, memory_order __order) noexcept;
52// template <class _Tp>
53// void __cxx_atomic_load_inplace(_Atmc<_Tp> const* __a, _Tp* __dst, memory_order __order) noexcept;
54//
55// template <class _Tp>
56// _Tp __cxx_atomic_exchange(_Atmc<_Tp> volatile* __a, _Tp __value, memory_order __order) noexcept;
57// template <class _Tp>
58// _Tp __cxx_atomic_exchange(_Atmc<_Tp>* __a, _Tp __value, memory_order __order) noexcept;
59//
60// template <class _Tp>
61// bool __cxx_atomic_compare_exchange_strong(_Atmc<_Tp> volatile* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) noexcept;
62// template <class _Tp>
63// bool __cxx_atomic_compare_exchange_strong(_Atmc<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) noexcept;
64//
65// template <class _Tp>
66// bool __cxx_atomic_compare_exchange_weak(_Atmc<_Tp> volatile* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) noexcept;
67// template <class _Tp>
68// bool __cxx_atomic_compare_exchange_weak(_Atmc<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) noexcept;
69//
70// template <class _Tp>
71// _Tp __cxx_atomic_fetch_add(_Atmc<_Tp> volatile* __a, _Tp __delta, memory_order __order) noexcept;
72// template <class _Tp>
73// _Tp __cxx_atomic_fetch_add(_Atmc<_Tp>* __a, _Tp __delta, memory_order __order) noexcept;
74//
75// template <class _Tp>
76// _Tp* __cxx_atomic_fetch_add(_Atmc<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) noexcept;
77// template <class _Tp>
78// _Tp* __cxx_atomic_fetch_add(_Atmc<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) noexcept;
79//
80// template <class _Tp>
81// _Tp __cxx_atomic_fetch_sub(_Atmc<_Tp> volatile* __a, _Tp __delta, memory_order __order) noexcept;
82// template <class _Tp>
83// _Tp __cxx_atomic_fetch_sub(_Atmc<_Tp>* __a, _Tp __delta, memory_order __order) noexcept;
84// template <class _Tp>
85// _Tp* __cxx_atomic_fetch_sub(_Atmc<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) noexcept;
86// template <class _Tp>
87// _Tp* __cxx_atomic_fetch_sub(_Atmc<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) noexcept;
88//
89// template <class _Tp>
90// _Tp __cxx_atomic_fetch_and(_Atmc<_Tp> volatile* __a, _Tp __pattern, memory_order __order) noexcept;
91// template <class _Tp>
92// _Tp __cxx_atomic_fetch_and(_Atmc<_Tp>* __a, _Tp __pattern, memory_order __order) noexcept;
93//
94// template <class _Tp>
95// _Tp __cxx_atomic_fetch_or(_Atmc<_Tp> volatile* __a, _Tp __pattern, memory_order __order) noexcept;
96// template <class _Tp>
97// _Tp __cxx_atomic_fetch_or(_Atmc<_Tp>* __a, _Tp __pattern, memory_order __order) noexcept;
98// template <class _Tp>
99// _Tp __cxx_atomic_fetch_xor(_Atmc<_Tp> volatile* __a, _Tp __pattern, memory_order __order) noexcept;
100// template <class _Tp>
101// _Tp __cxx_atomic_fetch_xor(_Atmc<_Tp>* __a, _Tp __pattern, memory_order __order) noexcept;
102//
103// clang-format on
104//
105
106#if _LIBCPP_HAS_GCC_ATOMIC_IMP
107# include <__atomic/support/gcc.h>
108#elif _LIBCPP_HAS_C_ATOMIC_IMP
109# include <__atomic/support/c11.h>
110#endif
111
112_LIBCPP_BEGIN_NAMESPACE_STD
113
114template <typename _Tp, typename _Base = __cxx_atomic_base_impl<_Tp> >
115struct __cxx_atomic_impl : public _Base {
116 static_assert(is_trivially_copyable<_Tp>::value, "std::atomic<T> requires that 'T' be a trivially copyable type");
117
118 _LIBCPP_HIDE_FROM_ABI __cxx_atomic_impl() _NOEXCEPT = default;
119 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp __value) _NOEXCEPT : _Base(__value) {}
120};
121
122_LIBCPP_END_NAMESPACE_STD
123
124#endif // _LIBCPP___ATOMIC_SUPPORT_H
lib/libcxx/include/__atomic/support/c11.h created+264
...@@ -0,0 +1,264 @@
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___ATOMIC_SUPPORT_C11_H
10#define _LIBCPP___ATOMIC_SUPPORT_C11_H
11
12#include <__atomic/memory_order.h>
13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
15#include <__memory/addressof.h>
16#include <__type_traits/remove_const.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22//
23// This file implements support for C11-style atomics
24//
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28template <typename _Tp>
29struct __cxx_atomic_base_impl {
30 _LIBCPP_HIDE_FROM_ABI
31#ifndef _LIBCPP_CXX03_LANG
32 __cxx_atomic_base_impl() _NOEXCEPT = default;
33#else
34 __cxx_atomic_base_impl() _NOEXCEPT : __a_value() {
35 }
36#endif // _LIBCPP_CXX03_LANG
37 _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp __value) _NOEXCEPT : __a_value(__value) {}
38 _LIBCPP_DISABLE_EXTENSION_WARNING _Atomic(_Tp) __a_value;
39};
40
41#define __cxx_atomic_is_lock_free(__s) __c11_atomic_is_lock_free(__s)
42
43_LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_thread_fence(memory_order __order) _NOEXCEPT {
44 __c11_atomic_thread_fence(static_cast<__memory_order_underlying_t>(__order));
45}
46
47_LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_signal_fence(memory_order __order) _NOEXCEPT {
48 __c11_atomic_signal_fence(static_cast<__memory_order_underlying_t>(__order));
49}
50
51template <class _Tp>
52_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val) _NOEXCEPT {
53 __c11_atomic_init(std::addressof(__a->__a_value), __val);
54}
55template <class _Tp>
56_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val) _NOEXCEPT {
57 __c11_atomic_init(std::addressof(__a->__a_value), __val);
58}
59
60template <class _Tp>
61_LIBCPP_HIDE_FROM_ABI void
62__cxx_atomic_store(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val, memory_order __order) _NOEXCEPT {
63 __c11_atomic_store(std::addressof(__a->__a_value), __val, static_cast<__memory_order_underlying_t>(__order));
64}
65template <class _Tp>
66_LIBCPP_HIDE_FROM_ABI void
67__cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) _NOEXCEPT {
68 __c11_atomic_store(std::addressof(__a->__a_value), __val, static_cast<__memory_order_underlying_t>(__order));
69}
70
71template <class _Tp>
72_LIBCPP_HIDE_FROM_ABI _Tp
73__cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const volatile* __a, memory_order __order) _NOEXCEPT {
74 using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;
75 return __c11_atomic_load(
76 const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order));
77}
78template <class _Tp>
79_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const* __a, memory_order __order) _NOEXCEPT {
80 using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;
81 return __c11_atomic_load(
82 const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order));
83}
84
85template <class _Tp>
86_LIBCPP_HIDE_FROM_ABI void
87__cxx_atomic_load_inplace(__cxx_atomic_base_impl<_Tp> const volatile* __a, _Tp* __dst, memory_order __order) _NOEXCEPT {
88 using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;
89 *__dst = __c11_atomic_load(
90 const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order));
91}
92template <class _Tp>
93_LIBCPP_HIDE_FROM_ABI void
94__cxx_atomic_load_inplace(__cxx_atomic_base_impl<_Tp> const* __a, _Tp* __dst, memory_order __order) _NOEXCEPT {
95 using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;
96 *__dst = __c11_atomic_load(
97 const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order));
98}
99
100template <class _Tp>
101_LIBCPP_HIDE_FROM_ABI _Tp
102__cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __value, memory_order __order) _NOEXCEPT {
103 return __c11_atomic_exchange(
104 std::addressof(__a->__a_value), __value, static_cast<__memory_order_underlying_t>(__order));
105}
106template <class _Tp>
107_LIBCPP_HIDE_FROM_ABI _Tp
108__cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) _NOEXCEPT {
109 return __c11_atomic_exchange(
110 std::addressof(__a->__a_value), __value, static_cast<__memory_order_underlying_t>(__order));
111}
112
113_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR memory_order __to_failure_order(memory_order __order) {
114 // Avoid switch statement to make this a constexpr.
115 return __order == memory_order_release
116 ? memory_order_relaxed
117 : (__order == memory_order_acq_rel ? memory_order_acquire : __order);
118}
119
120template <class _Tp>
121_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(
122 __cxx_atomic_base_impl<_Tp> volatile* __a,
123 _Tp* __expected,
124 _Tp __value,
125 memory_order __success,
126 memory_order __failure) _NOEXCEPT {
127 return __c11_atomic_compare_exchange_strong(
128 std::addressof(__a->__a_value),
129 __expected,
130 __value,
131 static_cast<__memory_order_underlying_t>(__success),
132 static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
133}
134template <class _Tp>
135_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(
136 __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure)
137 _NOEXCEPT {
138 return __c11_atomic_compare_exchange_strong(
139 std::addressof(__a->__a_value),
140 __expected,
141 __value,
142 static_cast<__memory_order_underlying_t>(__success),
143 static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
144}
145
146template <class _Tp>
147_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(
148 __cxx_atomic_base_impl<_Tp> volatile* __a,
149 _Tp* __expected,
150 _Tp __value,
151 memory_order __success,
152 memory_order __failure) _NOEXCEPT {
153 return __c11_atomic_compare_exchange_weak(
154 std::addressof(__a->__a_value),
155 __expected,
156 __value,
157 static_cast<__memory_order_underlying_t>(__success),
158 static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
159}
160template <class _Tp>
161_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(
162 __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure)
163 _NOEXCEPT {
164 return __c11_atomic_compare_exchange_weak(
165 std::addressof(__a->__a_value),
166 __expected,
167 __value,
168 static_cast<__memory_order_underlying_t>(__success),
169 static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
170}
171
172template <class _Tp>
173_LIBCPP_HIDE_FROM_ABI _Tp
174__cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
175 return __c11_atomic_fetch_add(
176 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
177}
178template <class _Tp>
179_LIBCPP_HIDE_FROM_ABI _Tp
180__cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
181 return __c11_atomic_fetch_add(
182 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
183}
184
185template <class _Tp>
186_LIBCPP_HIDE_FROM_ABI _Tp*
187__cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
188 return __c11_atomic_fetch_add(
189 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
190}
191template <class _Tp>
192_LIBCPP_HIDE_FROM_ABI _Tp*
193__cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
194 return __c11_atomic_fetch_add(
195 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
196}
197
198template <class _Tp>
199_LIBCPP_HIDE_FROM_ABI _Tp
200__cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
201 return __c11_atomic_fetch_sub(
202 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
203}
204template <class _Tp>
205_LIBCPP_HIDE_FROM_ABI _Tp
206__cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
207 return __c11_atomic_fetch_sub(
208 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
209}
210template <class _Tp>
211_LIBCPP_HIDE_FROM_ABI _Tp*
212__cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
213 return __c11_atomic_fetch_sub(
214 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
215}
216template <class _Tp>
217_LIBCPP_HIDE_FROM_ABI _Tp*
218__cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
219 return __c11_atomic_fetch_sub(
220 std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order));
221}
222
223template <class _Tp>
224_LIBCPP_HIDE_FROM_ABI _Tp
225__cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
226 return __c11_atomic_fetch_and(
227 std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
228}
229template <class _Tp>
230_LIBCPP_HIDE_FROM_ABI _Tp
231__cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
232 return __c11_atomic_fetch_and(
233 std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
234}
235
236template <class _Tp>
237_LIBCPP_HIDE_FROM_ABI _Tp
238__cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
239 return __c11_atomic_fetch_or(
240 std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
241}
242template <class _Tp>
243_LIBCPP_HIDE_FROM_ABI _Tp
244__cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
245 return __c11_atomic_fetch_or(
246 std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
247}
248
249template <class _Tp>
250_LIBCPP_HIDE_FROM_ABI _Tp
251__cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
252 return __c11_atomic_fetch_xor(
253 std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
254}
255template <class _Tp>
256_LIBCPP_HIDE_FROM_ABI _Tp
257__cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
258 return __c11_atomic_fetch_xor(
259 std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
260}
261
262_LIBCPP_END_NAMESPACE_STD
263
264#endif // _LIBCPP___ATOMIC_SUPPORT_C11_H
lib/libcxx/include/__atomic/support/gcc.h created+265
...@@ -0,0 +1,265 @@
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___ATOMIC_SUPPORT_GCC_H
10#define _LIBCPP___ATOMIC_SUPPORT_GCC_H
11
12#include <__atomic/memory_order.h>
13#include <__atomic/to_gcc_order.h>
14#include <__config>
15#include <__memory/addressof.h>
16#include <__type_traits/enable_if.h>
17#include <__type_traits/is_assignable.h>
18#include <__type_traits/remove_const.h>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24//
25// This file implements support for GCC-style atomics
26//
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30// [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because
31// the default operator= in an object is not volatile, a byte-by-byte copy
32// is required.
33template <typename _Tp, typename _Tv, __enable_if_t<is_assignable<_Tp&, _Tv>::value, int> = 0>
34_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp& __a_value, _Tv const& __val) {
35 __a_value = __val;
36}
37template <typename _Tp, typename _Tv, __enable_if_t<is_assignable<_Tp&, _Tv>::value, int> = 0>
38_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp volatile& __a_value, _Tv volatile const& __val) {
39 volatile char* __to = reinterpret_cast<volatile char*>(std::addressof(__a_value));
40 volatile char* __end = __to + sizeof(_Tp);
41 volatile const char* __from = reinterpret_cast<volatile const char*>(std::addressof(__val));
42 while (__to != __end)
43 *__to++ = *__from++;
44}
45
46template <typename _Tp>
47struct __cxx_atomic_base_impl {
48 _LIBCPP_HIDE_FROM_ABI
49#ifndef _LIBCPP_CXX03_LANG
50 __cxx_atomic_base_impl() _NOEXCEPT = default;
51#else
52 __cxx_atomic_base_impl() _NOEXCEPT : __a_value() {
53 }
54#endif // _LIBCPP_CXX03_LANG
55 _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp value) _NOEXCEPT : __a_value(value) {}
56 _Tp __a_value;
57};
58
59template <typename _Tp>
60_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val) {
61 __cxx_atomic_assign_volatile(__a->__a_value, __val);
62}
63
64template <typename _Tp>
65_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val) {
66 __a->__a_value = __val;
67}
68
69_LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_thread_fence(memory_order __order) {
70 __atomic_thread_fence(__to_gcc_order(__order));
71}
72
73_LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_signal_fence(memory_order __order) {
74 __atomic_signal_fence(__to_gcc_order(__order));
75}
76
77template <typename _Tp>
78_LIBCPP_HIDE_FROM_ABI void
79__cxx_atomic_store(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) {
80 __atomic_store(std::addressof(__a->__a_value), std::addressof(__val), __to_gcc_order(__order));
81}
82
83template <typename _Tp>
84_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) {
85 __atomic_store(std::addressof(__a->__a_value), std::addressof(__val), __to_gcc_order(__order));
86}
87
88template <typename _Tp>
89_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const volatile __cxx_atomic_base_impl<_Tp>* __a, memory_order __order) {
90 _Tp __ret;
91 __atomic_load(std::addressof(__a->__a_value), std::addressof(__ret), __to_gcc_order(__order));
92 return __ret;
93}
94
95template <typename _Tp>
96_LIBCPP_HIDE_FROM_ABI void
97__cxx_atomic_load_inplace(const volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp* __dst, memory_order __order) {
98 __atomic_load(std::addressof(__a->__a_value), __dst, __to_gcc_order(__order));
99}
100
101template <typename _Tp>
102_LIBCPP_HIDE_FROM_ABI void
103__cxx_atomic_load_inplace(const __cxx_atomic_base_impl<_Tp>* __a, _Tp* __dst, memory_order __order) {
104 __atomic_load(std::addressof(__a->__a_value), __dst, __to_gcc_order(__order));
105}
106
107template <typename _Tp>
108_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const __cxx_atomic_base_impl<_Tp>* __a, memory_order __order) {
109 _Tp __ret;
110 __atomic_load(std::addressof(__a->__a_value), std::addressof(__ret), __to_gcc_order(__order));
111 return __ret;
112}
113
114template <typename _Tp>
115_LIBCPP_HIDE_FROM_ABI _Tp
116__cxx_atomic_exchange(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) {
117 _Tp __ret;
118 __atomic_exchange(
119 std::addressof(__a->__a_value), std::addressof(__value), std::addressof(__ret), __to_gcc_order(__order));
120 return __ret;
121}
122
123template <typename _Tp>
124_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) {
125 _Tp __ret;
126 __atomic_exchange(
127 std::addressof(__a->__a_value), std::addressof(__value), std::addressof(__ret), __to_gcc_order(__order));
128 return __ret;
129}
130
131template <typename _Tp>
132_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(
133 volatile __cxx_atomic_base_impl<_Tp>* __a,
134 _Tp* __expected,
135 _Tp __value,
136 memory_order __success,
137 memory_order __failure) {
138 return __atomic_compare_exchange(
139 std::addressof(__a->__a_value),
140 __expected,
141 std::addressof(__value),
142 false,
143 __to_gcc_order(__success),
144 __to_gcc_failure_order(__failure));
145}
146
147template <typename _Tp>
148_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(
149 __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) {
150 return __atomic_compare_exchange(
151 std::addressof(__a->__a_value),
152 __expected,
153 std::addressof(__value),
154 false,
155 __to_gcc_order(__success),
156 __to_gcc_failure_order(__failure));
157}
158
159template <typename _Tp>
160_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(
161 volatile __cxx_atomic_base_impl<_Tp>* __a,
162 _Tp* __expected,
163 _Tp __value,
164 memory_order __success,
165 memory_order __failure) {
166 return __atomic_compare_exchange(
167 std::addressof(__a->__a_value),
168 __expected,
169 std::addressof(__value),
170 true,
171 __to_gcc_order(__success),
172 __to_gcc_failure_order(__failure));
173}
174
175template <typename _Tp>
176_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(
177 __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) {
178 return __atomic_compare_exchange(
179 std::addressof(__a->__a_value),
180 __expected,
181 std::addressof(__value),
182 true,
183 __to_gcc_order(__success),
184 __to_gcc_failure_order(__failure));
185}
186
187template <typename _Tp>
188struct __skip_amt {
189 enum { value = 1 };
190};
191
192template <typename _Tp>
193struct __skip_amt<_Tp*> {
194 enum { value = sizeof(_Tp) };
195};
196
197// FIXME: Haven't figured out what the spec says about using arrays with
198// atomic_fetch_add. Force a failure rather than creating bad behavior.
199template <typename _Tp>
200struct __skip_amt<_Tp[]> {};
201template <typename _Tp, int n>
202struct __skip_amt<_Tp[n]> {};
203
204template <typename _Tp, typename _Td>
205_LIBCPP_HIDE_FROM_ABI _Tp
206__cxx_atomic_fetch_add(volatile __cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) {
207 return __atomic_fetch_add(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order));
208}
209
210template <typename _Tp, typename _Td>
211_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) {
212 return __atomic_fetch_add(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order));
213}
214
215template <typename _Tp, typename _Td>
216_LIBCPP_HIDE_FROM_ABI _Tp
217__cxx_atomic_fetch_sub(volatile __cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) {
218 return __atomic_fetch_sub(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order));
219}
220
221template <typename _Tp, typename _Td>
222_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) {
223 return __atomic_fetch_sub(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order));
224}
225
226template <typename _Tp>
227_LIBCPP_HIDE_FROM_ABI _Tp
228__cxx_atomic_fetch_and(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {
229 return __atomic_fetch_and(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));
230}
231
232template <typename _Tp>
233_LIBCPP_HIDE_FROM_ABI _Tp
234__cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {
235 return __atomic_fetch_and(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));
236}
237
238template <typename _Tp>
239_LIBCPP_HIDE_FROM_ABI _Tp
240__cxx_atomic_fetch_or(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {
241 return __atomic_fetch_or(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));
242}
243
244template <typename _Tp>
245_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {
246 return __atomic_fetch_or(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));
247}
248
249template <typename _Tp>
250_LIBCPP_HIDE_FROM_ABI _Tp
251__cxx_atomic_fetch_xor(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {
252 return __atomic_fetch_xor(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));
253}
254
255template <typename _Tp>
256_LIBCPP_HIDE_FROM_ABI _Tp
257__cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) {
258 return __atomic_fetch_xor(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order));
259}
260
261#define __cxx_atomic_is_lock_free(__s) __atomic_is_lock_free(__s, 0)
262
263_LIBCPP_END_NAMESPACE_STD
264
265#endif // _LIBCPP___ATOMIC_SUPPORT_GCC_H
lib/libcxx/include/__bit/bit_cast.h+1-1
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#ifndef _LIBCPP_CXX03_LANG22#ifndef _LIBCPP_CXX03_LANG
2323
24template <class _ToType, class _FromType>24template <class _ToType, class _FromType>
25_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr _ToType __bit_cast(const _FromType& __from) noexcept {25[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr _ToType __bit_cast(const _FromType& __from) noexcept {
26 return __builtin_bit_cast(_ToType, __from);26 return __builtin_bit_cast(_ToType, __from);
27}27}
2828
lib/libcxx/include/__bit/bit_log2.h+6-5
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___BIT_BIT_LOG2_H10#define _LIBCPP___BIT_BIT_LOG2_H
1111
12#include <__bit/countl.h>12#include <__bit/countl.h>
13#include <__concepts/arithmetic.h>
14#include <__config>13#include <__config>
14#include <__type_traits/is_unsigned_integer.h>
15#include <limits>15#include <limits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -20,14 +20,15 @@...@@ -20,14 +20,15 @@
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER >= 2023#if _LIBCPP_STD_VER >= 14
2424
25template <__libcpp_unsigned_integer _Tp>25template <class _Tp>
26_LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_log2(_Tp __t) noexcept {26_LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_log2(_Tp __t) noexcept {
27 return numeric_limits<_Tp>::digits - 1 - std::countl_zero(__t);27 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__bit_log2 requires an unsigned integer type");
28 return numeric_limits<_Tp>::digits - 1 - std::__countl_zero(__t);
28}29}
2930
30#endif // _LIBCPP_STD_VER >= 2031#endif // _LIBCPP_STD_VER >= 14
3132
32_LIBCPP_END_NAMESPACE_STD33_LIBCPP_END_NAMESPACE_STD
3334
lib/libcxx/include/__bit/byteswap.h+2-2
...@@ -32,7 +32,7 @@ template <integral _Tp>...@@ -32,7 +32,7 @@ template <integral _Tp>
32 return __builtin_bswap32(__val);32 return __builtin_bswap32(__val);
33 } else if constexpr (sizeof(_Tp) == 8) {33 } else if constexpr (sizeof(_Tp) == 8) {
34 return __builtin_bswap64(__val);34 return __builtin_bswap64(__val);
35# ifndef _LIBCPP_HAS_NO_INT12835# if _LIBCPP_HAS_INT128
36 } else if constexpr (sizeof(_Tp) == 16) {36 } else if constexpr (sizeof(_Tp) == 16) {
37# if __has_builtin(__builtin_bswap128)37# if __has_builtin(__builtin_bswap128)
38 return __builtin_bswap128(__val);38 return __builtin_bswap128(__val);
...@@ -40,7 +40,7 @@ template <integral _Tp>...@@ -40,7 +40,7 @@ template <integral _Tp>
40 return static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val))) << 64 |40 return static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val))) << 64 |
41 static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val >> 64)));41 static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val >> 64)));
42# endif // __has_builtin(__builtin_bswap128)42# endif // __has_builtin(__builtin_bswap128)
43# endif // _LIBCPP_HAS_NO_INT12843# endif // _LIBCPP_HAS_INT128
44 } else {44 } else {
45 static_assert(sizeof(_Tp) == 0, "byteswap is unimplemented for integral types of this size");45 static_assert(sizeof(_Tp) == 0, "byteswap is unimplemented for integral types of this size");
46 }46 }
lib/libcxx/include/__bit/countl.h+5-5
...@@ -27,19 +27,19 @@ _LIBCPP_PUSH_MACROS...@@ -27,19 +27,19 @@ _LIBCPP_PUSH_MACROS
2727
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
30_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned __x) _NOEXCEPT {30[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned __x) _NOEXCEPT {
31 return __builtin_clz(__x);31 return __builtin_clz(__x);
32}32}
3333
34_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long __x) _NOEXCEPT {34[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long __x) _NOEXCEPT {
35 return __builtin_clzl(__x);35 return __builtin_clzl(__x);
36}36}
3737
38_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long long __x) _NOEXCEPT {38[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long long __x) _NOEXCEPT {
39 return __builtin_clzll(__x);39 return __builtin_clzll(__x);
40}40}
4141
42#ifndef _LIBCPP_HAS_NO_INT12842#if _LIBCPP_HAS_INT128
43inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x) _NOEXCEPT {43inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x) _NOEXCEPT {
44# if __has_builtin(__builtin_clzg)44# if __has_builtin(__builtin_clzg)
45 return __builtin_clzg(__x);45 return __builtin_clzg(__x);
...@@ -57,7 +57,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x)...@@ -57,7 +57,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x)
57 : __builtin_clzll(static_cast<unsigned long long>(__x >> 64));57 : __builtin_clzll(static_cast<unsigned long long>(__x >> 64));
58# endif58# endif
59}59}
60#endif // _LIBCPP_HAS_NO_INT12860#endif // _LIBCPP_HAS_INT128
6161
62template <class _Tp>62template <class _Tp>
63_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT {63_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT {
lib/libcxx/include/__bit/countr.h+4-4
...@@ -26,20 +26,20 @@ _LIBCPP_PUSH_MACROS...@@ -26,20 +26,20 @@ _LIBCPP_PUSH_MACROS
2626
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2828
29_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned __x) _NOEXCEPT {29[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned __x) _NOEXCEPT {
30 return __builtin_ctz(__x);30 return __builtin_ctz(__x);
31}31}
3232
33_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long __x) _NOEXCEPT {33[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long __x) _NOEXCEPT {
34 return __builtin_ctzl(__x);34 return __builtin_ctzl(__x);
35}35}
3636
37_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long long __x) _NOEXCEPT {37[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long long __x) _NOEXCEPT {
38 return __builtin_ctzll(__x);38 return __builtin_ctzll(__x);
39}39}
4040
41template <class _Tp>41template <class _Tp>
42_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero(_Tp __t) _NOEXCEPT {42[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero(_Tp __t) _NOEXCEPT {
43#if __has_builtin(__builtin_ctzg)43#if __has_builtin(__builtin_ctzg)
44 return __builtin_ctzg(__t, numeric_limits<_Tp>::digits);44 return __builtin_ctzg(__t, numeric_limits<_Tp>::digits);
45#else // __has_builtin(__builtin_ctzg)45#else // __has_builtin(__builtin_ctzg)
lib/libcxx/include/__bit/rotate.h+8-8
...@@ -26,31 +26,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,31 +26,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD
26template <class _Tp>26template <class _Tp>
27_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) _NOEXCEPT {27_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) _NOEXCEPT {
28 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type");28 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type");
29 const int __N = numeric_limits<_Tp>::digits;29 const int __n = numeric_limits<_Tp>::digits;
30 int __r = __s % __N;30 int __r = __s % __n;
3131
32 if (__r == 0)32 if (__r == 0)
33 return __x;33 return __x;
3434
35 if (__r > 0)35 if (__r > 0)
36 return (__x << __r) | (__x >> (__N - __r));36 return (__x << __r) | (__x >> (__n - __r));
3737
38 return (__x >> -__r) | (__x << (__N + __r));38 return (__x >> -__r) | (__x << (__n + __r));
39}39}
4040
41template <class _Tp>41template <class _Tp>
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) _NOEXCEPT {42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) _NOEXCEPT {
43 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");43 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");
44 const int __N = numeric_limits<_Tp>::digits;44 const int __n = numeric_limits<_Tp>::digits;
45 int __r = __s % __N;45 int __r = __s % __n;
4646
47 if (__r == 0)47 if (__r == 0)
48 return __x;48 return __x;
4949
50 if (__r > 0)50 if (__r > 0)
51 return (__x >> __r) | (__x << (__N - __r));51 return (__x >> __r) | (__x << (__n - __r));
5252
53 return (__x << -__r) | (__x >> (__N + __r));53 return (__x << -__r) | (__x >> (__n + __r));
54}54}
5555
56#if _LIBCPP_STD_VER >= 2056#if _LIBCPP_STD_VER >= 20
lib/libcxx/include/__bit_reference+33-21
...@@ -11,20 +11,20 @@...@@ -11,20 +11,20 @@
11#define _LIBCPP___BIT_REFERENCE11#define _LIBCPP___BIT_REFERENCE
1212
13#include <__algorithm/copy_n.h>13#include <__algorithm/copy_n.h>
14#include <__algorithm/fill_n.h>
15#include <__algorithm/min.h>14#include <__algorithm/min.h>
16#include <__bit/countr.h>15#include <__bit/countr.h>
17#include <__bit/invert_if.h>
18#include <__bit/popcount.h>
19#include <__compare/ordering.h>16#include <__compare/ordering.h>
20#include <__config>17#include <__config>
18#include <__cstddef/ptrdiff_t.h>
19#include <__cstddef/size_t.h>
21#include <__fwd/bit_reference.h>20#include <__fwd/bit_reference.h>
22#include <__iterator/iterator_traits.h>21#include <__iterator/iterator_traits.h>
23#include <__memory/construct_at.h>22#include <__memory/construct_at.h>
24#include <__memory/pointer_traits.h>23#include <__memory/pointer_traits.h>
25#include <__type_traits/conditional.h>24#include <__type_traits/conditional.h>
25#include <__type_traits/is_constant_evaluated.h>
26#include <__type_traits/void_t.h>
26#include <__utility/swap.h>27#include <__utility/swap.h>
27#include <cstring>
2828
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header30# pragma GCC system_header
...@@ -43,10 +43,22 @@ struct __has_storage_type {...@@ -43,10 +43,22 @@ struct __has_storage_type {
43 static const bool value = false;43 static const bool value = false;
44};44};
4545
46template <class, class>
47struct __size_difference_type_traits {
48 using difference_type = ptrdiff_t;
49 using size_type = size_t;
50};
51
52template <class _Cp>
53struct __size_difference_type_traits<_Cp, __void_t<typename _Cp::difference_type, typename _Cp::size_type> > {
54 using difference_type = typename _Cp::difference_type;
55 using size_type = typename _Cp::size_type;
56};
57
46template <class _Cp, bool = __has_storage_type<_Cp>::value>58template <class _Cp, bool = __has_storage_type<_Cp>::value>
47class __bit_reference {59class __bit_reference {
48 using __storage_type = typename _Cp::__storage_type;60 using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type;
49 using __storage_pointer = typename _Cp::__storage_pointer;61 using __storage_pointer _LIBCPP_NODEBUG = typename _Cp::__storage_pointer;
5062
51 __storage_pointer __seg_;63 __storage_pointer __seg_;
52 __storage_type __mask_;64 __storage_type __mask_;
...@@ -57,7 +69,7 @@ class __bit_reference {...@@ -57,7 +69,7 @@ class __bit_reference {
57 friend class __bit_iterator<_Cp, false>;69 friend class __bit_iterator<_Cp, false>;
5870
59public:71public:
60 using __container = typename _Cp::__self;72 using __container _LIBCPP_NODEBUG = typename _Cp::__self;
6173
62 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_reference(const __bit_reference&) = default;74 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_reference(const __bit_reference&) = default;
6375
...@@ -137,8 +149,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(bool& __x,...@@ -137,8 +149,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(bool& __x,
137149
138template <class _Cp>150template <class _Cp>
139class __bit_const_reference {151class __bit_const_reference {
140 using __storage_type = typename _Cp::__storage_type;152 using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type;
141 using __storage_pointer = typename _Cp::__const_storage_pointer;153 using __storage_pointer _LIBCPP_NODEBUG = typename _Cp::__const_storage_pointer;
142154
143 __storage_pointer __seg_;155 __storage_pointer __seg_;
144 __storage_type __mask_;156 __storage_type __mask_;
...@@ -147,7 +159,7 @@ class __bit_const_reference {...@@ -147,7 +159,7 @@ class __bit_const_reference {
147 friend class __bit_iterator<_Cp, true>;159 friend class __bit_iterator<_Cp, true>;
148160
149public:161public:
150 using __container = typename _Cp::__self;162 using __container _LIBCPP_NODEBUG = typename _Cp::__self;
151163
152 _LIBCPP_HIDE_FROM_ABI __bit_const_reference(const __bit_const_reference&) = default;164 _LIBCPP_HIDE_FROM_ABI __bit_const_reference(const __bit_const_reference&) = default;
153 __bit_const_reference& operator=(const __bit_const_reference&) = delete;165 __bit_const_reference& operator=(const __bit_const_reference&) = delete;
...@@ -589,10 +601,10 @@ inline _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> swap_ranges(...@@ -589,10 +601,10 @@ inline _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> swap_ranges(
589601
590template <class _Cp>602template <class _Cp>
591struct __bit_array {603struct __bit_array {
592 using difference_type = typename _Cp::difference_type;604 using difference_type _LIBCPP_NODEBUG = typename __size_difference_type_traits<_Cp>::difference_type;
593 using __storage_type = typename _Cp::__storage_type;605 using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type;
594 using __storage_pointer = typename _Cp::__storage_pointer;606 using __storage_pointer _LIBCPP_NODEBUG = typename _Cp::__storage_pointer;
595 using iterator = typename _Cp::iterator;607 using iterator _LIBCPP_NODEBUG = typename _Cp::iterator;
596608
597 static const unsigned __bits_per_word = _Cp::__bits_per_word;609 static const unsigned __bits_per_word = _Cp::__bits_per_word;
598 static const unsigned _Np = 4;610 static const unsigned _Np = 4;
...@@ -781,7 +793,7 @@ equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __b...@@ -781,7 +793,7 @@ equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __b
781template <class _Cp, bool _IsConst, typename _Cp::__storage_type>793template <class _Cp, bool _IsConst, typename _Cp::__storage_type>
782class __bit_iterator {794class __bit_iterator {
783public:795public:
784 using difference_type = typename _Cp::difference_type;796 using difference_type = typename __size_difference_type_traits<_Cp>::difference_type;
785 using value_type = bool;797 using value_type = bool;
786 using pointer = __bit_iterator;798 using pointer = __bit_iterator;
787#ifndef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL799#ifndef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
...@@ -792,8 +804,8 @@ public:...@@ -792,8 +804,8 @@ public:
792 using iterator_category = random_access_iterator_tag;804 using iterator_category = random_access_iterator_tag;
793805
794private:806private:
795 using __storage_type = typename _Cp::__storage_type;807 using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type;
796 using __storage_pointer =808 using __storage_pointer _LIBCPP_NODEBUG =
797 __conditional_t<_IsConst, typename _Cp::__const_storage_pointer, typename _Cp::__storage_pointer>;809 __conditional_t<_IsConst, typename _Cp::__const_storage_pointer, typename _Cp::__storage_pointer>;
798810
799 static const unsigned __bits_per_word = _Cp::__bits_per_word;811 static const unsigned __bits_per_word = _Cp::__bits_per_word;
...@@ -968,7 +980,7 @@ private:...@@ -968,7 +980,7 @@ private:
968980
969 template <bool _FillVal, class _Dp>981 template <bool _FillVal, class _Dp>
970 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend void982 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend void
971 __fill_n_bool(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);983 __fill_n_bool(__bit_iterator<_Dp, false> __first, typename __size_difference_type_traits<_Dp>::size_type __n);
972984
973 template <class _Dp, bool _IC>985 template <class _Dp, bool _IC>
974 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_aligned(986 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_aligned(
...@@ -1011,10 +1023,10 @@ private:...@@ -1011,10 +1023,10 @@ private:
1011 equal(__bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC2>);1023 equal(__bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC2>);
1012 template <bool _ToFind, class _Dp, bool _IC>1024 template <bool _ToFind, class _Dp, bool _IC>
1013 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, _IC>1025 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, _IC>
1014 __find_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);1026 __find_bool(__bit_iterator<_Dp, _IC>, typename __size_difference_type_traits<_Dp>::size_type);
1015 template <bool _ToCount, class _Dp, bool _IC>1027 template <bool _ToCount, class _Dp, bool _IC>
1016 friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI1028 friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1017 _LIBCPP_CONSTEXPR_SINCE_CXX20 __count_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);1029 __count_bool(__bit_iterator<_Dp, _IC>, typename __size_difference_type_traits<_Dp>::size_type);
1018};1030};
10191031
1020_LIBCPP_END_NAMESPACE_STD1032_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__charconv/from_chars_floating_point.h created+73
...@@ -0,0 +1,73 @@
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___CHARCONV_FROM_CHARS_FLOATING_POINT_H
11#define _LIBCPP___CHARCONV_FROM_CHARS_FLOATING_POINT_H
12
13#include <__assert>
14#include <__charconv/chars_format.h>
15#include <__charconv/from_chars_result.h>
16#include <__config>
17#include <__cstddef/ptrdiff_t.h>
18#include <__system_error/errc.h>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24_LIBCPP_PUSH_MACROS
25#include <__undef_macros>
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29#if _LIBCPP_STD_VER >= 17
30
31template <class _Fp>
32struct __from_chars_result {
33 _Fp __value;
34 ptrdiff_t __n;
35 errc __ec;
36};
37
38template <class _Fp>
39_LIBCPP_EXPORTED_FROM_ABI __from_chars_result<_Fp> __from_chars_floating_point(
40 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
41
42extern template __from_chars_result<float> __from_chars_floating_point(
43 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
44
45extern template __from_chars_result<double> __from_chars_floating_point(
46 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
47
48template <class _Fp>
49_LIBCPP_HIDE_FROM_ABI from_chars_result
50__from_chars(const char* __first, const char* __last, _Fp& __value, chars_format __fmt) {
51 __from_chars_result<_Fp> __r = std::__from_chars_floating_point<_Fp>(__first, __last, __fmt);
52 if (__r.__ec != errc::invalid_argument)
53 __value = __r.__value;
54 return {__first + __r.__n, __r.__ec};
55}
56
57_LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_HIDE_FROM_ABI inline from_chars_result
58from_chars(const char* __first, const char* __last, float& __value, chars_format __fmt = chars_format::general) {
59 return std::__from_chars<float>(__first, __last, __value, __fmt);
60}
61
62_LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_HIDE_FROM_ABI inline from_chars_result
63from_chars(const char* __first, const char* __last, double& __value, chars_format __fmt = chars_format::general) {
64 return std::__from_chars<double>(__first, __last, __value, __fmt);
65}
66
67#endif // _LIBCPP_STD_VER >= 17
68
69_LIBCPP_END_NAMESPACE_STD
70
71_LIBCPP_POP_MACROS
72
73#endif // _LIBCPP___CHARCONV_FROM_CHARS_FLOATING_POINT_H
lib/libcxx/include/__charconv/tables.h+1-1
...@@ -95,7 +95,7 @@ inline constexpr uint64_t __pow10_64[20] = {...@@ -95,7 +95,7 @@ inline constexpr uint64_t __pow10_64[20] = {
95 UINT64_C(1000000000000000000),95 UINT64_C(1000000000000000000),
96 UINT64_C(10000000000000000000)};96 UINT64_C(10000000000000000000)};
9797
98# ifndef _LIBCPP_HAS_NO_INT12898# if _LIBCPP_HAS_INT128
99inline constexpr int __pow10_128_offset = 0;99inline constexpr int __pow10_128_offset = 0;
100inline constexpr __uint128_t __pow10_128[40] = {100inline constexpr __uint128_t __pow10_128[40] = {
101 UINT64_C(0),101 UINT64_C(0),
lib/libcxx/include/__charconv/to_chars_base_10.h+1-1
...@@ -124,7 +124,7 @@ __base_10_u64(char* __buffer, uint64_t __value) noexcept {...@@ -124,7 +124,7 @@ __base_10_u64(char* __buffer, uint64_t __value) noexcept {
124 return __itoa::__append10(__buffer, __value);124 return __itoa::__append10(__buffer, __value);
125}125}
126126
127# ifndef _LIBCPP_HAS_NO_INT128127# if _LIBCPP_HAS_INT128
128/// \returns 10^\a exp128/// \returns 10^\a exp
129///129///
130/// \pre \a exp [19, 39]130/// \pre \a exp [19, 39]
lib/libcxx/include/__charconv/to_chars_integral.h+3-2
...@@ -18,14 +18,15 @@...@@ -18,14 +18,15 @@
18#include <__charconv/to_chars_result.h>18#include <__charconv/to_chars_result.h>
19#include <__charconv/traits.h>19#include <__charconv/traits.h>
20#include <__config>20#include <__config>
21#include <__cstddef/ptrdiff_t.h>
21#include <__system_error/errc.h>22#include <__system_error/errc.h>
22#include <__type_traits/enable_if.h>23#include <__type_traits/enable_if.h>
23#include <__type_traits/integral_constant.h>24#include <__type_traits/integral_constant.h>
25#include <__type_traits/is_integral.h>
24#include <__type_traits/is_same.h>26#include <__type_traits/is_same.h>
25#include <__type_traits/make_32_64_or_128_bit.h>27#include <__type_traits/make_32_64_or_128_bit.h>
26#include <__type_traits/make_unsigned.h>28#include <__type_traits/make_unsigned.h>
27#include <__utility/unreachable.h>29#include <__utility/unreachable.h>
28#include <cstddef>
29#include <cstdint>30#include <cstdint>
30#include <limits>31#include <limits>
3132
...@@ -70,7 +71,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) {...@@ -70,7 +71,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) {
70 return {__last, errc::value_too_large};71 return {__last, errc::value_too_large};
71}72}
7273
73# ifndef _LIBCPP_HAS_NO_INT12874# if _LIBCPP_HAS_INT128
74template <>75template <>
75inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result76inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
76__to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) {77__to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) {
lib/libcxx/include/__charconv/traits.h+1-1
...@@ -88,7 +88,7 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(uin...@@ -88,7 +88,7 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(uin
88 }88 }
89};89};
9090
91# ifndef _LIBCPP_HAS_NO_INT12891# if _LIBCPP_HAS_INT128
92template <typename _Tp>92template <typename _Tp>
93struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__uint128_t)> > {93struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__uint128_t)> > {
94 using type = __uint128_t;94 using type = __uint128_t;
lib/libcxx/include/__chrono/convert_to_tm.h+27-5
...@@ -24,6 +24,7 @@...@@ -24,6 +24,7 @@
24#include <__chrono/sys_info.h>24#include <__chrono/sys_info.h>
25#include <__chrono/system_clock.h>25#include <__chrono/system_clock.h>
26#include <__chrono/time_point.h>26#include <__chrono/time_point.h>
27#include <__chrono/utc_clock.h>
27#include <__chrono/weekday.h>28#include <__chrono/weekday.h>
28#include <__chrono/year.h>29#include <__chrono/year.h>
29#include <__chrono/year_month.h>30#include <__chrono/year_month.h>
...@@ -98,6 +99,22 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const chrono::sys_time<_Duration> __tp...@@ -98,6 +99,22 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const chrono::sys_time<_Duration> __tp
98 return __result;99 return __result;
99}100}
100101
102# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
103# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
104
105template <class _Tm, class _Duration>
106_LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(chrono::utc_time<_Duration> __tp) {
107 _Tm __result = std::__convert_to_tm<_Tm>(chrono::utc_clock::to_sys(__tp));
108
109 if (chrono::get_leap_second_info(__tp).is_leap_second)
110 ++__result.tm_sec;
111
112 return __result;
113}
114
115# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
116# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
117
101// Convert a chrono (calendar) time point, or dururation to the given _Tm type,118// Convert a chrono (calendar) time point, or dururation to the given _Tm type,
102// which must have the same properties as std::tm.119// which must have the same properties as std::tm.
103template <class _Tm, class _ChronoT>120template <class _Tm, class _ChronoT>
...@@ -110,13 +127,19 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) {...@@ -110,13 +127,19 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) {
110 if constexpr (__is_time_point<_ChronoT>) {127 if constexpr (__is_time_point<_ChronoT>) {
111 if constexpr (same_as<typename _ChronoT::clock, chrono::system_clock>)128 if constexpr (same_as<typename _ChronoT::clock, chrono::system_clock>)
112 return std::__convert_to_tm<_Tm>(__value);129 return std::__convert_to_tm<_Tm>(__value);
130# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
131# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
132 else if constexpr (same_as<typename _ChronoT::clock, chrono::utc_clock>)
133 return std::__convert_to_tm<_Tm>(__value);
134# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
135# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
113 else if constexpr (same_as<typename _ChronoT::clock, chrono::file_clock>)136 else if constexpr (same_as<typename _ChronoT::clock, chrono::file_clock>)
114 return std::__convert_to_tm<_Tm>(_ChronoT::clock::to_sys(__value));137 return std::__convert_to_tm<_Tm>(_ChronoT::clock::to_sys(__value));
115 else if constexpr (same_as<typename _ChronoT::clock, chrono::local_t>)138 else if constexpr (same_as<typename _ChronoT::clock, chrono::local_t>)
116 return std::__convert_to_tm<_Tm>(chrono::sys_time<typename _ChronoT::duration>{__value.time_since_epoch()});139 return std::__convert_to_tm<_Tm>(chrono::sys_time<typename _ChronoT::duration>{__value.time_since_epoch()});
117 else140 else
118 static_assert(sizeof(_ChronoT) == 0, "TODO: Add the missing clock specialization");141 static_assert(sizeof(_ChronoT) == 0, "TODO: Add the missing clock specialization");
119 } else if constexpr (chrono::__is_duration<_ChronoT>::value) {142 } else if constexpr (chrono::__is_duration_v<_ChronoT>) {
120 // [time.format]/6143 // [time.format]/6
121 // ... However, if a flag refers to a "time of day" (e.g. %H, %I, %p,144 // ... However, if a flag refers to a "time of day" (e.g. %H, %I, %p,
122 // etc.), then a specialization of duration is interpreted as the time of145 // etc.), then a specialization of duration is interpreted as the time of
...@@ -175,18 +198,17 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) {...@@ -175,18 +198,17 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) {
175 if (__value.hours().count() > std::numeric_limits<decltype(__result.tm_hour)>::max())198 if (__value.hours().count() > std::numeric_limits<decltype(__result.tm_hour)>::max())
176 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour overflow");199 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour overflow");
177 __result.tm_hour = __value.hours().count();200 __result.tm_hour = __value.hours().count();
178# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)201# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
179 } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {202 } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
180 // Has no time information.203 // Has no time information.
181 } else if constexpr (same_as<_ChronoT, chrono::local_info>) {204 } else if constexpr (same_as<_ChronoT, chrono::local_info>) {
182 // Has no time information.205 // Has no time information.
183# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \206# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
184 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
185 } else if constexpr (__is_specialization_v<_ChronoT, chrono::zoned_time>) {207 } else if constexpr (__is_specialization_v<_ChronoT, chrono::zoned_time>) {
186 return std::__convert_to_tm<_Tm>(208 return std::__convert_to_tm<_Tm>(
187 chrono::sys_time<typename _ChronoT::duration>{__value.get_local_time().time_since_epoch()});209 chrono::sys_time<typename _ChronoT::duration>{__value.get_local_time().time_since_epoch()});
188# endif210# endif
189# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)211# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
190 } else212 } else
191 static_assert(sizeof(_ChronoT) == 0, "Add the missing type specialization");213 static_assert(sizeof(_ChronoT) == 0, "Add the missing type specialization");
192214
lib/libcxx/include/__chrono/day.h+1-1
...@@ -11,8 +11,8 @@...@@ -11,8 +11,8 @@
11#define _LIBCPP___CHRONO_DAY_H11#define _LIBCPP___CHRONO_DAY_H
1212
13#include <__chrono/duration.h>13#include <__chrono/duration.h>
14#include <__compare/ordering.h>
14#include <__config>15#include <__config>
15#include <compare>
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/__chrono/duration.h+16-21
...@@ -35,26 +35,25 @@ template <class _Rep, class _Period = ratio<1> >...@@ -35,26 +35,25 @@ template <class _Rep, class _Period = ratio<1> >
35class _LIBCPP_TEMPLATE_VIS duration;35class _LIBCPP_TEMPLATE_VIS duration;
3636
37template <class _Tp>37template <class _Tp>
38struct __is_duration : false_type {};38inline const bool __is_duration_v = false;
3939
40template <class _Rep, class _Period>40template <class _Rep, class _Period>
41struct __is_duration<duration<_Rep, _Period> > : true_type {};41inline const bool __is_duration_v<duration<_Rep, _Period> > = true;
4242
43template <class _Rep, class _Period>43template <class _Rep, class _Period>
44struct __is_duration<const duration<_Rep, _Period> > : true_type {};44inline const bool __is_duration_v<const duration<_Rep, _Period> > = true;
4545
46template <class _Rep, class _Period>46template <class _Rep, class _Period>
47struct __is_duration<volatile duration<_Rep, _Period> > : true_type {};47inline const bool __is_duration_v<volatile duration<_Rep, _Period> > = true;
4848
49template <class _Rep, class _Period>49template <class _Rep, class _Period>
50struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {};50inline const bool __is_duration_v<const volatile duration<_Rep, _Period> > = true;
5151
52} // namespace chrono52} // namespace chrono
5353
54template <class _Rep1, class _Period1, class _Rep2, class _Period2>54template <class _Rep1, class _Period1, class _Rep2, class _Period2>
55struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>, chrono::duration<_Rep2, _Period2> > {55struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>, chrono::duration<_Rep2, _Period2> > {
56 typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, typename __ratio_gcd<_Period1, _Period2>::type>56 typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, __ratio_gcd<_Period1, _Period2> > type;
57 type;
58};57};
5958
60namespace chrono {59namespace chrono {
...@@ -102,7 +101,7 @@ struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> {...@@ -102,7 +101,7 @@ struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> {
102 }101 }
103};102};
104103
105template <class _ToDuration, class _Rep, class _Period, __enable_if_t<__is_duration<_ToDuration>::value, int> = 0>104template <class _ToDuration, class _Rep, class _Period, __enable_if_t<__is_duration_v<_ToDuration>, int> = 0>
106inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration duration_cast(const duration<_Rep, _Period>& __fd) {105inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration duration_cast(const duration<_Rep, _Period>& __fd) {
107 return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd);106 return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd);
108}107}
...@@ -124,7 +123,7 @@ public:...@@ -124,7 +123,7 @@ public:
124};123};
125124
126#if _LIBCPP_STD_VER >= 17125#if _LIBCPP_STD_VER >= 17
127template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>126template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0>
128inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration floor(const duration<_Rep, _Period>& __d) {127inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration floor(const duration<_Rep, _Period>& __d) {
129 _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);128 _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
130 if (__t > __d)129 if (__t > __d)
...@@ -132,7 +131,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration floor(const duration<...@@ -132,7 +131,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration floor(const duration<
132 return __t;131 return __t;
133}132}
134133
135template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>134template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0>
136inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration ceil(const duration<_Rep, _Period>& __d) {135inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration ceil(const duration<_Rep, _Period>& __d) {
137 _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);136 _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
138 if (__t < __d)137 if (__t < __d)
...@@ -140,7 +139,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration ceil(const duration<_...@@ -140,7 +139,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration ceil(const duration<_
140 return __t;139 return __t;
141}140}
142141
143template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>142template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0>
144inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration<_Rep, _Period>& __d) {143inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration<_Rep, _Period>& __d) {
145 _ToDuration __lower = chrono::floor<_ToDuration>(__d);144 _ToDuration __lower = chrono::floor<_ToDuration>(__d);
146 _ToDuration __upper = __lower + _ToDuration{1};145 _ToDuration __upper = __lower + _ToDuration{1};
...@@ -158,15 +157,15 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration<...@@ -158,15 +157,15 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration<
158157
159template <class _Rep, class _Period>158template <class _Rep, class _Period>
160class _LIBCPP_TEMPLATE_VIS duration {159class _LIBCPP_TEMPLATE_VIS duration {
161 static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration");160 static_assert(!__is_duration_v<_Rep>, "A duration representation can not be a duration");
162 static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio");161 static_assert(__is_ratio_v<_Period>, "Second template parameter of duration must be a std::ratio");
163 static_assert(_Period::num > 0, "duration period must be positive");162 static_assert(_Period::num > 0, "duration period must be positive");
164163
165 template <class _R1, class _R2>164 template <class _R1, class _R2>
166 struct __no_overflow {165 struct __no_overflow {
167 private:166 private:
168 static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;167 static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>;
169 static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;168 static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>;
170 static const intmax_t __n1 = _R1::num / __gcd_n1_n2;169 static const intmax_t __n1 = _R1::num / __gcd_n1_n2;
171 static const intmax_t __d1 = _R1::den / __gcd_d1_d2;170 static const intmax_t __d1 = _R1::den / __gcd_d1_d2;
172 static const intmax_t __n2 = _R2::num / __gcd_n1_n2;171 static const intmax_t __n2 = _R2::num / __gcd_n1_n2;
...@@ -434,7 +433,7 @@ operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) {...@@ -434,7 +433,7 @@ operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) {
434template <class _Rep1,433template <class _Rep1,
435 class _Period,434 class _Period,
436 class _Rep2,435 class _Rep2,
437 __enable_if_t<!__is_duration<_Rep2>::value &&436 __enable_if_t<!__is_duration_v<_Rep2> &&
438 is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value,437 is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value,
439 int> = 0>438 int> = 0>
440inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>439inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>
...@@ -456,7 +455,7 @@ operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2...@@ -456,7 +455,7 @@ operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2
456template <class _Rep1,455template <class _Rep1,
457 class _Period,456 class _Period,
458 class _Rep2,457 class _Rep2,
459 __enable_if_t<!__is_duration<_Rep2>::value &&458 __enable_if_t<!__is_duration_v<_Rep2> &&
460 is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value,459 is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value,
461 int> = 0>460 int> = 0>
462inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>461inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>
...@@ -543,8 +542,4 @@ _LIBCPP_END_NAMESPACE_STD...@@ -543,8 +542,4 @@ _LIBCPP_END_NAMESPACE_STD
543542
544_LIBCPP_POP_MACROS543_LIBCPP_POP_MACROS
545544
546#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
547# include <type_traits>
548#endif
549
550#endif // _LIBCPP___CHRONO_DURATION_H545#endif // _LIBCPP___CHRONO_DURATION_H
lib/libcxx/include/__chrono/exception.h+6-6
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
1414
15#include <version>15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)17#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
1818
19# include <__chrono/calendar.h>19# include <__chrono/calendar.h>
20# include <__chrono/local_info.h>20# include <__chrono/local_info.h>
...@@ -71,9 +71,9 @@ private:...@@ -71,9 +71,9 @@ private:
71};71};
7272
73template <class _Duration>73template <class _Duration>
74_LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time(74[[noreturn]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time(
75 [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) {75 [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) {
76# ifndef _LIBCPP_HAS_NO_EXCEPTIONS76# if _LIBCPP_HAS_EXCEPTIONS
77 throw nonexistent_local_time(__time, __info);77 throw nonexistent_local_time(__time, __info);
78# else78# else
79 _LIBCPP_VERBOSE_ABORT("nonexistent_local_time was thrown in -fno-exceptions mode");79 _LIBCPP_VERBOSE_ABORT("nonexistent_local_time was thrown in -fno-exceptions mode");
...@@ -115,9 +115,9 @@ private:...@@ -115,9 +115,9 @@ private:
115};115};
116116
117template <class _Duration>117template <class _Duration>
118_LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_ambiguous_local_time(118[[noreturn]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_ambiguous_local_time(
119 [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) {119 [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) {
120# ifndef _LIBCPP_HAS_NO_EXCEPTIONS120# if _LIBCPP_HAS_EXCEPTIONS
121 throw ambiguous_local_time(__time, __info);121 throw ambiguous_local_time(__time, __info);
122# else122# else
123 _LIBCPP_VERBOSE_ABORT("ambiguous_local_time was thrown in -fno-exceptions mode");123 _LIBCPP_VERBOSE_ABORT("ambiguous_local_time was thrown in -fno-exceptions mode");
...@@ -130,6 +130,6 @@ _LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_am...@@ -130,6 +130,6 @@ _LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_am
130130
131_LIBCPP_END_NAMESPACE_STD131_LIBCPP_END_NAMESPACE_STD
132132
133#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)133#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
134134
135#endif // _LIBCPP___CHRONO_EXCEPTION_H135#endif // _LIBCPP___CHRONO_EXCEPTION_H
lib/libcxx/include/__chrono/file_clock.h+1-1
...@@ -47,7 +47,7 @@ _LIBCPP_END_NAMESPACE_STD...@@ -47,7 +47,7 @@ _LIBCPP_END_NAMESPACE_STD
47#ifndef _LIBCPP_CXX03_LANG47#ifndef _LIBCPP_CXX03_LANG
48_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM48_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
49struct _FilesystemClock {49struct _FilesystemClock {
50# if !defined(_LIBCPP_HAS_NO_INT128)50# if _LIBCPP_HAS_INT128
51 typedef __int128_t rep;51 typedef __int128_t rep;
52 typedef nano period;52 typedef nano period;
53# else53# else
lib/libcxx/include/__chrono/formatter.h+129-114
...@@ -10,55 +10,60 @@...@@ -10,55 +10,60 @@
10#ifndef _LIBCPP___CHRONO_FORMATTER_H10#ifndef _LIBCPP___CHRONO_FORMATTER_H
11#define _LIBCPP___CHRONO_FORMATTER_H11#define _LIBCPP___CHRONO_FORMATTER_H
1212
13#include <__algorithm/ranges_copy.h>
14#include <__chrono/calendar.h>
15#include <__chrono/concepts.h>
16#include <__chrono/convert_to_tm.h>
17#include <__chrono/day.h>
18#include <__chrono/duration.h>
19#include <__chrono/file_clock.h>
20#include <__chrono/hh_mm_ss.h>
21#include <__chrono/local_info.h>
22#include <__chrono/month.h>
23#include <__chrono/month_weekday.h>
24#include <__chrono/monthday.h>
25#include <__chrono/ostream.h>
26#include <__chrono/parser_std_format_spec.h>
27#include <__chrono/statically_widen.h>
28#include <__chrono/sys_info.h>
29#include <__chrono/system_clock.h>
30#include <__chrono/time_point.h>
31#include <__chrono/weekday.h>
32#include <__chrono/year.h>
33#include <__chrono/year_month.h>
34#include <__chrono/year_month_day.h>
35#include <__chrono/year_month_weekday.h>
36#include <__chrono/zoned_time.h>
37#include <__concepts/arithmetic.h>
38#include <__concepts/same_as.h>
39#include <__config>13#include <__config>
40#include <__format/concepts.h>14
41#include <__format/format_error.h>15#if _LIBCPP_HAS_LOCALIZATION
42#include <__format/format_functions.h>16
43#include <__format/format_parse_context.h>17# include <__algorithm/ranges_copy.h>
44#include <__format/formatter.h>18# include <__chrono/calendar.h>
45#include <__format/parser_std_format_spec.h>19# include <__chrono/concepts.h>
46#include <__format/write_escaped.h>20# include <__chrono/convert_to_tm.h>
47#include <__memory/addressof.h>21# include <__chrono/day.h>
48#include <__type_traits/is_specialization.h>22# include <__chrono/duration.h>
49#include <cmath>23# include <__chrono/file_clock.h>
50#include <ctime>24# include <__chrono/hh_mm_ss.h>
51#include <limits>25# include <__chrono/local_info.h>
52#include <sstream>26# include <__chrono/month.h>
53#include <string_view>27# include <__chrono/month_weekday.h>
5428# include <__chrono/monthday.h>
55#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29# include <__chrono/ostream.h>
56# pragma GCC system_header30# include <__chrono/parser_std_format_spec.h>
57#endif31# include <__chrono/statically_widen.h>
32# include <__chrono/sys_info.h>
33# include <__chrono/system_clock.h>
34# include <__chrono/time_point.h>
35# include <__chrono/utc_clock.h>
36# include <__chrono/weekday.h>
37# include <__chrono/year.h>
38# include <__chrono/year_month.h>
39# include <__chrono/year_month_day.h>
40# include <__chrono/year_month_weekday.h>
41# include <__chrono/zoned_time.h>
42# include <__concepts/arithmetic.h>
43# include <__concepts/same_as.h>
44# include <__format/concepts.h>
45# include <__format/format_error.h>
46# include <__format/format_functions.h>
47# include <__format/format_parse_context.h>
48# include <__format/formatter.h>
49# include <__format/parser_std_format_spec.h>
50# include <__format/write_escaped.h>
51# include <__memory/addressof.h>
52# include <__type_traits/is_specialization.h>
53# include <cmath>
54# include <ctime>
55# include <limits>
56# include <locale>
57# include <sstream>
58# include <string_view>
59
60# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
61# pragma GCC system_header
62# endif
5863
59_LIBCPP_BEGIN_NAMESPACE_STD64_LIBCPP_BEGIN_NAMESPACE_STD
6065
61#if _LIBCPP_STD_VER >= 2066# if _LIBCPP_STD_VER >= 20
6267
63namespace __formatter {68namespace __formatter {
6469
...@@ -139,25 +144,23 @@ __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::hh_mm_ss<...@@ -139,25 +144,23 @@ __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::hh_mm_ss<
139 __value.fractional_width);144 __value.fractional_width);
140}145}
141146
142# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \147# if _LIBCPP_HAS_EXPERIMENTAL_TZDB && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
143 !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
144template <class _CharT, class _Duration, class _TimeZonePtr>148template <class _CharT, class _Duration, class _TimeZonePtr>
145_LIBCPP_HIDE_FROM_ABI void149_LIBCPP_HIDE_FROM_ABI void
146__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::zoned_time<_Duration, _TimeZonePtr>& __value) {150__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::zoned_time<_Duration, _TimeZonePtr>& __value) {
147 __formatter::__format_sub_seconds(__sstr, __value.get_local_time().time_since_epoch());151 __formatter::__format_sub_seconds(__sstr, __value.get_local_time().time_since_epoch());
148}152}
149# endif153# endif
150154
151template <class _Tp>155template <class _Tp>
152consteval bool __use_fraction() {156consteval bool __use_fraction() {
153 if constexpr (__is_time_point<_Tp>)157 if constexpr (__is_time_point<_Tp>)
154 return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;158 return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;
155# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \159# if _LIBCPP_HAS_EXPERIMENTAL_TZDB && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
156 !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
157 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)160 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
158 return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;161 return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;
159# endif162# endif
160 else if constexpr (chrono::__is_duration<_Tp>::value)163 else if constexpr (chrono::__is_duration_v<_Tp>)
161 return chrono::hh_mm_ss<_Tp>::fractional_width;164 return chrono::hh_mm_ss<_Tp>::fractional_width;
162 else if constexpr (__is_hh_mm_ss<_Tp>)165 else if constexpr (__is_hh_mm_ss<_Tp>)
163 return _Tp::fractional_width;166 return _Tp::fractional_width;
...@@ -225,16 +228,15 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {...@@ -225,16 +228,15 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
225228
226template <class _Tp>229template <class _Tp>
227_LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] const _Tp& __value) {230_LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] const _Tp& __value) {
228# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)231# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
229 if constexpr (same_as<_Tp, chrono::sys_info>)232 if constexpr (same_as<_Tp, chrono::sys_info>)
230 return {__value.abbrev, __value.offset};233 return {__value.abbrev, __value.offset};
231# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \234# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
232 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
233 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)235 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
234 return __formatter::__convert_to_time_zone(__value.get_info());236 return __formatter::__convert_to_time_zone(__value.get_info());
235# endif237# endif
236 else238 else
237# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)239# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
238 return {"UTC", chrono::seconds{0}};240 return {"UTC", chrono::seconds{0}};
239}241}
240242
...@@ -272,7 +274,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(...@@ -272,7 +274,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
272 } break;274 } break;
273275
274 case _CharT('j'):276 case _CharT('j'):
275 if constexpr (chrono::__is_duration<_Tp>::value)277 if constexpr (chrono::__is_duration_v<_Tp>)
276 // Converting a duration where the period has a small ratio to days278 // Converting a duration where the period has a small ratio to days
277 // may fail to compile. This due to loss of precision in the279 // may fail to compile. This due to loss of precision in the
278 // conversion. In order to avoid that issue convert to seconds as280 // conversion. In order to avoid that issue convert to seconds as
...@@ -284,7 +286,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(...@@ -284,7 +286,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
284 break;286 break;
285287
286 case _CharT('q'):288 case _CharT('q'):
287 if constexpr (chrono::__is_duration<_Tp>::value) {289 if constexpr (chrono::__is_duration_v<_Tp>) {
288 __sstr << chrono::__units_suffix<_CharT, typename _Tp::period>();290 __sstr << chrono::__units_suffix<_CharT, typename _Tp::period>();
289 break;291 break;
290 }292 }
...@@ -300,7 +302,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(...@@ -300,7 +302,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
300 // MSVC STL ignores precision but uses separator302 // MSVC STL ignores precision but uses separator
301 // FMT honours precision and has a bug for separator303 // FMT honours precision and has a bug for separator
302 // https://godbolt.org/z/78b7sMxns304 // https://godbolt.org/z/78b7sMxns
303 if constexpr (chrono::__is_duration<_Tp>::value) {305 if constexpr (chrono::__is_duration_v<_Tp>) {
304 __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{}"), __value.count());306 __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{}"), __value.count());
305 break;307 break;
306 }308 }
...@@ -341,16 +343,16 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(...@@ -341,16 +343,16 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
341 //343 //
342 // TODO FMT evaluate the comment above.344 // TODO FMT evaluate the comment above.
343345
344# if defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)346# if defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
345 case _CharT('y'):347 case _CharT('y'):
346 // Glibc fails for negative values, AIX for positive values too.348 // Glibc fails for negative values, AIX for positive values too.
347 __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), (std::abs(__t.tm_year + 1900)) % 100);349 __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), (std::abs(__t.tm_year + 1900)) % 100);
348 break;350 break;
349# endif // defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)351# endif // defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
350352
351 case _CharT('Y'):353 case _CharT('Y'):
352 // Depending on the platform's libc the range of supported years is354 // Depending on the platform's libc the range of supported years is
353 // limited. Intead of of testing all conditions use the internal355 // limited. Instead of of testing all conditions use the internal
354 // implementation unconditionally.356 // implementation unconditionally.
355 __formatter::__format_year(__sstr, __t.tm_year + 1900);357 __formatter::__format_year(__sstr, __t.tm_year + 1900);
356 break;358 break;
...@@ -442,17 +444,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const _Tp& __value) {...@@ -442,17 +444,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const _Tp& __value) {
442 return __value.weekday().ok();444 return __value.weekday().ok();
443 else if constexpr (__is_hh_mm_ss<_Tp>)445 else if constexpr (__is_hh_mm_ss<_Tp>)
444 return true;446 return true;
445# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)447# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
446 else if constexpr (same_as<_Tp, chrono::sys_info>)448 else if constexpr (same_as<_Tp, chrono::sys_info>)
447 return true;449 return true;
448 else if constexpr (same_as<_Tp, chrono::local_info>)450 else if constexpr (same_as<_Tp, chrono::local_info>)
449 return true;451 return true;
450# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \452# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
451 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
452 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)453 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
453 return true;454 return true;
454# endif455# endif
455# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)456# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
456 else457 else
457 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");458 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
458}459}
...@@ -493,17 +494,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_name_ok(const _Tp& __value) {...@@ -493,17 +494,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_name_ok(const _Tp& __value) {
493 return __value.weekday().ok();494 return __value.weekday().ok();
494 else if constexpr (__is_hh_mm_ss<_Tp>)495 else if constexpr (__is_hh_mm_ss<_Tp>)
495 return true;496 return true;
496# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)497# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
497 else if constexpr (same_as<_Tp, chrono::sys_info>)498 else if constexpr (same_as<_Tp, chrono::sys_info>)
498 return true;499 return true;
499 else if constexpr (same_as<_Tp, chrono::local_info>)500 else if constexpr (same_as<_Tp, chrono::local_info>)
500 return true;501 return true;
501# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \502# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
502 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
503 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)503 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
504 return true;504 return true;
505# endif505# endif
506# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)506# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
507 else507 else
508 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");508 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
509}509}
...@@ -544,17 +544,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& __value) {...@@ -544,17 +544,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& __value) {
544 return __value.ok();544 return __value.ok();
545 else if constexpr (__is_hh_mm_ss<_Tp>)545 else if constexpr (__is_hh_mm_ss<_Tp>)
546 return true;546 return true;
547# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)547# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
548 else if constexpr (same_as<_Tp, chrono::sys_info>)548 else if constexpr (same_as<_Tp, chrono::sys_info>)
549 return true;549 return true;
550 else if constexpr (same_as<_Tp, chrono::local_info>)550 else if constexpr (same_as<_Tp, chrono::local_info>)
551 return true;551 return true;
552# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \552# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
553 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
554 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)553 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
555 return true;554 return true;
556# endif555# endif
557# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)556# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
558 else557 else
559 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");558 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
560}559}
...@@ -595,17 +594,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __month_name_ok(const _Tp& __value) {...@@ -595,17 +594,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __month_name_ok(const _Tp& __value) {
595 return __value.month().ok();594 return __value.month().ok();
596 else if constexpr (__is_hh_mm_ss<_Tp>)595 else if constexpr (__is_hh_mm_ss<_Tp>)
597 return true;596 return true;
598# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)597# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
599 else if constexpr (same_as<_Tp, chrono::sys_info>)598 else if constexpr (same_as<_Tp, chrono::sys_info>)
600 return true;599 return true;
601 else if constexpr (same_as<_Tp, chrono::local_info>)600 else if constexpr (same_as<_Tp, chrono::local_info>)
602 return true;601 return true;
603# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \602# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
604 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
605 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)603 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
606 return true;604 return true;
607# endif605# endif
608# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)606# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
609 else607 else
610 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");608 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
611}609}
...@@ -630,7 +628,7 @@ __format_chrono(const _Tp& __value,...@@ -630,7 +628,7 @@ __format_chrono(const _Tp& __value,
630 if (__chrono_specs.empty())628 if (__chrono_specs.empty())
631 __sstr << __value;629 __sstr << __value;
632 else {630 else {
633 if constexpr (chrono::__is_duration<_Tp>::value) {631 if constexpr (chrono::__is_duration_v<_Tp>) {
634 // A duration can be a user defined arithmetic type. Users may specialize632 // A duration can be a user defined arithmetic type. Users may specialize
635 // numeric_limits, but they may not specialize is_signed.633 // numeric_limits, but they may not specialize is_signed.
636 if constexpr (numeric_limits<typename _Tp::rep>::is_signed) {634 if constexpr (numeric_limits<typename _Tp::rep>::is_signed) {
...@@ -714,7 +712,7 @@ public:...@@ -714,7 +712,7 @@ public:
714template <class _Duration, __fmt_char_type _CharT>712template <class _Duration, __fmt_char_type _CharT>
715struct _LIBCPP_TEMPLATE_VIS formatter<chrono::sys_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {713struct _LIBCPP_TEMPLATE_VIS formatter<chrono::sys_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
716public:714public:
717 using _Base = __formatter_chrono<_CharT>;715 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
718716
719 template <class _ParseContext>717 template <class _ParseContext>
720 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {718 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -722,10 +720,27 @@ public:...@@ -722,10 +720,27 @@ public:
722 }720 }
723};721};
724722
723# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
724# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
725
726template <class _Duration, __fmt_char_type _CharT>
727struct _LIBCPP_TEMPLATE_VIS formatter<chrono::utc_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
728public:
729 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
730
731 template <class _ParseContext>
732 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
733 return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock);
734 }
735};
736
737# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
738# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
739
725template <class _Duration, __fmt_char_type _CharT>740template <class _Duration, __fmt_char_type _CharT>
726struct _LIBCPP_TEMPLATE_VIS formatter<chrono::file_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {741struct _LIBCPP_TEMPLATE_VIS formatter<chrono::file_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
727public:742public:
728 using _Base = __formatter_chrono<_CharT>;743 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
729744
730 template <class _ParseContext>745 template <class _ParseContext>
731 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {746 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -736,7 +751,7 @@ public:...@@ -736,7 +751,7 @@ public:
736template <class _Duration, __fmt_char_type _CharT>751template <class _Duration, __fmt_char_type _CharT>
737struct _LIBCPP_TEMPLATE_VIS formatter<chrono::local_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {752struct _LIBCPP_TEMPLATE_VIS formatter<chrono::local_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
738public:753public:
739 using _Base = __formatter_chrono<_CharT>;754 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
740755
741 template <class _ParseContext>756 template <class _ParseContext>
742 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {757 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -748,7 +763,7 @@ public:...@@ -748,7 +763,7 @@ public:
748template <class _Rep, class _Period, __fmt_char_type _CharT>763template <class _Rep, class _Period, __fmt_char_type _CharT>
749struct formatter<chrono::duration<_Rep, _Period>, _CharT> : public __formatter_chrono<_CharT> {764struct formatter<chrono::duration<_Rep, _Period>, _CharT> : public __formatter_chrono<_CharT> {
750public:765public:
751 using _Base = __formatter_chrono<_CharT>;766 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
752767
753 template <class _ParseContext>768 template <class _ParseContext>
754 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {769 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -770,7 +785,7 @@ public:...@@ -770,7 +785,7 @@ public:
770template <__fmt_char_type _CharT>785template <__fmt_char_type _CharT>
771struct _LIBCPP_TEMPLATE_VIS formatter<chrono::day, _CharT> : public __formatter_chrono<_CharT> {786struct _LIBCPP_TEMPLATE_VIS formatter<chrono::day, _CharT> : public __formatter_chrono<_CharT> {
772public:787public:
773 using _Base = __formatter_chrono<_CharT>;788 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
774789
775 template <class _ParseContext>790 template <class _ParseContext>
776 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {791 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -781,7 +796,7 @@ public:...@@ -781,7 +796,7 @@ public:
781template <__fmt_char_type _CharT>796template <__fmt_char_type _CharT>
782struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month, _CharT> : public __formatter_chrono<_CharT> {797struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month, _CharT> : public __formatter_chrono<_CharT> {
783public:798public:
784 using _Base = __formatter_chrono<_CharT>;799 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
785800
786 template <class _ParseContext>801 template <class _ParseContext>
787 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {802 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -792,7 +807,7 @@ public:...@@ -792,7 +807,7 @@ public:
792template <__fmt_char_type _CharT>807template <__fmt_char_type _CharT>
793struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year, _CharT> : public __formatter_chrono<_CharT> {808struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year, _CharT> : public __formatter_chrono<_CharT> {
794public:809public:
795 using _Base = __formatter_chrono<_CharT>;810 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
796811
797 template <class _ParseContext>812 template <class _ParseContext>
798 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {813 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -803,7 +818,7 @@ public:...@@ -803,7 +818,7 @@ public:
803template <__fmt_char_type _CharT>818template <__fmt_char_type _CharT>
804struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday, _CharT> : public __formatter_chrono<_CharT> {819struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday, _CharT> : public __formatter_chrono<_CharT> {
805public:820public:
806 using _Base = __formatter_chrono<_CharT>;821 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
807822
808 template <class _ParseContext>823 template <class _ParseContext>
809 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {824 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -814,7 +829,7 @@ public:...@@ -814,7 +829,7 @@ public:
814template <__fmt_char_type _CharT>829template <__fmt_char_type _CharT>
815struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_indexed, _CharT> : public __formatter_chrono<_CharT> {830struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_indexed, _CharT> : public __formatter_chrono<_CharT> {
816public:831public:
817 using _Base = __formatter_chrono<_CharT>;832 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
818833
819 template <class _ParseContext>834 template <class _ParseContext>
820 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {835 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -825,7 +840,7 @@ public:...@@ -825,7 +840,7 @@ public:
825template <__fmt_char_type _CharT>840template <__fmt_char_type _CharT>
826struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_last, _CharT> : public __formatter_chrono<_CharT> {841struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_last, _CharT> : public __formatter_chrono<_CharT> {
827public:842public:
828 using _Base = __formatter_chrono<_CharT>;843 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
829844
830 template <class _ParseContext>845 template <class _ParseContext>
831 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {846 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -836,7 +851,7 @@ public:...@@ -836,7 +851,7 @@ public:
836template <__fmt_char_type _CharT>851template <__fmt_char_type _CharT>
837struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day, _CharT> : public __formatter_chrono<_CharT> {852struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day, _CharT> : public __formatter_chrono<_CharT> {
838public:853public:
839 using _Base = __formatter_chrono<_CharT>;854 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
840855
841 template <class _ParseContext>856 template <class _ParseContext>
842 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {857 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -847,7 +862,7 @@ public:...@@ -847,7 +862,7 @@ public:
847template <__fmt_char_type _CharT>862template <__fmt_char_type _CharT>
848struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day_last, _CharT> : public __formatter_chrono<_CharT> {863struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day_last, _CharT> : public __formatter_chrono<_CharT> {
849public:864public:
850 using _Base = __formatter_chrono<_CharT>;865 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
851866
852 template <class _ParseContext>867 template <class _ParseContext>
853 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {868 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -858,7 +873,7 @@ public:...@@ -858,7 +873,7 @@ public:
858template <__fmt_char_type _CharT>873template <__fmt_char_type _CharT>
859struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday, _CharT> : public __formatter_chrono<_CharT> {874struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday, _CharT> : public __formatter_chrono<_CharT> {
860public:875public:
861 using _Base = __formatter_chrono<_CharT>;876 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
862877
863 template <class _ParseContext>878 template <class _ParseContext>
864 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {879 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -869,7 +884,7 @@ public:...@@ -869,7 +884,7 @@ public:
869template <__fmt_char_type _CharT>884template <__fmt_char_type _CharT>
870struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday_last, _CharT> : public __formatter_chrono<_CharT> {885struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday_last, _CharT> : public __formatter_chrono<_CharT> {
871public:886public:
872 using _Base = __formatter_chrono<_CharT>;887 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
873888
874 template <class _ParseContext>889 template <class _ParseContext>
875 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {890 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -880,7 +895,7 @@ public:...@@ -880,7 +895,7 @@ public:
880template <__fmt_char_type _CharT>895template <__fmt_char_type _CharT>
881struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month, _CharT> : public __formatter_chrono<_CharT> {896struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month, _CharT> : public __formatter_chrono<_CharT> {
882public:897public:
883 using _Base = __formatter_chrono<_CharT>;898 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
884899
885 template <class _ParseContext>900 template <class _ParseContext>
886 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {901 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -891,7 +906,7 @@ public:...@@ -891,7 +906,7 @@ public:
891template <__fmt_char_type _CharT>906template <__fmt_char_type _CharT>
892struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day, _CharT> : public __formatter_chrono<_CharT> {907struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day, _CharT> : public __formatter_chrono<_CharT> {
893public:908public:
894 using _Base = __formatter_chrono<_CharT>;909 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
895910
896 template <class _ParseContext>911 template <class _ParseContext>
897 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {912 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -902,7 +917,7 @@ public:...@@ -902,7 +917,7 @@ public:
902template <__fmt_char_type _CharT>917template <__fmt_char_type _CharT>
903struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day_last, _CharT> : public __formatter_chrono<_CharT> {918struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day_last, _CharT> : public __formatter_chrono<_CharT> {
904public:919public:
905 using _Base = __formatter_chrono<_CharT>;920 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
906921
907 template <class _ParseContext>922 template <class _ParseContext>
908 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {923 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -913,7 +928,7 @@ public:...@@ -913,7 +928,7 @@ public:
913template <__fmt_char_type _CharT>928template <__fmt_char_type _CharT>
914struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_weekday, _CharT> : public __formatter_chrono<_CharT> {929struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_weekday, _CharT> : public __formatter_chrono<_CharT> {
915public:930public:
916 using _Base = __formatter_chrono<_CharT>;931 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
917932
918 template <class _ParseContext>933 template <class _ParseContext>
919 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {934 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -924,7 +939,7 @@ public:...@@ -924,7 +939,7 @@ public:
924template <__fmt_char_type _CharT>939template <__fmt_char_type _CharT>
925struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_weekday_last, _CharT> : public __formatter_chrono<_CharT> {940struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_weekday_last, _CharT> : public __formatter_chrono<_CharT> {
926public:941public:
927 using _Base = __formatter_chrono<_CharT>;942 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
928943
929 template <class _ParseContext>944 template <class _ParseContext>
930 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {945 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -935,7 +950,7 @@ public:...@@ -935,7 +950,7 @@ public:
935template <class _Duration, __fmt_char_type _CharT>950template <class _Duration, __fmt_char_type _CharT>
936struct formatter<chrono::hh_mm_ss<_Duration>, _CharT> : public __formatter_chrono<_CharT> {951struct formatter<chrono::hh_mm_ss<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
937public:952public:
938 using _Base = __formatter_chrono<_CharT>;953 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
939954
940 template <class _ParseContext>955 template <class _ParseContext>
941 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {956 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -943,11 +958,11 @@ public:...@@ -943,11 +958,11 @@ public:
943 }958 }
944};959};
945960
946# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)961# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
947template <__fmt_char_type _CharT>962template <__fmt_char_type _CharT>
948struct formatter<chrono::sys_info, _CharT> : public __formatter_chrono<_CharT> {963struct formatter<chrono::sys_info, _CharT> : public __formatter_chrono<_CharT> {
949public:964public:
950 using _Base = __formatter_chrono<_CharT>;965 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
951966
952 template <class _ParseContext>967 template <class _ParseContext>
953 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {968 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -958,33 +973,33 @@ public:...@@ -958,33 +973,33 @@ public:
958template <__fmt_char_type _CharT>973template <__fmt_char_type _CharT>
959struct formatter<chrono::local_info, _CharT> : public __formatter_chrono<_CharT> {974struct formatter<chrono::local_info, _CharT> : public __formatter_chrono<_CharT> {
960public:975public:
961 using _Base = __formatter_chrono<_CharT>;976 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
962977
963 template <class _ParseContext>978 template <class _ParseContext>
964 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {979 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
965 return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags{});980 return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags{});
966 }981 }
967};982};
968# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \983# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
969 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
970// Note due to how libc++'s formatters are implemented there is no need to add984// Note due to how libc++'s formatters are implemented there is no need to add
971// the exposition only local-time-format-t abstraction.985// the exposition only local-time-format-t abstraction.
972template <class _Duration, class _TimeZonePtr, __fmt_char_type _CharT>986template <class _Duration, class _TimeZonePtr, __fmt_char_type _CharT>
973struct formatter<chrono::zoned_time<_Duration, _TimeZonePtr>, _CharT> : public __formatter_chrono<_CharT> {987struct formatter<chrono::zoned_time<_Duration, _TimeZonePtr>, _CharT> : public __formatter_chrono<_CharT> {
974public:988public:
975 using _Base = __formatter_chrono<_CharT>;989 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
976990
977 template <class _ParseContext>991 template <class _ParseContext>
978 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {992 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
979 return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock);993 return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock);
980 }994 }
981};995};
982# endif // !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&996# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
983 // !defined(_LIBCPP_HAS_NO_LOCALIZATION)997# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
984# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
985998
986#endif // if _LIBCPP_STD_VER >= 20999# endif // if _LIBCPP_STD_VER >= 20
9871000
988_LIBCPP_END_NAMESPACE_STD1001_LIBCPP_END_NAMESPACE_STD
9891002
1003#endif // _LIBCPP_HAS_LOCALIZATION
1004
990#endif // _LIBCPP___CHRONO_FORMATTER_H1005#endif // _LIBCPP___CHRONO_FORMATTER_H
lib/libcxx/include/__chrono/hh_mm_ss.h+2-2
...@@ -29,8 +29,8 @@ namespace chrono {...@@ -29,8 +29,8 @@ namespace chrono {
29template <class _Duration>29template <class _Duration>
30class hh_mm_ss {30class hh_mm_ss {
31private:31private:
32 static_assert(__is_duration<_Duration>::value, "template parameter of hh_mm_ss must be a std::chrono::duration");32 static_assert(__is_duration_v<_Duration>, "template parameter of hh_mm_ss must be a std::chrono::duration");
33 using __CommonType = common_type_t<_Duration, chrono::seconds>;33 using __CommonType _LIBCPP_NODEBUG = common_type_t<_Duration, chrono::seconds>;
3434
35 _LIBCPP_HIDE_FROM_ABI static constexpr uint64_t __pow10(unsigned __exp) {35 _LIBCPP_HIDE_FROM_ABI static constexpr uint64_t __pow10(unsigned __exp) {
36 uint64_t __ret = 1;36 uint64_t __ret = 1;
lib/libcxx/include/__chrono/high_resolution_clock.h+1-1
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
23namespace chrono {23namespace chrono {
2424
25#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK25#if _LIBCPP_HAS_MONOTONIC_CLOCK
26typedef steady_clock high_resolution_clock;26typedef steady_clock high_resolution_clock;
27#else27#else
28typedef system_clock high_resolution_clock;28typedef system_clock high_resolution_clock;
lib/libcxx/include/__chrono/leap_second.h+73-68
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
1414
15#include <version>15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)17#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
1818
19# include <__chrono/duration.h>19# include <__chrono/duration.h>
20# include <__chrono/system_clock.h>20# include <__chrono/system_clock.h>
...@@ -43,84 +43,89 @@ public:...@@ -43,84 +43,89 @@ public:
43 _LIBCPP_HIDE_FROM_ABI leap_second(const leap_second&) = default;43 _LIBCPP_HIDE_FROM_ABI leap_second(const leap_second&) = default;
44 _LIBCPP_HIDE_FROM_ABI leap_second& operator=(const leap_second&) = default;44 _LIBCPP_HIDE_FROM_ABI leap_second& operator=(const leap_second&) = default;
4545
46 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr sys_seconds date() const noexcept { return __date_; }46 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr sys_seconds date() const noexcept { return __date_; }
4747
48 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr seconds value() const noexcept { return __value_; }48 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr seconds value() const noexcept { return __value_; }
4949
50private:50private:
51 sys_seconds __date_;51 sys_seconds __date_;
52 seconds __value_;52 seconds __value_;
53};
5453
55_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const leap_second& __x, const leap_second& __y) {54 // The function
56 return __x.date() == __y.date();55 // template<class Duration>
57}56 // requires three_way_comparable_with<sys_seconds, sys_time<Duration>>
5857 // constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y) noexcept;
59_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const leap_second& __x, const leap_second& __y) {58 //
60 return __x.date() <=> __y.date();59 // Has constraints that are recursive (LWG4139). The proposed resolution is
61}60 // to make the funcion a hidden friend. For consistency make this change for
6261 // all comparison functions.
63template <class _Duration>62
64_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const leap_second& __x, const sys_time<_Duration>& __y) {63 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const leap_second& __x, const leap_second& __y) {
65 return __x.date() == __y;64 return __x.date() == __y.date();
66}65 }
6766
68template <class _Duration>67 _LIBCPP_HIDE_FROM_ABI friend constexpr strong_ordering operator<=>(const leap_second& __x, const leap_second& __y) {
69_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const leap_second& __x, const sys_time<_Duration>& __y) {68 return __x.date() <=> __y.date();
70 return __x.date() < __y;69 }
71}70
7271 template <class _Duration>
73template <class _Duration>72 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const leap_second& __x, const sys_time<_Duration>& __y) {
74_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const sys_time<_Duration>& __x, const leap_second& __y) {73 return __x.date() == __y;
75 return __x < __y.date();74 }
76}75
7776 template <class _Duration>
78template <class _Duration>77 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const leap_second& __x, const sys_time<_Duration>& __y) {
79_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const leap_second& __x, const sys_time<_Duration>& __y) {78 return __x.date() < __y;
80 return __y < __x;79 }
81}80
8281 template <class _Duration>
83template <class _Duration>82 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const sys_time<_Duration>& __x, const leap_second& __y) {
84_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const sys_time<_Duration>& __x, const leap_second& __y) {83 return __x < __y.date();
85 return __y < __x;84 }
86}85
8786 template <class _Duration>
88template <class _Duration>87 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const leap_second& __x, const sys_time<_Duration>& __y) {
89_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const leap_second& __x, const sys_time<_Duration>& __y) {88 return __y < __x;
90 return !(__y < __x);89 }
91}90
9291 template <class _Duration>
93template <class _Duration>92 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const sys_time<_Duration>& __x, const leap_second& __y) {
94_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const sys_time<_Duration>& __x, const leap_second& __y) {93 return __y < __x;
95 return !(__y < __x);94 }
96}95
9796 template <class _Duration>
98template <class _Duration>97 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const leap_second& __x, const sys_time<_Duration>& __y) {
99_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const leap_second& __x, const sys_time<_Duration>& __y) {98 return !(__y < __x);
100 return !(__x < __y);99 }
101}100
102101 template <class _Duration>
103template <class _Duration>102 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const sys_time<_Duration>& __x, const leap_second& __y) {
104_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const sys_time<_Duration>& __x, const leap_second& __y) {103 return !(__y < __x);
105 return !(__x < __y);104 }
106}105
107106 template <class _Duration>
108# ifndef _LIBCPP_COMPILER_GCC107 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const leap_second& __x, const sys_time<_Duration>& __y) {
109// This requirement cause a compilation loop in GCC-13 and running out of memory.108 return !(__x < __y);
110// TODO TZDB Test whether GCC-14 fixes this.109 }
111template <class _Duration>110
112 requires three_way_comparable_with<sys_seconds, sys_time<_Duration>>111 template <class _Duration>
113_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(const leap_second& __x, const sys_time<_Duration>& __y) {112 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const sys_time<_Duration>& __x, const leap_second& __y) {
114 return __x.date() <=> __y;113 return !(__x < __y);
115}114 }
116# endif115
116 template <class _Duration>
117 requires three_way_comparable_with<sys_seconds, sys_time<_Duration>>
118 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const leap_second& __x, const sys_time<_Duration>& __y) {
119 return __x.date() <=> __y;
120 }
121};
117122
118} // namespace chrono123} // namespace chrono
119124
120# endif //_LIBCPP_STD_VER >= 20125# endif // _LIBCPP_STD_VER >= 20
121126
122_LIBCPP_END_NAMESPACE_STD127_LIBCPP_END_NAMESPACE_STD
123128
124#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)129#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
125130
126#endif // _LIBCPP___CHRONO_LEAP_SECOND_H131#endif // _LIBCPP___CHRONO_LEAP_SECOND_H
lib/libcxx/include/__chrono/local_info.h+2-2
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
1414
15#include <version>15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)17#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
1818
19# include <__chrono/sys_info.h>19# include <__chrono/sys_info.h>
20# include <__config>20# include <__config>
...@@ -45,6 +45,6 @@ struct local_info {...@@ -45,6 +45,6 @@ struct local_info {
4545
46_LIBCPP_END_NAMESPACE_STD46_LIBCPP_END_NAMESPACE_STD
4747
48#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)48#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
4949
50#endif // _LIBCPP___CHRONO_LOCAL_INFO_H50#endif // _LIBCPP___CHRONO_LOCAL_INFO_H
lib/libcxx/include/__chrono/month.h+1-1
...@@ -11,8 +11,8 @@...@@ -11,8 +11,8 @@
11#define _LIBCPP___CHRONO_MONTH_H11#define _LIBCPP___CHRONO_MONTH_H
1212
13#include <__chrono/duration.h>13#include <__chrono/duration.h>
14#include <__compare/ordering.h>
14#include <__config>15#include <__config>
15#include <compare>
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/__chrono/monthday.h+1-1
...@@ -13,8 +13,8 @@...@@ -13,8 +13,8 @@
13#include <__chrono/calendar.h>13#include <__chrono/calendar.h>
14#include <__chrono/day.h>14#include <__chrono/day.h>
15#include <__chrono/month.h>15#include <__chrono/month.h>
16#include <__compare/ordering.h>
16#include <__config>17#include <__config>
17#include <compare>
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/__chrono/ostream.h+53-35
...@@ -10,37 +10,42 @@...@@ -10,37 +10,42 @@
10#ifndef _LIBCPP___CHRONO_OSTREAM_H10#ifndef _LIBCPP___CHRONO_OSTREAM_H
11#define _LIBCPP___CHRONO_OSTREAM_H11#define _LIBCPP___CHRONO_OSTREAM_H
1212
13#include <__chrono/calendar.h>
14#include <__chrono/day.h>
15#include <__chrono/duration.h>
16#include <__chrono/file_clock.h>
17#include <__chrono/hh_mm_ss.h>
18#include <__chrono/local_info.h>
19#include <__chrono/month.h>
20#include <__chrono/month_weekday.h>
21#include <__chrono/monthday.h>
22#include <__chrono/statically_widen.h>
23#include <__chrono/sys_info.h>
24#include <__chrono/system_clock.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 <__chrono/zoned_time.h>
31#include <__concepts/same_as.h>
32#include <__config>13#include <__config>
33#include <__format/format_functions.h>
34#include <__fwd/ostream.h>
35#include <ratio>
3614
37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if _LIBCPP_HAS_LOCALIZATION
38# pragma GCC system_header16
39#endif17# include <__chrono/calendar.h>
18# include <__chrono/day.h>
19# include <__chrono/duration.h>
20# include <__chrono/file_clock.h>
21# include <__chrono/hh_mm_ss.h>
22# include <__chrono/local_info.h>
23# include <__chrono/month.h>
24# include <__chrono/month_weekday.h>
25# include <__chrono/monthday.h>
26# include <__chrono/statically_widen.h>
27# include <__chrono/sys_info.h>
28# include <__chrono/system_clock.h>
29# include <__chrono/utc_clock.h>
30# include <__chrono/weekday.h>
31# include <__chrono/year.h>
32# include <__chrono/year_month.h>
33# include <__chrono/year_month_day.h>
34# include <__chrono/year_month_weekday.h>
35# include <__chrono/zoned_time.h>
36# include <__concepts/same_as.h>
37# include <__format/format_functions.h>
38# include <__fwd/ostream.h>
39# include <ratio>
40# include <sstream>
41
42# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
43# pragma GCC system_header
44# endif
4045
41_LIBCPP_BEGIN_NAMESPACE_STD46_LIBCPP_BEGIN_NAMESPACE_STD
4247
43#if _LIBCPP_STD_VER >= 2048# if _LIBCPP_STD_VER >= 20
4449
45namespace chrono {50namespace chrono {
4651
...@@ -57,6 +62,18 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const sys_days& __dp) {...@@ -57,6 +62,18 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const sys_days& __dp) {
57 return __os << year_month_day{__dp};62 return __os << year_month_day{__dp};
58}63}
5964
65# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
66# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
67
68template <class _CharT, class _Traits, class _Duration>
69_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
70operator<<(basic_ostream<_CharT, _Traits>& __os, const utc_time<_Duration>& __tp) {
71 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T}"), __tp);
72}
73
74# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
75# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
76
60template <class _CharT, class _Traits, class _Duration>77template <class _CharT, class _Traits, class _Duration>
61_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&78_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
62operator<<(basic_ostream<_CharT, _Traits>& __os, const file_time<_Duration> __tp) {79operator<<(basic_ostream<_CharT, _Traits>& __os, const file_time<_Duration> __tp) {
...@@ -82,11 +99,11 @@ _LIBCPP_HIDE_FROM_ABI auto __units_suffix() {...@@ -82,11 +99,11 @@ _LIBCPP_HIDE_FROM_ABI auto __units_suffix() {
82 else if constexpr (same_as<typename _Period::type, nano>)99 else if constexpr (same_as<typename _Period::type, nano>)
83 return _LIBCPP_STATICALLY_WIDEN(_CharT, "ns");100 return _LIBCPP_STATICALLY_WIDEN(_CharT, "ns");
84 else if constexpr (same_as<typename _Period::type, micro>)101 else if constexpr (same_as<typename _Period::type, micro>)
85# ifndef _LIBCPP_HAS_NO_UNICODE102# if _LIBCPP_HAS_UNICODE
86 return _LIBCPP_STATICALLY_WIDEN(_CharT, "\u00b5s");103 return _LIBCPP_STATICALLY_WIDEN(_CharT, "\u00b5s");
87# else104# else
88 return _LIBCPP_STATICALLY_WIDEN(_CharT, "us");105 return _LIBCPP_STATICALLY_WIDEN(_CharT, "us");
89# endif106# endif
90 else if constexpr (same_as<typename _Period::type, milli>)107 else if constexpr (same_as<typename _Period::type, milli>)
91 return _LIBCPP_STATICALLY_WIDEN(_CharT, "ms");108 return _LIBCPP_STATICALLY_WIDEN(_CharT, "ms");
92 else if constexpr (same_as<typename _Period::type, centi>)109 else if constexpr (same_as<typename _Period::type, centi>)
...@@ -265,7 +282,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const hh_mm_ss<_Duration> __hms...@@ -265,7 +282,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const hh_mm_ss<_Duration> __hms
265 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%T}"), __hms);282 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%T}"), __hms);
266}283}
267284
268# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)285# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
269286
270template <class _CharT, class _Traits>287template <class _CharT, class _Traits>
271_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&288_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
...@@ -303,20 +320,21 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const local_info& __info) {...@@ -303,20 +320,21 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const local_info& __info) {
303 _LIBCPP_STATICALLY_WIDEN(_CharT, "{}: {{{}, {}}}"), __result(), __info.first, __info.second);320 _LIBCPP_STATICALLY_WIDEN(_CharT, "{}: {{{}, {}}}"), __result(), __info.first, __info.second);
304}321}
305322
306# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \323# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
307 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
308template <class _CharT, class _Traits, class _Duration, class _TimeZonePtr>324template <class _CharT, class _Traits, class _Duration, class _TimeZonePtr>
309_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&325_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
310operator<<(basic_ostream<_CharT, _Traits>& __os, const zoned_time<_Duration, _TimeZonePtr>& __tp) {326operator<<(basic_ostream<_CharT, _Traits>& __os, const zoned_time<_Duration, _TimeZonePtr>& __tp) {
311 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T %Z}"), __tp);327 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T %Z}"), __tp);
312}328}
313# endif329# endif
314# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)330# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
315331
316} // namespace chrono332} // namespace chrono
317333
318#endif // if _LIBCPP_STD_VER >= 20334# endif // if _LIBCPP_STD_VER >= 20
319335
320_LIBCPP_END_NAMESPACE_STD336_LIBCPP_END_NAMESPACE_STD
321337
338#endif // _LIBCPP_HAS_LOCALIZATION
339
322#endif // _LIBCPP___CHRONO_OSTREAM_H340#endif // _LIBCPP___CHRONO_OSTREAM_H
lib/libcxx/include/__chrono/parser_std_format_spec.h+17-12
...@@ -11,20 +11,23 @@...@@ -11,20 +11,23 @@
11#define _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H11#define _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H
1212
13#include <__config>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>
2014
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if _LIBCPP_HAS_LOCALIZATION
22# pragma GCC system_header16
23#endif17# include <__format/concepts.h>
18# include <__format/format_error.h>
19# include <__format/format_parse_context.h>
20# include <__format/formatter_string.h>
21# include <__format/parser_std_format_spec.h>
22# include <string_view>
23
24# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26# endif
2427
25_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2629
27#if _LIBCPP_STD_VER >= 2030# if _LIBCPP_STD_VER >= 20
2831
29namespace __format_spec {32namespace __format_spec {
3033
...@@ -137,7 +140,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __validate_time_zone(__flags __flags) {...@@ -137,7 +140,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __validate_time_zone(__flags __flags) {
137140
138template <class _CharT>141template <class _CharT>
139class _LIBCPP_TEMPLATE_VIS __parser_chrono {142class _LIBCPP_TEMPLATE_VIS __parser_chrono {
140 using _ConstIterator = typename basic_format_parse_context<_CharT>::const_iterator;143 using _ConstIterator _LIBCPP_NODEBUG = typename basic_format_parse_context<_CharT>::const_iterator;
141144
142public:145public:
143 template <class _ParseContext>146 template <class _ParseContext>
...@@ -409,8 +412,10 @@ private:...@@ -409,8 +412,10 @@ private:
409412
410} // namespace __format_spec413} // namespace __format_spec
411414
412#endif //_LIBCPP_STD_VER >= 20415# endif // _LIBCPP_STD_VER >= 20
413416
414_LIBCPP_END_NAMESPACE_STD417_LIBCPP_END_NAMESPACE_STD
415418
419#endif // _LIBCPP_HAS_LOCALIZATION
420
416#endif // _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H421#endif // _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H
lib/libcxx/include/__chrono/statically_widen.h+4-4
...@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424
25#if _LIBCPP_STD_VER >= 2025#if _LIBCPP_STD_VER >= 20
2626
27# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS27# if _LIBCPP_HAS_WIDE_CHARACTERS
28template <__fmt_char_type _CharT>28template <__fmt_char_type _CharT>
29_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __str, const wchar_t* __wstr) {29_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __str, const wchar_t* __wstr) {
30 if constexpr (same_as<_CharT, char>)30 if constexpr (same_as<_CharT, char>)
...@@ -33,7 +33,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __s...@@ -33,7 +33,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __s
33 return __wstr;33 return __wstr;
34}34}
35# define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str, L##__str)35# define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str, L##__str)
36# else // _LIBCPP_HAS_NO_WIDE_CHARACTERS36# else // _LIBCPP_HAS_WIDE_CHARACTERS
3737
38// Without this indirection the unit test test/libcxx/modules_include.sh.cpp38// 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.39// fails for the CI build "No wide characters". This seems like a bug.
...@@ -43,9 +43,9 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __s...@@ -43,9 +43,9 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __s
43 return __str;43 return __str;
44}44}
45# define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str)45# define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str)
46# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS46# endif // _LIBCPP_HAS_WIDE_CHARACTERS
4747
48#endif //_LIBCPP_STD_VER >= 2048#endif // _LIBCPP_STD_VER >= 20
4949
50_LIBCPP_END_NAMESPACE_STD50_LIBCPP_END_NAMESPACE_STD
5151
lib/libcxx/include/__chrono/steady_clock.h+1-1
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
23namespace chrono {23namespace chrono {
2424
25#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK25#if _LIBCPP_HAS_MONOTONIC_CLOCK
26class _LIBCPP_EXPORTED_FROM_ABI steady_clock {26class _LIBCPP_EXPORTED_FROM_ABI steady_clock {
27public:27public:
28 typedef nanoseconds duration;28 typedef nanoseconds duration;
lib/libcxx/include/__chrono/sys_info.h+2-2
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
1414
15#include <version>15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)17#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
1818
19# include <__chrono/duration.h>19# include <__chrono/duration.h>
20# include <__chrono/system_clock.h>20# include <__chrono/system_clock.h>
...@@ -46,6 +46,6 @@ struct sys_info {...@@ -46,6 +46,6 @@ struct sys_info {
4646
47_LIBCPP_END_NAMESPACE_STD47_LIBCPP_END_NAMESPACE_STD
4848
49#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)49#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
5050
51#endif // _LIBCPP___CHRONO_SYS_INFO_H51#endif // _LIBCPP___CHRONO_SYS_INFO_H
lib/libcxx/include/__chrono/time_point.h+4-5
...@@ -32,8 +32,7 @@ namespace chrono {...@@ -32,8 +32,7 @@ namespace chrono {
3232
33template <class _Clock, class _Duration = typename _Clock::duration>33template <class _Clock, class _Duration = typename _Clock::duration>
34class _LIBCPP_TEMPLATE_VIS time_point {34class _LIBCPP_TEMPLATE_VIS time_point {
35 static_assert(__is_duration<_Duration>::value,35 static_assert(__is_duration_v<_Duration>, "Second template parameter of time_point must be a std::chrono::duration");
36 "Second template parameter of time_point must be a std::chrono::duration");
3736
38public:37public:
39 typedef _Clock clock;38 typedef _Clock clock;
...@@ -91,17 +90,17 @@ time_point_cast(const time_point<_Clock, _Duration>& __t) {...@@ -91,17 +90,17 @@ time_point_cast(const time_point<_Clock, _Duration>& __t) {
91}90}
9291
93#if _LIBCPP_STD_VER >= 1792#if _LIBCPP_STD_VER >= 17
94template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>93template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration_v<_ToDuration>, int> = 0>
95inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> floor(const time_point<_Clock, _Duration>& __t) {94inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> floor(const time_point<_Clock, _Duration>& __t) {
96 return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())};95 return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())};
97}96}
9897
99template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>98template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration_v<_ToDuration>, int> = 0>
100inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> ceil(const time_point<_Clock, _Duration>& __t) {99inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> ceil(const time_point<_Clock, _Duration>& __t) {
101 return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())};100 return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())};
102}101}
103102
104template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>103template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration_v<_ToDuration>, int> = 0>
105inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> round(const time_point<_Clock, _Duration>& __t) {104inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> round(const time_point<_Clock, _Duration>& __t) {
106 return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())};105 return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())};
107}106}
lib/libcxx/include/__chrono/time_zone.h+11-8
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
1414
15#include <version>15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)17#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
1818
19# include <__chrono/calendar.h>19# include <__chrono/calendar.h>
20# include <__chrono/duration.h>20# include <__chrono/duration.h>
...@@ -37,8 +37,7 @@ _LIBCPP_PUSH_MACROS...@@ -37,8 +37,7 @@ _LIBCPP_PUSH_MACROS
3737
38_LIBCPP_BEGIN_NAMESPACE_STD38_LIBCPP_BEGIN_NAMESPACE_STD
3939
40# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \40# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
41 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
4241
43namespace chrono {42namespace chrono {
4443
...@@ -104,10 +103,14 @@ public:...@@ -104,10 +103,14 @@ public:
104 to_sys(const local_time<_Duration>& __time, choose __z) const {103 to_sys(const local_time<_Duration>& __time, choose __z) const {
105 local_info __info = get_info(__time);104 local_info __info = get_info(__time);
106 switch (__info.result) {105 switch (__info.result) {
107 case local_info::unique:106 case local_info::unique: // first and second are the same
108 case local_info::nonexistent: // first and second are the same
109 return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.first.offset};107 return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.first.offset};
110108
109 case local_info::nonexistent:
110 // first and second are the same
111 // All non-existing values are converted to the same time.
112 return sys_time<common_type_t<_Duration, seconds>>{__info.first.end};
113
111 case local_info::ambiguous:114 case local_info::ambiguous:
112 switch (__z) {115 switch (__z) {
113 case choose::earliest:116 case choose::earliest:
...@@ -170,13 +173,13 @@ operator<=>(const time_zone& __x, const time_zone& __y) noexcept {...@@ -170,13 +173,13 @@ operator<=>(const time_zone& __x, const time_zone& __y) noexcept {
170173
171} // namespace chrono174} // namespace chrono
172175
173# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)176# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
174 // && !defined(_LIBCPP_HAS_NO_LOCALIZATION)177 // _LIBCPP_HAS_LOCALIZATION
175178
176_LIBCPP_END_NAMESPACE_STD179_LIBCPP_END_NAMESPACE_STD
177180
178_LIBCPP_POP_MACROS181_LIBCPP_POP_MACROS
179182
180#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)183#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
181184
182#endif // _LIBCPP___CHRONO_TIME_ZONE_H185#endif // _LIBCPP___CHRONO_TIME_ZONE_H
lib/libcxx/include/__chrono/time_zone_link.h+5-5
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
1414
15#include <version>15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)17#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
1818
19# include <__compare/strong_order.h>19# include <__compare/strong_order.h>
20# include <__config>20# include <__config>
...@@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS...@@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS
3131
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
34# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \34# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
35 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
3635
37namespace chrono {36namespace chrono {
3837
...@@ -68,12 +67,13 @@ operator<=>(const time_zone_link& __x, const time_zone_link& __y) noexcept {...@@ -68,12 +67,13 @@ operator<=>(const time_zone_link& __x, const time_zone_link& __y) noexcept {
6867
69} // namespace chrono68} // namespace chrono
7069
71# endif //_LIBCPP_STD_VER >= 2070# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
71 // _LIBCPP_HAS_LOCALIZATION
7272
73_LIBCPP_END_NAMESPACE_STD73_LIBCPP_END_NAMESPACE_STD
7474
75_LIBCPP_POP_MACROS75_LIBCPP_POP_MACROS
7676
77#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)77#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
7878
79#endif // _LIBCPP___CHRONO_TIME_ZONE_LINK_H79#endif // _LIBCPP___CHRONO_TIME_ZONE_LINK_H
lib/libcxx/include/__chrono/tzdb.h+9-7
...@@ -14,15 +14,18 @@...@@ -14,15 +14,18 @@
1414
15#include <version>15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)17#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
1818
19# include <__algorithm/ranges_lower_bound.h>19# include <__algorithm/ranges_lower_bound.h>
20# include <__chrono/leap_second.h>20# include <__chrono/leap_second.h>
21# include <__chrono/time_zone.h>21# include <__chrono/time_zone.h>
22# include <__chrono/time_zone_link.h>22# include <__chrono/time_zone_link.h>
23# include <__config>23# include <__config>
24# include <__memory/addressof.h>
25# include <__vector/vector.h>
26# include <stdexcept>
24# include <string>27# include <string>
25# include <vector>28# include <string_view>
2629
27# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header31# pragma GCC system_header
...@@ -33,8 +36,7 @@ _LIBCPP_PUSH_MACROS...@@ -33,8 +36,7 @@ _LIBCPP_PUSH_MACROS
3336
34_LIBCPP_BEGIN_NAMESPACE_STD37_LIBCPP_BEGIN_NAMESPACE_STD
3538
36# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \39# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
37 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
3840
39namespace chrono {41namespace chrono {
4042
...@@ -82,13 +84,13 @@ private:...@@ -82,13 +84,13 @@ private:
8284
83} // namespace chrono85} // namespace chrono
8486
85# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)87# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
86 // && !defined(_LIBCPP_HAS_NO_LOCALIZATION)88 // _LIBCPP_HAS_LOCALIZATION
8789
88_LIBCPP_END_NAMESPACE_STD90_LIBCPP_END_NAMESPACE_STD
8991
90_LIBCPP_POP_MACROS92_LIBCPP_POP_MACROS
9193
92#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)94#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
9395
94#endif // _LIBCPP___CHRONO_TZDB_H96#endif // _LIBCPP___CHRONO_TZDB_H
lib/libcxx/include/__chrono/tzdb_list.h+6-6
...@@ -14,13 +14,14 @@...@@ -14,13 +14,14 @@
1414
15#include <version>15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)17#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
1818
19# include <__chrono/time_zone.h>19# include <__chrono/time_zone.h>
20# include <__chrono/tzdb.h>20# include <__chrono/tzdb.h>
21# include <__config>21# include <__config>
22# include <__fwd/string.h>22# include <__fwd/string.h>
23# include <forward_list>23# include <forward_list>
24# include <string_view>
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
...@@ -28,8 +29,7 @@...@@ -28,8 +29,7 @@
2829
29_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3031
31# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \32# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
32 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
3333
34namespace chrono {34namespace chrono {
3535
...@@ -98,11 +98,11 @@ _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb();...@@ -98,11 +98,11 @@ _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb();
9898
99} // namespace chrono99} // namespace chrono
100100
101# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)101# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
102 // && !defined(_LIBCPP_HAS_NO_LOCALIZATION)102 // _LIBCPP_HAS_LOCALIZATION
103103
104_LIBCPP_END_NAMESPACE_STD104_LIBCPP_END_NAMESPACE_STD
105105
106#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)106#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
107107
108#endif // _LIBCPP___CHRONO_TZDB_LIST_H108#endif // _LIBCPP___CHRONO_TZDB_LIST_H
lib/libcxx/include/__chrono/utc_clock.h created+163
...@@ -0,0 +1,163 @@
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_UTC_CLOCK_H
11#define _LIBCPP___CHRONO_UTC_CLOCK_H
12
13#include <version>
14// Enable the contents of the header only when libc++ was built with experimental features enabled.
15#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
16
17# include <__chrono/duration.h>
18# include <__chrono/leap_second.h>
19# include <__chrono/system_clock.h>
20# include <__chrono/time_point.h>
21# include <__chrono/tzdb.h>
22# include <__chrono/tzdb_list.h>
23# include <__config>
24# include <__type_traits/common_type.h>
25
26# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28# endif
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
33
34namespace chrono {
35
36class utc_clock;
37
38template <class _Duration>
39using utc_time = time_point<utc_clock, _Duration>;
40using utc_seconds = utc_time<seconds>;
41
42class utc_clock {
43public:
44 using rep = system_clock::rep;
45 using period = system_clock::period;
46 using duration = chrono::duration<rep, period>;
47 using time_point = chrono::time_point<utc_clock>;
48 static constexpr bool is_steady = false; // The system_clock is not steady.
49
50 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static time_point now() { return from_sys(system_clock::now()); }
51
52 template <class _Duration>
53 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static sys_time<common_type_t<_Duration, seconds>>
54 to_sys(const utc_time<_Duration>& __time);
55
56 template <class _Duration>
57 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static utc_time<common_type_t<_Duration, seconds>>
58 from_sys(const sys_time<_Duration>& __time) {
59 using _Rp = utc_time<common_type_t<_Duration, seconds>>;
60 // TODO TZDB investigate optimizations.
61 //
62 // The leap second database stores all transitions, this mean to calculate
63 // the current number of leap seconds the code needs to iterate over all
64 // leap seconds to accumulate the sum. Then the sum can be used to determine
65 // the sys_time. Accessing the database involves acquiring a mutex.
66 //
67 // The historic entries in the database are immutable. Hard-coding these
68 // values in a table would allow:
69 // - To store the sum, allowing a binary search on the data.
70 // - Avoid acquiring a mutex.
71 // The disadvantage are:
72 // - A slightly larger code size.
73 //
74 // There are two optimization directions
75 // - hard-code the database and do a linear search for future entries. This
76 // search can start at the back, and should probably contain very few
77 // entries. (Adding leap seconds is quite rare and new release of libc++
78 // can add the new entries; they are announced half a year before they are
79 // added.)
80 // - During parsing the leap seconds store an additional database in the
81 // dylib with the list of the sum of the leap seconds. In that case there
82 // can be a private function __get_utc_to_sys_table that returns the
83 // table.
84 //
85 // Note for to_sys there are no optimizations to be done; it uses
86 // get_leap_second_info. The function get_leap_second_info could benefit
87 // from optimizations as described above; again both options apply.
88
89 // Both UTC and the system clock use the same epoch. The Standard
90 // specifies from 1970-01-01 even when UTC starts at
91 // 1972-01-01 00:00:10 TAI. So when the sys_time is before epoch we can be
92 // sure there both clocks return the same value.
93
94 const tzdb& __tzdb = chrono::get_tzdb();
95 _Rp __result{__time.time_since_epoch()};
96 for (const auto& __leap_second : __tzdb.leap_seconds) {
97 if (__leap_second > __time)
98 return __result;
99
100 __result += __leap_second.value();
101 }
102 return __result;
103 }
104};
105
106struct leap_second_info {
107 bool is_leap_second;
108 seconds elapsed;
109};
110
111template <class _Duration>
112[[nodiscard]] _LIBCPP_HIDE_FROM_ABI leap_second_info get_leap_second_info(const utc_time<_Duration>& __time) {
113 const tzdb& __tzdb = chrono::get_tzdb();
114 if (__tzdb.leap_seconds.empty()) [[unlikely]]
115 return {false, chrono::seconds{0}};
116
117 sys_seconds __sys{chrono::floor<seconds>(__time).time_since_epoch()};
118 seconds __elapsed{0};
119 for (const auto& __leap_second : __tzdb.leap_seconds) {
120 if (__sys == __leap_second.date() + __elapsed)
121 // A time point may only be a leap second during a positive leap second
122 // insertion, since time points that occur during a (theoretical)
123 // negative leap second don't exist.
124 return {__leap_second.value() > 0s, __elapsed + __leap_second.value()};
125
126 if (__sys < __leap_second.date() + __elapsed)
127 return {false, __elapsed};
128
129 __elapsed += __leap_second.value();
130 }
131
132 return {false, __elapsed};
133}
134
135template <class _Duration>
136[[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time<common_type_t<_Duration, seconds>>
137utc_clock::to_sys(const utc_time<_Duration>& __time) {
138 using _Dp = common_type_t<_Duration, seconds>;
139 leap_second_info __info = chrono::get_leap_second_info(__time);
140
141 // [time.clock.utc.members]/2
142 // Returns: A sys_time t, such that from_sys(t) == u if such a mapping
143 // exists. Otherwise u represents a time_point during a positive leap
144 // second insertion, the conversion counts that leap second as not
145 // inserted, and the last representable value of sys_time prior to the
146 // insertion of the leap second is returned.
147 sys_time<common_type_t<_Duration, seconds>> __result{__time.time_since_epoch() - __info.elapsed};
148 if (__info.is_leap_second)
149 return chrono::floor<seconds>(__result) + chrono::seconds{1} - _Dp{1};
150
151 return __result;
152}
153
154} // namespace chrono
155
156# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
157 // _LIBCPP_HAS_LOCALIZATION
158
159_LIBCPP_END_NAMESPACE_STD
160
161#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
162
163#endif // _LIBCPP___CHRONO_UTC_CLOCK_H
lib/libcxx/include/__chrono/weekday.h-19
...@@ -79,25 +79,6 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const weekday& __lhs, con...@@ -79,25 +79,6 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const weekday& __lhs, con
79 return __lhs.c_encoding() == __rhs.c_encoding();79 return __lhs.c_encoding() == __rhs.c_encoding();
80}80}
8181
82// TODO(LLVM 20): Remove the escape hatch
83# ifdef _LIBCPP_ENABLE_REMOVED_WEEKDAY_RELATIONAL_OPERATORS
84_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<(const weekday& __lhs, const weekday& __rhs) noexcept {
85 return __lhs.c_encoding() < __rhs.c_encoding();
86}
87
88_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>(const weekday& __lhs, const weekday& __rhs) noexcept {
89 return __rhs < __lhs;
90}
91
92_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept {
93 return !(__rhs < __lhs);
94}
95
96_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept {
97 return !(__lhs < __rhs);
98}
99# endif // _LIBCPP_ENABLE_REMOVED_WEEKDAY_RELATIONAL_OPERATORS
100
101_LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept {82_LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept {
102 auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count();83 auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count();
103 auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7;84 auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7;
lib/libcxx/include/__chrono/year.h+1-1
...@@ -11,8 +11,8 @@...@@ -11,8 +11,8 @@
11#define _LIBCPP___CHRONO_YEAR_H11#define _LIBCPP___CHRONO_YEAR_H
1212
13#include <__chrono/duration.h>13#include <__chrono/duration.h>
14#include <__compare/ordering.h>
14#include <__config>15#include <__config>
15#include <compare>
16#include <limits>16#include <limits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__chrono/year_month.h+1-1
...@@ -13,8 +13,8 @@...@@ -13,8 +13,8 @@
13#include <__chrono/duration.h>13#include <__chrono/duration.h>
14#include <__chrono/month.h>14#include <__chrono/month.h>
15#include <__chrono/year.h>15#include <__chrono/year.h>
16#include <__compare/ordering.h>
16#include <__config>17#include <__config>
17#include <compare>
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/__chrono/year_month_day.h+1-1
...@@ -19,8 +19,8 @@...@@ -19,8 +19,8 @@
19#include <__chrono/time_point.h>19#include <__chrono/time_point.h>
20#include <__chrono/year.h>20#include <__chrono/year.h>
21#include <__chrono/year_month.h>21#include <__chrono/year_month.h>
22#include <__compare/ordering.h>
22#include <__config>23#include <__config>
23#include <compare>
24#include <limits>24#include <limits>
2525
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__chrono/zoned_time.h+13-12
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
1414
15#include <version>15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)17#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
1818
19# include <__chrono/calendar.h>19# include <__chrono/calendar.h>
20# include <__chrono/duration.h>20# include <__chrono/duration.h>
...@@ -22,12 +22,14 @@...@@ -22,12 +22,14 @@
22# include <__chrono/system_clock.h>22# include <__chrono/system_clock.h>
23# include <__chrono/time_zone.h>23# include <__chrono/time_zone.h>
24# include <__chrono/tzdb_list.h>24# include <__chrono/tzdb_list.h>
25# include <__concepts/constructible.h>
25# include <__config>26# include <__config>
26# include <__fwd/string_view.h>
27# include <__type_traits/common_type.h>27# include <__type_traits/common_type.h>
28# include <__type_traits/conditional.h>28# include <__type_traits/conditional.h>
29# include <__type_traits/remove_cvref.h>29# include <__type_traits/remove_cvref.h>
30# include <__utility/declval.h>
30# include <__utility/move.h>31# include <__utility/move.h>
32# include <string_view>
3133
32# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)34# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
33# pragma GCC system_header35# pragma GCC system_header
...@@ -38,8 +40,7 @@ _LIBCPP_PUSH_MACROS...@@ -38,8 +40,7 @@ _LIBCPP_PUSH_MACROS
3840
39_LIBCPP_BEGIN_NAMESPACE_STD41_LIBCPP_BEGIN_NAMESPACE_STD
4042
41# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \43# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
42 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
4344
44namespace chrono {45namespace chrono {
4546
...@@ -57,7 +58,7 @@ struct zoned_traits<const time_zone*> {...@@ -57,7 +58,7 @@ struct zoned_traits<const time_zone*> {
57template <class _Duration, class _TimeZonePtr = const time_zone*>58template <class _Duration, class _TimeZonePtr = const time_zone*>
58class zoned_time {59class zoned_time {
59 // [time.zone.zonedtime.ctor]/260 // [time.zone.zonedtime.ctor]/2
60 static_assert(__is_duration<_Duration>::value,61 static_assert(__is_duration_v<_Duration>,
61 "the program is ill-formed since _Duration is not a specialization of std::chrono::duration");62 "the program is ill-formed since _Duration is not a specialization of std::chrono::duration");
6263
63 // The wording uses the constraints like64 // The wording uses the constraints like
...@@ -65,7 +66,7 @@ class zoned_time {...@@ -65,7 +66,7 @@ class zoned_time {
65 // Using these constraints in the code causes the compiler to give an66 // Using these constraints in the code causes the compiler to give an
66 // error that the constraint depends on itself. To avoid that issue use67 // error that the constraint depends on itself. To avoid that issue use
67 // the fact it is possible to create this object from a _TimeZonePtr.68 // the fact it is possible to create this object from a _TimeZonePtr.
68 using __traits = zoned_traits<_TimeZonePtr>;69 using __traits _LIBCPP_NODEBUG = zoned_traits<_TimeZonePtr>;
6970
70public:71public:
71 using duration = common_type_t<_Duration, seconds>;72 using duration = common_type_t<_Duration, seconds>;
...@@ -185,7 +186,7 @@ template <class _Duration>...@@ -185,7 +186,7 @@ template <class _Duration>
185zoned_time(sys_time<_Duration>) -> zoned_time<common_type_t<_Duration, seconds>>;186zoned_time(sys_time<_Duration>) -> zoned_time<common_type_t<_Duration, seconds>>;
186187
187template <class _TimeZonePtrOrName>188template <class _TimeZonePtrOrName>
188using __time_zone_representation =189using __time_zone_representation _LIBCPP_NODEBUG =
189 conditional_t<is_convertible_v<_TimeZonePtrOrName, string_view>,190 conditional_t<is_convertible_v<_TimeZonePtrOrName, string_view>,
190 const time_zone*,191 const time_zone*,
191 remove_cvref_t<_TimeZonePtrOrName>>;192 remove_cvref_t<_TimeZonePtrOrName>>;
...@@ -201,8 +202,8 @@ template <class _TimeZonePtrOrName, class _Duration>...@@ -201,8 +202,8 @@ template <class _TimeZonePtrOrName, class _Duration>
201zoned_time(_TimeZonePtrOrName&&, local_time<_Duration>, choose = choose::earliest)202zoned_time(_TimeZonePtrOrName&&, local_time<_Duration>, choose = choose::earliest)
202 -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>;203 -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>;
203204
204template <class _Duration, class _TimeZonePtrOrName, class TimeZonePtr2>205template <class _Duration, class _TimeZonePtrOrName, class _TimeZonePtr2>
205zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, TimeZonePtr2>, choose = choose::earliest)206zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, _TimeZonePtr2>, choose = choose::earliest)
206 -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>;207 -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>;
207208
208using zoned_seconds = zoned_time<seconds>;209using zoned_seconds = zoned_time<seconds>;
...@@ -215,13 +216,13 @@ operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const zoned_time<_...@@ -215,13 +216,13 @@ operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const zoned_time<_
215216
216} // namespace chrono217} // namespace chrono
217218
218# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)219# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
219 // && !defined(_LIBCPP_HAS_NO_LOCALIZATION)220 // _LIBCPP_HAS_LOCALIZATION
220221
221_LIBCPP_END_NAMESPACE_STD222_LIBCPP_END_NAMESPACE_STD
222223
223_LIBCPP_POP_MACROS224_LIBCPP_POP_MACROS
224225
225#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)226#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
226227
227#endif // _LIBCPP___CHRONO_ZONED_TIME_H228#endif // _LIBCPP___CHRONO_ZONED_TIME_H
lib/libcxx/include/__compare/common_comparison_category.h+1-1
...@@ -11,8 +11,8 @@...@@ -11,8 +11,8 @@
1111
12#include <__compare/ordering.h>12#include <__compare/ordering.h>
13#include <__config>13#include <__config>
14#include <__cstddef/size_t.h>
14#include <__type_traits/is_same.h>15#include <__type_traits/is_same.h>
15#include <cstddef>
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/__compare/compare_partial_order_fallback.h+11-12
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__compare/ordering.h>12#include <__compare/ordering.h>
13#include <__compare/partial_order.h>13#include <__compare/partial_order.h>
14#include <__concepts/boolean_testable.h>
14#include <__config>15#include <__config>
15#include <__type_traits/decay.h>16#include <__type_traits/decay.h>
16#include <__type_traits/is_same.h>17#include <__type_traits/is_same.h>
...@@ -37,18 +38,16 @@ struct __fn {...@@ -37,18 +38,16 @@ struct __fn {
37 }38 }
3839
39 template <class _Tp, class _Up>40 template <class _Tp, class _Up>
40 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>41 requires is_same_v<decay_t<_Tp>, decay_t<_Up>> && requires(_Tp&& __t, _Up&& __u) {
41 _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept(42 { std::forward<_Tp>(__t) == std::forward<_Up>(__u) } -> __boolean_testable;
42 std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? partial_ordering::equivalent43 { std::forward<_Tp>(__t) < std::forward<_Up>(__u) } -> __boolean_testable;
43 : std::forward<_Tp>(__t) < std::forward<_Up>(__u) ? partial_ordering::less44 { std::forward<_Up>(__u) < std::forward<_Tp>(__t) } -> __boolean_testable;
44 : std::forward<_Up>(__u) < std::forward<_Tp>(__t)45 }
45 ? partial_ordering::greater46 _LIBCPP_HIDE_FROM_ABI static constexpr partial_ordering __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(
46 : partial_ordering::unordered))47 noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? partial_ordering::equivalent
47 -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? partial_ordering::equivalent48 : std::forward<_Tp>(__t) < std::forward<_Up>(__u) ? partial_ordering::less
48 : std::forward<_Tp>(__t) < std::forward<_Up>(__u) ? partial_ordering::less49 : std::forward<_Up>(__u) < std::forward<_Tp>(__t) ? partial_ordering::greater
49 : std::forward<_Up>(__u) < std::forward<_Tp>(__t)50 : partial_ordering::unordered)) {
50 ? partial_ordering::greater
51 : partial_ordering::unordered) {
52 return std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? partial_ordering::equivalent51 return std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? partial_ordering::equivalent
53 : std::forward<_Tp>(__t) < std::forward<_Up>(__u) ? partial_ordering::less52 : std::forward<_Tp>(__t) < std::forward<_Up>(__u) ? partial_ordering::less
54 : std::forward<_Up>(__u) < std::forward<_Tp>(__t)53 : std::forward<_Up>(__u) < std::forward<_Tp>(__t)
lib/libcxx/include/__compare/compare_strong_order_fallback.h+9-10
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__compare/ordering.h>12#include <__compare/ordering.h>
13#include <__compare/strong_order.h>13#include <__compare/strong_order.h>
14#include <__concepts/boolean_testable.h>
14#include <__config>15#include <__config>
15#include <__type_traits/decay.h>16#include <__type_traits/decay.h>
16#include <__type_traits/is_same.h>17#include <__type_traits/is_same.h>
...@@ -37,16 +38,14 @@ struct __fn {...@@ -37,16 +38,14 @@ struct __fn {
37 }38 }
3839
39 template <class _Tp, class _Up>40 template <class _Tp, class _Up>
40 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>41 requires is_same_v<decay_t<_Tp>, decay_t<_Up>> && requires(_Tp&& __t, _Up&& __u) {
41 _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept(42 { std::forward<_Tp>(__t) == std::forward<_Up>(__u) } -> __boolean_testable;
42 std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? strong_ordering::equal43 { std::forward<_Tp>(__t) < std::forward<_Up>(__u) } -> __boolean_testable;
43 : std::forward<_Tp>(__t) < std::forward<_Up>(__u)44 }
44 ? strong_ordering::less45 _LIBCPP_HIDE_FROM_ABI static constexpr strong_ordering __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(
45 : strong_ordering::greater))46 noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? strong_ordering::equal
46 -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? strong_ordering::equal47 : std::forward<_Tp>(__t) < std::forward<_Up>(__u) ? strong_ordering::less
47 : std::forward<_Tp>(__t) < std::forward<_Up>(__u)48 : strong_ordering::greater)) {
48 ? strong_ordering::less
49 : strong_ordering::greater) {
50 return std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? strong_ordering::equal49 return std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? strong_ordering::equal
51 : std::forward<_Tp>(__t) < std::forward<_Up>(__u)50 : std::forward<_Tp>(__t) < std::forward<_Up>(__u)
52 ? strong_ordering::less51 ? strong_ordering::less
lib/libcxx/include/__compare/compare_three_way_result.h+2-1
...@@ -33,7 +33,8 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<...@@ -33,7 +33,8 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<
33};33};
3434
35template <class _Tp, class _Up = _Tp>35template <class _Tp, class _Up = _Tp>
36struct _LIBCPP_TEMPLATE_VIS compare_three_way_result : __compare_three_way_result<_Tp, _Up, void> {};36struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS compare_three_way_result
37 : __compare_three_way_result<_Tp, _Up, void> {};
3738
38template <class _Tp, class _Up = _Tp>39template <class _Tp, class _Up = _Tp>
39using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type;40using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type;
lib/libcxx/include/__compare/compare_weak_order_fallback.h+7-7
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__compare/ordering.h>12#include <__compare/ordering.h>
13#include <__compare/weak_order.h>13#include <__compare/weak_order.h>
14#include <__concepts/boolean_testable.h>
14#include <__config>15#include <__config>
15#include <__type_traits/decay.h>16#include <__type_traits/decay.h>
16#include <__type_traits/is_same.h>17#include <__type_traits/is_same.h>
...@@ -37,16 +38,15 @@ struct __fn {...@@ -37,16 +38,15 @@ struct __fn {
37 }38 }
3839
39 template <class _Tp, class _Up>40 template <class _Tp, class _Up>
40 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>41 requires is_same_v<decay_t<_Tp>, decay_t<_Up>> && requires(_Tp&& __t, _Up&& __u) {
41 _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept(42 { std::forward<_Tp>(__t) == std::forward<_Up>(__u) } -> __boolean_testable;
43 { std::forward<_Tp>(__t) < std::forward<_Up>(__u) } -> __boolean_testable;
44 }
45 _LIBCPP_HIDE_FROM_ABI static constexpr weak_ordering __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept(
42 std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? weak_ordering::equivalent46 std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? weak_ordering::equivalent
43 : std::forward<_Tp>(__t) < std::forward<_Up>(__u)47 : std::forward<_Tp>(__t) < std::forward<_Up>(__u)
44 ? weak_ordering::less48 ? weak_ordering::less
45 : weak_ordering::greater))49 : weak_ordering::greater)) {
46 -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? weak_ordering::equivalent
47 : std::forward<_Tp>(__t) < std::forward<_Up>(__u)
48 ? weak_ordering::less
49 : weak_ordering::greater) {
50 return std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? weak_ordering::equivalent50 return std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? weak_ordering::equivalent
51 : std::forward<_Tp>(__t) < std::forward<_Up>(__u)51 : std::forward<_Tp>(__t) < std::forward<_Up>(__u)
52 ? weak_ordering::less52 ? weak_ordering::less
lib/libcxx/include/__compare/ordering.h+38-34
...@@ -24,32 +24,35 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,32 +24,35 @@ _LIBCPP_BEGIN_NAMESPACE_STD
24// exposition only24// exposition only
25enum class _OrdResult : signed char { __less = -1, __equiv = 0, __greater = 1 };25enum class _OrdResult : signed char { __less = -1, __equiv = 0, __greater = 1 };
2626
27enum class _NCmpResult : signed char { __unordered = -127 };27enum class _PartialOrdResult : signed char {
28 __less = static_cast<signed char>(_OrdResult::__less),
29 __equiv = static_cast<signed char>(_OrdResult::__equiv),
30 __greater = static_cast<signed char>(_OrdResult::__greater),
31 __unordered = -127,
32};
2833
29class partial_ordering;34class partial_ordering;
30class weak_ordering;35class weak_ordering;
31class strong_ordering;36class strong_ordering;
3237
33template <class _Tp, class... _Args>
34inline constexpr bool __one_of_v = (is_same_v<_Tp, _Args> || ...);
35
36struct _CmpUnspecifiedParam {38struct _CmpUnspecifiedParam {
37 _LIBCPP_HIDE_FROM_ABI constexpr _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}39 // If anything other than a literal 0 is provided, the behavior is undefined by the Standard.
3840 //
39 template <class _Tp, class = enable_if_t<!__one_of_v<_Tp, int, partial_ordering, weak_ordering, strong_ordering>>>41 // The alternative to the `__enable_if__` attribute would be to use the fact that a pointer
40 _CmpUnspecifiedParam(_Tp) = delete;42 // can be constructed from literal 0, but this conflicts with `-Wzero-as-null-pointer-constant`.
43 template <class _Tp, class = __enable_if_t<is_same_v<_Tp, int> > >
44 _LIBCPP_HIDE_FROM_ABI consteval _CmpUnspecifiedParam(_Tp __zero) noexcept
45# if __has_attribute(__enable_if__)
46 __attribute__((__enable_if__(
47 __zero == 0, "Only literal 0 is allowed as the operand of a comparison with one of the ordering types")))
48# endif
49 {
50 (void)__zero;
51 }
41};52};
4253
43class partial_ordering {54class partial_ordering {
44 using _ValueT = signed char;55 _LIBCPP_HIDE_FROM_ABI explicit constexpr partial_ordering(_PartialOrdResult __v) noexcept : __value_(__v) {}
45
46 _LIBCPP_HIDE_FROM_ABI explicit constexpr partial_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
47
48 _LIBCPP_HIDE_FROM_ABI explicit constexpr partial_ordering(_NCmpResult __v) noexcept : __value_(_ValueT(__v)) {}
49
50 _LIBCPP_HIDE_FROM_ABI constexpr bool __is_ordered() const noexcept {
51 return __value_ != _ValueT(_NCmpResult::__unordered);
52 }
5356
54public:57public:
55 // valid values58 // valid values
...@@ -62,39 +65,39 @@ public:...@@ -62,39 +65,39 @@ public:
62 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(partial_ordering, partial_ordering) noexcept = default;65 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(partial_ordering, partial_ordering) noexcept = default;
6366
64 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {67 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
65 return __v.__is_ordered() && __v.__value_ == 0;68 return __v.__value_ == _PartialOrdResult::__equiv;
66 }69 }
6770
68 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(partial_ordering __v, _CmpUnspecifiedParam) noexcept {71 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
69 return __v.__is_ordered() && __v.__value_ < 0;72 return __v.__value_ == _PartialOrdResult::__less;
70 }73 }
7174
72 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {75 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
73 return __v.__is_ordered() && __v.__value_ <= 0;76 return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__less;
74 }77 }
7578
76 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {79 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
77 return __v.__is_ordered() && __v.__value_ > 0;80 return __v.__value_ == _PartialOrdResult::__greater;
78 }81 }
7982
80 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {83 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
81 return __v.__is_ordered() && __v.__value_ >= 0;84 return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__greater;
82 }85 }
8386
84 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(_CmpUnspecifiedParam, partial_ordering __v) noexcept {87 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
85 return __v.__is_ordered() && 0 < __v.__value_;88 return __v.__value_ == _PartialOrdResult::__greater;
86 }89 }
8790
88 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {91 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
89 return __v.__is_ordered() && 0 <= __v.__value_;92 return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__greater;
90 }93 }
9194
92 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(_CmpUnspecifiedParam, partial_ordering __v) noexcept {95 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
93 return __v.__is_ordered() && 0 > __v.__value_;96 return __v.__value_ == _PartialOrdResult::__less;
94 }97 }
9598
96 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {99 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
97 return __v.__is_ordered() && 0 >= __v.__value_;100 return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__less;
98 }101 }
99102
100 _LIBCPP_HIDE_FROM_ABI friend constexpr partial_ordering103 _LIBCPP_HIDE_FROM_ABI friend constexpr partial_ordering
...@@ -108,16 +111,16 @@ public:...@@ -108,16 +111,16 @@ public:
108 }111 }
109112
110private:113private:
111 _ValueT __value_;114 _PartialOrdResult __value_;
112};115};
113116
114inline constexpr partial_ordering partial_ordering::less(_OrdResult::__less);117inline constexpr partial_ordering partial_ordering::less(_PartialOrdResult::__less);
115inline constexpr partial_ordering partial_ordering::equivalent(_OrdResult::__equiv);118inline constexpr partial_ordering partial_ordering::equivalent(_PartialOrdResult::__equiv);
116inline constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater);119inline constexpr partial_ordering partial_ordering::greater(_PartialOrdResult::__greater);
117inline constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered);120inline constexpr partial_ordering partial_ordering::unordered(_PartialOrdResult::__unordered);
118121
119class weak_ordering {122class weak_ordering {
120 using _ValueT = signed char;123 using _ValueT _LIBCPP_NODEBUG = signed char;
121124
122 _LIBCPP_HIDE_FROM_ABI explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}125 _LIBCPP_HIDE_FROM_ABI explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
123126
...@@ -187,7 +190,7 @@ inline constexpr weak_ordering weak_ordering::equivalent(_OrdResult::__equiv);...@@ -187,7 +190,7 @@ inline constexpr weak_ordering weak_ordering::equivalent(_OrdResult::__equiv);
187inline constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater);190inline constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater);
188191
189class strong_ordering {192class strong_ordering {
190 using _ValueT = signed char;193 using _ValueT _LIBCPP_NODEBUG = signed char;
191194
192 _LIBCPP_HIDE_FROM_ABI explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}195 _LIBCPP_HIDE_FROM_ABI explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
193196
...@@ -269,7 +272,8 @@ inline constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater)...@@ -269,7 +272,8 @@ inline constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater)
269/// The types partial_ordering, weak_ordering, and strong_ordering are272/// The types partial_ordering, weak_ordering, and strong_ordering are
270/// collectively termed the comparison category types.273/// collectively termed the comparison category types.
271template <class _Tp>274template <class _Tp>
272concept __comparison_category = __one_of_v<_Tp, partial_ordering, weak_ordering, strong_ordering>;275concept __comparison_category =
276 is_same_v<_Tp, partial_ordering> || is_same_v<_Tp, weak_ordering> || is_same_v<_Tp, strong_ordering>;
273277
274#endif // _LIBCPP_STD_VER >= 20278#endif // _LIBCPP_STD_VER >= 20
275279
lib/libcxx/include/__compare/synth_three_way.h+2-1
...@@ -43,7 +43,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, cl...@@ -43,7 +43,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, cl
43};43};
4444
45template <class _Tp, class _Up = _Tp>45template <class _Tp, class _Up = _Tp>
46using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));46using __synth_three_way_result _LIBCPP_NODEBUG =
47 decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));
4748
48#endif // _LIBCPP_STD_VER >= 2049#endif // _LIBCPP_STD_VER >= 20
4950
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 <__functional/invoke.h>15#include <__type_traits/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/swappable.h+1-1
...@@ -14,6 +14,7 @@...@@ -14,6 +14,7 @@
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 <__cstddef/size_t.h>
17#include <__type_traits/extent.h>18#include <__type_traits/extent.h>
18#include <__type_traits/is_nothrow_assignable.h>19#include <__type_traits/is_nothrow_assignable.h>
19#include <__type_traits/is_nothrow_constructible.h>20#include <__type_traits/is_nothrow_constructible.h>
...@@ -22,7 +23,6 @@...@@ -22,7 +23,6 @@
22#include <__utility/forward.h>23#include <__utility/forward.h>
23#include <__utility/move.h>24#include <__utility/move.h>
24#include <__utility/swap.h>25#include <__utility/swap.h>
25#include <cstddef>
2626
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header28# pragma GCC system_header
lib/libcxx/include/__condition_variable/condition_variable.h+9-9
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <__config>16#include <__config>
17#include <__mutex/mutex.h>17#include <__mutex/mutex.h>
18#include <__mutex/unique_lock.h>18#include <__mutex/unique_lock.h>
19#include <__system_error/system_error.h>19#include <__system_error/throw_system_error.h>
20#include <__thread/support.h>20#include <__thread/support.h>
21#include <__type_traits/enable_if.h>21#include <__type_traits/enable_if.h>
22#include <__type_traits/is_floating_point.h>22#include <__type_traits/is_floating_point.h>
...@@ -33,7 +33,7 @@ _LIBCPP_PUSH_MACROS...@@ -33,7 +33,7 @@ _LIBCPP_PUSH_MACROS
3333
34_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3535
36#ifndef _LIBCPP_HAS_NO_THREADS36#if _LIBCPP_HAS_THREADS
3737
38// enum class cv_status38// enum class cv_status
39_LIBCPP_DECLARE_STRONG_ENUM(cv_status){no_timeout, timeout};39_LIBCPP_DECLARE_STRONG_ENUM(cv_status){no_timeout, timeout};
...@@ -45,7 +45,7 @@ class _LIBCPP_EXPORTED_FROM_ABI condition_variable {...@@ -45,7 +45,7 @@ class _LIBCPP_EXPORTED_FROM_ABI condition_variable {
45public:45public:
46 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR condition_variable() _NOEXCEPT = default;46 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR condition_variable() _NOEXCEPT = default;
4747
48# ifdef _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION48# if _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
49 ~condition_variable() = default;49 ~condition_variable() = default;
50# else50# else
51 ~condition_variable();51 ~condition_variable();
...@@ -83,7 +83,7 @@ public:...@@ -83,7 +83,7 @@ public:
83private:83private:
84 void84 void
85 __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT;85 __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT;
86# if defined(_LIBCPP_HAS_COND_CLOCKWAIT)86# if _LIBCPP_HAS_COND_CLOCKWAIT
87 _LIBCPP_HIDE_FROM_ABI void87 _LIBCPP_HIDE_FROM_ABI void
88 __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds>) _NOEXCEPT;88 __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds>) _NOEXCEPT;
89# endif89# endif
...@@ -91,7 +91,7 @@ private:...@@ -91,7 +91,7 @@ private:
91 _LIBCPP_HIDE_FROM_ABI void91 _LIBCPP_HIDE_FROM_ABI void
92 __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<_Clock, chrono::nanoseconds>) _NOEXCEPT;92 __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<_Clock, chrono::nanoseconds>) _NOEXCEPT;
93};93};
94#endif // !_LIBCPP_HAS_NO_THREADS94#endif // _LIBCPP_HAS_THREADS
9595
96template <class _Rep, class _Period, __enable_if_t<is_floating_point<_Rep>::value, int> = 0>96template <class _Rep, class _Period, __enable_if_t<is_floating_point<_Rep>::value, int> = 0>
97inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) {97inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) {
...@@ -140,7 +140,7 @@ inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::...@@ -140,7 +140,7 @@ inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::
140 return nanoseconds(__result);140 return nanoseconds(__result);
141}141}
142142
143#ifndef _LIBCPP_HAS_NO_THREADS143#if _LIBCPP_HAS_THREADS
144template <class _Predicate>144template <class _Predicate>
145void condition_variable::wait(unique_lock<mutex>& __lk, _Predicate __pred) {145void condition_variable::wait(unique_lock<mutex>& __lk, _Predicate __pred) {
146 while (!__pred())146 while (!__pred())
...@@ -180,7 +180,7 @@ cv_status condition_variable::wait_for(unique_lock<mutex>& __lk, const chrono::d...@@ -180,7 +180,7 @@ cv_status condition_variable::wait_for(unique_lock<mutex>& __lk, const chrono::d
180 using __ns_rep = nanoseconds::rep;180 using __ns_rep = nanoseconds::rep;
181 steady_clock::time_point __c_now = steady_clock::now();181 steady_clock::time_point __c_now = steady_clock::now();
182182
183# if defined(_LIBCPP_HAS_COND_CLOCKWAIT)183# if _LIBCPP_HAS_COND_CLOCKWAIT
184 using __clock_tp_ns = time_point<steady_clock, nanoseconds>;184 using __clock_tp_ns = time_point<steady_clock, nanoseconds>;
185 __ns_rep __now_count_ns = std::__safe_nanosecond_cast(__c_now.time_since_epoch()).count();185 __ns_rep __now_count_ns = std::__safe_nanosecond_cast(__c_now.time_since_epoch()).count();
186# else186# else
...@@ -205,7 +205,7 @@ condition_variable::wait_for(unique_lock<mutex>& __lk, const chrono::duration<_R...@@ -205,7 +205,7 @@ condition_variable::wait_for(unique_lock<mutex>& __lk, const chrono::duration<_R
205 return wait_until(__lk, chrono::steady_clock::now() + __d, std::move(__pred));205 return wait_until(__lk, chrono::steady_clock::now() + __d, std::move(__pred));
206}206}
207207
208# if defined(_LIBCPP_HAS_COND_CLOCKWAIT)208# if _LIBCPP_HAS_COND_CLOCKWAIT
209inline void condition_variable::__do_timed_wait(209inline void condition_variable::__do_timed_wait(
210 unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds> __tp) _NOEXCEPT {210 unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds> __tp) _NOEXCEPT {
211 using namespace chrono;211 using namespace chrono;
...@@ -235,7 +235,7 @@ inline void condition_variable::__do_timed_wait(unique_lock<mutex>& __lk,...@@ -235,7 +235,7 @@ inline void condition_variable::__do_timed_wait(unique_lock<mutex>& __lk,
235 wait_for(__lk, __tp - _Clock::now());235 wait_for(__lk, __tp - _Clock::now());
236}236}
237237
238#endif // _LIBCPP_HAS_NO_THREADS238#endif // _LIBCPP_HAS_THREADS
239239
240_LIBCPP_END_NAMESPACE_STD240_LIBCPP_END_NAMESPACE_STD
241241
lib/libcxx/include/__config+154-139
...@@ -14,6 +14,7 @@...@@ -14,6 +14,7 @@
14#include <__configuration/abi.h>14#include <__configuration/abi.h>
15#include <__configuration/availability.h>15#include <__configuration/availability.h>
16#include <__configuration/compiler.h>16#include <__configuration/compiler.h>
17#include <__configuration/language.h>
17#include <__configuration/platform.h>18#include <__configuration/platform.h>
1819
19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER20#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
...@@ -27,10 +28,11 @@...@@ -27,10 +28,11 @@
27// _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.28// _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.
28// Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is29// Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is
29// defined to XXYYZZ.30// defined to XXYYZZ.
30# define _LIBCPP_VERSION 19010031# define _LIBCPP_VERSION 200100
3132
32# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y33# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
33# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)34# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
35# define _LIBCPP_CONCAT3(X, Y, Z) _LIBCPP_CONCAT(X, _LIBCPP_CONCAT(Y, Z))
3436
35# if __STDC_HOSTED__ == 037# if __STDC_HOSTED__ == 0
36# define _LIBCPP_FREESTANDING38# define _LIBCPP_FREESTANDING
...@@ -38,16 +40,9 @@...@@ -38,16 +40,9 @@
3840
39// HARDENING {41// HARDENING {
4042
41// This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes)43// TODO: Remove in LLVM 21. We're making this an error to catch folks who might not have migrated.
42// equivalent to setting the extensive mode. This is deprecated and will be removed in LLVM 20.
43# ifdef _LIBCPP_ENABLE_ASSERTIONS44# ifdef _LIBCPP_ENABLE_ASSERTIONS
44# warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"45# error "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE instead"
45# if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1
46# error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1"
47# endif
48# if _LIBCPP_ENABLE_ASSERTIONS
49# define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_EXTENSIVE
50# endif
51# endif46# endif
5247
53// The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values:48// The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values:
...@@ -191,25 +186,6 @@ _LIBCPP_HARDENING_MODE_DEBUG...@@ -191,25 +186,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
191# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"186# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
192# endif187# endif
193188
194// FIXME: ABI detection should be done via compiler builtin macros. This
195// is just a placeholder until Clang implements such macros. For now assume
196// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
197// and allow the user to explicitly specify the ABI to handle cases where this
198// heuristic falls short.
199# if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
200# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
201# elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
202# define _LIBCPP_ABI_ITANIUM
203# elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
204# define _LIBCPP_ABI_MICROSOFT
205# else
206# if defined(_WIN32) && defined(_MSC_VER)
207# define _LIBCPP_ABI_MICROSOFT
208# else
209# define _LIBCPP_ABI_ITANIUM
210# endif
211# endif
212
213# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)189# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
214# define _LIBCPP_ABI_VCRUNTIME190# define _LIBCPP_ABI_VCRUNTIME
215# endif191# endif
...@@ -222,13 +198,16 @@ _LIBCPP_HARDENING_MODE_DEBUG...@@ -222,13 +198,16 @@ _LIBCPP_HARDENING_MODE_DEBUG
222198
223// Incomplete features get their own specific disabling flags. This makes it199// Incomplete features get their own specific disabling flags. This makes it
224// easier to grep for target specific flags once the feature is complete.200// easier to grep for target specific flags once the feature is complete.
225# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)201# if defined(_LIBCPP_ENABLE_EXPERIMENTAL) || defined(_LIBCPP_BUILDING_LIBRARY)
226# define _LIBCPP_HAS_NO_INCOMPLETE_PSTL202# define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 1
227# define _LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN203# else
228# define _LIBCPP_HAS_NO_EXPERIMENTAL_TZDB204# define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 0
229# define _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM
230# endif205# endif
231206
207# define _LIBCPP_HAS_EXPERIMENTAL_PSTL _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
208# define _LIBCPP_HAS_EXPERIMENTAL_TZDB _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
209# define _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
210
232# if defined(__MVS__)211# if defined(__MVS__)
233# include <features.h> // for __NATIVE_ASCII_F212# include <features.h> // for __NATIVE_ASCII_F
234# endif213# endif
...@@ -244,9 +223,14 @@ _LIBCPP_HARDENING_MODE_DEBUG...@@ -244,9 +223,14 @@ _LIBCPP_HARDENING_MODE_DEBUG
244# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library223# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
245# endif224# endif
246# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))225# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
247# define _LIBCPP_HAS_BITSCAN64226# define _LIBCPP_HAS_BITSCAN64 1
227# else
228# define _LIBCPP_HAS_BITSCAN64 0
248# endif229# endif
249# define _LIBCPP_HAS_OPEN_WITH_WCHAR230# define _LIBCPP_HAS_OPEN_WITH_WCHAR 1
231# else
232# define _LIBCPP_HAS_OPEN_WITH_WCHAR 0
233# define _LIBCPP_HAS_BITSCAN64 0
250# endif // defined(_WIN32)234# endif // defined(_WIN32)
251235
252# if defined(_AIX) && !defined(__64BIT__)236# if defined(_AIX) && !defined(__64BIT__)
...@@ -312,7 +296,6 @@ _LIBCPP_HARDENING_MODE_DEBUG...@@ -312,7 +296,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
312# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)296# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
313# define _ALIGNAS_TYPE(x) alignas(x)297# define _ALIGNAS_TYPE(x) alignas(x)
314# define _ALIGNAS(x) alignas(x)298# define _ALIGNAS(x) alignas(x)
315# define _LIBCPP_NORETURN [[noreturn]]
316# define _NOEXCEPT noexcept299# define _NOEXCEPT noexcept
317# define _NOEXCEPT_(...) noexcept(__VA_ARGS__)300# define _NOEXCEPT_(...) noexcept(__VA_ARGS__)
318# define _LIBCPP_CONSTEXPR constexpr301# define _LIBCPP_CONSTEXPR constexpr
...@@ -322,8 +305,6 @@ _LIBCPP_HARDENING_MODE_DEBUG...@@ -322,8 +305,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
322# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)305# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
323# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))306# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
324# define _ALIGNAS(x) __attribute__((__aligned__(x)))307# define _ALIGNAS(x) __attribute__((__aligned__(x)))
325# define _LIBCPP_NORETURN __attribute__((__noreturn__))
326# define _LIBCPP_HAS_NO_NOEXCEPT
327# define nullptr __nullptr308# define nullptr __nullptr
328# define _NOEXCEPT throw()309# define _NOEXCEPT throw()
329# define _NOEXCEPT_(...)310# define _NOEXCEPT_(...)
...@@ -340,23 +321,33 @@ typedef __char32_t char32_t;...@@ -340,23 +321,33 @@ typedef __char32_t char32_t;
340321
341// Objective-C++ features (opt-in)322// Objective-C++ features (opt-in)
342# if __has_feature(objc_arc)323# if __has_feature(objc_arc)
343# define _LIBCPP_HAS_OBJC_ARC324# define _LIBCPP_HAS_OBJC_ARC 1
325# else
326# define _LIBCPP_HAS_OBJC_ARC 0
344# endif327# endif
345328
346# if __has_feature(objc_arc_weak)329# if __has_feature(objc_arc_weak)
347# define _LIBCPP_HAS_OBJC_ARC_WEAK330# define _LIBCPP_HAS_OBJC_ARC_WEAK 1
331# else
332# define _LIBCPP_HAS_OBJC_ARC_WEAK 0
348# endif333# endif
349334
350# if __has_extension(blocks)335# if __has_extension(blocks)
351# define _LIBCPP_HAS_EXTENSION_BLOCKS336# define _LIBCPP_HAS_EXTENSION_BLOCKS 1
337# else
338# define _LIBCPP_HAS_EXTENSION_BLOCKS 0
352# endif339# endif
353340
354# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)341# if _LIBCPP_HAS_EXTENSION_BLOCKS && defined(__APPLE__)
355# define _LIBCPP_HAS_BLOCKS_RUNTIME342# define _LIBCPP_HAS_BLOCKS_RUNTIME 1
343# else
344# define _LIBCPP_HAS_BLOCKS_RUNTIME 0
356# endif345# endif
357346
358# if !__has_feature(address_sanitizer)347# if __has_feature(address_sanitizer)
359# define _LIBCPP_HAS_NO_ASAN348# define _LIBCPP_HAS_ASAN 1
349# else
350# define _LIBCPP_HAS_ASAN 0
360# endif351# endif
361352
362# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))353# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
...@@ -479,7 +470,7 @@ typedef __char32_t char32_t;...@@ -479,7 +470,7 @@ typedef __char32_t char32_t;
479# define _LIBCPP_HARDENING_SIG n // "none"470# define _LIBCPP_HARDENING_SIG n // "none"
480# endif471# endif
481472
482# ifdef _LIBCPP_HAS_NO_EXCEPTIONS473# if !_LIBCPP_HAS_EXCEPTIONS
483# define _LIBCPP_EXCEPTIONS_SIG n474# define _LIBCPP_EXCEPTIONS_SIG n
484# else475# else
485# define _LIBCPP_EXCEPTIONS_SIG e476# define _LIBCPP_EXCEPTIONS_SIG e
...@@ -593,6 +584,15 @@ typedef __char32_t char32_t;...@@ -593,6 +584,15 @@ typedef __char32_t char32_t;
593 inline namespace _LIBCPP_ABI_NAMESPACE {584 inline namespace _LIBCPP_ABI_NAMESPACE {
594# define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_POP_EXTENSION_DIAGNOSTICS585# define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_POP_EXTENSION_DIAGNOSTICS
595586
587#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental {
588#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL }}
589
590#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {
591#define _LIBCPP_END_NAMESPACE_LFTS } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
592
593#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 {
594#define _LIBCPP_END_NAMESPACE_LFTS_V2 } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
595
596#ifdef _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE596#ifdef _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE
597# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD namespace filesystem {597# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD namespace filesystem {
598# define _LIBCPP_END_NAMESPACE_FILESYSTEM } _LIBCPP_END_NAMESPACE_STD598# define _LIBCPP_END_NAMESPACE_FILESYSTEM } _LIBCPP_END_NAMESPACE_STD
...@@ -610,7 +610,9 @@ typedef __char32_t char32_t;...@@ -610,7 +610,9 @@ typedef __char32_t char32_t;
610# endif610# endif
611611
612# if !defined(__SIZEOF_INT128__) || defined(_MSC_VER)612# if !defined(__SIZEOF_INT128__) || defined(_MSC_VER)
613# define _LIBCPP_HAS_NO_INT128613# define _LIBCPP_HAS_INT128 0
614# else
615# define _LIBCPP_HAS_INT128 1
614# endif616# endif
615617
616# ifdef _LIBCPP_CXX03_LANG618# ifdef _LIBCPP_CXX03_LANG
...@@ -631,10 +633,6 @@ typedef __char32_t char32_t;...@@ -631,10 +633,6 @@ typedef __char32_t char32_t;
631# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)633# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
632# endif // _LIBCPP_CXX03_LANG634# endif // _LIBCPP_CXX03_LANG
633635
634# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__NetBSD__)
635# define _LIBCPP_LOCALE__L_EXTENSIONS 1
636# endif
637
638# ifdef __FreeBSD__636# ifdef __FreeBSD__
639# define _DECLARE_C99_LDBL_MATH 1637# define _DECLARE_C99_LDBL_MATH 1
640# endif638# endif
...@@ -642,29 +640,39 @@ typedef __char32_t char32_t;...@@ -642,29 +640,39 @@ typedef __char32_t char32_t;
642// If we are getting operator new from the MSVC CRT, then allocation overloads640// If we are getting operator new from the MSVC CRT, then allocation overloads
643// for align_val_t were added in 19.12, aka VS 2017 version 15.3.641// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
644# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912642# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
645# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION643# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0
646# elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)644# elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
647// We're deferring to Microsoft's STL to provide aligned new et al. We don't645// We're deferring to Microsoft's STL to provide aligned new et al. We don't
648// have it unless the language feature test macro is defined.646// have it unless the language feature test macro is defined.
649# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION647# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0
650# elif defined(__MVS__)648# elif defined(__MVS__)
651# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION649# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0
650# else
651# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 1
652# endif652# endif
653653
654# if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)654# if !_LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
655# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION655# define _LIBCPP_HAS_ALIGNED_ALLOCATION 0
656# else
657# define _LIBCPP_HAS_ALIGNED_ALLOCATION 1
656# endif658# endif
657659
658// It is not yet possible to use aligned_alloc() on all Apple platforms since660// It is not yet possible to use aligned_alloc() on all Apple platforms since
659// 10.15 was the first version to ship an implementation of aligned_alloc().661// 10.15 was the first version to ship an implementation of aligned_alloc().
660# if defined(__APPLE__)662# if defined(__APPLE__)
661# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \663# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
662 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500)664 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
663# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC665 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
666 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000)
667# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0
668# else
669# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1
664# endif670# endif
665# elif defined(__ANDROID__) && __ANDROID_API__ < 28671# elif defined(__ANDROID__) && __ANDROID_API__ < 28
666// Android only provides aligned_alloc when targeting API 28 or higher.672// Android only provides aligned_alloc when targeting API 28 or higher.
667# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC673# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0
674# else
675# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1
668# endif676# endif
669677
670# if defined(__APPLE__) || defined(__FreeBSD__)678# if defined(__APPLE__) || defined(__FreeBSD__)
...@@ -676,7 +684,9 @@ typedef __char32_t char32_t;...@@ -676,7 +684,9 @@ typedef __char32_t char32_t;
676# endif684# endif
677685
678# if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)686# if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
679# define _LIBCPP_HAS_NO_CHAR8_T687# define _LIBCPP_HAS_CHAR8_T 0
688# else
689# define _LIBCPP_HAS_CHAR8_T 1
680# endif690# endif
681691
682// Deprecation macros.692// Deprecation macros.
...@@ -699,14 +709,6 @@ typedef __char32_t char32_t;...@@ -699,14 +709,6 @@ typedef __char32_t char32_t;
699# define _LIBCPP_DEPRECATED_(m)709# define _LIBCPP_DEPRECATED_(m)
700# endif710# endif
701711
702# if _LIBCPP_STD_VER < 20
703# define _LIBCPP_DEPRECATED_ATOMIC_SYNC \
704 _LIBCPP_DEPRECATED_("The C++20 synchronization library has been deprecated prior to C++20. Please update to " \
705 "using -std=c++20 if you need to use these facilities.")
706# else
707# define _LIBCPP_DEPRECATED_ATOMIC_SYNC /* nothing */
708# endif
709
710# if !defined(_LIBCPP_CXX03_LANG)712# if !defined(_LIBCPP_CXX03_LANG)
711# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED713# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
712# else714# else
...@@ -743,7 +745,7 @@ typedef __char32_t char32_t;...@@ -743,7 +745,7 @@ typedef __char32_t char32_t;
743# define _LIBCPP_DEPRECATED_IN_CXX26745# define _LIBCPP_DEPRECATED_IN_CXX26
744# endif746# endif
745747
746# if !defined(_LIBCPP_HAS_NO_CHAR8_T)748# if _LIBCPP_HAS_CHAR8_T
747# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED749# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
748# else750# else
749# define _LIBCPP_DEPRECATED_WITH_CHAR8_T751# define _LIBCPP_DEPRECATED_WITH_CHAR8_T
...@@ -796,16 +798,22 @@ typedef __char32_t char32_t;...@@ -796,16 +798,22 @@ typedef __char32_t char32_t;
796# define _LIBCPP_CONSTEXPR_SINCE_CXX23798# define _LIBCPP_CONSTEXPR_SINCE_CXX23
797# endif799# endif
798800
801# if _LIBCPP_STD_VER >= 26
802# define _LIBCPP_CONSTEXPR_SINCE_CXX26 constexpr
803# else
804# define _LIBCPP_CONSTEXPR_SINCE_CXX26
805# endif
806
799# ifndef _LIBCPP_WEAK807# ifndef _LIBCPP_WEAK
800# define _LIBCPP_WEAK __attribute__((__weak__))808# define _LIBCPP_WEAK __attribute__((__weak__))
801# endif809# endif
802810
803// Thread API811// Thread API
804// clang-format off812// clang-format off
805# if !defined(_LIBCPP_HAS_NO_THREADS) && \813# if _LIBCPP_HAS_THREADS && \
806 !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \814 !_LIBCPP_HAS_THREAD_API_PTHREAD && \
807 !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \815 !_LIBCPP_HAS_THREAD_API_WIN32 && \
808 !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)816 !_LIBCPP_HAS_THREAD_API_EXTERNAL
809817
810# if defined(__FreeBSD__) || \818# if defined(__FreeBSD__) || \
811 defined(__wasi__) || \819 defined(__wasi__) || \
...@@ -819,43 +827,49 @@ typedef __char32_t char32_t;...@@ -819,43 +827,49 @@ typedef __char32_t char32_t;
819 defined(_AIX) || \827 defined(_AIX) || \
820 defined(__EMSCRIPTEN__)828 defined(__EMSCRIPTEN__)
821// clang-format on829// clang-format on
822# define _LIBCPP_HAS_THREAD_API_PTHREAD830# undef _LIBCPP_HAS_THREAD_API_PTHREAD
831# define _LIBCPP_HAS_THREAD_API_PTHREAD 1
823# elif defined(__Fuchsia__)832# elif defined(__Fuchsia__)
824// TODO(44575): Switch to C11 thread API when possible.833// TODO(44575): Switch to C11 thread API when possible.
825# define _LIBCPP_HAS_THREAD_API_PTHREAD834# undef _LIBCPP_HAS_THREAD_API_PTHREAD
835# define _LIBCPP_HAS_THREAD_API_PTHREAD 1
826# elif defined(_LIBCPP_WIN32API)836# elif defined(_LIBCPP_WIN32API)
827# define _LIBCPP_HAS_THREAD_API_WIN32837# undef _LIBCPP_HAS_THREAD_API_WIN32
838# define _LIBCPP_HAS_THREAD_API_WIN32 1
828# else839# else
829# error "No thread API"840# error "No thread API"
830# endif // _LIBCPP_HAS_THREAD_API841# endif // _LIBCPP_HAS_THREAD_API
831# endif // _LIBCPP_HAS_NO_THREADS842# endif // _LIBCPP_HAS_THREADS
832843
833# if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)844# if _LIBCPP_HAS_THREAD_API_PTHREAD
834# if defined(__ANDROID__) && __ANDROID_API__ >= 30845# if defined(__ANDROID__) && __ANDROID_API__ >= 30
835# define _LIBCPP_HAS_COND_CLOCKWAIT846# define _LIBCPP_HAS_COND_CLOCKWAIT 1
836# elif defined(_LIBCPP_GLIBC_PREREQ)847# elif defined(_LIBCPP_GLIBC_PREREQ)
837# if _LIBCPP_GLIBC_PREREQ(2, 30)848# if _LIBCPP_GLIBC_PREREQ(2, 30)
838# define _LIBCPP_HAS_COND_CLOCKWAIT849# define _LIBCPP_HAS_COND_CLOCKWAIT 1
850# else
851# define _LIBCPP_HAS_COND_CLOCKWAIT 0
839# endif852# endif
853# else
854# define _LIBCPP_HAS_COND_CLOCKWAIT 0
840# endif855# endif
856# else
857# define _LIBCPP_HAS_COND_CLOCKWAIT 0
841# endif858# endif
842859
843# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)860# if !_LIBCPP_HAS_THREADS && _LIBCPP_HAS_THREAD_API_PTHREAD
844# error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \861# error _LIBCPP_HAS_THREAD_API_PTHREAD may only be true when _LIBCPP_HAS_THREADS is true.
845 _LIBCPP_HAS_NO_THREADS is not defined.
846# endif862# endif
847863
848# if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)864# if !_LIBCPP_HAS_THREADS && _LIBCPP_HAS_THREAD_API_EXTERNAL
849# error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \865# error _LIBCPP_HAS_THREAD_API_EXTERNAL may only be true when _LIBCPP_HAS_THREADS is true.
850 _LIBCPP_HAS_NO_THREADS is defined.
851# endif866# endif
852867
853# if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)868# if !_LIBCPP_HAS_MONOTONIC_CLOCK && _LIBCPP_HAS_THREADS
854# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \869# error _LIBCPP_HAS_MONOTONIC_CLOCK may only be false when _LIBCPP_HAS_THREADS is false.
855 _LIBCPP_HAS_NO_THREADS is defined.
856# endif870# endif
857871
858# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)872# if _LIBCPP_HAS_THREADS && !defined(__STDCPP_THREADS__)
859# define __STDCPP_THREADS__ 1873# define __STDCPP_THREADS__ 1
860# endif874# endif
861875
...@@ -870,11 +884,13 @@ typedef __char32_t char32_t;...@@ -870,11 +884,13 @@ typedef __char32_t char32_t;
870// TODO(EricWF): Enable this optimization on Bionic after speaking to their884// TODO(EricWF): Enable this optimization on Bionic after speaking to their
871// respective stakeholders.885// respective stakeholders.
872// clang-format off886// clang-format off
873# if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \887# if (_LIBCPP_HAS_THREAD_API_PTHREAD && defined(__GLIBC__)) || \
874 (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \888 (_LIBCPP_HAS_THREAD_API_C11 && defined(__Fuchsia__)) || \
875 defined(_LIBCPP_HAS_THREAD_API_WIN32)889 _LIBCPP_HAS_THREAD_API_WIN32
876// clang-format on890// clang-format on
877# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION891# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 1
892# else
893# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 0
878# endif894# endif
879895
880// Destroying a condvar is a nop on Windows.896// Destroying a condvar is a nop on Windows.
...@@ -885,25 +901,31 @@ typedef __char32_t char32_t;...@@ -885,25 +901,31 @@ typedef __char32_t char32_t;
885//901//
886// TODO(EricWF): This is potentially true for some pthread implementations902// TODO(EricWF): This is potentially true for some pthread implementations
887// as well.903// as well.
888# if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32)904# if (_LIBCPP_HAS_THREAD_API_C11 && defined(__Fuchsia__)) || _LIBCPP_HAS_THREAD_API_WIN32
889# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION905# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 1
906# else
907# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 0
890# endif908# endif
891909
892# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \910# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \
893 defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__)911 _LIBCPP_HAS_MUSL_LIBC || defined(__OpenBSD__) || defined(__LLVM_LIBC__)
894# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE912# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
895# endif913# endif
896914
897# if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)915# if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
898# define _LIBCPP_HAS_C_ATOMIC_IMP916# define _LIBCPP_HAS_C_ATOMIC_IMP 1
917# define _LIBCPP_HAS_GCC_ATOMIC_IMP 0
918# define _LIBCPP_HAS_EXTERNAL_ATOMIC_IMP 0
899# elif defined(_LIBCPP_COMPILER_GCC)919# elif defined(_LIBCPP_COMPILER_GCC)
900# define _LIBCPP_HAS_GCC_ATOMIC_IMP920# define _LIBCPP_HAS_C_ATOMIC_IMP 0
921# define _LIBCPP_HAS_GCC_ATOMIC_IMP 1
922# define _LIBCPP_HAS_EXTERNAL_ATOMIC_IMP 0
901# endif923# endif
902924
903# if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \925# if !_LIBCPP_HAS_C_ATOMIC_IMP && !_LIBCPP_HAS_GCC_ATOMIC_IMP && !_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP
904 !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)926# define _LIBCPP_HAS_ATOMIC_HEADER 0
905# define _LIBCPP_HAS_NO_ATOMIC_HEADER
906# else927# else
928# define _LIBCPP_HAS_ATOMIC_HEADER 1
907# ifndef _LIBCPP_ATOMIC_FLAG_TYPE929# ifndef _LIBCPP_ATOMIC_FLAG_TYPE
908# define _LIBCPP_ATOMIC_FLAG_TYPE bool930# define _LIBCPP_ATOMIC_FLAG_TYPE bool
909# endif931# endif
...@@ -915,19 +937,18 @@ typedef __char32_t char32_t;...@@ -915,19 +937,18 @@ typedef __char32_t char32_t;
915# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS937# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
916# endif938# endif
917939
918# if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
919# if defined(__clang__) && __has_attribute(acquire_capability)
920// Work around the attribute handling in clang. When both __declspec and940// Work around the attribute handling in clang. When both __declspec and
921// __attribute__ are present, the processing goes awry preventing the definition941// __attribute__ are present, the processing goes awry preventing the definition
922// of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus942// of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus
923// combining the two does work.943// combining the two does work.
924# if !defined(_MSC_VER)944# if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) && \
925# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS945 __has_attribute(acquire_capability) && !defined(_MSC_VER)
926# endif946# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1
927# endif947# else
948# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 0
928# endif949# endif
929950
930# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS951# if _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
931# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))952# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
932# else953# else
933# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)954# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
...@@ -962,7 +983,7 @@ typedef __char32_t char32_t;...@@ -962,7 +983,7 @@ typedef __char32_t char32_t;
962// When wide characters are disabled, it can be useful to have a quick way of983// When wide characters are disabled, it can be useful to have a quick way of
963// disabling it without having to resort to #if-#endif, which has a larger984// disabling it without having to resort to #if-#endif, which has a larger
964// impact on readability.985// impact on readability.
965# if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)986# if !_LIBCPP_HAS_WIDE_CHARACTERS
966# define _LIBCPP_IF_WIDE_CHARACTERS(...)987# define _LIBCPP_IF_WIDE_CHARACTERS(...)
967# else988# else
968# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__989# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
...@@ -999,28 +1020,16 @@ typedef __char32_t char32_t;...@@ -999,28 +1020,16 @@ typedef __char32_t char32_t;
999// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)1020// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
1000// However, MSVC implements [[msvc::no_unique_address]] which does what1021// However, MSVC implements [[msvc::no_unique_address]] which does what
1001// [[no_unique_address]] is supposed to do, in general.1022// [[no_unique_address]] is supposed to do, in general.
1002
1003// Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
1004// [[msvc::no_unique_address]] though. If/when it does implement
1005// [[msvc::no_unique_address]], this should be preferred though.
1006# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]1023# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
1007# elif __has_cpp_attribute(no_unique_address)
1008# define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
1009# else1024# else
1010# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */1025# define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
1011// Note that this can be replaced by #error as soon as clang-cl
1012// implements msvc::no_unique_address, since there should be no C++20
1013// compiler that doesn't support one of the two attributes at that point.
1014// We generally don't want to use this macro outside of C++20-only code,
1015// because using it conditionally in one language version only would make
1016// the ABI inconsistent.
1017# endif1026# endif
10181027
1019// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these1028// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
1020// functions is gradually being added to existing C libraries. The conditions1029// functions is gradually being added to existing C libraries. The conditions
1021// below check for known C library versions and conditions under which these1030// below check for known C library versions and conditions under which these
1022// functions are declared by the C library.1031// functions are declared by the C library.
1023# define _LIBCPP_HAS_NO_C8RTOMB_MBRTOC81032//
1024// GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if1033// GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if
1025// __cpp_char8_t is defined or if C2X extensions are enabled. Determining1034// __cpp_char8_t is defined or if C2X extensions are enabled. Determining
1026// the latter depends on internal GNU libc details that are not appropriate1035// the latter depends on internal GNU libc details that are not appropriate
...@@ -1028,8 +1037,12 @@ typedef __char32_t char32_t;...@@ -1028,8 +1037,12 @@ typedef __char32_t char32_t;
1028// defined are ignored.1037// defined are ignored.
1029# if defined(_LIBCPP_GLIBC_PREREQ)1038# if defined(_LIBCPP_GLIBC_PREREQ)
1030# if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)1039# if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
1031# undef _LIBCPP_HAS_NO_C8RTOMB_MBRTOC81040# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1
1041# else
1042# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
1032# endif1043# endif
1044# else
1045# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
1033# endif1046# endif
10341047
1035// There are a handful of public standard library types that are intended to1048// There are a handful of public standard library types that are intended to
...@@ -1124,15 +1137,6 @@ typedef __char32_t char32_t;...@@ -1124,15 +1137,6 @@ typedef __char32_t char32_t;
1124# define _LIBCPP_USING_IF_EXISTS1137# define _LIBCPP_USING_IF_EXISTS
1125# endif1138# endif
11261139
1127# if __has_cpp_attribute(__nodiscard__)
1128# define _LIBCPP_NODISCARD [[__nodiscard__]]
1129# else
1130// We can't use GCC's [[gnu::warn_unused_result]] and
1131// __attribute__((warn_unused_result)), because GCC does not silence them via
1132// (void) cast.
1133# define _LIBCPP_NODISCARD
1134# endif
1135
1136# if __has_attribute(__no_destroy__)1140# if __has_attribute(__no_destroy__)
1137# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))1141# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
1138# else1142# else
...@@ -1160,10 +1164,19 @@ typedef __char32_t char32_t;...@@ -1160,10 +1164,19 @@ typedef __char32_t char32_t;
1160# define _LIBCPP_LIFETIMEBOUND1164# define _LIBCPP_LIFETIMEBOUND
1161# endif1165# endif
11621166
1163# if __has_attribute(__nodebug__)1167# if __has_cpp_attribute(_Clang::__noescape__)
1164# define _LIBCPP_NODEBUG __attribute__((__nodebug__))1168# define _LIBCPP_NOESCAPE [[_Clang::__noescape__]]
1169# else
1170# define _LIBCPP_NOESCAPE
1171# endif
1172
1173# define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]]
1174
1175# if __has_cpp_attribute(_Clang::__no_specializations__)
1176# define _LIBCPP_NO_SPECIALIZATIONS \
1177 [[_Clang::__no_specializations__("Users are not allowed to specialize this standard library entity")]]
1165# else1178# else
1166# define _LIBCPP_NODEBUG1179# define _LIBCPP_NO_SPECIALIZATIONS
1167# endif1180# endif
11681181
1169# if __has_attribute(__standalone_debug__)1182# if __has_attribute(__standalone_debug__)
...@@ -1220,7 +1233,9 @@ typedef __char32_t char32_t;...@@ -1220,7 +1233,9 @@ typedef __char32_t char32_t;
12201233
1221// Clang-18 has support for deducing this, but it does not set the FTM.1234// Clang-18 has support for deducing this, but it does not set the FTM.
1222# if defined(__cpp_explicit_this_parameter) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1800)1235# if defined(__cpp_explicit_this_parameter) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1800)
1223# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER1236# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 1
1237# else
1238# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0
1224# endif1239# endif
12251240
1226#endif // __cplusplus1241#endif // __cplusplus
lib/libcxx/include/__configuration/abi.h+46-4
...@@ -18,6 +18,25 @@...@@ -18,6 +18,25 @@
18# pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21// FIXME: ABI detection should be done via compiler builtin macros. This
22// is just a placeholder until Clang implements such macros. For now assume
23// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
24// and allow the user to explicitly specify the ABI to handle cases where this
25// heuristic falls short.
26#if _LIBCPP_ABI_FORCE_ITANIUM && _LIBCPP_ABI_FORCE_MICROSOFT
27# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be true"
28#elif _LIBCPP_ABI_FORCE_ITANIUM
29# define _LIBCPP_ABI_ITANIUM
30#elif _LIBCPP_ABI_FORCE_MICROSOFT
31# define _LIBCPP_ABI_MICROSOFT
32#else
33# if defined(_WIN32) && defined(_MSC_VER)
34# define _LIBCPP_ABI_MICROSOFT
35# else
36# define _LIBCPP_ABI_ITANIUM
37# endif
38#endif
39
21#if _LIBCPP_ABI_VERSION >= 240#if _LIBCPP_ABI_VERSION >= 2
22// Change short string representation so that string data starts at offset 0,41// Change short string representation so that string data starts at offset 0,
23// improving its alignment in some cases.42// improving its alignment in some cases.
...@@ -98,10 +117,13 @@...@@ -98,10 +117,13 @@
98// and WCHAR_MAX. This ABI setting determines whether we should instead track whether the fill117// and WCHAR_MAX. This ABI setting determines whether we should instead track whether the fill
99// value has been initialized using a separate boolean, which changes the ABI.118// value has been initialized using a separate boolean, which changes the ABI.
100# define _LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE119# define _LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE
101// Make a std::pair of trivially copyable types trivially copyable.120// Historically, libc++ used a type called `__compressed_pair` to reduce storage needs in cases of empty types (e.g. an
102// While this technically doesn't change the layout of pair itself, other types may decide to programatically change121// empty allocator in std::vector). We switched to using `[[no_unique_address]]`. However, for ABI compatibility reasons
103// their representation based on whether something is trivially copyable.122// we had to add artificial padding in a few places.
104# define _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR123//
124// This setting disables the addition of such artificial padding, leading to a more optimal
125// representation for several types.
126# define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
105#elif _LIBCPP_ABI_VERSION == 1127#elif _LIBCPP_ABI_VERSION == 1
106# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))128# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
107// Enable compiling copies of now inline methods into the dylib to support129// Enable compiling copies of now inline methods into the dylib to support
...@@ -154,6 +176,26 @@...@@ -154,6 +176,26 @@
154// ABI impact: changes the iterator type of `vector` (except `vector<bool>`).176// ABI impact: changes the iterator type of `vector` (except `vector<bool>`).
155// #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR177// #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
156178
179// Changes the iterator type of `array` to a bounded iterator that keeps track of whether it's within the bounds of the
180// container and asserts it on every dereference and when performing iterator arithmetic.
181//
182// ABI impact: changes the iterator type of `array`, its size and its layout.
183// #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY
184
185// [[msvc::no_unique_address]] seems to mostly affect empty classes, so the padding scheme for Itanium doesn't work.
186#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING)
187# define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
188#endif
189
190// Tracks the bounds of the array owned by std::unique_ptr<T[]>, allowing it to trap when accessed out-of-bounds.
191// Note that limited bounds checking is also available outside of this ABI configuration, but only some categories
192// of types can be checked.
193//
194// ABI impact: This causes the layout of std::unique_ptr<T[]> to change and its size to increase.
195// This also affects the representation of a few library types that use std::unique_ptr
196// internally, such as the unordered containers.
197// #define _LIBCPP_ABI_BOUNDED_UNIQUE_PTR
198
157#if defined(_LIBCPP_COMPILER_CLANG_BASED)199#if defined(_LIBCPP_COMPILER_CLANG_BASED)
158# if defined(__APPLE__)200# if defined(__APPLE__)
159# if defined(__i386__) || defined(__x86_64__)201# if defined(__i386__) || defined(__x86_64__)
lib/libcxx/include/__configuration/availability.h+53-69
...@@ -67,25 +67,19 @@...@@ -67,25 +67,19 @@
67//67//
68// [1]: https://clang.llvm.org/docs/AttributeReference.html#availability68// [1]: https://clang.llvm.org/docs/AttributeReference.html#availability
6969
70// For backwards compatibility, allow users to define _LIBCPP_DISABLE_AVAILABILITY
71// for a while.
72#if defined(_LIBCPP_DISABLE_AVAILABILITY)
73# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
74# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
75# endif
76#endif
77
78// Availability markup is disabled when building the library, or when a non-Clang70// Availability markup is disabled when building the library, or when a non-Clang
79// compiler is used because only Clang supports the necessary attributes.71// compiler is used because only Clang supports the necessary attributes.
80#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || !defined(_LIBCPP_COMPILER_CLANG_BASED)72#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || !defined(_LIBCPP_COMPILER_CLANG_BASED)
81# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)73# undef _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS
82# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS74# define _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS 0
83# endif
84#endif75#endif
8576
86// When availability annotations are disabled, we take for granted that features introduced77// When availability annotations are disabled, we take for granted that features introduced
87// in all versions of the library are available.78// in all versions of the library are available.
88#if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)79#if !_LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS
80
81# define _LIBCPP_INTRODUCED_IN_LLVM_20 1
82# define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE /* nothing */
8983
90# define _LIBCPP_INTRODUCED_IN_LLVM_19 184# define _LIBCPP_INTRODUCED_IN_LLVM_19 1
91# define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE /* nothing */85# define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE /* nothing */
...@@ -93,9 +87,6 @@...@@ -93,9 +87,6 @@
93# define _LIBCPP_INTRODUCED_IN_LLVM_18 187# define _LIBCPP_INTRODUCED_IN_LLVM_18 1
94# define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE /* nothing */88# define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE /* nothing */
9589
96# define _LIBCPP_INTRODUCED_IN_LLVM_17 1
97# define _LIBCPP_INTRODUCED_IN_LLVM_17_ATTRIBUTE /* nothing */
98
99# define _LIBCPP_INTRODUCED_IN_LLVM_16 190# define _LIBCPP_INTRODUCED_IN_LLVM_16 1
100# define _LIBCPP_INTRODUCED_IN_LLVM_16_ATTRIBUTE /* nothing */91# define _LIBCPP_INTRODUCED_IN_LLVM_16_ATTRIBUTE /* nothing */
10192
...@@ -105,26 +96,17 @@...@@ -105,26 +96,17 @@
105# define _LIBCPP_INTRODUCED_IN_LLVM_14 196# define _LIBCPP_INTRODUCED_IN_LLVM_14 1
106# define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE /* nothing */97# define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE /* nothing */
10798
108# define _LIBCPP_INTRODUCED_IN_LLVM_13 1
109# define _LIBCPP_INTRODUCED_IN_LLVM_13_ATTRIBUTE /* nothing */
110
111# define _LIBCPP_INTRODUCED_IN_LLVM_12 199# define _LIBCPP_INTRODUCED_IN_LLVM_12 1
112# define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE /* nothing */100# define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE /* nothing */
113101
114# define _LIBCPP_INTRODUCED_IN_LLVM_11 1102# define _LIBCPP_INTRODUCED_IN_LLVM_11 1
115# define _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE /* nothing */103# define _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE /* nothing */
116104
117# define _LIBCPP_INTRODUCED_IN_LLVM_10 1
118# define _LIBCPP_INTRODUCED_IN_LLVM_10_ATTRIBUTE /* nothing */
119
120# define _LIBCPP_INTRODUCED_IN_LLVM_9 1105# define _LIBCPP_INTRODUCED_IN_LLVM_9 1
121# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE /* nothing */106# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE /* nothing */
122# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */107# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */
123# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP /* nothing */108# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP /* nothing */
124109
125# define _LIBCPP_INTRODUCED_IN_LLVM_8 1
126# define _LIBCPP_INTRODUCED_IN_LLVM_8_ATTRIBUTE /* nothing */
127
128# define _LIBCPP_INTRODUCED_IN_LLVM_4 1110# define _LIBCPP_INTRODUCED_IN_LLVM_4 1
129# define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE /* nothing */111# define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE /* nothing */
130112
...@@ -132,36 +114,42 @@...@@ -132,36 +114,42 @@
132114
133// clang-format off115// clang-format off
134116
117// LLVM 20
118// TODO: Fill this in
119# define _LIBCPP_INTRODUCED_IN_LLVM_20 0
120# define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE __attribute__((unavailable))
121
135// LLVM 19122// LLVM 19
136// TODO: Fill this in123// TODO: Fill this in
137# define _LIBCPP_INTRODUCED_IN_LLVM_19 0124# define _LIBCPP_INTRODUCED_IN_LLVM_19 0
138# define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE __attribute__((unavailable))125# define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE __attribute__((unavailable))
139126
140// LLVM 18127// LLVM 18
141// TODO: Fill this in128# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 150000) || \
142# define _LIBCPP_INTRODUCED_IN_LLVM_18 0129 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 180000) || \
143# define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE __attribute__((unavailable))130 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 180000) || \
144131 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 110000) || \
145// LLVM 17132 (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 90000) || \
146# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140400) || \133 (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 240000)
147 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170400) || \134# define _LIBCPP_INTRODUCED_IN_LLVM_18 0
148 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170400) || \
149 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100400)
150# define _LIBCPP_INTRODUCED_IN_LLVM_17 0
151# else135# else
152# define _LIBCPP_INTRODUCED_IN_LLVM_17 1136# define _LIBCPP_INTRODUCED_IN_LLVM_18 1
153# endif137# endif
154# define _LIBCPP_INTRODUCED_IN_LLVM_17_ATTRIBUTE \138# define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE \
155 __attribute__((availability(macos, strict, introduced = 14.4))) \139 __attribute__((availability(macos, strict, introduced = 15.0))) \
156 __attribute__((availability(ios, strict, introduced = 17.4))) \140 __attribute__((availability(ios, strict, introduced = 18.0))) \
157 __attribute__((availability(tvos, strict, introduced = 17.4))) \141 __attribute__((availability(tvos, strict, introduced = 18.0))) \
158 __attribute__((availability(watchos, strict, introduced = 10.4)))142 __attribute__((availability(watchos, strict, introduced = 11.0))) \
143 __attribute__((availability(bridgeos, strict, introduced = 9.0))) \
144 __attribute__((availability(driverkit, strict, introduced = 24.0)))
159145
160// LLVM 16146// LLVM 16
161# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000) || \147# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000) || \
162 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170000) || \148 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170000) || \
163 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170000) || \149 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170000) || \
164 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100000)150 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100000) || \
151 (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 80000) || \
152 (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 230000)
165# define _LIBCPP_INTRODUCED_IN_LLVM_16 0153# define _LIBCPP_INTRODUCED_IN_LLVM_16 0
166# else154# else
167# define _LIBCPP_INTRODUCED_IN_LLVM_16 1155# define _LIBCPP_INTRODUCED_IN_LLVM_16 1
...@@ -170,13 +158,17 @@...@@ -170,13 +158,17 @@
170 __attribute__((availability(macos, strict, introduced = 14.0))) \158 __attribute__((availability(macos, strict, introduced = 14.0))) \
171 __attribute__((availability(ios, strict, introduced = 17.0))) \159 __attribute__((availability(ios, strict, introduced = 17.0))) \
172 __attribute__((availability(tvos, strict, introduced = 17.0))) \160 __attribute__((availability(tvos, strict, introduced = 17.0))) \
173 __attribute__((availability(watchos, strict, introduced = 10.0)))161 __attribute__((availability(watchos, strict, introduced = 10.0))) \
162 __attribute__((availability(bridgeos, strict, introduced = 8.0))) \
163 __attribute__((availability(driverkit, strict, introduced = 23.0)))
174164
175// LLVM 15165// LLVM 15
176# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130400) || \166# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130400) || \
177 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160500) || \167 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160500) || \
178 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160500) || \168 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160500) || \
179 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90500)169 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90500) || \
170 (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 70500) || \
171 (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 220400)
180# define _LIBCPP_INTRODUCED_IN_LLVM_15 0172# define _LIBCPP_INTRODUCED_IN_LLVM_15 0
181# else173# else
182# define _LIBCPP_INTRODUCED_IN_LLVM_15 1174# define _LIBCPP_INTRODUCED_IN_LLVM_15 1
...@@ -185,32 +177,21 @@...@@ -185,32 +177,21 @@
185 __attribute__((availability(macos, strict, introduced = 13.4))) \177 __attribute__((availability(macos, strict, introduced = 13.4))) \
186 __attribute__((availability(ios, strict, introduced = 16.5))) \178 __attribute__((availability(ios, strict, introduced = 16.5))) \
187 __attribute__((availability(tvos, strict, introduced = 16.5))) \179 __attribute__((availability(tvos, strict, introduced = 16.5))) \
188 __attribute__((availability(watchos, strict, introduced = 9.5)))180 __attribute__((availability(watchos, strict, introduced = 9.5))) \
181 __attribute__((availability(bridgeos, strict, introduced = 7.5))) \
182 __attribute__((availability(driverkit, strict, introduced = 22.4)))
189183
190// LLVM 14184// LLVM 14
191# define _LIBCPP_INTRODUCED_IN_LLVM_14 _LIBCPP_INTRODUCED_IN_LLVM_15185# define _LIBCPP_INTRODUCED_IN_LLVM_14 _LIBCPP_INTRODUCED_IN_LLVM_15
192# define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE186# define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE
193187
194// LLVM 13
195# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130000) || \
196 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160000) || \
197 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160000) || \
198 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90000)
199# define _LIBCPP_INTRODUCED_IN_LLVM_13 0
200# else
201# define _LIBCPP_INTRODUCED_IN_LLVM_13 1
202# endif
203# define _LIBCPP_INTRODUCED_IN_LLVM_13_ATTRIBUTE \
204 __attribute__((availability(macos, strict, introduced = 13.0))) \
205 __attribute__((availability(ios, strict, introduced = 16.0))) \
206 __attribute__((availability(tvos, strict, introduced = 16.0))) \
207 __attribute__((availability(watchos, strict, introduced = 9.0)))
208
209// LLVM 12188// LLVM 12
210# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 120300) || \189# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 120300) || \
211 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 150300) || \190 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 150300) || \
212 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 150300) || \191 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 150300) || \
213 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 80300)192 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 80300) || \
193 (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 60000) || \
194 (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 210300)
214# define _LIBCPP_INTRODUCED_IN_LLVM_12 0195# define _LIBCPP_INTRODUCED_IN_LLVM_12 0
215# else196# else
216# define _LIBCPP_INTRODUCED_IN_LLVM_12 1197# define _LIBCPP_INTRODUCED_IN_LLVM_12 1
...@@ -219,7 +200,9 @@...@@ -219,7 +200,9 @@
219 __attribute__((availability(macos, strict, introduced = 12.3))) \200 __attribute__((availability(macos, strict, introduced = 12.3))) \
220 __attribute__((availability(ios, strict, introduced = 15.3))) \201 __attribute__((availability(ios, strict, introduced = 15.3))) \
221 __attribute__((availability(tvos, strict, introduced = 15.3))) \202 __attribute__((availability(tvos, strict, introduced = 15.3))) \
222 __attribute__((availability(watchos, strict, introduced = 8.3)))203 __attribute__((availability(watchos, strict, introduced = 8.3))) \
204 __attribute__((availability(bridgeos, strict, introduced = 6.0))) \
205 __attribute__((availability(driverkit, strict, introduced = 21.3)))
223206
224// LLVM 11207// LLVM 11
225# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \208# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \
...@@ -236,10 +219,6 @@...@@ -236,10 +219,6 @@
236 __attribute__((availability(tvos, strict, introduced = 14.0))) \219 __attribute__((availability(tvos, strict, introduced = 14.0))) \
237 __attribute__((availability(watchos, strict, introduced = 7.0)))220 __attribute__((availability(watchos, strict, introduced = 7.0)))
238221
239// LLVM 10
240# define _LIBCPP_INTRODUCED_IN_LLVM_10 _LIBCPP_INTRODUCED_IN_LLVM_11
241# define _LIBCPP_INTRODUCED_IN_LLVM_10_ATTRIBUTE _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE
242
243// LLVM 9222// LLVM 9
244# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \223# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
245 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \224 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \
...@@ -375,10 +354,15 @@...@@ -375,10 +354,15 @@
375#define _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19354#define _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19
376#define _LIBCPP_AVAILABILITY_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE355#define _LIBCPP_AVAILABILITY_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE
377356
378// Define availability attributes that depend on _LIBCPP_HAS_NO_EXCEPTIONS.357// This controls the availability of floating-point std::from_chars functions.
358// These overloads were added later than the integer overloads.
359#define _LIBCPP_AVAILABILITY_HAS_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20
360#define _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE
361
362// Define availability attributes that depend on _LIBCPP_HAS_EXCEPTIONS.
379// Those are defined in terms of the availability attributes above, and363// Those are defined in terms of the availability attributes above, and
380// should not be vendor-specific.364// should not be vendor-specific.
381#if defined(_LIBCPP_HAS_NO_EXCEPTIONS)365#if !_LIBCPP_HAS_EXCEPTIONS
382# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST366# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
383# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS367# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
384# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS368# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
...@@ -389,8 +373,8 @@...@@ -389,8 +373,8 @@
389#endif373#endif
390374
391// Define availability attributes that depend on both375// Define availability attributes that depend on both
392// _LIBCPP_HAS_NO_EXCEPTIONS and _LIBCPP_HAS_NO_RTTI.376// _LIBCPP_HAS_EXCEPTIONS and _LIBCPP_HAS_RTTI.
393#if defined(_LIBCPP_HAS_NO_EXCEPTIONS) || defined(_LIBCPP_HAS_NO_RTTI)377#if !_LIBCPP_HAS_EXCEPTIONS || !_LIBCPP_HAS_RTTI
394# undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION378# undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
395# undef _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION379# undef _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
396# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0380# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0
lib/libcxx/include/__configuration/compiler.h+2-2
...@@ -33,8 +33,8 @@...@@ -33,8 +33,8 @@
33// Warn if a compiler version is used that is not supported anymore33// Warn if a compiler version is used that is not supported anymore
34// LLVM RELEASE Update the minimum compiler versions34// LLVM RELEASE Update the minimum compiler versions
35# if defined(_LIBCPP_CLANG_VER)35# if defined(_LIBCPP_CLANG_VER)
36# if _LIBCPP_CLANG_VER < 170036# if _LIBCPP_CLANG_VER < 1800
37# warning "Libc++ only supports Clang 17 and later"37# warning "Libc++ only supports Clang 18 and later"
38# endif38# endif
39# elif defined(_LIBCPP_APPLE_CLANG_VER)39# elif defined(_LIBCPP_APPLE_CLANG_VER)
40# if _LIBCPP_APPLE_CLANG_VER < 150040# if _LIBCPP_APPLE_CLANG_VER < 1500
lib/libcxx/include/__configuration/language.h+8-4
...@@ -35,12 +35,16 @@...@@ -35,12 +35,16 @@
35#endif // __cplusplus35#endif // __cplusplus
36// NOLINTEND(libcpp-cpp-version-check)36// NOLINTEND(libcpp-cpp-version-check)
3737
38#if !defined(__cpp_rtti) || __cpp_rtti < 199711L38#if defined(__cpp_rtti) && __cpp_rtti >= 199711L
39# define _LIBCPP_HAS_NO_RTTI39# define _LIBCPP_HAS_RTTI 1
40#else
41# define _LIBCPP_HAS_RTTI 0
40#endif42#endif
4143
42#if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L44#if defined(__cpp_exceptions) && __cpp_exceptions >= 199711L
43# define _LIBCPP_HAS_NO_EXCEPTIONS45# define _LIBCPP_HAS_EXCEPTIONS 1
46#else
47# define _LIBCPP_HAS_EXCEPTIONS 0
44#endif48#endif
4549
46#endif // _LIBCPP___CONFIGURATION_LANGUAGE_H50#endif // _LIBCPP___CONFIGURATION_LANGUAGE_H
lib/libcxx/include/__configuration/platform.h+10-8
...@@ -31,14 +31,16 @@...@@ -31,14 +31,16 @@
31#endif31#endif
3232
33// Need to detect which libc we're using if we're on Linux.33// Need to detect which libc we're using if we're on Linux.
34#if defined(__linux__)34#if defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__)
35# include <features.h>35# if __has_include(<features.h>)
36# if defined(__GLIBC_PREREQ)36# include <features.h>
37# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)37# if defined(__GLIBC_PREREQ)
38# else38# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
39# define _LIBCPP_GLIBC_PREREQ(a, b) 039# else
40# endif // defined(__GLIBC_PREREQ)40# define _LIBCPP_GLIBC_PREREQ(a, b) 0
41#endif // defined(__linux__)41# endif // defined(__GLIBC_PREREQ)
42# endif
43#endif
4244
43#ifndef __BYTE_ORDER__45#ifndef __BYTE_ORDER__
44# error \46# error \
lib/libcxx/include/__coroutine/coroutine_handle.h+2-1
...@@ -11,11 +11,12 @@...@@ -11,11 +11,12 @@
1111
12#include <__assert>12#include <__assert>
13#include <__config>13#include <__config>
14#include <__cstddef/nullptr_t.h>
15#include <__cstddef/size_t.h>
14#include <__functional/hash.h>16#include <__functional/hash.h>
15#include <__memory/addressof.h>17#include <__memory/addressof.h>
16#include <__type_traits/remove_cv.h>18#include <__type_traits/remove_cv.h>
17#include <compare>19#include <compare>
18#include <cstddef>
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/__cstddef/byte.h created+85
...@@ -0,0 +1,85 @@
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___CSTDDEF_BYTE_H
10#define _LIBCPP___CSTDDEF_BYTE_H
11
12#include <__config>
13#include <__fwd/byte.h>
14#include <__type_traits/enable_if.h>
15#include <__type_traits/is_integral.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21#if _LIBCPP_STD_VER >= 17
22namespace std { // purposefully not versioned
23
24enum class byte : unsigned char {};
25
26_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept {
27 return static_cast<byte>(
28 static_cast<unsigned char>(static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)));
29}
30
31_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept {
32 return __lhs = __lhs | __rhs;
33}
34
35_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator&(byte __lhs, byte __rhs) noexcept {
36 return static_cast<byte>(
37 static_cast<unsigned char>(static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)));
38}
39
40_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept {
41 return __lhs = __lhs & __rhs;
42}
43
44_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^(byte __lhs, byte __rhs) noexcept {
45 return static_cast<byte>(
46 static_cast<unsigned char>(static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)));
47}
48
49_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept {
50 return __lhs = __lhs ^ __rhs;
51}
52
53_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~(byte __b) noexcept {
54 return static_cast<byte>(static_cast<unsigned char>(~static_cast<unsigned int>(__b)));
55}
56
57template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
58_LIBCPP_HIDE_FROM_ABI constexpr byte& operator<<=(byte& __lhs, _Integer __shift) noexcept {
59 return __lhs = __lhs << __shift;
60}
61
62template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
63_LIBCPP_HIDE_FROM_ABI constexpr byte operator<<(byte __lhs, _Integer __shift) noexcept {
64 return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift));
65}
66
67template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
68_LIBCPP_HIDE_FROM_ABI constexpr byte& operator>>=(byte& __lhs, _Integer __shift) noexcept {
69 return __lhs = __lhs >> __shift;
70}
71
72template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
73_LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) noexcept {
74 return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift));
75}
76
77template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
78[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept {
79 return static_cast<_Integer>(__b);
80}
81
82} // namespace std
83#endif // _LIBCPP_STD_VER >= 17
84
85#endif // _LIBCPP___CSTDDEF_BYTE_H
lib/libcxx/include/__cstddef/max_align_t.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___CSTDDEF_MAX_ALIGN_T_H
10#define _LIBCPP___CSTDDEF_MAX_ALIGN_T_H
11
12#include <__config>
13#include <stddef.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#if !defined(_LIBCPP_CXX03_LANG)
22using ::max_align_t _LIBCPP_USING_IF_EXISTS;
23#endif
24
25_LIBCPP_END_NAMESPACE_STD
26
27#endif // _LIBCPP___CSTDDEF_MAX_ALIGN_T_H
lib/libcxx/include/__cstddef/nullptr_t.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___CSTDDEF_NULLPTR_T_H
10#define _LIBCPP___CSTDDEF_NULLPTR_T_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
20using nullptr_t = decltype(nullptr);
21
22_LIBCPP_END_NAMESPACE_STD
23
24#endif // _LIBCPP___CSTDDEF_NULLPTR_T_H
lib/libcxx/include/__cstddef/ptrdiff_t.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___CSTDDEF_PTRDIFF_T_H
10#define _LIBCPP___CSTDDEF_PTRDIFF_T_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
20using ptrdiff_t = decltype(static_cast<int*>(nullptr) - static_cast<int*>(nullptr));
21
22_LIBCPP_END_NAMESPACE_STD
23
24#endif // _LIBCPP___CSTDDEF_PTRDIFF_T_H
lib/libcxx/include/__cstddef/size_t.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___CSTDDEF_SIZE_T_H
10#define _LIBCPP___CSTDDEF_SIZE_T_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
20using size_t = decltype(sizeof(int));
21
22_LIBCPP_END_NAMESPACE_STD
23
24#endif // _LIBCPP___CSTDDEF_SIZE_T_H
lib/libcxx/include/__debug_utils/sanitizers.h+5-5
...@@ -17,7 +17,7 @@...@@ -17,7 +17,7 @@
17# pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20#ifndef _LIBCPP_HAS_NO_ASAN20#if _LIBCPP_HAS_ASAN
2121
22extern "C" {22extern "C" {
23_LIBCPP_EXPORTED_FROM_ABI void23_LIBCPP_EXPORTED_FROM_ABI void
...@@ -28,12 +28,12 @@ _LIBCPP_EXPORTED_FROM_ABI int...@@ -28,12 +28,12 @@ _LIBCPP_EXPORTED_FROM_ABI int
28__sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*);28__sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*);
29}29}
3030
31#endif // _LIBCPP_HAS_NO_ASAN31#endif // _LIBCPP_HAS_ASAN
3232
33_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3434
35// ASan choices35// ASan choices
36#ifndef _LIBCPP_HAS_NO_ASAN36#if _LIBCPP_HAS_ASAN
37# define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 137# define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 1
38#endif38#endif
3939
...@@ -57,7 +57,7 @@ _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container(...@@ -57,7 +57,7 @@ _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container(
57 const void* __last_old_contained,57 const void* __last_old_contained,
58 const void* __first_new_contained,58 const void* __first_new_contained,
59 const void* __last_new_contained) {59 const void* __last_new_contained) {
60#ifdef _LIBCPP_HAS_NO_ASAN60#if !_LIBCPP_HAS_ASAN
61 (void)__first_storage;61 (void)__first_storage;
62 (void)__last_storage;62 (void)__last_storage;
63 (void)__first_old_contained;63 (void)__first_old_contained;
...@@ -86,7 +86,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __annotate_contiguous_c...@@ -86,7 +86,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __annotate_contiguous_c
86 const void* __last_storage,86 const void* __last_storage,
87 const void* __old_last_contained,87 const void* __old_last_contained,
88 const void* __new_last_contained) {88 const void* __new_last_contained) {
89#ifdef _LIBCPP_HAS_NO_ASAN89#if !_LIBCPP_HAS_ASAN
90 (void)__first_storage;90 (void)__first_storage;
91 (void)__last_storage;91 (void)__last_storage;
92 (void)__old_last_contained;92 (void)__old_last_contained;
lib/libcxx/include/__exception/exception_ptr.h+4-5
...@@ -10,13 +10,12 @@...@@ -10,13 +10,12 @@
10#define _LIBCPP___EXCEPTION_EXCEPTION_PTR_H10#define _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/nullptr_t.h>
13#include <__exception/operations.h>14#include <__exception/operations.h>
14#include <__memory/addressof.h>15#include <__memory/addressof.h>
15#include <__memory/construct_at.h>16#include <__memory/construct_at.h>
16#include <__type_traits/decay.h>17#include <__type_traits/decay.h>
17#include <cstddef>
18#include <cstdlib>18#include <cstdlib>
19#include <new>
20#include <typeinfo>19#include <typeinfo>
2120
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -67,7 +66,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {...@@ -67,7 +66,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
6766
68public:67public:
69 // exception_ptr is basically a COW string.68 // exception_ptr is basically a COW string.
70 using __trivially_relocatable = exception_ptr;69 using __trivially_relocatable _LIBCPP_NODEBUG = exception_ptr;
7170
72 _LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {}71 _LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {}
73 _LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}72 _LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}
...@@ -92,7 +91,7 @@ public:...@@ -92,7 +91,7 @@ public:
9291
93template <class _Ep>92template <class _Ep>
94_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {93_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
95# ifndef _LIBCPP_HAS_NO_EXCEPTIONS94# if _LIBCPP_HAS_EXCEPTIONS
96# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && __cplusplus >= 201103L95# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && __cplusplus >= 201103L
97 using _Ep2 = __decay_t<_Ep>;96 using _Ep2 = __decay_t<_Ep>;
9897
...@@ -159,7 +158,7 @@ _LIBCPP_EXPORTED_FROM_ABI void swap(exception_ptr&, exception_ptr&) _NOEXCEPT;...@@ -159,7 +158,7 @@ _LIBCPP_EXPORTED_FROM_ABI void swap(exception_ptr&, exception_ptr&) _NOEXCEPT;
159158
160_LIBCPP_EXPORTED_FROM_ABI exception_ptr __copy_exception_ptr(void* __except, const void* __ptr);159_LIBCPP_EXPORTED_FROM_ABI exception_ptr __copy_exception_ptr(void* __except, const void* __ptr);
161_LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT;160_LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT;
162_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);161[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
163162
164// This is a built-in template function which automagically extracts the required163// This is a built-in template function which automagically extracts the required
165// information.164// information.
lib/libcxx/include/__exception/nested_exception.h+8-7
...@@ -13,6 +13,8 @@...@@ -13,6 +13,8 @@
13#include <__exception/exception_ptr.h>13#include <__exception/exception_ptr.h>
14#include <__memory/addressof.h>14#include <__memory/addressof.h>
15#include <__type_traits/decay.h>15#include <__type_traits/decay.h>
16#include <__type_traits/enable_if.h>
17#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_base_of.h>18#include <__type_traits/is_base_of.h>
17#include <__type_traits/is_class.h>19#include <__type_traits/is_class.h>
18#include <__type_traits/is_constructible.h>20#include <__type_traits/is_constructible.h>
...@@ -20,7 +22,6 @@...@@ -20,7 +22,6 @@
20#include <__type_traits/is_final.h>22#include <__type_traits/is_final.h>
21#include <__type_traits/is_polymorphic.h>23#include <__type_traits/is_polymorphic.h>
22#include <__utility/forward.h>24#include <__utility/forward.h>
23#include <cstddef>
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
...@@ -38,7 +39,7 @@ public:...@@ -38,7 +39,7 @@ public:
38 virtual ~nested_exception() _NOEXCEPT;39 virtual ~nested_exception() _NOEXCEPT;
3940
40 // access functions41 // access functions
41 _LIBCPP_NORETURN void rethrow_nested() const;42 [[__noreturn__]] void rethrow_nested() const;
42 _LIBCPP_HIDE_FROM_ABI exception_ptr nested_ptr() const _NOEXCEPT { return __ptr_; }43 _LIBCPP_HIDE_FROM_ABI exception_ptr nested_ptr() const _NOEXCEPT { return __ptr_; }
43};44};
4445
...@@ -47,26 +48,26 @@ struct __nested : public _Tp, public nested_exception {...@@ -47,26 +48,26 @@ struct __nested : public _Tp, public nested_exception {
47 _LIBCPP_HIDE_FROM_ABI explicit __nested(const _Tp& __t) : _Tp(__t) {}48 _LIBCPP_HIDE_FROM_ABI explicit __nested(const _Tp& __t) : _Tp(__t) {}
48};49};
4950
50#ifndef _LIBCPP_HAS_NO_EXCEPTIONS51#if _LIBCPP_HAS_EXCEPTIONS
51template <class _Tp, class _Up, bool>52template <class _Tp, class _Up, bool>
52struct __throw_with_nested;53struct __throw_with_nested;
5354
54template <class _Tp, class _Up>55template <class _Tp, class _Up>
55struct __throw_with_nested<_Tp, _Up, true> {56struct __throw_with_nested<_Tp, _Up, true> {
56 _LIBCPP_NORETURN static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) {57 [[__noreturn__]] static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) {
57 throw __nested<_Up>(std::forward<_Tp>(__t));58 throw __nested<_Up>(std::forward<_Tp>(__t));
58 }59 }
59};60};
6061
61template <class _Tp, class _Up>62template <class _Tp, class _Up>
62struct __throw_with_nested<_Tp, _Up, false> {63struct __throw_with_nested<_Tp, _Up, false> {
63 _LIBCPP_NORETURN static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) { throw std::forward<_Tp>(__t); }64 [[__noreturn__]] static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) { throw std::forward<_Tp>(__t); }
64};65};
65#endif66#endif
6667
67template <class _Tp>68template <class _Tp>
68_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void throw_with_nested(_Tp&& __t) {69[[__noreturn__]] _LIBCPP_HIDE_FROM_ABI void throw_with_nested(_Tp&& __t) {
69#ifndef _LIBCPP_HAS_NO_EXCEPTIONS70#if _LIBCPP_HAS_EXCEPTIONS
70 using _Up = __decay_t<_Tp>;71 using _Up = __decay_t<_Tp>;
71 static_assert(is_copy_constructible<_Up>::value, "type thrown must be CopyConstructible");72 static_assert(is_copy_constructible<_Up>::value, "type thrown must be CopyConstructible");
72 __throw_with_nested<_Tp,73 __throw_with_nested<_Tp,
lib/libcxx/include/__exception/operations.h+5-4
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___EXCEPTION_OPERATIONS_H10#define _LIBCPP___EXCEPTION_OPERATIONS_H
1111
12#include <__config>12#include <__config>
13#include <cstddef>
1413
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header15# pragma GCC system_header
...@@ -22,20 +21,22 @@ namespace std { // purposefully not using versioning namespace...@@ -22,20 +21,22 @@ namespace std { // purposefully not using versioning namespace
22using unexpected_handler = void (*)();21using unexpected_handler = void (*)();
23_LIBCPP_EXPORTED_FROM_ABI unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT;22_LIBCPP_EXPORTED_FROM_ABI unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT;
24_LIBCPP_EXPORTED_FROM_ABI unexpected_handler get_unexpected() _NOEXCEPT;23_LIBCPP_EXPORTED_FROM_ABI unexpected_handler get_unexpected() _NOEXCEPT;
25_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void unexpected();24[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void unexpected();
26#endif25#endif
2726
28using terminate_handler = void (*)();27using terminate_handler = void (*)();
29_LIBCPP_EXPORTED_FROM_ABI terminate_handler set_terminate(terminate_handler) _NOEXCEPT;28_LIBCPP_EXPORTED_FROM_ABI terminate_handler set_terminate(terminate_handler) _NOEXCEPT;
30_LIBCPP_EXPORTED_FROM_ABI terminate_handler get_terminate() _NOEXCEPT;29_LIBCPP_EXPORTED_FROM_ABI terminate_handler get_terminate() _NOEXCEPT;
3130
32_LIBCPP_EXPORTED_FROM_ABI bool uncaught_exception() _NOEXCEPT;31#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION)
32_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 bool uncaught_exception() _NOEXCEPT;
33#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION)
33_LIBCPP_EXPORTED_FROM_ABI int uncaught_exceptions() _NOEXCEPT;34_LIBCPP_EXPORTED_FROM_ABI int uncaught_exceptions() _NOEXCEPT;
3435
35class _LIBCPP_EXPORTED_FROM_ABI exception_ptr;36class _LIBCPP_EXPORTED_FROM_ABI exception_ptr;
3637
37_LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT;38_LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT;
38_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);39[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
39} // namespace std40} // namespace std
4041
41#endif // _LIBCPP___EXCEPTION_OPERATIONS_H42#endif // _LIBCPP___EXCEPTION_OPERATIONS_H
lib/libcxx/include/__exception/terminate.h+1-1
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#endif16#endif
1717
18namespace std { // purposefully not using versioning namespace18namespace std { // purposefully not using versioning namespace
19_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void terminate() _NOEXCEPT;19[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void terminate() _NOEXCEPT;
20} // namespace std20} // namespace std
2121
22#endif // _LIBCPP___EXCEPTION_TERMINATE_H22#endif // _LIBCPP___EXCEPTION_TERMINATE_H
lib/libcxx/include/__expected/expected.h+33-34
...@@ -17,9 +17,11 @@...@@ -17,9 +17,11 @@
17#include <__functional/invoke.h>17#include <__functional/invoke.h>
18#include <__memory/addressof.h>18#include <__memory/addressof.h>
19#include <__memory/construct_at.h>19#include <__memory/construct_at.h>
20#include <__type_traits/conditional.h>
20#include <__type_traits/conjunction.h>21#include <__type_traits/conjunction.h>
21#include <__type_traits/disjunction.h>22#include <__type_traits/disjunction.h>
22#include <__type_traits/integral_constant.h>23#include <__type_traits/integral_constant.h>
24#include <__type_traits/invoke.h>
23#include <__type_traits/is_assignable.h>25#include <__type_traits/is_assignable.h>
24#include <__type_traits/is_constructible.h>26#include <__type_traits/is_constructible.h>
25#include <__type_traits/is_convertible.h>27#include <__type_traits/is_convertible.h>
...@@ -71,7 +73,7 @@ struct __expected_construct_unexpected_from_invoke_tag {};...@@ -71,7 +73,7 @@ struct __expected_construct_unexpected_from_invoke_tag {};
7173
72template <class _Err, class _Arg>74template <class _Err, class _Arg>
73_LIBCPP_HIDE_FROM_ABI void __throw_bad_expected_access(_Arg&& __arg) {75_LIBCPP_HIDE_FROM_ABI void __throw_bad_expected_access(_Arg&& __arg) {
74# ifndef _LIBCPP_HAS_NO_EXCEPTIONS76# if _LIBCPP_HAS_EXCEPTIONS
75 throw bad_expected_access<_Err>(std::forward<_Arg>(__arg));77 throw bad_expected_access<_Err>(std::forward<_Arg>(__arg));
76# else78# else
77 (void)__arg;79 (void)__arg;
...@@ -457,14 +459,14 @@ class expected : private __expected_base<_Tp, _Err> {...@@ -457,14 +459,14 @@ class expected : private __expected_base<_Tp, _Err> {
457 template <class _Up, class _OtherErr>459 template <class _Up, class _OtherErr>
458 friend class expected;460 friend class expected;
459461
460 using __base = __expected_base<_Tp, _Err>;462 using __base _LIBCPP_NODEBUG = __expected_base<_Tp, _Err>;
461463
462public:464public:
463 using value_type = _Tp;465 using value_type = _Tp;
464 using error_type = _Err;466 using error_type = _Err;
465 using unexpected_type = unexpected<_Err>;467 using unexpected_type = unexpected<_Err>;
466468
467 using __trivially_relocatable =469 using __trivially_relocatable _LIBCPP_NODEBUG =
468 __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value && __libcpp_is_trivially_relocatable<_Err>::value,470 __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value && __libcpp_is_trivially_relocatable<_Err>::value,
469 expected,471 expected,
470 void>;472 void>;
...@@ -503,25 +505,24 @@ public:...@@ -503,25 +505,24 @@ public:
503505
504private:506private:
505 template <class _Up, class _OtherErr, class _UfQual, class _OtherErrQual>507 template <class _Up, class _OtherErr, class _UfQual, class _OtherErrQual>
506 using __can_convert =508 using __can_convert _LIBCPP_NODEBUG = _And<
507 _And< is_constructible<_Tp, _UfQual>,509 is_constructible<_Tp, _UfQual>,
508 is_constructible<_Err, _OtherErrQual>,510 is_constructible<_Err, _OtherErrQual>,
509 _If<_Not<is_same<remove_cv_t<_Tp>, bool>>::value,511 _If<_Not<is_same<remove_cv_t<_Tp>, bool>>::value,
510 _And< 512 _And< _Not<_And<is_same<_Tp, _Up>, is_same<_Err, _OtherErr>>>, // use the copy constructor instead, see #92676
511 _Not<_And<is_same<_Tp, _Up>, is_same<_Err, _OtherErr>>>, // use the copy constructor instead, see #92676513 _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>,
512 _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>,514 _Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>,
513 _Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>,515 _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>,
514 _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>,516 _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>,
515 _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>,517 _Not<is_convertible<expected<_Up, _OtherErr>&, _Tp>>,
516 _Not<is_convertible<expected<_Up, _OtherErr>&, _Tp>>,518 _Not<is_convertible<expected<_Up, _OtherErr>&&, _Tp>>,
517 _Not<is_convertible<expected<_Up, _OtherErr>&&, _Tp>>,519 _Not<is_convertible<const expected<_Up, _OtherErr>&, _Tp>>,
518 _Not<is_convertible<const expected<_Up, _OtherErr>&, _Tp>>,520 _Not<is_convertible<const expected<_Up, _OtherErr>&&, _Tp>>>,
519 _Not<is_convertible<const expected<_Up, _OtherErr>&&, _Tp>>>,521 true_type>,
520 true_type>,522 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>,
521 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>,523 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>,
522 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>,524 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>,
523 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>,525 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>> >;
524 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>> >;
525526
526 template <class _Func, class... _Args>527 template <class _Func, class... _Args>
527 _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(528 _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(
...@@ -918,9 +919,9 @@ public:...@@ -918,9 +919,9 @@ public:
918 requires is_constructible_v<_Err, _Err&>919 requires is_constructible_v<_Err, _Err&>
919 _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & {920 _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & {
920 using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&>>;921 using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&>>;
921 static_assert(__is_std_expected<_Up>::value, "The result of f(**this) must be a specialization of std::expected");922 static_assert(__is_std_expected<_Up>::value, "The result of f(value()) must be a specialization of std::expected");
922 static_assert(is_same_v<typename _Up::error_type, _Err>,923 static_assert(is_same_v<typename _Up::error_type, _Err>,
923 "The result of f(**this) must have the same error_type as this expected");924 "The result of f(value()) must have the same error_type as this expected");
924 if (has_value()) {925 if (has_value()) {
925 return std::invoke(std::forward<_Func>(__f), this->__val());926 return std::invoke(std::forward<_Func>(__f), this->__val());
926 }927 }
...@@ -931,9 +932,9 @@ public:...@@ -931,9 +932,9 @@ public:
931 requires is_constructible_v<_Err, const _Err&>932 requires is_constructible_v<_Err, const _Err&>
932 _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& {933 _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& {
933 using _Up = remove_cvref_t<invoke_result_t<_Func, const _Tp&>>;934 using _Up = remove_cvref_t<invoke_result_t<_Func, const _Tp&>>;
934 static_assert(__is_std_expected<_Up>::value, "The result of f(**this) must be a specialization of std::expected");935 static_assert(__is_std_expected<_Up>::value, "The result of f(value()) must be a specialization of std::expected");
935 static_assert(is_same_v<typename _Up::error_type, _Err>,936 static_assert(is_same_v<typename _Up::error_type, _Err>,
936 "The result of f(**this) must have the same error_type as this expected");937 "The result of f(value()) must have the same error_type as this expected");
937 if (has_value()) {938 if (has_value()) {
938 return std::invoke(std::forward<_Func>(__f), this->__val());939 return std::invoke(std::forward<_Func>(__f), this->__val());
939 }940 }
...@@ -945,9 +946,9 @@ public:...@@ -945,9 +946,9 @@ public:
945 _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && {946 _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && {
946 using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&&>>;947 using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&&>>;
947 static_assert(948 static_assert(
948 __is_std_expected<_Up>::value, "The result of f(std::move(**this)) must be a specialization of std::expected");949 __is_std_expected<_Up>::value, "The result of f(std::move(value())) must be a specialization of std::expected");
949 static_assert(is_same_v<typename _Up::error_type, _Err>,950 static_assert(is_same_v<typename _Up::error_type, _Err>,
950 "The result of f(std::move(**this)) must have the same error_type as this expected");951 "The result of f(std::move(value())) must have the same error_type as this expected");
951 if (has_value()) {952 if (has_value()) {
952 return std::invoke(std::forward<_Func>(__f), std::move(this->__val()));953 return std::invoke(std::forward<_Func>(__f), std::move(this->__val()));
953 }954 }
...@@ -959,9 +960,9 @@ public:...@@ -959,9 +960,9 @@ public:
959 _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const&& {960 _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const&& {
960 using _Up = remove_cvref_t<invoke_result_t<_Func, const _Tp&&>>;961 using _Up = remove_cvref_t<invoke_result_t<_Func, const _Tp&&>>;
961 static_assert(962 static_assert(
962 __is_std_expected<_Up>::value, "The result of f(std::move(**this)) must be a specialization of std::expected");963 __is_std_expected<_Up>::value, "The result of f(std::move(value())) must be a specialization of std::expected");
963 static_assert(is_same_v<typename _Up::error_type, _Err>,964 static_assert(is_same_v<typename _Up::error_type, _Err>,
964 "The result of f(std::move(**this)) must have the same error_type as this expected");965 "The result of f(std::move(value())) must have the same error_type as this expected");
965 if (has_value()) {966 if (has_value()) {
966 return std::invoke(std::forward<_Func>(__f), std::move(this->__val()));967 return std::invoke(std::forward<_Func>(__f), std::move(this->__val()));
967 }968 }
...@@ -1362,7 +1363,7 @@ class expected<_Tp, _Err> : private __expected_void_base<_Err> {...@@ -1362,7 +1363,7 @@ class expected<_Tp, _Err> : private __expected_void_base<_Err> {
1362 friend class expected;1363 friend class expected;
13631364
1364 template <class _Up, class _OtherErr, class _OtherErrQual>1365 template <class _Up, class _OtherErr, class _OtherErrQual>
1365 using __can_convert =1366 using __can_convert _LIBCPP_NODEBUG =
1366 _And< is_void<_Up>,1367 _And< is_void<_Up>,
1367 is_constructible<_Err, _OtherErrQual>,1368 is_constructible<_Err, _OtherErrQual>,
1368 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>,1369 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>,
...@@ -1370,7 +1371,7 @@ class expected<_Tp, _Err> : private __expected_void_base<_Err> {...@@ -1370,7 +1371,7 @@ class expected<_Tp, _Err> : private __expected_void_base<_Err> {
1370 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>,1371 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>,
1371 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>>>;1372 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>>>;
13721373
1373 using __base = __expected_void_base<_Err>;1374 using __base _LIBCPP_NODEBUG = __expected_void_base<_Err>;
13741375
1375public:1376public:
1376 using value_type = _Tp;1377 using value_type = _Tp;
...@@ -1492,8 +1493,6 @@ public:...@@ -1492,8 +1493,6 @@ public:
1492 return *this;1493 return *this;
1493 }1494 }
14941495
1495 _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(expected&&) = delete;
1496
1497 _LIBCPP_HIDE_FROM_ABI constexpr expected&1496 _LIBCPP_HIDE_FROM_ABI constexpr expected&
1498 operator=(expected&& __rhs) noexcept(is_nothrow_move_assignable_v<_Err> && is_nothrow_move_constructible_v<_Err>)1497 operator=(expected&& __rhs) noexcept(is_nothrow_move_assignable_v<_Err> && is_nothrow_move_constructible_v<_Err>)
1499 requires(is_move_assignable_v<_Err> && is_move_constructible_v<_Err>)1498 requires(is_move_assignable_v<_Err> && is_move_constructible_v<_Err>)
lib/libcxx/include/__expected/unexpected.h+7-7
...@@ -48,12 +48,12 @@ template <class _Err>...@@ -48,12 +48,12 @@ template <class _Err>
48struct __is_std_unexpected<unexpected<_Err>> : true_type {};48struct __is_std_unexpected<unexpected<_Err>> : true_type {};
4949
50template <class _Tp>50template <class _Tp>
51using __valid_std_unexpected = _BoolConstant< //51using __valid_std_unexpected _LIBCPP_NODEBUG = _BoolConstant< //
52 is_object_v<_Tp> && //52 is_object_v<_Tp> && //
53 !is_array_v<_Tp> && //53 !is_array_v<_Tp> && //
54 !__is_std_unexpected<_Tp>::value && //54 !__is_std_unexpected<_Tp>::value && //
55 !is_const_v<_Tp> && //55 !is_const_v<_Tp> && //
56 !is_volatile_v<_Tp> //56 !is_volatile_v<_Tp> //
57 >;57 >;
5858
59template <class _Err>59template <class _Err>
...@@ -108,7 +108,7 @@ public:...@@ -108,7 +108,7 @@ public:
108108
109 template <class _Err2>109 template <class _Err2>
110 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const unexpected& __x, const unexpected<_Err2>& __y) {110 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const unexpected& __x, const unexpected<_Err2>& __y) {
111 return __x.__unex_ == __y.__unex_;111 return __x.__unex_ == __y.error();
112 }112 }
113113
114private:114private:
lib/libcxx/include/__filesystem/directory_entry.h+48-13
...@@ -20,8 +20,11 @@...@@ -20,8 +20,11 @@
20#include <__filesystem/operations.h>20#include <__filesystem/operations.h>
21#include <__filesystem/path.h>21#include <__filesystem/path.h>
22#include <__filesystem/perms.h>22#include <__filesystem/perms.h>
23#include <__fwd/ostream.h>
23#include <__system_error/errc.h>24#include <__system_error/errc.h>
25#include <__system_error/error_category.h>
24#include <__system_error/error_code.h>26#include <__system_error/error_code.h>
27#include <__system_error/error_condition.h>
25#include <__utility/move.h>28#include <__utility/move.h>
26#include <__utility/unreachable.h>29#include <__utility/unreachable.h>
27#include <cstdint>30#include <cstdint>
...@@ -33,7 +36,7 @@...@@ -33,7 +36,7 @@
33_LIBCPP_PUSH_MACROS36_LIBCPP_PUSH_MACROS
34#include <__undef_macros>37#include <__undef_macros>
3538
36#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)39#if _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM
3740
38_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM41_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
3942
...@@ -201,7 +204,9 @@ private:...@@ -201,7 +204,9 @@ private:
201 _IterNonSymlink,204 _IterNonSymlink,
202 _RefreshSymlink,205 _RefreshSymlink,
203 _RefreshSymlinkUnresolved,206 _RefreshSymlinkUnresolved,
204 _RefreshNonSymlink207 _RefreshNonSymlink,
208 _IterCachedSymlink,
209 _IterCachedNonSymlink
205 };210 };
206211
207 struct __cached_data {212 struct __cached_data {
...@@ -240,6 +245,29 @@ private:...@@ -240,6 +245,29 @@ private:
240 return __data;245 return __data;
241 }246 }
242247
248 _LIBCPP_HIDE_FROM_ABI static __cached_data
249 __create_iter_cached_result(file_type __ft, uintmax_t __size, perms __perm, file_time_type __write_time) {
250 __cached_data __data;
251 __data.__type_ = __ft;
252 __data.__size_ = __size;
253 __data.__write_time_ = __write_time;
254 if (__ft == file_type::symlink)
255 __data.__sym_perms_ = __perm;
256 else
257 __data.__non_sym_perms_ = __perm;
258 __data.__cache_type_ = [&]() {
259 switch (__ft) {
260 case file_type::none:
261 return _Empty;
262 case file_type::symlink:
263 return _IterCachedSymlink;
264 default:
265 return _IterCachedNonSymlink;
266 }
267 }();
268 return __data;
269 }
270
243 _LIBCPP_HIDE_FROM_ABI void __assign_iter_entry(_Path&& __p, __cached_data __dt) {271 _LIBCPP_HIDE_FROM_ABI void __assign_iter_entry(_Path&& __p, __cached_data __dt) {
244 __p_ = std::move(__p);272 __p_ = std::move(__p);
245 __data_ = __dt;273 __data_ = __dt;
...@@ -248,15 +276,7 @@ private:...@@ -248,15 +276,7 @@ private:
248 _LIBCPP_EXPORTED_FROM_ABI error_code __do_refresh() noexcept;276 _LIBCPP_EXPORTED_FROM_ABI error_code __do_refresh() noexcept;
249277
250 _LIBCPP_HIDE_FROM_ABI static bool __is_dne_error(error_code const& __ec) {278 _LIBCPP_HIDE_FROM_ABI static bool __is_dne_error(error_code const& __ec) {
251 if (!__ec)279 return !__ec || __ec == errc::no_such_file_or_directory || __ec == errc::not_a_directory;
252 return true;
253 switch (static_cast<errc>(__ec.value())) {
254 case errc::no_such_file_or_directory:
255 case errc::not_a_directory:
256 return true;
257 default:
258 return false;
259 }
260 }280 }
261281
262 _LIBCPP_HIDE_FROM_ABI void282 _LIBCPP_HIDE_FROM_ABI void
...@@ -281,13 +301,15 @@ private:...@@ -281,13 +301,15 @@ private:
281 case _Empty:301 case _Empty:
282 return __symlink_status(__p_, __ec).type();302 return __symlink_status(__p_, __ec).type();
283 case _IterSymlink:303 case _IterSymlink:
304 case _IterCachedSymlink:
284 case _RefreshSymlink:305 case _RefreshSymlink:
285 case _RefreshSymlinkUnresolved:306 case _RefreshSymlinkUnresolved:
286 if (__ec)307 if (__ec)
287 __ec->clear();308 __ec->clear();
288 return file_type::symlink;309 return file_type::symlink;
310 case _IterCachedNonSymlink:
289 case _IterNonSymlink:311 case _IterNonSymlink:
290 case _RefreshNonSymlink:312 case _RefreshNonSymlink: {
291 file_status __st(__data_.__type_);313 file_status __st(__data_.__type_);
292 if (__ec && !filesystem::exists(__st))314 if (__ec && !filesystem::exists(__st))
293 *__ec = make_error_code(errc::no_such_file_or_directory);315 *__ec = make_error_code(errc::no_such_file_or_directory);
...@@ -295,6 +317,7 @@ private:...@@ -295,6 +317,7 @@ private:
295 __ec->clear();317 __ec->clear();
296 return __data_.__type_;318 return __data_.__type_;
297 }319 }
320 }
298 __libcpp_unreachable();321 __libcpp_unreachable();
299 }322 }
300323
...@@ -302,8 +325,10 @@ private:...@@ -302,8 +325,10 @@ private:
302 switch (__data_.__cache_type_) {325 switch (__data_.__cache_type_) {
303 case _Empty:326 case _Empty:
304 case _IterSymlink:327 case _IterSymlink:
328 case _IterCachedSymlink:
305 case _RefreshSymlinkUnresolved:329 case _RefreshSymlinkUnresolved:
306 return __status(__p_, __ec).type();330 return __status(__p_, __ec).type();
331 case _IterCachedNonSymlink:
307 case _IterNonSymlink:332 case _IterNonSymlink:
308 case _RefreshNonSymlink:333 case _RefreshNonSymlink:
309 case _RefreshSymlink: {334 case _RefreshSymlink: {
...@@ -323,8 +348,10 @@ private:...@@ -323,8 +348,10 @@ private:
323 case _Empty:348 case _Empty:
324 case _IterNonSymlink:349 case _IterNonSymlink:
325 case _IterSymlink:350 case _IterSymlink:
351 case _IterCachedSymlink:
326 case _RefreshSymlinkUnresolved:352 case _RefreshSymlinkUnresolved:
327 return __status(__p_, __ec);353 return __status(__p_, __ec);
354 case _IterCachedNonSymlink:
328 case _RefreshNonSymlink:355 case _RefreshNonSymlink:
329 case _RefreshSymlink:356 case _RefreshSymlink:
330 return file_status(__get_ft(__ec), __data_.__non_sym_perms_);357 return file_status(__get_ft(__ec), __data_.__non_sym_perms_);
...@@ -338,8 +365,10 @@ private:...@@ -338,8 +365,10 @@ private:
338 case _IterNonSymlink:365 case _IterNonSymlink:
339 case _IterSymlink:366 case _IterSymlink:
340 return __symlink_status(__p_, __ec);367 return __symlink_status(__p_, __ec);
368 case _IterCachedNonSymlink:
341 case _RefreshNonSymlink:369 case _RefreshNonSymlink:
342 return file_status(__get_sym_ft(__ec), __data_.__non_sym_perms_);370 return file_status(__get_sym_ft(__ec), __data_.__non_sym_perms_);
371 case _IterCachedSymlink:
343 case _RefreshSymlink:372 case _RefreshSymlink:
344 case _RefreshSymlinkUnresolved:373 case _RefreshSymlinkUnresolved:
345 return file_status(__get_sym_ft(__ec), __data_.__sym_perms_);374 return file_status(__get_sym_ft(__ec), __data_.__sym_perms_);
...@@ -352,8 +381,10 @@ private:...@@ -352,8 +381,10 @@ private:
352 case _Empty:381 case _Empty:
353 case _IterNonSymlink:382 case _IterNonSymlink:
354 case _IterSymlink:383 case _IterSymlink:
384 case _IterCachedSymlink:
355 case _RefreshSymlinkUnresolved:385 case _RefreshSymlinkUnresolved:
356 return filesystem::__file_size(__p_, __ec);386 return filesystem::__file_size(__p_, __ec);
387 case _IterCachedNonSymlink:
357 case _RefreshSymlink:388 case _RefreshSymlink:
358 case _RefreshNonSymlink: {389 case _RefreshNonSymlink: {
359 error_code __m_ec;390 error_code __m_ec;
...@@ -374,6 +405,8 @@ private:...@@ -374,6 +405,8 @@ private:
374 case _Empty:405 case _Empty:
375 case _IterNonSymlink:406 case _IterNonSymlink:
376 case _IterSymlink:407 case _IterSymlink:
408 case _IterCachedNonSymlink:
409 case _IterCachedSymlink:
377 case _RefreshSymlinkUnresolved:410 case _RefreshSymlinkUnresolved:
378 return filesystem::__hard_link_count(__p_, __ec);411 return filesystem::__hard_link_count(__p_, __ec);
379 case _RefreshSymlink:412 case _RefreshSymlink:
...@@ -392,8 +425,10 @@ private:...@@ -392,8 +425,10 @@ private:
392 case _Empty:425 case _Empty:
393 case _IterNonSymlink:426 case _IterNonSymlink:
394 case _IterSymlink:427 case _IterSymlink:
428 case _IterCachedSymlink:
395 case _RefreshSymlinkUnresolved:429 case _RefreshSymlinkUnresolved:
396 return filesystem::__last_write_time(__p_, __ec);430 return filesystem::__last_write_time(__p_, __ec);
431 case _IterCachedNonSymlink:
397 case _RefreshSymlink:432 case _RefreshSymlink:
398 case _RefreshNonSymlink: {433 case _RefreshNonSymlink: {
399 error_code __m_ec;434 error_code __m_ec;
...@@ -428,7 +463,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP...@@ -428,7 +463,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP
428463
429_LIBCPP_END_NAMESPACE_FILESYSTEM464_LIBCPP_END_NAMESPACE_FILESYSTEM
430465
431#endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)466#endif // _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM
432467
433_LIBCPP_POP_MACROS468_LIBCPP_POP_MACROS
434469
lib/libcxx/include/__filesystem/directory_iterator.h+2-3
...@@ -22,7 +22,6 @@...@@ -22,7 +22,6 @@
22#include <__ranges/enable_view.h>22#include <__ranges/enable_view.h>
23#include <__system_error/error_code.h>23#include <__system_error/error_code.h>
24#include <__utility/move.h>24#include <__utility/move.h>
25#include <cstddef>
2625
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header27# pragma GCC system_header
...@@ -31,7 +30,7 @@...@@ -31,7 +30,7 @@
31_LIBCPP_PUSH_MACROS30_LIBCPP_PUSH_MACROS
32#include <__undef_macros>31#include <__undef_macros>
3332
34#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)33#if _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM
3534
36_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM35_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
3736
...@@ -144,7 +143,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool...@@ -144,7 +143,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool
144143
145# endif // _LIBCPP_STD_VER >= 20144# endif // _LIBCPP_STD_VER >= 20
146145
147#endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)146#endif // _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM
148147
149_LIBCPP_POP_MACROS148_LIBCPP_POP_MACROS
150149
lib/libcxx/include/__filesystem/filesystem_error.h+3-3
...@@ -67,15 +67,15 @@ private:...@@ -67,15 +67,15 @@ private:
67 shared_ptr<_Storage> __storage_;67 shared_ptr<_Storage> __storage_;
68};68};
6969
70# ifndef _LIBCPP_HAS_NO_EXCEPTIONS70# if _LIBCPP_HAS_EXCEPTIONS
71template <class... _Args>71template <class... _Args>
72_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void72[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void
73__throw_filesystem_error(_Args&&... __args) {73__throw_filesystem_error(_Args&&... __args) {
74 throw filesystem_error(std::forward<_Args>(__args)...);74 throw filesystem_error(std::forward<_Args>(__args)...);
75}75}
76# else76# else
77template <class... _Args>77template <class... _Args>
78_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void78[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void
79__throw_filesystem_error(_Args&&...) {79__throw_filesystem_error(_Args&&...) {
80 _LIBCPP_VERBOSE_ABORT("filesystem_error was thrown in -fno-exceptions mode");80 _LIBCPP_VERBOSE_ABORT("filesystem_error was thrown in -fno-exceptions mode");
81}81}
lib/libcxx/include/__filesystem/operations.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_FILESYSTEM)30#if _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM
3131
32_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM32_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
3333
...@@ -305,6 +305,6 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP...@@ -305,6 +305,6 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP
305305
306_LIBCPP_END_NAMESPACE_FILESYSTEM306_LIBCPP_END_NAMESPACE_FILESYSTEM
307307
308#endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)308#endif // _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM
309309
310#endif // _LIBCPP___FILESYSTEM_OPERATIONS_H310#endif // _LIBCPP___FILESYSTEM_OPERATIONS_H
lib/libcxx/include/__filesystem/path.h+39-39
...@@ -21,11 +21,11 @@...@@ -21,11 +21,11 @@
21#include <__type_traits/is_pointer.h>21#include <__type_traits/is_pointer.h>
22#include <__type_traits/remove_const.h>22#include <__type_traits/remove_const.h>
23#include <__type_traits/remove_pointer.h>23#include <__type_traits/remove_pointer.h>
24#include <cstddef>24#include <__utility/move.h>
25#include <string>25#include <string>
26#include <string_view>26#include <string_view>
2727
28#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)28#if _LIBCPP_HAS_LOCALIZATION
29# include <iomanip> // for quoted29# include <iomanip> // for quoted
30# include <locale>30# include <locale>
31#endif31#endif
...@@ -51,30 +51,30 @@ template <class _Tp>...@@ -51,30 +51,30 @@ template <class _Tp>
51struct __can_convert_char<const _Tp> : public __can_convert_char<_Tp> {};51struct __can_convert_char<const _Tp> : public __can_convert_char<_Tp> {};
52template <>52template <>
53struct __can_convert_char<char> {53struct __can_convert_char<char> {
54 static const bool value = true;54 static const bool value = true;
55 using __char_type = char;55 using __char_type _LIBCPP_NODEBUG = char;
56};56};
57template <>57template <>
58struct __can_convert_char<wchar_t> {58struct __can_convert_char<wchar_t> {
59 static const bool value = true;59 static const bool value = true;
60 using __char_type = wchar_t;60 using __char_type _LIBCPP_NODEBUG = wchar_t;
61};61};
62# ifndef _LIBCPP_HAS_NO_CHAR8_T62# if _LIBCPP_HAS_CHAR8_T
63template <>63template <>
64struct __can_convert_char<char8_t> {64struct __can_convert_char<char8_t> {
65 static const bool value = true;65 static const bool value = true;
66 using __char_type = char8_t;66 using __char_type _LIBCPP_NODEBUG = char8_t;
67};67};
68# endif68# endif
69template <>69template <>
70struct __can_convert_char<char16_t> {70struct __can_convert_char<char16_t> {
71 static const bool value = true;71 static const bool value = true;
72 using __char_type = char16_t;72 using __char_type _LIBCPP_NODEBUG = char16_t;
73};73};
74template <>74template <>
75struct __can_convert_char<char32_t> {75struct __can_convert_char<char32_t> {
76 static const bool value = true;76 static const bool value = true;
77 using __char_type = char32_t;77 using __char_type _LIBCPP_NODEBUG = char32_t;
78};78};
7979
80template <class _ECharT, __enable_if_t<__can_convert_char<_ECharT>::value, int> = 0>80template <class _ECharT, __enable_if_t<__can_convert_char<_ECharT>::value, int> = 0>
...@@ -86,7 +86,7 @@ _LIBCPP_HIDE_FROM_ABI bool __is_separator(_ECharT __e) {...@@ -86,7 +86,7 @@ _LIBCPP_HIDE_FROM_ABI bool __is_separator(_ECharT __e) {
86# endif86# endif
87}87}
8888
89# ifndef _LIBCPP_HAS_NO_CHAR8_T89# if _LIBCPP_HAS_CHAR8_T
90typedef u8string __u8_string;90typedef u8string __u8_string;
91# else91# else
92typedef string __u8_string;92typedef string __u8_string;
...@@ -95,7 +95,7 @@ typedef string __u8_string;...@@ -95,7 +95,7 @@ typedef string __u8_string;
95struct _NullSentinel {};95struct _NullSentinel {};
9696
97template <class _Tp>97template <class _Tp>
98using _Void = void;98using _Void _LIBCPP_NODEBUG = void;
9999
100template <class _Tp, class = void>100template <class _Tp, class = void>
101struct __is_pathable_string : public false_type {};101struct __is_pathable_string : public false_type {};
...@@ -104,7 +104,7 @@ template <class _ECharT, class _Traits, class _Alloc>...@@ -104,7 +104,7 @@ template <class _ECharT, class _Traits, class _Alloc>
104struct __is_pathable_string< basic_string<_ECharT, _Traits, _Alloc>,104struct __is_pathable_string< basic_string<_ECharT, _Traits, _Alloc>,
105 _Void<typename __can_convert_char<_ECharT>::__char_type> >105 _Void<typename __can_convert_char<_ECharT>::__char_type> >
106 : public __can_convert_char<_ECharT> {106 : public __can_convert_char<_ECharT> {
107 using _Str = basic_string<_ECharT, _Traits, _Alloc>;107 using _Str _LIBCPP_NODEBUG = basic_string<_ECharT, _Traits, _Alloc>;
108108
109 _LIBCPP_HIDE_FROM_ABI static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }109 _LIBCPP_HIDE_FROM_ABI static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
110110
...@@ -117,7 +117,7 @@ template <class _ECharT, class _Traits>...@@ -117,7 +117,7 @@ template <class _ECharT, class _Traits>
117struct __is_pathable_string< basic_string_view<_ECharT, _Traits>,117struct __is_pathable_string< basic_string_view<_ECharT, _Traits>,
118 _Void<typename __can_convert_char<_ECharT>::__char_type> >118 _Void<typename __can_convert_char<_ECharT>::__char_type> >
119 : public __can_convert_char<_ECharT> {119 : public __can_convert_char<_ECharT> {
120 using _Str = basic_string_view<_ECharT, _Traits>;120 using _Str _LIBCPP_NODEBUG = basic_string_view<_ECharT, _Traits>;
121121
122 _LIBCPP_HIDE_FROM_ABI static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }122 _LIBCPP_HIDE_FROM_ABI static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
123123
...@@ -157,7 +157,7 @@ struct __is_pathable_iter<...@@ -157,7 +157,7 @@ struct __is_pathable_iter<
157 true,157 true,
158 _Void<typename __can_convert_char< typename iterator_traits<_Iter>::value_type>::__char_type> >158 _Void<typename __can_convert_char< typename iterator_traits<_Iter>::value_type>::__char_type> >
159 : __can_convert_char<typename iterator_traits<_Iter>::value_type> {159 : __can_convert_char<typename iterator_traits<_Iter>::value_type> {
160 using _ECharT = typename iterator_traits<_Iter>::value_type;160 using _ECharT _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::value_type;
161161
162 _LIBCPP_HIDE_FROM_ABI static _Iter __range_begin(_Iter __b) { return __b; }162 _LIBCPP_HIDE_FROM_ABI static _Iter __range_begin(_Iter __b) { return __b; }
163163
...@@ -199,7 +199,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t __char_to_wide(const string&, wchar_t*, size_t)...@@ -199,7 +199,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t __char_to_wide(const string&, wchar_t*, size_t)
199template <class _ECharT>199template <class _ECharT>
200struct _PathCVT;200struct _PathCVT;
201201
202# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)202# if _LIBCPP_HAS_LOCALIZATION
203template <class _ECharT>203template <class _ECharT>
204struct _PathCVT {204struct _PathCVT {
205 static_assert(__can_convert_char<_ECharT>::value, "Char type not convertible");205 static_assert(__can_convert_char<_ECharT>::value, "Char type not convertible");
...@@ -258,7 +258,7 @@ struct _PathCVT {...@@ -258,7 +258,7 @@ struct _PathCVT {
258 __append_range(__dest, _Traits::__range_begin(__s), _Traits::__range_end(__s));258 __append_range(__dest, _Traits::__range_begin(__s), _Traits::__range_end(__s));
259 }259 }
260};260};
261# endif // !_LIBCPP_HAS_NO_LOCALIZATION261# endif // _LIBCPP_HAS_LOCALIZATION
262262
263template <>263template <>
264struct _PathCVT<__path_value> {264struct _PathCVT<__path_value> {
...@@ -365,7 +365,7 @@ struct _PathExport<char16_t> {...@@ -365,7 +365,7 @@ struct _PathExport<char16_t> {
365 }365 }
366};366};
367367
368# ifndef _LIBCPP_HAS_NO_CHAR8_T368# if _LIBCPP_HAS_CHAR8_T
369template <>369template <>
370struct _PathExport<char8_t> {370struct _PathExport<char8_t> {
371 typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;371 typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;
...@@ -375,18 +375,18 @@ struct _PathExport<char8_t> {...@@ -375,18 +375,18 @@ struct _PathExport<char8_t> {
375 _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size());375 _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size());
376 }376 }
377};377};
378# endif /* !_LIBCPP_HAS_NO_CHAR8_T */378# endif // _LIBCPP_HAS_CHAR8_T
379# endif /* _LIBCPP_WIN32API */379# endif /* _LIBCPP_WIN32API */
380380
381class _LIBCPP_EXPORTED_FROM_ABI path {381class _LIBCPP_EXPORTED_FROM_ABI path {
382 template <class _SourceOrIter, class _Tp = path&>382 template <class _SourceOrIter, class _Tp = path&>
383 using _EnableIfPathable = __enable_if_t<__is_pathable<_SourceOrIter>::value, _Tp>;383 using _EnableIfPathable _LIBCPP_NODEBUG = __enable_if_t<__is_pathable<_SourceOrIter>::value, _Tp>;
384384
385 template <class _Tp>385 template <class _Tp>
386 using _SourceChar = typename __is_pathable<_Tp>::__char_type;386 using _SourceChar _LIBCPP_NODEBUG = typename __is_pathable<_Tp>::__char_type;
387387
388 template <class _Tp>388 template <class _Tp>
389 using _SourceCVT = _PathCVT<_SourceChar<_Tp> >;389 using _SourceCVT _LIBCPP_NODEBUG = _PathCVT<_SourceChar<_Tp> >;
390390
391public:391public:
392# if defined(_LIBCPP_WIN32API)392# if defined(_LIBCPP_WIN32API)
...@@ -420,7 +420,7 @@ public:...@@ -420,7 +420,7 @@ public:
420 }420 }
421421
422 /*422 /*
423 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)423 #if _LIBCPP_HAS_LOCALIZATION
424 // TODO Implement locale conversions.424 // TODO Implement locale conversions.
425 template <class _Source, class = _EnableIfPathable<_Source, void> >425 template <class _Source, class = _EnableIfPathable<_Source, void> >
426 path(const _Source& __src, const locale& __loc, format = format::auto_format);426 path(const _Source& __src, const locale& __loc, format = format::auto_format);
...@@ -682,7 +682,7 @@ public:...@@ -682,7 +682,7 @@ public:
682 return __s;682 return __s;
683 }683 }
684684
685# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)685# if _LIBCPP_HAS_LOCALIZATION
686 template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> >686 template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> >
687 _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const {687 _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const {
688 using _Str = basic_string<_ECharT, _Traits, _Allocator>;688 using _Str = basic_string<_ECharT, _Traits, _Allocator>;
...@@ -725,17 +725,17 @@ public:...@@ -725,17 +725,17 @@ public:
725 std::replace(__s.begin(), __s.end(), '\\', '/');725 std::replace(__s.begin(), __s.end(), '\\', '/');
726 return __s;726 return __s;
727 }727 }
728# endif /* !_LIBCPP_HAS_NO_LOCALIZATION */728# endif // _LIBCPP_HAS_LOCALIZATION
729# else /* _LIBCPP_WIN32API */729# else /* _LIBCPP_WIN32API */
730730
731 _LIBCPP_HIDE_FROM_ABI std::string string() const { return __pn_; }731 _LIBCPP_HIDE_FROM_ABI std::string string() const { return __pn_; }
732# ifndef _LIBCPP_HAS_NO_CHAR8_T732# if _LIBCPP_HAS_CHAR8_T
733 _LIBCPP_HIDE_FROM_ABI std::u8string u8string() const { return std::u8string(__pn_.begin(), __pn_.end()); }733 _LIBCPP_HIDE_FROM_ABI std::u8string u8string() const { return std::u8string(__pn_.begin(), __pn_.end()); }
734# else734# else
735 _LIBCPP_HIDE_FROM_ABI std::string u8string() const { return __pn_; }735 _LIBCPP_HIDE_FROM_ABI std::string u8string() const { return __pn_; }
736# endif736# endif
737737
738# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)738# if _LIBCPP_HAS_LOCALIZATION
739 template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> >739 template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> >
740 _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const {740 _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const {
741 using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>;741 using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>;
...@@ -746,34 +746,34 @@ public:...@@ -746,34 +746,34 @@ public:
746 return __s;746 return __s;
747 }747 }
748748
749# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS749# if _LIBCPP_HAS_WIDE_CHARACTERS
750 _LIBCPP_HIDE_FROM_ABI std::wstring wstring() const { return string<wchar_t>(); }750 _LIBCPP_HIDE_FROM_ABI std::wstring wstring() const { return string<wchar_t>(); }
751# endif751# endif
752 _LIBCPP_HIDE_FROM_ABI std::u16string u16string() const { return string<char16_t>(); }752 _LIBCPP_HIDE_FROM_ABI std::u16string u16string() const { return string<char16_t>(); }
753 _LIBCPP_HIDE_FROM_ABI std::u32string u32string() const { return string<char32_t>(); }753 _LIBCPP_HIDE_FROM_ABI std::u32string u32string() const { return string<char32_t>(); }
754# endif /* !_LIBCPP_HAS_NO_LOCALIZATION */754# endif // _LIBCPP_HAS_LOCALIZATION
755755
756 // generic format observers756 // generic format observers
757 _LIBCPP_HIDE_FROM_ABI std::string generic_string() const { return __pn_; }757 _LIBCPP_HIDE_FROM_ABI std::string generic_string() const { return __pn_; }
758# ifndef _LIBCPP_HAS_NO_CHAR8_T758# if _LIBCPP_HAS_CHAR8_T
759 _LIBCPP_HIDE_FROM_ABI std::u8string generic_u8string() const { return std::u8string(__pn_.begin(), __pn_.end()); }759 _LIBCPP_HIDE_FROM_ABI std::u8string generic_u8string() const { return std::u8string(__pn_.begin(), __pn_.end()); }
760# else760# else
761 _LIBCPP_HIDE_FROM_ABI std::string generic_u8string() const { return __pn_; }761 _LIBCPP_HIDE_FROM_ABI std::string generic_u8string() const { return __pn_; }
762# endif762# endif
763763
764# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)764# if _LIBCPP_HAS_LOCALIZATION
765 template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> >765 template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> >
766 _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator>766 _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator>
767 generic_string(const _Allocator& __a = _Allocator()) const {767 generic_string(const _Allocator& __a = _Allocator()) const {
768 return string<_ECharT, _Traits, _Allocator>(__a);768 return string<_ECharT, _Traits, _Allocator>(__a);
769 }769 }
770770
771# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS771# if _LIBCPP_HAS_WIDE_CHARACTERS
772 _LIBCPP_HIDE_FROM_ABI std::wstring generic_wstring() const { return string<wchar_t>(); }772 _LIBCPP_HIDE_FROM_ABI std::wstring generic_wstring() const { return string<wchar_t>(); }
773# endif773# endif
774 _LIBCPP_HIDE_FROM_ABI std::u16string generic_u16string() const { return string<char16_t>(); }774 _LIBCPP_HIDE_FROM_ABI std::u16string generic_u16string() const { return string<char16_t>(); }
775 _LIBCPP_HIDE_FROM_ABI std::u32string generic_u32string() const { return string<char32_t>(); }775 _LIBCPP_HIDE_FROM_ABI std::u32string generic_u32string() const { return string<char32_t>(); }
776# endif /* !_LIBCPP_HAS_NO_LOCALIZATION */776# endif // _LIBCPP_HAS_LOCALIZATION
777# endif /* !_LIBCPP_WIN32API */777# endif /* !_LIBCPP_WIN32API */
778778
779private:779private:
...@@ -811,7 +811,7 @@ public:...@@ -811,7 +811,7 @@ public:
811 _LIBCPP_HIDE_FROM_ABI path extension() const { return string_type(__extension()); }811 _LIBCPP_HIDE_FROM_ABI path extension() const { return string_type(__extension()); }
812812
813 // query813 // query
814 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __pn_.empty(); }814 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __pn_.empty(); }
815815
816 _LIBCPP_HIDE_FROM_ABI bool has_root_name() const { return !__root_name().empty(); }816 _LIBCPP_HIDE_FROM_ABI bool has_root_name() const { return !__root_name().empty(); }
817 _LIBCPP_HIDE_FROM_ABI bool has_root_directory() const { return !__root_directory().empty(); }817 _LIBCPP_HIDE_FROM_ABI bool has_root_directory() const { return !__root_directory().empty(); }
...@@ -866,7 +866,7 @@ public:...@@ -866,7 +866,7 @@ public:
866 iterator begin() const;866 iterator begin() const;
867 iterator end() const;867 iterator end() const;
868868
869# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)869# if _LIBCPP_HAS_LOCALIZATION
870 template <870 template <
871 class _CharT,871 class _CharT,
872 class _Traits,872 class _Traits,
...@@ -895,7 +895,7 @@ public:...@@ -895,7 +895,7 @@ public:
895 __p = __tmp;895 __p = __tmp;
896 return __is;896 return __is;
897 }897 }
898# endif // !_LIBCPP_HAS_NO_LOCALIZATION898# endif // _LIBCPP_HAS_LOCALIZATION
899899
900private:900private:
901 inline _LIBCPP_HIDE_FROM_ABI path& __assign_view(__string_view const& __s) {901 inline _LIBCPP_HIDE_FROM_ABI path& __assign_view(__string_view const& __s) {
lib/libcxx/include/__filesystem/path_iterator.h-3
...@@ -14,9 +14,6 @@...@@ -14,9 +14,6 @@
14#include <__config>14#include <__config>
15#include <__filesystem/path.h>15#include <__filesystem/path.h>
16#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
17#include <cstddef>
18#include <string>
19#include <string_view>
2017
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header19# pragma GCC system_header
lib/libcxx/include/__filesystem/recursive_directory_iterator.h+2-3
...@@ -21,7 +21,6 @@...@@ -21,7 +21,6 @@
21#include <__ranges/enable_view.h>21#include <__ranges/enable_view.h>
22#include <__system_error/error_code.h>22#include <__system_error/error_code.h>
23#include <__utility/move.h>23#include <__utility/move.h>
24#include <cstddef>
2524
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header26# pragma GCC system_header
...@@ -30,7 +29,7 @@...@@ -30,7 +29,7 @@
30_LIBCPP_PUSH_MACROS29_LIBCPP_PUSH_MACROS
31#include <__undef_macros>30#include <__undef_macros>
3231
33#if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)32#if _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM
3433
35_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM34_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
3635
...@@ -157,7 +156,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool...@@ -157,7 +156,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool
157156
158# endif // _LIBCPP_STD_VER >= 20157# endif // _LIBCPP_STD_VER >= 20
159158
160#endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM)159#endif // _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM
161160
162_LIBCPP_POP_MACROS161_LIBCPP_POP_MACROS
163162
lib/libcxx/include/__filesystem/u8path.h+3-3
...@@ -34,7 +34,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH...@@ -34,7 +34,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH
34template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0>34template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0>
35_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _InputIt __l) {35_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _InputIt __l) {
36 static_assert(36 static_assert(
37# ifndef _LIBCPP_HAS_NO_CHAR8_T37# if _LIBCPP_HAS_CHAR8_T
38 is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||38 is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||
39# endif39# endif
40 is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,40 is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
...@@ -56,7 +56,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f,...@@ -56,7 +56,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f,
56template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0>56template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0>
57_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _NullSentinel) {57_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _NullSentinel) {
58 static_assert(58 static_assert(
59# ifndef _LIBCPP_HAS_NO_CHAR8_T59# if _LIBCPP_HAS_CHAR8_T
60 is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||60 is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||
61# endif61# endif
62 is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,62 is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
...@@ -77,7 +77,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f,...@@ -77,7 +77,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f,
77template <class _Source, __enable_if_t<__is_pathable<_Source>::value, int> = 0>77template <class _Source, __enable_if_t<__is_pathable<_Source>::value, int> = 0>
78_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(const _Source& __s) {78_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(const _Source& __s) {
79 static_assert(79 static_assert(
80# ifndef _LIBCPP_HAS_NO_CHAR8_T80# if _LIBCPP_HAS_CHAR8_T
81 is_same<typename __is_pathable<_Source>::__char_type, char8_t>::value ||81 is_same<typename __is_pathable<_Source>::__char_type, char8_t>::value ||
82# endif82# endif
83 is_same<typename __is_pathable<_Source>::__char_type, char>::value,83 is_same<typename __is_pathable<_Source>::__char_type, char>::value,
lib/libcxx/include/__flat_map/flat_map.h created+1199
...@@ -0,0 +1,1199 @@
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___FLAT_MAP_FLAT_MAP_H
11#define _LIBCPP___FLAT_MAP_FLAT_MAP_H
12
13#include <__algorithm/lexicographical_compare_three_way.h>
14#include <__algorithm/min.h>
15#include <__algorithm/ranges_adjacent_find.h>
16#include <__algorithm/ranges_equal.h>
17#include <__algorithm/ranges_inplace_merge.h>
18#include <__algorithm/ranges_lower_bound.h>
19#include <__algorithm/ranges_partition_point.h>
20#include <__algorithm/ranges_sort.h>
21#include <__algorithm/ranges_unique.h>
22#include <__algorithm/ranges_upper_bound.h>
23#include <__algorithm/remove_if.h>
24#include <__assert>
25#include <__compare/synth_three_way.h>
26#include <__concepts/swappable.h>
27#include <__config>
28#include <__cstddef/byte.h>
29#include <__cstddef/ptrdiff_t.h>
30#include <__flat_map/key_value_iterator.h>
31#include <__flat_map/sorted_unique.h>
32#include <__flat_map/utils.h>
33#include <__functional/invoke.h>
34#include <__functional/is_transparent.h>
35#include <__functional/operations.h>
36#include <__fwd/vector.h>
37#include <__iterator/concepts.h>
38#include <__iterator/distance.h>
39#include <__iterator/iterator_traits.h>
40#include <__iterator/next.h>
41#include <__iterator/ranges_iterator_traits.h>
42#include <__iterator/reverse_iterator.h>
43#include <__memory/allocator_traits.h>
44#include <__memory/uses_allocator.h>
45#include <__memory/uses_allocator_construction.h>
46#include <__ranges/access.h>
47#include <__ranges/concepts.h>
48#include <__ranges/container_compatible_range.h>
49#include <__ranges/drop_view.h>
50#include <__ranges/from_range.h>
51#include <__ranges/ref_view.h>
52#include <__ranges/size.h>
53#include <__ranges/subrange.h>
54#include <__ranges/zip_view.h>
55#include <__type_traits/conjunction.h>
56#include <__type_traits/container_traits.h>
57#include <__type_traits/invoke.h>
58#include <__type_traits/is_allocator.h>
59#include <__type_traits/is_nothrow_constructible.h>
60#include <__type_traits/is_same.h>
61#include <__utility/exception_guard.h>
62#include <__utility/move.h>
63#include <__utility/pair.h>
64#include <__utility/scope_guard.h>
65#include <__vector/vector.h>
66#include <initializer_list>
67#include <stdexcept>
68
69#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
70# pragma GCC system_header
71#endif
72
73_LIBCPP_PUSH_MACROS
74#include <__undef_macros>
75
76#if _LIBCPP_STD_VER >= 23
77
78_LIBCPP_BEGIN_NAMESPACE_STD
79
80template <class _Key,
81 class _Tp,
82 class _Compare = less<_Key>,
83 class _KeyContainer = vector<_Key>,
84 class _MappedContainer = vector<_Tp>>
85class flat_map {
86 template <class, class, class, class, class>
87 friend class flat_map;
88
89 static_assert(is_same_v<_Key, typename _KeyContainer::value_type>);
90 static_assert(is_same_v<_Tp, typename _MappedContainer::value_type>);
91 static_assert(!is_same_v<_KeyContainer, std::vector<bool>>, "vector<bool> is not a sequence container");
92 static_assert(!is_same_v<_MappedContainer, std::vector<bool>>, "vector<bool> is not a sequence container");
93
94 template <bool _Const>
95 using __iterator _LIBCPP_NODEBUG = __key_value_iterator<flat_map, _KeyContainer, _MappedContainer, _Const>;
96
97public:
98 // types
99 using key_type = _Key;
100 using mapped_type = _Tp;
101 using value_type = pair<key_type, mapped_type>;
102 using key_compare = __type_identity_t<_Compare>;
103 using reference = pair<const key_type&, mapped_type&>;
104 using const_reference = pair<const key_type&, const mapped_type&>;
105 using size_type = size_t;
106 using difference_type = ptrdiff_t;
107 using iterator = __iterator<false>; // see [container.requirements]
108 using const_iterator = __iterator<true>; // see [container.requirements]
109 using reverse_iterator = std::reverse_iterator<iterator>;
110 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
111 using key_container_type = _KeyContainer;
112 using mapped_container_type = _MappedContainer;
113
114 class value_compare {
115 private:
116 key_compare __comp_;
117 _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {}
118 friend flat_map;
119
120 public:
121 _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const {
122 return __comp_(__x.first, __y.first);
123 }
124 };
125
126 struct containers {
127 key_container_type keys;
128 mapped_container_type values;
129 };
130
131private:
132 template <class _Allocator>
133 _LIBCPP_HIDE_FROM_ABI static constexpr bool __allocator_ctor_constraint =
134 _And<uses_allocator<key_container_type, _Allocator>, uses_allocator<mapped_container_type, _Allocator>>::value;
135
136 _LIBCPP_HIDE_FROM_ABI static constexpr bool __is_compare_transparent = __is_transparent_v<_Compare>;
137
138public:
139 // [flat.map.cons], construct/copy/destroy
140 _LIBCPP_HIDE_FROM_ABI flat_map() noexcept(
141 is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_MappedContainer> &&
142 is_nothrow_default_constructible_v<_Compare>)
143 : __containers_(), __compare_() {}
144
145 _LIBCPP_HIDE_FROM_ABI flat_map(const flat_map&) = default;
146
147 _LIBCPP_HIDE_FROM_ABI flat_map(flat_map&& __other) noexcept(
148 is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_MappedContainer> &&
149 is_nothrow_move_constructible_v<_Compare>)
150# if _LIBCPP_HAS_EXCEPTIONS
151 try
152# endif // _LIBCPP_HAS_EXCEPTIONS
153 : __containers_(std::move(__other.__containers_)), __compare_(std::move(__other.__compare_)) {
154 __other.clear();
155# if _LIBCPP_HAS_EXCEPTIONS
156 } catch (...) {
157 __other.clear();
158 // gcc does not like the `throw` keyword in a conditionally noexcept function
159 if constexpr (!(is_nothrow_move_constructible_v<_KeyContainer> &&
160 is_nothrow_move_constructible_v<_MappedContainer> && is_nothrow_move_constructible_v<_Compare>)) {
161 throw;
162 }
163# endif // _LIBCPP_HAS_EXCEPTIONS
164 }
165
166 template <class _Allocator>
167 requires __allocator_ctor_constraint<_Allocator>
168 _LIBCPP_HIDE_FROM_ABI flat_map(const flat_map& __other, const _Allocator& __alloc)
169 : flat_map(__ctor_uses_allocator_tag{},
170 __alloc,
171 __other.__containers_.keys,
172 __other.__containers_.values,
173 __other.__compare_) {}
174
175 template <class _Allocator>
176 requires __allocator_ctor_constraint<_Allocator>
177 _LIBCPP_HIDE_FROM_ABI flat_map(flat_map&& __other, const _Allocator& __alloc)
178# if _LIBCPP_HAS_EXCEPTIONS
179 try
180# endif // _LIBCPP_HAS_EXCEPTIONS
181 : flat_map(__ctor_uses_allocator_tag{},
182 __alloc,
183 std::move(__other.__containers_.keys),
184 std::move(__other.__containers_.values),
185 std::move(__other.__compare_)) {
186 __other.clear();
187# if _LIBCPP_HAS_EXCEPTIONS
188 } catch (...) {
189 __other.clear();
190 throw;
191# endif // _LIBCPP_HAS_EXCEPTIONS
192 }
193
194 _LIBCPP_HIDE_FROM_ABI flat_map(
195 key_container_type __key_cont, mapped_container_type __mapped_cont, const key_compare& __comp = key_compare())
196 : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) {
197 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
198 "flat_map keys and mapped containers have different size");
199 __sort_and_unique();
200 }
201
202 template <class _Allocator>
203 requires __allocator_ctor_constraint<_Allocator>
204 _LIBCPP_HIDE_FROM_ABI
205 flat_map(const key_container_type& __key_cont, const mapped_container_type& __mapped_cont, const _Allocator& __alloc)
206 : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) {
207 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
208 "flat_map keys and mapped containers have different size");
209 __sort_and_unique();
210 }
211
212 template <class _Allocator>
213 requires __allocator_ctor_constraint<_Allocator>
214 _LIBCPP_HIDE_FROM_ABI
215 flat_map(const key_container_type& __key_cont,
216 const mapped_container_type& __mapped_cont,
217 const key_compare& __comp,
218 const _Allocator& __alloc)
219 : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) {
220 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
221 "flat_map keys and mapped containers have different size");
222 __sort_and_unique();
223 }
224
225 _LIBCPP_HIDE_FROM_ABI
226 flat_map(sorted_unique_t,
227 key_container_type __key_cont,
228 mapped_container_type __mapped_cont,
229 const key_compare& __comp = key_compare())
230 : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) {
231 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
232 "flat_map keys and mapped containers have different size");
233 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
234 __is_sorted_and_unique(__containers_.keys), "Either the key container is not sorted or it contains duplicates");
235 }
236
237 template <class _Allocator>
238 requires __allocator_ctor_constraint<_Allocator>
239 _LIBCPP_HIDE_FROM_ABI
240 flat_map(sorted_unique_t,
241 const key_container_type& __key_cont,
242 const mapped_container_type& __mapped_cont,
243 const _Allocator& __alloc)
244 : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) {
245 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
246 "flat_map keys and mapped containers have different size");
247 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
248 __is_sorted_and_unique(__containers_.keys), "Either the key container is not sorted or it contains duplicates");
249 }
250
251 template <class _Allocator>
252 requires __allocator_ctor_constraint<_Allocator>
253 _LIBCPP_HIDE_FROM_ABI
254 flat_map(sorted_unique_t,
255 const key_container_type& __key_cont,
256 const mapped_container_type& __mapped_cont,
257 const key_compare& __comp,
258 const _Allocator& __alloc)
259 : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) {
260 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
261 "flat_map keys and mapped containers have different size");
262 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
263 __is_sorted_and_unique(__containers_.keys), "Either the key container is not sorted or it contains duplicates");
264 }
265
266 _LIBCPP_HIDE_FROM_ABI explicit flat_map(const key_compare& __comp) : __containers_(), __compare_(__comp) {}
267
268 template <class _Allocator>
269 requires __allocator_ctor_constraint<_Allocator>
270 _LIBCPP_HIDE_FROM_ABI flat_map(const key_compare& __comp, const _Allocator& __alloc)
271 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {}
272
273 template <class _Allocator>
274 requires __allocator_ctor_constraint<_Allocator>
275 _LIBCPP_HIDE_FROM_ABI explicit flat_map(const _Allocator& __alloc)
276 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {}
277
278 template <class _InputIterator>
279 requires __has_input_iterator_category<_InputIterator>::value
280 _LIBCPP_HIDE_FROM_ABI
281 flat_map(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
282 : __containers_(), __compare_(__comp) {
283 insert(__first, __last);
284 }
285
286 template <class _InputIterator, class _Allocator>
287 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)
288 _LIBCPP_HIDE_FROM_ABI
289 flat_map(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc)
290 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {
291 insert(__first, __last);
292 }
293
294 template <class _InputIterator, class _Allocator>
295 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)
296 _LIBCPP_HIDE_FROM_ABI flat_map(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
297 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {
298 insert(__first, __last);
299 }
300
301 template <_ContainerCompatibleRange<value_type> _Range>
302 _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t __fr, _Range&& __rg)
303 : flat_map(__fr, std::forward<_Range>(__rg), key_compare()) {}
304
305 template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
306 requires __allocator_ctor_constraint<_Allocator>
307 _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t, _Range&& __rg, const _Allocator& __alloc)
308 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {
309 insert_range(std::forward<_Range>(__rg));
310 }
311
312 template <_ContainerCompatibleRange<value_type> _Range>
313 _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t, _Range&& __rg, const key_compare& __comp) : flat_map(__comp) {
314 insert_range(std::forward<_Range>(__rg));
315 }
316
317 template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
318 requires __allocator_ctor_constraint<_Allocator>
319 _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc)
320 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {
321 insert_range(std::forward<_Range>(__rg));
322 }
323
324 template <class _InputIterator>
325 requires __has_input_iterator_category<_InputIterator>::value
326 _LIBCPP_HIDE_FROM_ABI
327 flat_map(sorted_unique_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
328 : __containers_(), __compare_(__comp) {
329 insert(sorted_unique, __first, __last);
330 }
331 template <class _InputIterator, class _Allocator>
332 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)
333 _LIBCPP_HIDE_FROM_ABI
334 flat_map(sorted_unique_t,
335 _InputIterator __first,
336 _InputIterator __last,
337 const key_compare& __comp,
338 const _Allocator& __alloc)
339 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {
340 insert(sorted_unique, __first, __last);
341 }
342
343 template <class _InputIterator, class _Allocator>
344 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)
345 _LIBCPP_HIDE_FROM_ABI
346 flat_map(sorted_unique_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
347 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {
348 insert(sorted_unique, __first, __last);
349 }
350
351 _LIBCPP_HIDE_FROM_ABI flat_map(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
352 : flat_map(__il.begin(), __il.end(), __comp) {}
353
354 template <class _Allocator>
355 requires __allocator_ctor_constraint<_Allocator>
356 _LIBCPP_HIDE_FROM_ABI
357 flat_map(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
358 : flat_map(__il.begin(), __il.end(), __comp, __alloc) {}
359
360 template <class _Allocator>
361 requires __allocator_ctor_constraint<_Allocator>
362 _LIBCPP_HIDE_FROM_ABI flat_map(initializer_list<value_type> __il, const _Allocator& __alloc)
363 : flat_map(__il.begin(), __il.end(), __alloc) {}
364
365 _LIBCPP_HIDE_FROM_ABI
366 flat_map(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare())
367 : flat_map(sorted_unique, __il.begin(), __il.end(), __comp) {}
368
369 template <class _Allocator>
370 requires __allocator_ctor_constraint<_Allocator>
371 _LIBCPP_HIDE_FROM_ABI
372 flat_map(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
373 : flat_map(sorted_unique, __il.begin(), __il.end(), __comp, __alloc) {}
374
375 template <class _Allocator>
376 requires __allocator_ctor_constraint<_Allocator>
377 _LIBCPP_HIDE_FROM_ABI flat_map(sorted_unique_t, initializer_list<value_type> __il, const _Allocator& __alloc)
378 : flat_map(sorted_unique, __il.begin(), __il.end(), __alloc) {}
379
380 _LIBCPP_HIDE_FROM_ABI flat_map& operator=(initializer_list<value_type> __il) {
381 clear();
382 insert(__il);
383 return *this;
384 }
385
386 _LIBCPP_HIDE_FROM_ABI flat_map& operator=(const flat_map&) = default;
387
388 _LIBCPP_HIDE_FROM_ABI flat_map& operator=(flat_map&& __other) noexcept(
389 is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_MappedContainer> &&
390 is_nothrow_move_assignable_v<_Compare>) {
391 // No matter what happens, we always want to clear the other container before returning
392 // since we moved from it
393 auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; });
394 {
395 // If an exception is thrown, we have no choice but to clear *this to preserve invariants
396 auto __on_exception = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
397 __containers_ = std::move(__other.__containers_);
398 __compare_ = std::move(__other.__compare_);
399 __on_exception.__complete();
400 }
401 return *this;
402 }
403
404 // iterators
405 _LIBCPP_HIDE_FROM_ABI iterator begin() noexcept {
406 return iterator(__containers_.keys.begin(), __containers_.values.begin());
407 }
408
409 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept {
410 return const_iterator(__containers_.keys.begin(), __containers_.values.begin());
411 }
412
413 _LIBCPP_HIDE_FROM_ABI iterator end() noexcept {
414 return iterator(__containers_.keys.end(), __containers_.values.end());
415 }
416
417 _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept {
418 return const_iterator(__containers_.keys.end(), __containers_.values.end());
419 }
420
421 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() noexcept { return reverse_iterator(end()); }
422 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
423 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() noexcept { return reverse_iterator(begin()); }
424 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
425
426 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return begin(); }
427 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return end(); }
428 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); }
429 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); }
430
431 // [flat.map.capacity], capacity
432 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __containers_.keys.empty(); }
433
434 _LIBCPP_HIDE_FROM_ABI size_type size() const noexcept { return __containers_.keys.size(); }
435
436 _LIBCPP_HIDE_FROM_ABI size_type max_size() const noexcept {
437 return std::min<size_type>(__containers_.keys.max_size(), __containers_.values.max_size());
438 }
439
440 // [flat.map.access], element access
441 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __x)
442 requires is_constructible_v<mapped_type>
443 {
444 return try_emplace(__x).first->second;
445 }
446
447 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __x)
448 requires is_constructible_v<mapped_type>
449 {
450 return try_emplace(std::move(__x)).first->second;
451 }
452
453 template <class _Kp>
454 requires(__is_compare_transparent && is_constructible_v<key_type, _Kp> && is_constructible_v<mapped_type> &&
455 !is_convertible_v<_Kp &&, const_iterator> && !is_convertible_v<_Kp &&, iterator>)
456 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](_Kp&& __x) {
457 return try_emplace(std::forward<_Kp>(__x)).first->second;
458 }
459
460 _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __x) {
461 auto __it = find(__x);
462 if (__it == end()) {
463 std::__throw_out_of_range("flat_map::at(const key_type&): Key does not exist");
464 }
465 return __it->second;
466 }
467
468 _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __x) const {
469 auto __it = find(__x);
470 if (__it == end()) {
471 std::__throw_out_of_range("flat_map::at(const key_type&) const: Key does not exist");
472 }
473 return __it->second;
474 }
475
476 template <class _Kp>
477 requires __is_compare_transparent
478 _LIBCPP_HIDE_FROM_ABI mapped_type& at(const _Kp& __x) {
479 auto __it = find(__x);
480 if (__it == end()) {
481 std::__throw_out_of_range("flat_map::at(const K&): Key does not exist");
482 }
483 return __it->second;
484 }
485
486 template <class _Kp>
487 requires __is_compare_transparent
488 _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const _Kp& __x) const {
489 auto __it = find(__x);
490 if (__it == end()) {
491 std::__throw_out_of_range("flat_map::at(const K&) const: Key does not exist");
492 }
493 return __it->second;
494 }
495
496 // [flat.map.modifiers], modifiers
497 template <class... _Args>
498 requires is_constructible_v<pair<key_type, mapped_type>, _Args...>
499 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {
500 std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...);
501 return __try_emplace(std::move(__pair.first), std::move(__pair.second));
502 }
503
504 template <class... _Args>
505 requires is_constructible_v<pair<key_type, mapped_type>, _Args...>
506 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __hint, _Args&&... __args) {
507 std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...);
508 return __try_emplace_hint(__hint, std::move(__pair.first), std::move(__pair.second)).first;
509 }
510
511 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return emplace(__x); }
512
513 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) { return emplace(std::move(__x)); }
514
515 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, const value_type& __x) {
516 return emplace_hint(__hint, __x);
517 }
518
519 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, value_type&& __x) {
520 return emplace_hint(__hint, std::move(__x));
521 }
522
523 template <class _PairLike>
524 requires is_constructible_v<pair<key_type, mapped_type>, _PairLike>
525 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_PairLike&& __x) {
526 return emplace(std::forward<_PairLike>(__x));
527 }
528
529 template <class _PairLike>
530 requires is_constructible_v<pair<key_type, mapped_type>, _PairLike>
531 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, _PairLike&& __x) {
532 return emplace_hint(__hint, std::forward<_PairLike>(__x));
533 }
534
535 template <class _InputIterator>
536 requires __has_input_iterator_category<_InputIterator>::value
537 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) {
538 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
539 __reserve(__last - __first);
540 }
541 __append_sort_merge_unique</*WasSorted = */ false>(std::move(__first), std::move(__last));
542 }
543
544 template <class _InputIterator>
545 requires __has_input_iterator_category<_InputIterator>::value
546 _LIBCPP_HIDE_FROM_ABI void insert(sorted_unique_t, _InputIterator __first, _InputIterator __last) {
547 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
548 __reserve(__last - __first);
549 }
550
551 __append_sort_merge_unique</*WasSorted = */ true>(std::move(__first), std::move(__last));
552 }
553
554 template <_ContainerCompatibleRange<value_type> _Range>
555 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
556 if constexpr (ranges::sized_range<_Range>) {
557 __reserve(ranges::size(__range));
558 }
559
560 __append_sort_merge_unique</*WasSorted = */ false>(ranges::begin(__range), ranges::end(__range));
561 }
562
563 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
564
565 _LIBCPP_HIDE_FROM_ABI void insert(sorted_unique_t, initializer_list<value_type> __il) {
566 insert(sorted_unique, __il.begin(), __il.end());
567 }
568
569 _LIBCPP_HIDE_FROM_ABI containers extract() && {
570 auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; });
571 auto __ret = std::move(__containers_);
572 return __ret;
573 }
574
575 _LIBCPP_HIDE_FROM_ABI void replace(key_container_type&& __key_cont, mapped_container_type&& __mapped_cont) {
576 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
577 __key_cont.size() == __mapped_cont.size(), "flat_map keys and mapped containers have different size");
578
579 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
580 __is_sorted_and_unique(__key_cont), "Either the key container is not sorted or it contains duplicates");
581 auto __guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
582 __containers_.keys = std::move(__key_cont);
583 __containers_.values = std::move(__mapped_cont);
584 __guard.__complete();
585 }
586
587 template <class... _Args>
588 requires is_constructible_v<mapped_type, _Args...>
589 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __key, _Args&&... __args) {
590 return __try_emplace(__key, std::forward<_Args>(__args)...);
591 }
592
593 template <class... _Args>
594 requires is_constructible_v<mapped_type, _Args...>
595 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(key_type&& __key, _Args&&... __args) {
596 return __try_emplace(std::move(__key), std::forward<_Args>(__args)...);
597 }
598
599 template <class _Kp, class... _Args>
600 requires(__is_compare_transparent && is_constructible_v<key_type, _Kp> &&
601 is_constructible_v<mapped_type, _Args...> && !is_convertible_v<_Kp &&, const_iterator> &&
602 !is_convertible_v<_Kp &&, iterator>)
603 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(_Kp&& __key, _Args&&... __args) {
604 return __try_emplace(std::forward<_Kp>(__key), std::forward<_Args>(__args)...);
605 }
606
607 template <class... _Args>
608 requires is_constructible_v<mapped_type, _Args...>
609 _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __hint, const key_type& __key, _Args&&... __args) {
610 return __try_emplace_hint(__hint, __key, std::forward<_Args>(__args)...).first;
611 }
612
613 template <class... _Args>
614 requires is_constructible_v<mapped_type, _Args...>
615 _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __hint, key_type&& __key, _Args&&... __args) {
616 return __try_emplace_hint(__hint, std::move(__key), std::forward<_Args>(__args)...).first;
617 }
618
619 template <class _Kp, class... _Args>
620 requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_constructible_v<mapped_type, _Args...>
621 _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __hint, _Kp&& __key, _Args&&... __args) {
622 return __try_emplace_hint(__hint, std::forward<_Kp>(__key), std::forward<_Args>(__args)...).first;
623 }
624
625 template <class _Mapped>
626 requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped>
627 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(const key_type& __key, _Mapped&& __obj) {
628 return __insert_or_assign(__key, std::forward<_Mapped>(__obj));
629 }
630
631 template <class _Mapped>
632 requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped>
633 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(key_type&& __key, _Mapped&& __obj) {
634 return __insert_or_assign(std::move(__key), std::forward<_Mapped>(__obj));
635 }
636
637 template <class _Kp, class _Mapped>
638 requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_assignable_v<mapped_type&, _Mapped> &&
639 is_constructible_v<mapped_type, _Mapped>
640 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(_Kp&& __key, _Mapped&& __obj) {
641 return __insert_or_assign(std::forward<_Kp>(__key), std::forward<_Mapped>(__obj));
642 }
643
644 template <class _Mapped>
645 requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped>
646 _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __hint, const key_type& __key, _Mapped&& __obj) {
647 return __insert_or_assign(__hint, __key, std::forward<_Mapped>(__obj));
648 }
649
650 template <class _Mapped>
651 requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped>
652 _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __hint, key_type&& __key, _Mapped&& __obj) {
653 return __insert_or_assign(__hint, std::move(__key), std::forward<_Mapped>(__obj));
654 }
655
656 template <class _Kp, class _Mapped>
657 requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_assignable_v<mapped_type&, _Mapped> &&
658 is_constructible_v<mapped_type, _Mapped>
659 _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __hint, _Kp&& __key, _Mapped&& __obj) {
660 return __insert_or_assign(__hint, std::forward<_Kp>(__key), std::forward<_Mapped>(__obj));
661 }
662
663 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __position) {
664 return __erase(__position.__key_iter_, __position.__mapped_iter_);
665 }
666
667 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position) {
668 return __erase(__position.__key_iter_, __position.__mapped_iter_);
669 }
670
671 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __x) {
672 auto __iter = find(__x);
673 if (__iter != end()) {
674 erase(__iter);
675 return 1;
676 }
677 return 0;
678 }
679
680 template <class _Kp>
681 requires(__is_compare_transparent && !is_convertible_v<_Kp &&, iterator> &&
682 !is_convertible_v<_Kp &&, const_iterator>)
683 _LIBCPP_HIDE_FROM_ABI size_type erase(_Kp&& __x) {
684 auto [__first, __last] = equal_range(__x);
685 auto __res = __last - __first;
686 erase(__first, __last);
687 return __res;
688 }
689
690 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) {
691 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
692 auto __key_it = __containers_.keys.erase(__first.__key_iter_, __last.__key_iter_);
693 auto __mapped_it = __containers_.values.erase(__first.__mapped_iter_, __last.__mapped_iter_);
694 __on_failure.__complete();
695 return iterator(std::move(__key_it), std::move(__mapped_it));
696 }
697
698 _LIBCPP_HIDE_FROM_ABI void swap(flat_map& __y) noexcept {
699 // warning: The spec has unconditional noexcept, which means that
700 // if any of the following functions throw an exception,
701 // std::terminate will be called.
702 // This is discussed in P2767, which hasn't been voted on yet.
703 ranges::swap(__compare_, __y.__compare_);
704 ranges::swap(__containers_.keys, __y.__containers_.keys);
705 ranges::swap(__containers_.values, __y.__containers_.values);
706 }
707
708 _LIBCPP_HIDE_FROM_ABI void clear() noexcept {
709 __containers_.keys.clear();
710 __containers_.values.clear();
711 }
712
713 // observers
714 _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __compare_; }
715 _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__compare_); }
716
717 _LIBCPP_HIDE_FROM_ABI const key_container_type& keys() const noexcept { return __containers_.keys; }
718 _LIBCPP_HIDE_FROM_ABI const mapped_container_type& values() const noexcept { return __containers_.values; }
719
720 // map operations
721 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __x) { return __find_impl(*this, __x); }
722
723 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __x) const { return __find_impl(*this, __x); }
724
725 template <class _Kp>
726 requires __is_compare_transparent
727 _LIBCPP_HIDE_FROM_ABI iterator find(const _Kp& __x) {
728 return __find_impl(*this, __x);
729 }
730
731 template <class _Kp>
732 requires __is_compare_transparent
733 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Kp& __x) const {
734 return __find_impl(*this, __x);
735 }
736
737 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __x) const { return contains(__x) ? 1 : 0; }
738
739 template <class _Kp>
740 requires __is_compare_transparent
741 _LIBCPP_HIDE_FROM_ABI size_type count(const _Kp& __x) const {
742 return contains(__x) ? 1 : 0;
743 }
744
745 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __x) const { return find(__x) != end(); }
746
747 template <class _Kp>
748 requires __is_compare_transparent
749 _LIBCPP_HIDE_FROM_ABI bool contains(const _Kp& __x) const {
750 return find(__x) != end();
751 }
752
753 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __x) { return __lower_bound<iterator>(*this, __x); }
754
755 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __x) const {
756 return __lower_bound<const_iterator>(*this, __x);
757 }
758
759 template <class _Kp>
760 requires __is_compare_transparent
761 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Kp& __x) {
762 return __lower_bound<iterator>(*this, __x);
763 }
764
765 template <class _Kp>
766 requires __is_compare_transparent
767 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Kp& __x) const {
768 return __lower_bound<const_iterator>(*this, __x);
769 }
770
771 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __x) { return __upper_bound<iterator>(*this, __x); }
772
773 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __x) const {
774 return __upper_bound<const_iterator>(*this, __x);
775 }
776
777 template <class _Kp>
778 requires __is_compare_transparent
779 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Kp& __x) {
780 return __upper_bound<iterator>(*this, __x);
781 }
782
783 template <class _Kp>
784 requires __is_compare_transparent
785 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Kp& __x) const {
786 return __upper_bound<const_iterator>(*this, __x);
787 }
788
789 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __x) {
790 return __equal_range_impl(*this, __x);
791 }
792
793 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __x) const {
794 return __equal_range_impl(*this, __x);
795 }
796
797 template <class _Kp>
798 requires __is_compare_transparent
799 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _Kp& __x) {
800 return __equal_range_impl(*this, __x);
801 }
802 template <class _Kp>
803 requires __is_compare_transparent
804 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _Kp& __x) const {
805 return __equal_range_impl(*this, __x);
806 }
807
808 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const flat_map& __x, const flat_map& __y) {
809 return ranges::equal(__x, __y);
810 }
811
812 friend _LIBCPP_HIDE_FROM_ABI auto operator<=>(const flat_map& __x, const flat_map& __y) {
813 return std::lexicographical_compare_three_way(
814 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
815 }
816
817 friend _LIBCPP_HIDE_FROM_ABI void swap(flat_map& __x, flat_map& __y) noexcept { __x.swap(__y); }
818
819private:
820 struct __ctor_uses_allocator_tag {
821 explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_tag() = default;
822 };
823 struct __ctor_uses_allocator_empty_tag {
824 explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_empty_tag() = default;
825 };
826
827 template <class _Allocator, class _KeyCont, class _MappedCont, class... _CompArg>
828 requires __allocator_ctor_constraint<_Allocator>
829 _LIBCPP_HIDE_FROM_ABI
830 flat_map(__ctor_uses_allocator_tag,
831 const _Allocator& __alloc,
832 _KeyCont&& __key_cont,
833 _MappedCont&& __mapped_cont,
834 _CompArg&&... __comp)
835 : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(
836 __alloc, std::forward<_KeyCont>(__key_cont)),
837 .values = std::make_obj_using_allocator<mapped_container_type>(
838 __alloc, std::forward<_MappedCont>(__mapped_cont))},
839 __compare_(std::forward<_CompArg>(__comp)...) {}
840
841 template <class _Allocator, class... _CompArg>
842 requires __allocator_ctor_constraint<_Allocator>
843 _LIBCPP_HIDE_FROM_ABI flat_map(__ctor_uses_allocator_empty_tag, const _Allocator& __alloc, _CompArg&&... __comp)
844 : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(__alloc),
845 .values = std::make_obj_using_allocator<mapped_container_type>(__alloc)},
846 __compare_(std::forward<_CompArg>(__comp)...) {}
847
848 _LIBCPP_HIDE_FROM_ABI bool __is_sorted_and_unique(auto&& __key_container) const {
849 auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) { return !__compare_(__x, __y); };
850 return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container);
851 }
852
853 // This function is only used in constructors. So there is not exception handling in this function.
854 // If the function exits via an exception, there will be no flat_map object constructed, thus, there
855 // is no invariant state to preserve
856 _LIBCPP_HIDE_FROM_ABI void __sort_and_unique() {
857 auto __zv = ranges::views::zip(__containers_.keys, __containers_.values);
858 ranges::sort(__zv, __compare_, [](const auto& __p) -> decltype(auto) { return std::get<0>(__p); });
859 auto __dup_start = ranges::unique(__zv, __key_equiv(__compare_)).begin();
860 auto __dist = ranges::distance(__zv.begin(), __dup_start);
861 __containers_.keys.erase(__containers_.keys.begin() + __dist, __containers_.keys.end());
862 __containers_.values.erase(__containers_.values.begin() + __dist, __containers_.values.end());
863 }
864
865 template <bool _WasSorted, class _InputIterator, class _Sentinel>
866 _LIBCPP_HIDE_FROM_ABI void __append_sort_merge_unique(_InputIterator __first, _Sentinel __last) {
867 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
868 size_t __num_of_appended = __flat_map_utils::__append(*this, std::move(__first), std::move(__last));
869 if (__num_of_appended != 0) {
870 auto __zv = ranges::views::zip(__containers_.keys, __containers_.values);
871 auto __append_start_offset = __containers_.keys.size() - __num_of_appended;
872 auto __end = __zv.end();
873 auto __compare_key = [this](const auto& __p1, const auto& __p2) {
874 return __compare_(std::get<0>(__p1), std::get<0>(__p2));
875 };
876 if constexpr (!_WasSorted) {
877 ranges::sort(__zv.begin() + __append_start_offset, __end, __compare_key);
878 } else {
879 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
880 __is_sorted_and_unique(__containers_.keys | ranges::views::drop(__append_start_offset)),
881 "Either the key container is not sorted or it contains duplicates");
882 }
883 ranges::inplace_merge(__zv.begin(), __zv.begin() + __append_start_offset, __end, __compare_key);
884
885 auto __dup_start = ranges::unique(__zv, __key_equiv(__compare_)).begin();
886 auto __dist = ranges::distance(__zv.begin(), __dup_start);
887 __containers_.keys.erase(__containers_.keys.begin() + __dist, __containers_.keys.end());
888 __containers_.values.erase(__containers_.values.begin() + __dist, __containers_.values.end());
889 }
890 __on_failure.__complete();
891 }
892
893 template <class _Self, class _Kp>
894 _LIBCPP_HIDE_FROM_ABI static auto __find_impl(_Self&& __self, const _Kp& __key) {
895 auto __it = __self.lower_bound(__key);
896 auto __last = __self.end();
897 if (__it == __last || __self.__compare_(__key, __it->first)) {
898 return __last;
899 }
900 return __it;
901 }
902
903 template <class _Self, class _Kp>
904 _LIBCPP_HIDE_FROM_ABI static auto __key_equal_range(_Self&& __self, const _Kp& __key) {
905 auto __it = ranges::lower_bound(__self.__containers_.keys, __key, __self.__compare_);
906 auto __last = __self.__containers_.keys.end();
907 if (__it == __last || __self.__compare_(__key, *__it)) {
908 return std::make_pair(__it, __it);
909 }
910 return std::make_pair(__it, std::next(__it));
911 }
912
913 template <class _Self, class _Kp>
914 _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) {
915 auto [__key_first, __key_last] = __key_equal_range(__self, __key);
916
917 const auto __make_mapped_iter = [&](const auto& __key_iter) {
918 return __self.__containers_.values.begin() +
919 static_cast<ranges::range_difference_t<mapped_container_type>>(
920 ranges::distance(__self.__containers_.keys.begin(), __key_iter));
921 };
922
923 using __iterator_type = ranges::iterator_t<decltype(__self)>;
924 return std::make_pair(__iterator_type(__key_first, __make_mapped_iter(__key_first)),
925 __iterator_type(__key_last, __make_mapped_iter(__key_last)));
926 }
927
928 template <class _Res, class _Self, class _Kp>
929 _LIBCPP_HIDE_FROM_ABI static _Res __lower_bound(_Self&& __self, _Kp& __x) {
930 return __binary_search<_Res>(__self, ranges::lower_bound, __x);
931 }
932
933 template <class _Res, class _Self, class _Kp>
934 _LIBCPP_HIDE_FROM_ABI static _Res __upper_bound(_Self&& __self, _Kp& __x) {
935 return __binary_search<_Res>(__self, ranges::upper_bound, __x);
936 }
937
938 template <class _Res, class _Self, class _Fn, class _Kp>
939 _LIBCPP_HIDE_FROM_ABI static _Res __binary_search(_Self&& __self, _Fn __search_fn, _Kp& __x) {
940 auto __key_iter = __search_fn(__self.__containers_.keys, __x, __self.__compare_);
941 auto __mapped_iter =
942 __self.__containers_.values.begin() +
943 static_cast<ranges::range_difference_t<mapped_container_type>>(
944 ranges::distance(__self.__containers_.keys.begin(), __key_iter));
945
946 return _Res(std::move(__key_iter), std::move(__mapped_iter));
947 }
948
949 template <class _KeyArg, class... _MArgs>
950 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __try_emplace(_KeyArg&& __key, _MArgs&&... __mapped_args) {
951 auto __key_it = ranges::lower_bound(__containers_.keys, __key, __compare_);
952 auto __mapped_it = __containers_.values.begin() + ranges::distance(__containers_.keys.begin(), __key_it);
953
954 if (__key_it == __containers_.keys.end() || __compare_(__key, *__key_it)) {
955 return pair<iterator, bool>(
956 __flat_map_utils::__emplace_exact_pos(
957 *this,
958 std::move(__key_it),
959 std::move(__mapped_it),
960 std::forward<_KeyArg>(__key),
961 std::forward<_MArgs>(__mapped_args)...),
962 true);
963 } else {
964 return pair<iterator, bool>(iterator(std::move(__key_it), std::move(__mapped_it)), false);
965 }
966 }
967
968 template <class _Kp>
969 _LIBCPP_HIDE_FROM_ABI bool __is_hint_correct(const_iterator __hint, _Kp&& __key) {
970 if (__hint != cbegin() && !__compare_((__hint - 1)->first, __key)) {
971 return false;
972 }
973 if (__hint != cend() && __compare_(__hint->first, __key)) {
974 return false;
975 }
976 return true;
977 }
978
979 template <class _Kp, class... _Args>
980 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __try_emplace_hint(const_iterator __hint, _Kp&& __key, _Args&&... __args) {
981 if (__is_hint_correct(__hint, __key)) {
982 if (__hint == cend() || __compare_(__key, __hint->first)) {
983 return {__flat_map_utils::__emplace_exact_pos(
984 *this,
985 __hint.__key_iter_,
986 __hint.__mapped_iter_,
987 std::forward<_Kp>(__key),
988 std::forward<_Args>(__args)...),
989 true};
990 } else {
991 // key equals
992 auto __dist = __hint - cbegin();
993 return {iterator(__containers_.keys.begin() + __dist, __containers_.values.begin() + __dist), false};
994 }
995 } else {
996 return __try_emplace(std::forward<_Kp>(__key), std::forward<_Args>(__args)...);
997 }
998 }
999
1000 template <class _Kp, class _Mapped>
1001 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_or_assign(_Kp&& __key, _Mapped&& __mapped) {
1002 auto __r = try_emplace(std::forward<_Kp>(__key), std::forward<_Mapped>(__mapped));
1003 if (!__r.second) {
1004 __r.first->second = std::forward<_Mapped>(__mapped);
1005 }
1006 return __r;
1007 }
1008
1009 template <class _Kp, class _Mapped>
1010 _LIBCPP_HIDE_FROM_ABI iterator __insert_or_assign(const_iterator __hint, _Kp&& __key, _Mapped&& __mapped) {
1011 auto __r = __try_emplace_hint(__hint, std::forward<_Kp>(__key), std::forward<_Mapped>(__mapped));
1012 if (!__r.second) {
1013 __r.first->second = std::forward<_Mapped>(__mapped);
1014 }
1015 return __r.first;
1016 }
1017
1018 _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) {
1019 if constexpr (requires { __containers_.keys.reserve(__size); }) {
1020 __containers_.keys.reserve(__size);
1021 }
1022
1023 if constexpr (requires { __containers_.values.reserve(__size); }) {
1024 __containers_.values.reserve(__size);
1025 }
1026 }
1027
1028 template <class _KIter, class _MIter>
1029 _LIBCPP_HIDE_FROM_ABI iterator __erase(_KIter __key_iter_to_remove, _MIter __mapped_iter_to_remove) {
1030 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
1031 auto __key_iter = __containers_.keys.erase(__key_iter_to_remove);
1032 auto __mapped_iter = __containers_.values.erase(__mapped_iter_to_remove);
1033 __on_failure.__complete();
1034 return iterator(std::move(__key_iter), std::move(__mapped_iter));
1035 }
1036
1037 template <class _Key2, class _Tp2, class _Compare2, class _KeyContainer2, class _MappedContainer2, class _Predicate>
1038 friend typename flat_map<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>::size_type
1039 erase_if(flat_map<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>&, _Predicate);
1040
1041 friend __flat_map_utils;
1042
1043 containers __containers_;
1044 _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_;
1045
1046 struct __key_equiv {
1047 _LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {}
1048 _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const {
1049 return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x));
1050 }
1051 key_compare __comp_;
1052 };
1053};
1054
1055template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>>
1056 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
1057 !__is_allocator<_MappedContainer>::value &&
1058 is_invocable_v<const _Compare&,
1059 const typename _KeyContainer::value_type&,
1060 const typename _KeyContainer::value_type&>)
1061flat_map(_KeyContainer, _MappedContainer, _Compare = _Compare())
1062 -> flat_map<typename _KeyContainer::value_type,
1063 typename _MappedContainer::value_type,
1064 _Compare,
1065 _KeyContainer,
1066 _MappedContainer>;
1067
1068template <class _KeyContainer, class _MappedContainer, class _Allocator>
1069 requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
1070 !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value)
1071flat_map(_KeyContainer, _MappedContainer, _Allocator)
1072 -> flat_map<typename _KeyContainer::value_type,
1073 typename _MappedContainer::value_type,
1074 less<typename _KeyContainer::value_type>,
1075 _KeyContainer,
1076 _MappedContainer>;
1077
1078template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator>
1079 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
1080 !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> &&
1081 uses_allocator_v<_MappedContainer, _Allocator> &&
1082 is_invocable_v<const _Compare&,
1083 const typename _KeyContainer::value_type&,
1084 const typename _KeyContainer::value_type&>)
1085flat_map(_KeyContainer, _MappedContainer, _Compare, _Allocator)
1086 -> flat_map<typename _KeyContainer::value_type,
1087 typename _MappedContainer::value_type,
1088 _Compare,
1089 _KeyContainer,
1090 _MappedContainer>;
1091
1092template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>>
1093 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
1094 !__is_allocator<_MappedContainer>::value &&
1095 is_invocable_v<const _Compare&,
1096 const typename _KeyContainer::value_type&,
1097 const typename _KeyContainer::value_type&>)
1098flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Compare = _Compare())
1099 -> flat_map<typename _KeyContainer::value_type,
1100 typename _MappedContainer::value_type,
1101 _Compare,
1102 _KeyContainer,
1103 _MappedContainer>;
1104
1105template <class _KeyContainer, class _MappedContainer, class _Allocator>
1106 requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
1107 !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value)
1108flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Allocator)
1109 -> flat_map<typename _KeyContainer::value_type,
1110 typename _MappedContainer::value_type,
1111 less<typename _KeyContainer::value_type>,
1112 _KeyContainer,
1113 _MappedContainer>;
1114
1115template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator>
1116 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
1117 !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> &&
1118 uses_allocator_v<_MappedContainer, _Allocator> &&
1119 is_invocable_v<const _Compare&,
1120 const typename _KeyContainer::value_type&,
1121 const typename _KeyContainer::value_type&>)
1122flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Compare, _Allocator)
1123 -> flat_map<typename _KeyContainer::value_type,
1124 typename _MappedContainer::value_type,
1125 _Compare,
1126 _KeyContainer,
1127 _MappedContainer>;
1128
1129template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>>
1130 requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
1131flat_map(_InputIterator, _InputIterator, _Compare = _Compare())
1132 -> flat_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>;
1133
1134template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>>
1135 requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
1136flat_map(sorted_unique_t, _InputIterator, _InputIterator, _Compare = _Compare())
1137 -> flat_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>;
1138
1139template <ranges::input_range _Range,
1140 class _Compare = less<__range_key_type<_Range>>,
1141 class _Allocator = allocator<byte>,
1142 class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>>
1143flat_map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_map<
1144 __range_key_type<_Range>,
1145 __range_mapped_type<_Range>,
1146 _Compare,
1147 vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>,
1148 vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>;
1149
1150template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>>
1151flat_map(from_range_t, _Range&&, _Allocator) -> flat_map<
1152 __range_key_type<_Range>,
1153 __range_mapped_type<_Range>,
1154 less<__range_key_type<_Range>>,
1155 vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>,
1156 vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>;
1157
1158template <class _Key, class _Tp, class _Compare = less<_Key>>
1159 requires(!__is_allocator<_Compare>::value)
1160flat_map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_map<_Key, _Tp, _Compare>;
1161
1162template <class _Key, class _Tp, class _Compare = less<_Key>>
1163 requires(!__is_allocator<_Compare>::value)
1164flat_map(sorted_unique_t, initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_map<_Key, _Tp, _Compare>;
1165
1166template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Allocator>
1167struct uses_allocator<flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>, _Allocator>
1168 : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator>> {};
1169
1170template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Predicate>
1171_LIBCPP_HIDE_FROM_ABI typename flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::size_type
1172erase_if(flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>& __flat_map, _Predicate __pred) {
1173 auto __zv = ranges::views::zip(__flat_map.__containers_.keys, __flat_map.__containers_.values);
1174 auto __first = __zv.begin();
1175 auto __last = __zv.end();
1176 auto __guard = std::__make_exception_guard([&] { __flat_map.clear(); });
1177 auto __it = std::remove_if(__first, __last, [&](auto&& __zipped) -> bool {
1178 using _Ref = typename flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::const_reference;
1179 return __pred(_Ref(std::get<0>(__zipped), std::get<1>(__zipped)));
1180 });
1181 auto __res = __last - __it;
1182 auto __offset = __it - __first;
1183
1184 const auto __erase_container = [&](auto& __cont) { __cont.erase(__cont.begin() + __offset, __cont.end()); };
1185
1186 __erase_container(__flat_map.__containers_.keys);
1187 __erase_container(__flat_map.__containers_.values);
1188
1189 __guard.__complete();
1190 return __res;
1191}
1192
1193_LIBCPP_END_NAMESPACE_STD
1194
1195#endif // _LIBCPP_STD_VER >= 23
1196
1197_LIBCPP_POP_MACROS
1198
1199#endif // _LIBCPP___FLAT_MAP_FLAT_MAP_H
lib/libcxx/include/__flat_map/flat_multimap.h created+1010
...@@ -0,0 +1,1010 @@
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___FLAT_MAP_FLAT_MULTIMAP_H
11#define _LIBCPP___FLAT_MAP_FLAT_MULTIMAP_H
12
13#include <__algorithm/lexicographical_compare_three_way.h>
14#include <__algorithm/min.h>
15#include <__algorithm/ranges_equal.h>
16#include <__algorithm/ranges_equal_range.h>
17#include <__algorithm/ranges_inplace_merge.h>
18#include <__algorithm/ranges_is_sorted.h>
19#include <__algorithm/ranges_lower_bound.h>
20#include <__algorithm/ranges_partition_point.h>
21#include <__algorithm/ranges_sort.h>
22#include <__algorithm/ranges_unique.h>
23#include <__algorithm/ranges_upper_bound.h>
24#include <__algorithm/remove_if.h>
25#include <__assert>
26#include <__compare/synth_three_way.h>
27#include <__concepts/convertible_to.h>
28#include <__concepts/swappable.h>
29#include <__config>
30#include <__cstddef/byte.h>
31#include <__cstddef/ptrdiff_t.h>
32#include <__flat_map/key_value_iterator.h>
33#include <__flat_map/sorted_equivalent.h>
34#include <__flat_map/utils.h>
35#include <__functional/invoke.h>
36#include <__functional/is_transparent.h>
37#include <__functional/operations.h>
38#include <__fwd/vector.h>
39#include <__iterator/concepts.h>
40#include <__iterator/distance.h>
41#include <__iterator/iterator_traits.h>
42#include <__iterator/ranges_iterator_traits.h>
43#include <__iterator/reverse_iterator.h>
44#include <__memory/allocator_traits.h>
45#include <__memory/uses_allocator.h>
46#include <__memory/uses_allocator_construction.h>
47#include <__ranges/access.h>
48#include <__ranges/concepts.h>
49#include <__ranges/container_compatible_range.h>
50#include <__ranges/drop_view.h>
51#include <__ranges/from_range.h>
52#include <__ranges/ref_view.h>
53#include <__ranges/size.h>
54#include <__ranges/subrange.h>
55#include <__ranges/zip_view.h>
56#include <__type_traits/conjunction.h>
57#include <__type_traits/container_traits.h>
58#include <__type_traits/invoke.h>
59#include <__type_traits/is_allocator.h>
60#include <__type_traits/is_nothrow_constructible.h>
61#include <__type_traits/is_same.h>
62#include <__type_traits/maybe_const.h>
63#include <__utility/exception_guard.h>
64#include <__utility/move.h>
65#include <__utility/pair.h>
66#include <__utility/scope_guard.h>
67#include <__vector/vector.h>
68#include <initializer_list>
69#include <stdexcept>
70
71#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
72# pragma GCC system_header
73#endif
74
75_LIBCPP_PUSH_MACROS
76#include <__undef_macros>
77
78#if _LIBCPP_STD_VER >= 23
79
80_LIBCPP_BEGIN_NAMESPACE_STD
81
82template <class _Key,
83 class _Tp,
84 class _Compare = less<_Key>,
85 class _KeyContainer = vector<_Key>,
86 class _MappedContainer = vector<_Tp>>
87class flat_multimap {
88 template <class, class, class, class, class>
89 friend class flat_multimap;
90
91 static_assert(is_same_v<_Key, typename _KeyContainer::value_type>);
92 static_assert(is_same_v<_Tp, typename _MappedContainer::value_type>);
93 static_assert(!is_same_v<_KeyContainer, std::vector<bool>>, "vector<bool> is not a sequence container");
94 static_assert(!is_same_v<_MappedContainer, std::vector<bool>>, "vector<bool> is not a sequence container");
95
96 template <bool _Const>
97 using __iterator _LIBCPP_NODEBUG = __key_value_iterator<flat_multimap, _KeyContainer, _MappedContainer, _Const>;
98
99public:
100 // types
101 using key_type = _Key;
102 using mapped_type = _Tp;
103 using value_type = pair<key_type, mapped_type>;
104 using key_compare = __type_identity_t<_Compare>;
105 using reference = pair<const key_type&, mapped_type&>;
106 using const_reference = pair<const key_type&, const mapped_type&>;
107 using size_type = size_t;
108 using difference_type = ptrdiff_t;
109 using iterator = __iterator<false>; // see [container.requirements]
110 using const_iterator = __iterator<true>; // see [container.requirements]
111 using reverse_iterator = std::reverse_iterator<iterator>;
112 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
113 using key_container_type = _KeyContainer;
114 using mapped_container_type = _MappedContainer;
115
116 class value_compare {
117 private:
118 key_compare __comp_;
119 _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {}
120 friend flat_multimap;
121
122 public:
123 _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const {
124 return __comp_(__x.first, __y.first);
125 }
126 };
127
128 struct containers {
129 key_container_type keys;
130 mapped_container_type values;
131 };
132
133private:
134 template <class _Allocator>
135 _LIBCPP_HIDE_FROM_ABI static constexpr bool __allocator_ctor_constraint =
136 _And<uses_allocator<key_container_type, _Allocator>, uses_allocator<mapped_container_type, _Allocator>>::value;
137
138 _LIBCPP_HIDE_FROM_ABI static constexpr bool __is_compare_transparent = __is_transparent_v<_Compare>;
139
140public:
141 // [flat.map.cons], construct/copy/destroy
142 _LIBCPP_HIDE_FROM_ABI flat_multimap() noexcept(
143 is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_MappedContainer> &&
144 is_nothrow_default_constructible_v<_Compare>)
145 : __containers_(), __compare_() {}
146
147 _LIBCPP_HIDE_FROM_ABI flat_multimap(const flat_multimap&) = default;
148
149 // The copy/move constructors are not specified in the spec, which means they should be defaulted.
150 // However, the move constructor can potentially leave a moved-from object in an inconsistent
151 // state if an exception is thrown.
152 _LIBCPP_HIDE_FROM_ABI flat_multimap(flat_multimap&& __other) noexcept(
153 is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_MappedContainer> &&
154 is_nothrow_move_constructible_v<_Compare>)
155# if _LIBCPP_HAS_EXCEPTIONS
156 try
157# endif // _LIBCPP_HAS_EXCEPTIONS
158 : __containers_(std::move(__other.__containers_)), __compare_(std::move(__other.__compare_)) {
159 __other.clear();
160# if _LIBCPP_HAS_EXCEPTIONS
161 } catch (...) {
162 __other.clear();
163 // gcc does not like the `throw` keyword in a conditionally noexcept function
164 if constexpr (!(is_nothrow_move_constructible_v<_KeyContainer> &&
165 is_nothrow_move_constructible_v<_MappedContainer> && is_nothrow_move_constructible_v<_Compare>)) {
166 throw;
167 }
168# endif // _LIBCPP_HAS_EXCEPTIONS
169 }
170
171 template <class _Allocator>
172 requires __allocator_ctor_constraint<_Allocator>
173 _LIBCPP_HIDE_FROM_ABI flat_multimap(const flat_multimap& __other, const _Allocator& __alloc)
174 : flat_multimap(__ctor_uses_allocator_tag{},
175 __alloc,
176 __other.__containers_.keys,
177 __other.__containers_.values,
178 __other.__compare_) {}
179
180 template <class _Allocator>
181 requires __allocator_ctor_constraint<_Allocator>
182 _LIBCPP_HIDE_FROM_ABI flat_multimap(flat_multimap&& __other, const _Allocator& __alloc)
183# if _LIBCPP_HAS_EXCEPTIONS
184 try
185# endif // _LIBCPP_HAS_EXCEPTIONS
186 : flat_multimap(__ctor_uses_allocator_tag{},
187 __alloc,
188 std::move(__other.__containers_.keys),
189 std::move(__other.__containers_.values),
190 std::move(__other.__compare_)) {
191 __other.clear();
192# if _LIBCPP_HAS_EXCEPTIONS
193 } catch (...) {
194 __other.clear();
195 throw;
196# endif // _LIBCPP_HAS_EXCEPTIONS
197 }
198
199 _LIBCPP_HIDE_FROM_ABI flat_multimap(
200 key_container_type __key_cont, mapped_container_type __mapped_cont, const key_compare& __comp = key_compare())
201 : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) {
202 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
203 "flat_multimap keys and mapped containers have different size");
204 __sort();
205 }
206
207 template <class _Allocator>
208 requires __allocator_ctor_constraint<_Allocator>
209 _LIBCPP_HIDE_FROM_ABI flat_multimap(
210 const key_container_type& __key_cont, const mapped_container_type& __mapped_cont, const _Allocator& __alloc)
211 : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) {
212 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
213 "flat_multimap keys and mapped containers have different size");
214 __sort();
215 }
216
217 template <class _Allocator>
218 requires __allocator_ctor_constraint<_Allocator>
219 _LIBCPP_HIDE_FROM_ABI
220 flat_multimap(const key_container_type& __key_cont,
221 const mapped_container_type& __mapped_cont,
222 const key_compare& __comp,
223 const _Allocator& __alloc)
224 : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) {
225 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
226 "flat_multimap keys and mapped containers have different size");
227 __sort();
228 }
229
230 _LIBCPP_HIDE_FROM_ABI
231 flat_multimap(sorted_equivalent_t,
232 key_container_type __key_cont,
233 mapped_container_type __mapped_cont,
234 const key_compare& __comp = key_compare())
235 : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) {
236 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
237 "flat_multimap keys and mapped containers have different size");
238 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__is_sorted(__containers_.keys), "Key container is not sorted");
239 }
240
241 template <class _Allocator>
242 requires __allocator_ctor_constraint<_Allocator>
243 _LIBCPP_HIDE_FROM_ABI
244 flat_multimap(sorted_equivalent_t,
245 const key_container_type& __key_cont,
246 const mapped_container_type& __mapped_cont,
247 const _Allocator& __alloc)
248 : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) {
249 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
250 "flat_multimap keys and mapped containers have different size");
251 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__is_sorted(__containers_.keys), "Key container is not sorted");
252 }
253
254 template <class _Allocator>
255 requires __allocator_ctor_constraint<_Allocator>
256 _LIBCPP_HIDE_FROM_ABI
257 flat_multimap(sorted_equivalent_t,
258 const key_container_type& __key_cont,
259 const mapped_container_type& __mapped_cont,
260 const key_compare& __comp,
261 const _Allocator& __alloc)
262 : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) {
263 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
264 "flat_multimap keys and mapped containers have different size");
265 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__is_sorted(__containers_.keys), "Key container is not sorted");
266 }
267
268 _LIBCPP_HIDE_FROM_ABI explicit flat_multimap(const key_compare& __comp) : __containers_(), __compare_(__comp) {}
269
270 template <class _Allocator>
271 requires __allocator_ctor_constraint<_Allocator>
272 _LIBCPP_HIDE_FROM_ABI flat_multimap(const key_compare& __comp, const _Allocator& __alloc)
273 : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {}
274
275 template <class _Allocator>
276 requires __allocator_ctor_constraint<_Allocator>
277 _LIBCPP_HIDE_FROM_ABI explicit flat_multimap(const _Allocator& __alloc)
278 : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) {}
279
280 template <class _InputIterator>
281 requires __has_input_iterator_category<_InputIterator>::value
282 _LIBCPP_HIDE_FROM_ABI
283 flat_multimap(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
284 : __containers_(), __compare_(__comp) {
285 insert(__first, __last);
286 }
287
288 template <class _InputIterator, class _Allocator>
289 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)
290 _LIBCPP_HIDE_FROM_ABI
291 flat_multimap(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc)
292 : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {
293 insert(__first, __last);
294 }
295
296 template <class _InputIterator, class _Allocator>
297 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)
298 _LIBCPP_HIDE_FROM_ABI flat_multimap(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
299 : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) {
300 insert(__first, __last);
301 }
302
303 template <_ContainerCompatibleRange<value_type> _Range>
304 _LIBCPP_HIDE_FROM_ABI flat_multimap(from_range_t __fr, _Range&& __rg)
305 : flat_multimap(__fr, std::forward<_Range>(__rg), key_compare()) {}
306
307 template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
308 requires __allocator_ctor_constraint<_Allocator>
309 _LIBCPP_HIDE_FROM_ABI flat_multimap(from_range_t, _Range&& __rg, const _Allocator& __alloc)
310 : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) {
311 insert_range(std::forward<_Range>(__rg));
312 }
313
314 template <_ContainerCompatibleRange<value_type> _Range>
315 _LIBCPP_HIDE_FROM_ABI flat_multimap(from_range_t, _Range&& __rg, const key_compare& __comp) : flat_multimap(__comp) {
316 insert_range(std::forward<_Range>(__rg));
317 }
318
319 template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
320 requires __allocator_ctor_constraint<_Allocator>
321 _LIBCPP_HIDE_FROM_ABI flat_multimap(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc)
322 : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {
323 insert_range(std::forward<_Range>(__rg));
324 }
325
326 template <class _InputIterator>
327 requires __has_input_iterator_category<_InputIterator>::value
328 _LIBCPP_HIDE_FROM_ABI flat_multimap(
329 sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
330 : __containers_(), __compare_(__comp) {
331 insert(sorted_equivalent, __first, __last);
332 }
333 template <class _InputIterator, class _Allocator>
334 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)
335 _LIBCPP_HIDE_FROM_ABI
336 flat_multimap(sorted_equivalent_t,
337 _InputIterator __first,
338 _InputIterator __last,
339 const key_compare& __comp,
340 const _Allocator& __alloc)
341 : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {
342 insert(sorted_equivalent, __first, __last);
343 }
344
345 template <class _InputIterator, class _Allocator>
346 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)
347 _LIBCPP_HIDE_FROM_ABI
348 flat_multimap(sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
349 : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) {
350 insert(sorted_equivalent, __first, __last);
351 }
352
353 _LIBCPP_HIDE_FROM_ABI flat_multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
354 : flat_multimap(__il.begin(), __il.end(), __comp) {}
355
356 template <class _Allocator>
357 requires __allocator_ctor_constraint<_Allocator>
358 _LIBCPP_HIDE_FROM_ABI
359 flat_multimap(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
360 : flat_multimap(__il.begin(), __il.end(), __comp, __alloc) {}
361
362 template <class _Allocator>
363 requires __allocator_ctor_constraint<_Allocator>
364 _LIBCPP_HIDE_FROM_ABI flat_multimap(initializer_list<value_type> __il, const _Allocator& __alloc)
365 : flat_multimap(__il.begin(), __il.end(), __alloc) {}
366
367 _LIBCPP_HIDE_FROM_ABI
368 flat_multimap(sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare())
369 : flat_multimap(sorted_equivalent, __il.begin(), __il.end(), __comp) {}
370
371 template <class _Allocator>
372 requires __allocator_ctor_constraint<_Allocator>
373 _LIBCPP_HIDE_FROM_ABI flat_multimap(
374 sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
375 : flat_multimap(sorted_equivalent, __il.begin(), __il.end(), __comp, __alloc) {}
376
377 template <class _Allocator>
378 requires __allocator_ctor_constraint<_Allocator>
379 _LIBCPP_HIDE_FROM_ABI flat_multimap(sorted_equivalent_t, initializer_list<value_type> __il, const _Allocator& __alloc)
380 : flat_multimap(sorted_equivalent, __il.begin(), __il.end(), __alloc) {}
381
382 _LIBCPP_HIDE_FROM_ABI flat_multimap& operator=(initializer_list<value_type> __il) {
383 clear();
384 insert(__il);
385 return *this;
386 }
387
388 // copy/move assignment are not specified in the spec (defaulted)
389 // but move assignment can potentially leave moved from object in an inconsistent
390 // state if an exception is thrown
391 _LIBCPP_HIDE_FROM_ABI flat_multimap& operator=(const flat_multimap&) = default;
392
393 _LIBCPP_HIDE_FROM_ABI flat_multimap& operator=(flat_multimap&& __other) noexcept(
394 is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_MappedContainer> &&
395 is_nothrow_move_assignable_v<_Compare>) {
396 auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; });
397 auto __clear_self_guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
398 __containers_ = std::move(__other.__containers_);
399 __compare_ = std::move(__other.__compare_);
400 __clear_self_guard.__complete();
401 return *this;
402 }
403
404 // iterators
405 _LIBCPP_HIDE_FROM_ABI iterator begin() noexcept {
406 return iterator(__containers_.keys.begin(), __containers_.values.begin());
407 }
408
409 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept {
410 return const_iterator(__containers_.keys.begin(), __containers_.values.begin());
411 }
412
413 _LIBCPP_HIDE_FROM_ABI iterator end() noexcept {
414 return iterator(__containers_.keys.end(), __containers_.values.end());
415 }
416
417 _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept {
418 return const_iterator(__containers_.keys.end(), __containers_.values.end());
419 }
420
421 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() noexcept { return reverse_iterator(end()); }
422 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
423 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() noexcept { return reverse_iterator(begin()); }
424 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
425
426 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return begin(); }
427 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return end(); }
428 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); }
429 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); }
430
431 // [flat.map.capacity], capacity
432 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __containers_.keys.empty(); }
433
434 _LIBCPP_HIDE_FROM_ABI size_type size() const noexcept { return __containers_.keys.size(); }
435
436 _LIBCPP_HIDE_FROM_ABI size_type max_size() const noexcept {
437 return std::min<size_type>(__containers_.keys.max_size(), __containers_.values.max_size());
438 }
439
440 // [flat.map.modifiers], modifiers
441 template <class... _Args>
442 requires is_constructible_v<pair<key_type, mapped_type>, _Args...> && is_move_constructible_v<key_type> &&
443 is_move_constructible_v<mapped_type>
444 _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {
445 std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...);
446 auto __key_it = ranges::upper_bound(__containers_.keys, __pair.first, __compare_);
447 auto __mapped_it = __corresponding_mapped_it(*this, __key_it);
448
449 return __flat_map_utils::__emplace_exact_pos(
450 *this, std::move(__key_it), std::move(__mapped_it), std::move(__pair.first), std::move(__pair.second));
451 }
452
453 template <class... _Args>
454 requires is_constructible_v<pair<key_type, mapped_type>, _Args...>
455 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __hint, _Args&&... __args) {
456 std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...);
457
458 auto __prev_larger = __hint != cbegin() && __compare_(__pair.first, (__hint - 1)->first);
459 auto __next_smaller = __hint != cend() && __compare_(__hint->first, __pair.first);
460
461 auto __hint_distance = __hint.__key_iter_ - __containers_.keys.cbegin();
462 auto __key_iter = __containers_.keys.begin() + __hint_distance;
463 auto __mapped_iter = __containers_.values.begin() + __hint_distance;
464
465 if (!__prev_larger && !__next_smaller) [[likely]] {
466 // hint correct, just use exact hint iterators
467 } else if (__prev_larger && !__next_smaller) {
468 // the hint position is more to the right than the key should have been.
469 // we want to emplace the element to a position as right as possible
470 // e.g. Insert new element "2" in the following range
471 // 1, 1, 2, 2, 2, 3, 4, 6
472 // ^
473 // |
474 // hint
475 // We want to insert "2" after the last existing "2"
476 __key_iter = ranges::upper_bound(__containers_.keys.begin(), __key_iter, __pair.first, __compare_);
477 __mapped_iter = __corresponding_mapped_it(*this, __key_iter);
478 } else {
479 _LIBCPP_ASSERT_INTERNAL(!__prev_larger && __next_smaller, "this means that the multimap is not sorted");
480
481 // the hint position is more to the left than the key should have been.
482 // we want to emplace the element to a position as left as possible
483 // 1, 1, 2, 2, 2, 3, 4, 6
484 // ^
485 // |
486 // hint
487 // We want to insert "2" before the first existing "2"
488 __key_iter = ranges::lower_bound(__key_iter, __containers_.keys.end(), __pair.first, __compare_);
489 __mapped_iter = __corresponding_mapped_it(*this, __key_iter);
490 }
491 return __flat_map_utils::__emplace_exact_pos(
492 *this, __key_iter, __mapped_iter, std::move(__pair.first), std::move(__pair.second));
493 }
494
495 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return emplace(__x); }
496
497 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return emplace(std::move(__x)); }
498
499 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, const value_type& __x) {
500 return emplace_hint(__hint, __x);
501 }
502
503 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, value_type&& __x) {
504 return emplace_hint(__hint, std::move(__x));
505 }
506
507 template <class _PairLike>
508 requires is_constructible_v<pair<key_type, mapped_type>, _PairLike>
509 _LIBCPP_HIDE_FROM_ABI iterator insert(_PairLike&& __x) {
510 return emplace(std::forward<_PairLike>(__x));
511 }
512
513 template <class _PairLike>
514 requires is_constructible_v<pair<key_type, mapped_type>, _PairLike>
515 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, _PairLike&& __x) {
516 return emplace_hint(__hint, std::forward<_PairLike>(__x));
517 }
518
519 template <class _InputIterator>
520 requires __has_input_iterator_category<_InputIterator>::value
521 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) {
522 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
523 __reserve(__last - __first);
524 }
525 __append_sort_merge</*WasSorted = */ false>(std::move(__first), std::move(__last));
526 }
527
528 template <class _InputIterator>
529 requires __has_input_iterator_category<_InputIterator>::value
530 _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, _InputIterator __first, _InputIterator __last) {
531 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
532 __reserve(__last - __first);
533 }
534
535 __append_sort_merge</*WasSorted = */ true>(std::move(__first), std::move(__last));
536 }
537
538 template <_ContainerCompatibleRange<value_type> _Range>
539 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
540 if constexpr (ranges::sized_range<_Range>) {
541 __reserve(ranges::size(__range));
542 }
543
544 __append_sort_merge</*WasSorted = */ false>(ranges::begin(__range), ranges::end(__range));
545 }
546
547 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
548
549 _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, initializer_list<value_type> __il) {
550 insert(sorted_equivalent, __il.begin(), __il.end());
551 }
552
553 _LIBCPP_HIDE_FROM_ABI containers extract() && {
554 auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; });
555 auto __ret = std::move(__containers_);
556 return __ret;
557 }
558
559 _LIBCPP_HIDE_FROM_ABI void replace(key_container_type&& __key_cont, mapped_container_type&& __mapped_cont) {
560 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
561 __key_cont.size() == __mapped_cont.size(), "flat_multimap keys and mapped containers have different size");
562
563 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__is_sorted(__key_cont), "Key container is not sorted");
564 auto __guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
565 __containers_.keys = std::move(__key_cont);
566 __containers_.values = std::move(__mapped_cont);
567 __guard.__complete();
568 }
569
570 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __position) {
571 return __erase(__position.__key_iter_, __position.__mapped_iter_);
572 }
573
574 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position) {
575 return __erase(__position.__key_iter_, __position.__mapped_iter_);
576 }
577
578 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __x) {
579 auto [__first, __last] = equal_range(__x);
580 auto __res = __last - __first;
581 erase(__first, __last);
582 return __res;
583 }
584
585 template <class _Kp>
586 requires(__is_compare_transparent && !is_convertible_v<_Kp &&, iterator> &&
587 !is_convertible_v<_Kp &&, const_iterator>)
588 _LIBCPP_HIDE_FROM_ABI size_type erase(_Kp&& __x) {
589 auto [__first, __last] = equal_range(__x);
590 auto __res = __last - __first;
591 erase(__first, __last);
592 return __res;
593 }
594
595 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) {
596 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
597 auto __key_it = __containers_.keys.erase(__first.__key_iter_, __last.__key_iter_);
598 auto __mapped_it = __containers_.values.erase(__first.__mapped_iter_, __last.__mapped_iter_);
599 __on_failure.__complete();
600 return iterator(std::move(__key_it), std::move(__mapped_it));
601 }
602
603 _LIBCPP_HIDE_FROM_ABI void swap(flat_multimap& __y) noexcept {
604 // warning: The spec has unconditional noexcept, which means that
605 // if any of the following functions throw an exception,
606 // std::terminate will be called
607 ranges::swap(__compare_, __y.__compare_);
608 ranges::swap(__containers_.keys, __y.__containers_.keys);
609 ranges::swap(__containers_.values, __y.__containers_.values);
610 }
611
612 _LIBCPP_HIDE_FROM_ABI void clear() noexcept {
613 __containers_.keys.clear();
614 __containers_.values.clear();
615 }
616
617 // observers
618 _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __compare_; }
619 _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__compare_); }
620
621 _LIBCPP_HIDE_FROM_ABI const key_container_type& keys() const noexcept { return __containers_.keys; }
622 _LIBCPP_HIDE_FROM_ABI const mapped_container_type& values() const noexcept { return __containers_.values; }
623
624 // map operations
625 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __x) { return __find_impl(*this, __x); }
626
627 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __x) const { return __find_impl(*this, __x); }
628
629 template <class _Kp>
630 requires __is_compare_transparent
631 _LIBCPP_HIDE_FROM_ABI iterator find(const _Kp& __x) {
632 return __find_impl(*this, __x);
633 }
634
635 template <class _Kp>
636 requires __is_compare_transparent
637 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Kp& __x) const {
638 return __find_impl(*this, __x);
639 }
640
641 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __x) const {
642 auto [__first, __last] = equal_range(__x);
643 return __last - __first;
644 }
645
646 template <class _Kp>
647 requires __is_compare_transparent
648 _LIBCPP_HIDE_FROM_ABI size_type count(const _Kp& __x) const {
649 auto [__first, __last] = equal_range(__x);
650 return __last - __first;
651 }
652
653 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __x) const { return find(__x) != end(); }
654
655 template <class _Kp>
656 requires __is_compare_transparent
657 _LIBCPP_HIDE_FROM_ABI bool contains(const _Kp& __x) const {
658 return find(__x) != end();
659 }
660
661 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __x) { return __lower_bound<iterator>(*this, __x); }
662
663 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __x) const {
664 return __lower_bound<const_iterator>(*this, __x);
665 }
666
667 template <class _Kp>
668 requires __is_compare_transparent
669 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Kp& __x) {
670 return __lower_bound<iterator>(*this, __x);
671 }
672
673 template <class _Kp>
674 requires __is_compare_transparent
675 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Kp& __x) const {
676 return __lower_bound<const_iterator>(*this, __x);
677 }
678
679 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __x) { return __upper_bound<iterator>(*this, __x); }
680
681 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __x) const {
682 return __upper_bound<const_iterator>(*this, __x);
683 }
684
685 template <class _Kp>
686 requires __is_compare_transparent
687 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Kp& __x) {
688 return __upper_bound<iterator>(*this, __x);
689 }
690
691 template <class _Kp>
692 requires __is_compare_transparent
693 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Kp& __x) const {
694 return __upper_bound<const_iterator>(*this, __x);
695 }
696
697 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __x) {
698 return __equal_range_impl(*this, __x);
699 }
700
701 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __x) const {
702 return __equal_range_impl(*this, __x);
703 }
704
705 template <class _Kp>
706 requires __is_compare_transparent
707 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _Kp& __x) {
708 return __equal_range_impl(*this, __x);
709 }
710 template <class _Kp>
711 requires __is_compare_transparent
712 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _Kp& __x) const {
713 return __equal_range_impl(*this, __x);
714 }
715
716 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const flat_multimap& __x, const flat_multimap& __y) {
717 return ranges::equal(__x, __y);
718 }
719
720 friend _LIBCPP_HIDE_FROM_ABI auto operator<=>(const flat_multimap& __x, const flat_multimap& __y) {
721 return std::lexicographical_compare_three_way(
722 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
723 }
724
725 friend _LIBCPP_HIDE_FROM_ABI void swap(flat_multimap& __x, flat_multimap& __y) noexcept { __x.swap(__y); }
726
727private:
728 struct __ctor_uses_allocator_tag {
729 explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_tag() = default;
730 };
731 struct __ctor_uses_allocator_empty_tag {
732 explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_empty_tag() = default;
733 };
734
735 template <class _Allocator, class _KeyCont, class _MappedCont, class... _CompArg>
736 requires __allocator_ctor_constraint<_Allocator>
737 _LIBCPP_HIDE_FROM_ABI
738 flat_multimap(__ctor_uses_allocator_tag,
739 const _Allocator& __alloc,
740 _KeyCont&& __key_cont,
741 _MappedCont&& __mapped_cont,
742 _CompArg&&... __comp)
743 : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(
744 __alloc, std::forward<_KeyCont>(__key_cont)),
745 .values = std::make_obj_using_allocator<mapped_container_type>(
746 __alloc, std::forward<_MappedCont>(__mapped_cont))},
747 __compare_(std::forward<_CompArg>(__comp)...) {}
748
749 template <class _Allocator, class... _CompArg>
750 requires __allocator_ctor_constraint<_Allocator>
751 _LIBCPP_HIDE_FROM_ABI flat_multimap(__ctor_uses_allocator_empty_tag, const _Allocator& __alloc, _CompArg&&... __comp)
752 : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(__alloc),
753 .values = std::make_obj_using_allocator<mapped_container_type>(__alloc)},
754 __compare_(std::forward<_CompArg>(__comp)...) {}
755
756 _LIBCPP_HIDE_FROM_ABI bool __is_sorted(auto&& __key_container) const {
757 return ranges::is_sorted(__key_container, __compare_);
758 }
759
760 _LIBCPP_HIDE_FROM_ABI void __sort() {
761 auto __zv = ranges::views::zip(__containers_.keys, __containers_.values);
762 ranges::sort(__zv, __compare_, [](const auto& __p) -> decltype(auto) { return std::get<0>(__p); });
763 }
764
765 template <class _Self, class _KeyIter>
766 _LIBCPP_HIDE_FROM_ABI static auto __corresponding_mapped_it(_Self&& __self, _KeyIter&& __key_iter) {
767 return __self.__containers_.values.begin() +
768 static_cast<ranges::range_difference_t<mapped_container_type>>(
769 ranges::distance(__self.__containers_.keys.begin(), __key_iter));
770 }
771
772 template <bool _WasSorted, class _InputIterator, class _Sentinel>
773 _LIBCPP_HIDE_FROM_ABI void __append_sort_merge(_InputIterator __first, _Sentinel __last) {
774 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
775 size_t __num_appended = __flat_map_utils::__append(*this, std::move(__first), std::move(__last));
776 if (__num_appended != 0) {
777 auto __zv = ranges::views::zip(__containers_.keys, __containers_.values);
778 auto __append_start_offset = __containers_.keys.size() - __num_appended;
779 auto __end = __zv.end();
780 auto __compare_key = [this](const auto& __p1, const auto& __p2) {
781 return __compare_(std::get<0>(__p1), std::get<0>(__p2));
782 };
783 if constexpr (!_WasSorted) {
784 ranges::sort(__zv.begin() + __append_start_offset, __end, __compare_key);
785 } else {
786 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
787 __is_sorted(__containers_.keys | ranges::views::drop(__append_start_offset)),
788 "Key container is not sorted");
789 }
790 ranges::inplace_merge(__zv.begin(), __zv.begin() + __append_start_offset, __end, __compare_key);
791 }
792 __on_failure.__complete();
793 }
794
795 template <class _Self, class _Kp>
796 _LIBCPP_HIDE_FROM_ABI static auto __find_impl(_Self&& __self, const _Kp& __key) {
797 auto __it = __self.lower_bound(__key);
798 auto __last = __self.end();
799 if (__it == __last || __self.__compare_(__key, __it->first)) {
800 return __last;
801 }
802 return __it;
803 }
804
805 template <class _Self, class _Kp>
806 _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) {
807 auto [__key_first, __key_last] = ranges::equal_range(__self.__containers_.keys, __key, __self.__compare_);
808
809 using __iterator_type = ranges::iterator_t<decltype(__self)>;
810 return std::make_pair(__iterator_type(__key_first, __corresponding_mapped_it(__self, __key_first)),
811 __iterator_type(__key_last, __corresponding_mapped_it(__self, __key_last)));
812 }
813
814 template <class _Res, class _Self, class _Kp>
815 _LIBCPP_HIDE_FROM_ABI static _Res __lower_bound(_Self&& __self, _Kp& __x) {
816 auto __key_iter = ranges::lower_bound(__self.__containers_.keys, __x, __self.__compare_);
817 auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter);
818 return _Res(std::move(__key_iter), std::move(__mapped_iter));
819 }
820
821 template <class _Res, class _Self, class _Kp>
822 _LIBCPP_HIDE_FROM_ABI static _Res __upper_bound(_Self&& __self, _Kp& __x) {
823 auto __key_iter = ranges::upper_bound(__self.__containers_.keys, __x, __self.__compare_);
824 auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter);
825 return _Res(std::move(__key_iter), std::move(__mapped_iter));
826 }
827
828 _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) {
829 if constexpr (requires { __containers_.keys.reserve(__size); }) {
830 __containers_.keys.reserve(__size);
831 }
832
833 if constexpr (requires { __containers_.values.reserve(__size); }) {
834 __containers_.values.reserve(__size);
835 }
836 }
837
838 template <class _KIter, class _MIter>
839 _LIBCPP_HIDE_FROM_ABI iterator __erase(_KIter __key_iter_to_remove, _MIter __mapped_iter_to_remove) {
840 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
841 auto __key_iter = __containers_.keys.erase(__key_iter_to_remove);
842 auto __mapped_iter = __containers_.values.erase(__mapped_iter_to_remove);
843 __on_failure.__complete();
844 return iterator(std::move(__key_iter), std::move(__mapped_iter));
845 }
846
847 template <class _Key2, class _Tp2, class _Compare2, class _KeyContainer2, class _MappedContainer2, class _Predicate>
848 friend typename flat_multimap<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>::size_type
849 erase_if(flat_multimap<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>&, _Predicate);
850
851 friend __flat_map_utils;
852
853 containers __containers_;
854 _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_;
855
856 struct __key_equiv {
857 _LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {}
858 _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const {
859 return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x));
860 }
861 key_compare __comp_;
862 };
863};
864
865template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>>
866 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
867 !__is_allocator<_MappedContainer>::value &&
868 is_invocable_v<const _Compare&,
869 const typename _KeyContainer::value_type&,
870 const typename _KeyContainer::value_type&>)
871flat_multimap(_KeyContainer, _MappedContainer, _Compare = _Compare())
872 -> flat_multimap<typename _KeyContainer::value_type,
873 typename _MappedContainer::value_type,
874 _Compare,
875 _KeyContainer,
876 _MappedContainer>;
877
878template <class _KeyContainer, class _MappedContainer, class _Allocator>
879 requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
880 !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value)
881flat_multimap(_KeyContainer, _MappedContainer, _Allocator)
882 -> flat_multimap<typename _KeyContainer::value_type,
883 typename _MappedContainer::value_type,
884 less<typename _KeyContainer::value_type>,
885 _KeyContainer,
886 _MappedContainer>;
887
888template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator>
889 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
890 !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> &&
891 uses_allocator_v<_MappedContainer, _Allocator> &&
892 is_invocable_v<const _Compare&,
893 const typename _KeyContainer::value_type&,
894 const typename _KeyContainer::value_type&>)
895flat_multimap(_KeyContainer, _MappedContainer, _Compare, _Allocator)
896 -> flat_multimap<typename _KeyContainer::value_type,
897 typename _MappedContainer::value_type,
898 _Compare,
899 _KeyContainer,
900 _MappedContainer>;
901
902template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>>
903 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
904 !__is_allocator<_MappedContainer>::value &&
905 is_invocable_v<const _Compare&,
906 const typename _KeyContainer::value_type&,
907 const typename _KeyContainer::value_type&>)
908flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Compare = _Compare())
909 -> flat_multimap<typename _KeyContainer::value_type,
910 typename _MappedContainer::value_type,
911 _Compare,
912 _KeyContainer,
913 _MappedContainer>;
914
915template <class _KeyContainer, class _MappedContainer, class _Allocator>
916 requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
917 !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value)
918flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Allocator)
919 -> flat_multimap<typename _KeyContainer::value_type,
920 typename _MappedContainer::value_type,
921 less<typename _KeyContainer::value_type>,
922 _KeyContainer,
923 _MappedContainer>;
924
925template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator>
926 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
927 !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> &&
928 uses_allocator_v<_MappedContainer, _Allocator> &&
929 is_invocable_v<const _Compare&,
930 const typename _KeyContainer::value_type&,
931 const typename _KeyContainer::value_type&>)
932flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Compare, _Allocator)
933 -> flat_multimap<typename _KeyContainer::value_type,
934 typename _MappedContainer::value_type,
935 _Compare,
936 _KeyContainer,
937 _MappedContainer>;
938
939template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>>
940 requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
941flat_multimap(_InputIterator, _InputIterator, _Compare = _Compare())
942 -> flat_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>;
943
944template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>>
945 requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
946flat_multimap(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare())
947 -> flat_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>;
948
949template <ranges::input_range _Range,
950 class _Compare = less<__range_key_type<_Range>>,
951 class _Allocator = allocator<byte>,
952 class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>>
953flat_multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_multimap<
954 __range_key_type<_Range>,
955 __range_mapped_type<_Range>,
956 _Compare,
957 vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>,
958 vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>;
959
960template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>>
961flat_multimap(from_range_t, _Range&&, _Allocator) -> flat_multimap<
962 __range_key_type<_Range>,
963 __range_mapped_type<_Range>,
964 less<__range_key_type<_Range>>,
965 vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>,
966 vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>;
967
968template <class _Key, class _Tp, class _Compare = less<_Key>>
969 requires(!__is_allocator<_Compare>::value)
970flat_multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_multimap<_Key, _Tp, _Compare>;
971
972template <class _Key, class _Tp, class _Compare = less<_Key>>
973 requires(!__is_allocator<_Compare>::value)
974flat_multimap(sorted_equivalent_t, initializer_list<pair<_Key, _Tp>>, _Compare = _Compare())
975 -> flat_multimap<_Key, _Tp, _Compare>;
976
977template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Allocator>
978struct uses_allocator<flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>, _Allocator>
979 : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator>> {};
980
981template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Predicate>
982_LIBCPP_HIDE_FROM_ABI typename flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::size_type
983erase_if(flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>& __flat_multimap, _Predicate __pred) {
984 auto __zv = ranges::views::zip(__flat_multimap.__containers_.keys, __flat_multimap.__containers_.values);
985 auto __first = __zv.begin();
986 auto __last = __zv.end();
987 auto __guard = std::__make_exception_guard([&] { __flat_multimap.clear(); });
988 auto __it = std::remove_if(__first, __last, [&](auto&& __zipped) -> bool {
989 using _Ref = typename flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::const_reference;
990 return __pred(_Ref(std::get<0>(__zipped), std::get<1>(__zipped)));
991 });
992 auto __res = __last - __it;
993 auto __offset = __it - __first;
994
995 const auto __erase_container = [&](auto& __cont) { __cont.erase(__cont.begin() + __offset, __cont.end()); };
996
997 __erase_container(__flat_multimap.__containers_.keys);
998 __erase_container(__flat_multimap.__containers_.values);
999
1000 __guard.__complete();
1001 return __res;
1002}
1003
1004_LIBCPP_END_NAMESPACE_STD
1005
1006#endif // _LIBCPP_STD_VER >= 23
1007
1008_LIBCPP_POP_MACROS
1009
1010#endif // _LIBCPP___FLAT_MAP_FLAT_MULTIMAP_H
lib/libcxx/include/__flat_map/key_value_iterator.h created+176
...@@ -0,0 +1,176 @@
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___FLAT_MAP_KEY_VALUE_ITERATOR_H
11#define _LIBCPP___FLAT_MAP_KEY_VALUE_ITERATOR_H
12
13#include <__compare/three_way_comparable.h>
14#include <__concepts/convertible_to.h>
15#include <__config>
16#include <__iterator/iterator_traits.h>
17#include <__memory/addressof.h>
18#include <__type_traits/conditional.h>
19#include <__utility/move.h>
20#include <__utility/pair.h>
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 >= 23
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33/**
34 * __key_value_iterator is a proxy iterator which zips the underlying
35 * _KeyContainer::iterator and the underlying _MappedContainer::iterator.
36 * The two underlying iterators will be incremented/decremented together.
37 * And the reference is a pair of the const key reference and the value reference.
38 */
39template <class _Owner, class _KeyContainer, class _MappedContainer, bool _Const>
40struct __key_value_iterator {
41private:
42 using __key_iterator _LIBCPP_NODEBUG = typename _KeyContainer::const_iterator;
43 using __mapped_iterator _LIBCPP_NODEBUG =
44 _If<_Const, typename _MappedContainer::const_iterator, typename _MappedContainer::iterator>;
45 using __reference _LIBCPP_NODEBUG = _If<_Const, typename _Owner::const_reference, typename _Owner::reference>;
46
47 struct __arrow_proxy {
48 __reference __ref_;
49 _LIBCPP_HIDE_FROM_ABI __reference* operator->() { return std::addressof(__ref_); }
50 };
51
52 __key_iterator __key_iter_;
53 __mapped_iterator __mapped_iter_;
54
55 friend _Owner;
56
57 template <class, class, class, bool>
58 friend struct __key_value_iterator;
59
60public:
61 using iterator_concept = random_access_iterator_tag;
62 // `__key_value_iterator` only satisfy "Cpp17InputIterator" named requirements, because
63 // its `reference` is not a reference type.
64 // However, to avoid surprising runtime behaviour when it is used with the
65 // Cpp17 algorithms or operations, iterator_category is set to random_access_iterator_tag.
66 using iterator_category = random_access_iterator_tag;
67 using value_type = typename _Owner::value_type;
68 using difference_type = typename _Owner::difference_type;
69
70 _LIBCPP_HIDE_FROM_ABI __key_value_iterator() = default;
71
72 _LIBCPP_HIDE_FROM_ABI __key_value_iterator(__key_value_iterator<_Owner, _KeyContainer, _MappedContainer, !_Const> __i)
73 requires _Const && convertible_to<typename _KeyContainer::iterator, __key_iterator> &&
74 convertible_to<typename _MappedContainer::iterator, __mapped_iterator>
75 : __key_iter_(std::move(__i.__key_iter_)), __mapped_iter_(std::move(__i.__mapped_iter_)) {}
76
77 _LIBCPP_HIDE_FROM_ABI __key_value_iterator(__key_iterator __key_iter, __mapped_iterator __mapped_iter)
78 : __key_iter_(std::move(__key_iter)), __mapped_iter_(std::move(__mapped_iter)) {}
79
80 _LIBCPP_HIDE_FROM_ABI __reference operator*() const { return __reference(*__key_iter_, *__mapped_iter_); }
81 _LIBCPP_HIDE_FROM_ABI __arrow_proxy operator->() const { return __arrow_proxy{**this}; }
82
83 _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator++() {
84 ++__key_iter_;
85 ++__mapped_iter_;
86 return *this;
87 }
88
89 _LIBCPP_HIDE_FROM_ABI __key_value_iterator operator++(int) {
90 __key_value_iterator __tmp(*this);
91 ++*this;
92 return __tmp;
93 }
94
95 _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator--() {
96 --__key_iter_;
97 --__mapped_iter_;
98 return *this;
99 }
100
101 _LIBCPP_HIDE_FROM_ABI __key_value_iterator operator--(int) {
102 __key_value_iterator __tmp(*this);
103 --*this;
104 return __tmp;
105 }
106
107 _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator+=(difference_type __x) {
108 __key_iter_ += __x;
109 __mapped_iter_ += __x;
110 return *this;
111 }
112
113 _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator-=(difference_type __x) {
114 __key_iter_ -= __x;
115 __mapped_iter_ -= __x;
116 return *this;
117 }
118
119 _LIBCPP_HIDE_FROM_ABI __reference operator[](difference_type __n) const { return *(*this + __n); }
120
121 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
122 operator==(const __key_value_iterator& __x, const __key_value_iterator& __y) {
123 return __x.__key_iter_ == __y.__key_iter_;
124 }
125
126 _LIBCPP_HIDE_FROM_ABI friend bool operator<(const __key_value_iterator& __x, const __key_value_iterator& __y) {
127 return __x.__key_iter_ < __y.__key_iter_;
128 }
129
130 _LIBCPP_HIDE_FROM_ABI friend bool operator>(const __key_value_iterator& __x, const __key_value_iterator& __y) {
131 return __y < __x;
132 }
133
134 _LIBCPP_HIDE_FROM_ABI friend bool operator<=(const __key_value_iterator& __x, const __key_value_iterator& __y) {
135 return !(__y < __x);
136 }
137
138 _LIBCPP_HIDE_FROM_ABI friend bool operator>=(const __key_value_iterator& __x, const __key_value_iterator& __y) {
139 return !(__x < __y);
140 }
141
142 _LIBCPP_HIDE_FROM_ABI friend auto operator<=>(const __key_value_iterator& __x, const __key_value_iterator& __y)
143 requires three_way_comparable<__key_iterator>
144 {
145 return __x.__key_iter_ <=> __y.__key_iter_;
146 }
147
148 _LIBCPP_HIDE_FROM_ABI friend __key_value_iterator operator+(const __key_value_iterator& __i, difference_type __n) {
149 auto __tmp = __i;
150 __tmp += __n;
151 return __tmp;
152 }
153
154 _LIBCPP_HIDE_FROM_ABI friend __key_value_iterator operator+(difference_type __n, const __key_value_iterator& __i) {
155 return __i + __n;
156 }
157
158 _LIBCPP_HIDE_FROM_ABI friend __key_value_iterator operator-(const __key_value_iterator& __i, difference_type __n) {
159 auto __tmp = __i;
160 __tmp -= __n;
161 return __tmp;
162 }
163
164 _LIBCPP_HIDE_FROM_ABI friend difference_type
165 operator-(const __key_value_iterator& __x, const __key_value_iterator& __y) {
166 return difference_type(__x.__key_iter_ - __y.__key_iter_);
167 }
168};
169
170_LIBCPP_END_NAMESPACE_STD
171
172#endif // _LIBCPP_STD_VER >= 23
173
174_LIBCPP_POP_MACROS
175
176#endif // _LIBCPP___FLAT_MAP_KEY_VALUE_ITERATOR_H
lib/libcxx/include/__flat_map/sorted_equivalent.h created+31
...@@ -0,0 +1,31 @@
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___FLAT_MAP_SORTED_EQUIVALENT_H
10#define _LIBCPP___FLAT_MAP_SORTED_EQUIVALENT_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 sorted_equivalent_t {
23 explicit sorted_equivalent_t() = default;
24};
25inline constexpr sorted_equivalent_t sorted_equivalent{};
26
27_LIBCPP_END_NAMESPACE_STD
28
29#endif // _LIBCPP_STD_VER >= 23
30
31#endif // _LIBCPP___FLAT_MAP_SORTED_EQUIVALENT_H
lib/libcxx/include/__flat_map/sorted_unique.h created+31
...@@ -0,0 +1,31 @@
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___FLAT_MAP_SORTED_UNIQUE_H
10#define _LIBCPP___FLAT_MAP_SORTED_UNIQUE_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 sorted_unique_t {
23 explicit sorted_unique_t() = default;
24};
25inline constexpr sorted_unique_t sorted_unique{};
26
27_LIBCPP_END_NAMESPACE_STD
28
29#endif // _LIBCPP_STD_VER >= 23
30
31#endif // _LIBCPP___FLAT_MAP_SORTED_UNIQUE_H
lib/libcxx/include/__flat_map/utils.h created+103
...@@ -0,0 +1,103 @@
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___FLAT_MAP_UTILS_H
11#define _LIBCPP___FLAT_MAP_UTILS_H
12
13#include <__config>
14#include <__type_traits/container_traits.h>
15#include <__utility/exception_guard.h>
16#include <__utility/forward.h>
17#include <__utility/move.h>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_PUSH_MACROS
24#include <__undef_macros>
25
26#if _LIBCPP_STD_VER >= 23
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30// These utilities are defined in a class instead of a namespace so that this class can be befriended more easily.
31struct __flat_map_utils {
32 // Emplace a {key: value} into a flat_{multi}map, at the exact position that
33 // __it_key and __it_mapped point to, assuming that the key is not already present in the map.
34 // When an exception is thrown during the emplacement, the function will try its best to
35 // roll back the changes it made to the map. If it cannot roll back the changes, it will
36 // clear the map.
37 template <class _Map, class _IterK, class _IterM, class _KeyArg, class... _MArgs>
38 _LIBCPP_HIDE_FROM_ABI static typename _Map::iterator __emplace_exact_pos(
39 _Map& __map, _IterK&& __it_key, _IterM&& __it_mapped, _KeyArg&& __key, _MArgs&&... __mapped_args) {
40 auto __on_key_failed = std::__make_exception_guard([&]() noexcept {
41 using _KeyContainer = typename _Map::key_container_type;
42 if constexpr (__container_traits<_KeyContainer>::__emplacement_has_strong_exception_safety_guarantee) {
43 // Nothing to roll back!
44 } else {
45 // we need to clear both because we don't know the state of our keys anymore
46 __map.clear() /* noexcept */;
47 }
48 });
49 auto __key_it = __map.__containers_.keys.emplace(__it_key, std::forward<_KeyArg>(__key));
50 __on_key_failed.__complete();
51
52 auto __on_value_failed = std::__make_exception_guard([&]() noexcept {
53 using _MappedContainer = typename _Map::mapped_container_type;
54 if constexpr (!__container_traits<_MappedContainer>::__emplacement_has_strong_exception_safety_guarantee) {
55 // we need to clear both because we don't know the state of our values anymore
56 __map.clear() /* noexcept */;
57 } else {
58 // In this case, we know the values are just like before we attempted emplacement,
59 // and we also know that the keys have been emplaced successfully. Just roll back the keys.
60# if _LIBCPP_HAS_EXCEPTIONS
61 try {
62# endif // _LIBCPP_HAS_EXCEPTIONS
63 __map.__containers_.keys.erase(__key_it);
64# if _LIBCPP_HAS_EXCEPTIONS
65 } catch (...) {
66 // Now things are funky for real. We're failing to rollback the keys.
67 // Just give up and clear the whole thing.
68 //
69 // Also, swallow the exception that happened during the rollback and let the
70 // original value-emplacement exception propagate normally.
71 __map.clear() /* noexcept */;
72 }
73# endif // _LIBCPP_HAS_EXCEPTIONS
74 }
75 });
76 auto __mapped_it = __map.__containers_.values.emplace(__it_mapped, std::forward<_MArgs>(__mapped_args)...);
77 __on_value_failed.__complete();
78
79 return typename _Map::iterator(std::move(__key_it), std::move(__mapped_it));
80 }
81
82 // TODO: We could optimize this, see
83 // https://github.com/llvm/llvm-project/issues/108624
84 template <class _Map, class _InputIterator, class _Sentinel>
85 _LIBCPP_HIDE_FROM_ABI static typename _Map::size_type
86 __append(_Map& __map, _InputIterator __first, _Sentinel __last) {
87 typename _Map::size_type __num_appended = 0;
88 for (; __first != __last; ++__first) {
89 typename _Map::value_type __kv = *__first;
90 __map.__containers_.keys.insert(__map.__containers_.keys.end(), std::move(__kv.first));
91 __map.__containers_.values.insert(__map.__containers_.values.end(), std::move(__kv.second));
92 ++__num_appended;
93 }
94 return __num_appended;
95 }
96};
97_LIBCPP_END_NAMESPACE_STD
98
99#endif // _LIBCPP_STD_VER >= 23
100
101_LIBCPP_POP_MACROS
102
103#endif // #define _LIBCPP___FLAT_MAP_UTILS_H
lib/libcxx/include/__format/buffer.h+341-287
...@@ -14,6 +14,7 @@...@@ -14,6 +14,7 @@
14#include <__algorithm/fill_n.h>14#include <__algorithm/fill_n.h>
15#include <__algorithm/max.h>15#include <__algorithm/max.h>
16#include <__algorithm/min.h>16#include <__algorithm/min.h>
17#include <__algorithm/ranges_copy.h>
17#include <__algorithm/ranges_copy_n.h>18#include <__algorithm/ranges_copy_n.h>
18#include <__algorithm/transform.h>19#include <__algorithm/transform.h>
19#include <__algorithm/unwrap_iter.h>20#include <__algorithm/unwrap_iter.h>
...@@ -29,6 +30,7 @@...@@ -29,6 +30,7 @@
29#include <__iterator/wrap_iter.h>30#include <__iterator/wrap_iter.h>
30#include <__memory/addressof.h>31#include <__memory/addressof.h>
31#include <__memory/allocate_at_least.h>32#include <__memory/allocate_at_least.h>
33#include <__memory/allocator.h>
32#include <__memory/allocator_traits.h>34#include <__memory/allocator_traits.h>
33#include <__memory/construct_at.h>35#include <__memory/construct_at.h>
34#include <__memory/ranges_construct_at.h>36#include <__memory/ranges_construct_at.h>
...@@ -37,7 +39,7 @@...@@ -37,7 +39,7 @@
37#include <__type_traits/conditional.h>39#include <__type_traits/conditional.h>
38#include <__utility/exception_guard.h>40#include <__utility/exception_guard.h>
39#include <__utility/move.h>41#include <__utility/move.h>
40#include <cstddef>42#include <stdexcept>
41#include <string_view>43#include <string_view>
4244
43#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)45#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -53,24 +55,147 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -53,24 +55,147 @@ _LIBCPP_BEGIN_NAMESPACE_STD
5355
54namespace __format {56namespace __format {
5557
58// A helper to limit the total size of code units written.
59class _LIBCPP_HIDE_FROM_ABI __max_output_size {
60public:
61 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __max_output_size(size_t __max_size) : __max_size_{__max_size} {}
62
63 // This function adjusts the size of a (bulk) write operations. It ensures the
64 // number of code units written by a __output_buffer never exceeds
65 // __max_size_ code units.
66 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __write_request(size_t __code_units) {
67 size_t __result =
68 __code_units_written_ < __max_size_ ? std::min(__code_units, __max_size_ - __code_units_written_) : 0;
69 __code_units_written_ += __code_units;
70 return __result;
71 }
72
73 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __code_units_written() const noexcept { return __code_units_written_; }
74
75private:
76 size_t __max_size_;
77 // The code units that would have been written if there was no limit.
78 // format_to_n returns this value.
79 size_t __code_units_written_{0};
80};
81
56/// A "buffer" that handles writing to the proper iterator.82/// A "buffer" that handles writing to the proper iterator.
57///83///
58/// This helper is used together with the @ref back_insert_iterator to offer84/// This helper is used together with the @ref back_insert_iterator to offer
59/// type-erasure for the formatting functions. This reduces the number to85/// type-erasure for the formatting functions. This reduces the number to
60/// template instantiations.86/// template instantiations.
87///
88/// The design is the following:
89/// - There is an external object that connects the buffer to the output.
90/// - This buffer object:
91/// - inherits publicly from this class.
92/// - has a static or dynamic buffer.
93/// - has a static member function to make space in its buffer write
94/// operations. This can be done by increasing the size of the internal
95/// buffer or by writing the contents of the buffer to the output iterator.
96///
97/// This member function is a constructor argument, so its name is not
98/// fixed. The code uses the name __prepare_write.
99/// - The number of output code units can be limited by a __max_output_size
100/// object. This is used in format_to_n This object:
101/// - Contains the maximum number of code units to be written.
102/// - Contains the number of code units that are requested to be written.
103/// This number is returned to the user of format_to_n.
104/// - The write functions call the object's __request_write member function.
105/// This function:
106/// - Updates the number of code units that are requested to be written.
107/// - Returns the number of code units that can be written without
108/// exceeding the maximum number of code units to be written.
109///
110/// Documentation for the buffer usage members:
111/// - __ptr_
112/// The start of the buffer.
113/// - __capacity_
114/// The number of code units that can be written. This means
115/// [__ptr_, __ptr_ + __capacity_) is a valid range to write to.
116/// - __size_
117/// The number of code units written in the buffer. The next code unit will
118/// be written at __ptr_ + __size_. This __size_ may NOT contain the total
119/// number of code units written by the __output_buffer. Whether or not it
120/// does depends on the sub-class used. Typically the total number of code
121/// units written is not interesting. It is interesting for format_to_n which
122/// has its own way to track this number.
123///
124/// Documentation for the modifying buffer operations:
125/// The subclasses have a function with the following signature:
126///
127/// static void __prepare_write(
128/// __output_buffer<_CharT>& __buffer, size_t __code_units);
129///
130/// This function is called when a write function writes more code units than
131/// the buffer's available space. When an __max_output_size object is provided
132/// the number of code units is the number of code units returned from
133/// __max_output_size::__request_write function.
134///
135/// - The __buffer contains *this. Since the class containing this function
136/// inherits from __output_buffer it's safe to cast it to the subclass being
137/// used.
138/// - The __code_units is the number of code units the caller will write + 1.
139/// - This value does not take the available space of the buffer into account.
140/// - The push_back function is more efficient when writing before resizing,
141/// this means the buffer should always have room for one code unit. Hence
142/// the + 1 is the size.
143/// - When the function returns there is room for at least one additional code
144/// unit. There is no requirement there is room for __code_units code units:
145/// - The class has some "bulk" operations. For example, __copy which copies
146/// the contents of a basic_string_view to the output. If the sub-class has
147/// a fixed size buffer the size of the basic_string_view may be larger
148/// than the buffer. In that case it's impossible to honor the requested
149/// size.
150/// - When the buffer has room for at least one code unit the function may be
151/// a no-op.
152/// - When the function makes space for more code units it uses one for these
153/// functions to signal the change:
154/// - __buffer_flushed()
155/// - This function is typically used for a fixed sized buffer.
156/// - The current contents of [__ptr_, __ptr_ + __size_) have been
157/// processed.
158/// - __ptr_ remains unchanged.
159/// - __capacity_ remains unchanged.
160/// - __size_ will be set to 0.
161/// - __buffer_moved(_CharT* __ptr, size_t __capacity)
162/// - This function is typically used for a dynamic sized buffer. There the
163/// location of the buffer changes due to reallocations.
164/// - __ptr_ will be set to __ptr. (This value may be the old value of
165/// __ptr_).
166/// - __capacity_ will be set to __capacity. (This value may be the old
167/// value of __capacity_).
168/// - __size_ remains unchanged,
169/// - The range [__ptr, __ptr + __size_) contains the original data of the
170/// range [__ptr_, __ptr_ + __size_).
171///
172/// The push_back function expects a valid buffer and a capacity of at least 1.
173/// This means:
174/// - The class is constructed with a valid buffer,
175/// - __buffer_moved is called with a valid buffer is used before the first
176/// write operation,
177/// - no write function is ever called, or
178/// - the class is constructed with a __max_output_size object with __max_size 0.
179///
180/// The latter option allows formatted_size to use the output buffer without
181/// ever writing anything to the buffer.
61template <__fmt_char_type _CharT>182template <__fmt_char_type _CharT>
62class _LIBCPP_TEMPLATE_VIS __output_buffer {183class _LIBCPP_TEMPLATE_VIS __output_buffer {
63public:184public:
64 using value_type = _CharT;185 using value_type _LIBCPP_NODEBUG = _CharT;
186 using __prepare_write_type _LIBCPP_NODEBUG = void (*)(__output_buffer<_CharT>&, size_t);
65187
66 template <class _Tp>188 [[nodiscard]]
67 _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, size_t __capacity, _Tp* __obj)189 _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, size_t __capacity, __prepare_write_type __function)
68 : __ptr_(__ptr),190 : __output_buffer{__ptr, __capacity, __function, nullptr} {}
69 __capacity_(__capacity),
70 __flush_([](_CharT* __p, size_t __n, void* __o) { static_cast<_Tp*>(__o)->__flush(__p, __n); }),
71 __obj_(__obj) {}
72191
73 _LIBCPP_HIDE_FROM_ABI void __reset(_CharT* __ptr, size_t __capacity) {192 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(
193 _CharT* __ptr, size_t __capacity, __prepare_write_type __function, __max_output_size* __max_output_size)
194 : __ptr_(__ptr), __capacity_(__capacity), __prepare_write_(__function), __max_output_size_(__max_output_size) {}
195
196 _LIBCPP_HIDE_FROM_ABI void __buffer_flushed() { __size_ = 0; }
197
198 _LIBCPP_HIDE_FROM_ABI void __buffer_moved(_CharT* __ptr, size_t __capacity) {
74 __ptr_ = __ptr;199 __ptr_ = __ptr;
75 __capacity_ = __capacity;200 __capacity_ = __capacity;
76 }201 }
...@@ -79,12 +204,18 @@ public:...@@ -79,12 +204,18 @@ public:
79204
80 // Used in std::back_insert_iterator.205 // Used in std::back_insert_iterator.
81 _LIBCPP_HIDE_FROM_ABI void push_back(_CharT __c) {206 _LIBCPP_HIDE_FROM_ABI void push_back(_CharT __c) {
207 if (__max_output_size_ && __max_output_size_->__write_request(1) == 0)
208 return;
209
210 _LIBCPP_ASSERT_INTERNAL(
211 __ptr_ && __size_ < __capacity_ && __available() >= 1, "attempted to write outside the buffer");
212
82 __ptr_[__size_++] = __c;213 __ptr_[__size_++] = __c;
83214
84 // Profiling showed flushing after adding is more efficient than flushing215 // Profiling showed flushing after adding is more efficient than flushing
85 // when entering the function.216 // when entering the function.
86 if (__size_ == __capacity_)217 if (__size_ == __capacity_)
87 __flush();218 __prepare_write(0);
88 }219 }
89220
90 /// Copies the input __str to the buffer.221 /// Copies the input __str to the buffer.
...@@ -105,25 +236,20 @@ public:...@@ -105,25 +236,20 @@ public:
105 // upper case. For integral these strings are short.236 // upper case. For integral these strings are short.
106 // TODO FMT Look at the improvements above.237 // TODO FMT Look at the improvements above.
107 size_t __n = __str.size();238 size_t __n = __str.size();
108239 if (__max_output_size_) {
109 __flush_on_overflow(__n);240 __n = __max_output_size_->__write_request(__n);
110 if (__n < __capacity_) { // push_back requires the buffer to have room for at least one character (so use <).241 if (__n == 0)
111 std::copy_n(__str.data(), __n, std::addressof(__ptr_[__size_]));242 return;
112 __size_ += __n;
113 return;
114 }243 }
115244
116 // The output doesn't fit in the internal buffer.
117 // Copy the data in "__capacity_" sized chunks.
118 _LIBCPP_ASSERT_INTERNAL(__size_ == 0, "the buffer should be flushed by __flush_on_overflow");
119 const _InCharT* __first = __str.data();245 const _InCharT* __first = __str.data();
120 do {246 do {
121 size_t __chunk = std::min(__n, __capacity_);247 __prepare_write(__n);
248 size_t __chunk = std::min(__n, __available());
122 std::copy_n(__first, __chunk, std::addressof(__ptr_[__size_]));249 std::copy_n(__first, __chunk, std::addressof(__ptr_[__size_]));
123 __size_ = __chunk;250 __size_ += __chunk;
124 __first += __chunk;251 __first += __chunk;
125 __n -= __chunk;252 __n -= __chunk;
126 __flush();
127 } while (__n);253 } while (__n);
128 }254 }
129255
...@@ -137,121 +263,59 @@ public:...@@ -137,121 +263,59 @@ public:
137 _LIBCPP_ASSERT_INTERNAL(__first <= __last, "not a valid range");263 _LIBCPP_ASSERT_INTERNAL(__first <= __last, "not a valid range");
138264
139 size_t __n = static_cast<size_t>(__last - __first);265 size_t __n = static_cast<size_t>(__last - __first);
140 __flush_on_overflow(__n);266 if (__max_output_size_) {
141 if (__n < __capacity_) { // push_back requires the buffer to have room for at least one character (so use <).267 __n = __max_output_size_->__write_request(__n);
142 std::transform(__first, __last, std::addressof(__ptr_[__size_]), std::move(__operation));268 if (__n == 0)
143 __size_ += __n;269 return;
144 return;
145 }270 }
146271
147 // The output doesn't fit in the internal buffer.
148 // Transform the data in "__capacity_" sized chunks.
149 _LIBCPP_ASSERT_INTERNAL(__size_ == 0, "the buffer should be flushed by __flush_on_overflow");
150 do {272 do {
151 size_t __chunk = std::min(__n, __capacity_);273 __prepare_write(__n);
274 size_t __chunk = std::min(__n, __available());
152 std::transform(__first, __first + __chunk, std::addressof(__ptr_[__size_]), __operation);275 std::transform(__first, __first + __chunk, std::addressof(__ptr_[__size_]), __operation);
153 __size_ = __chunk;276 __size_ += __chunk;
154 __first += __chunk;277 __first += __chunk;
155 __n -= __chunk;278 __n -= __chunk;
156 __flush();
157 } while (__n);279 } while (__n);
158 }280 }
159281
160 /// A \c fill_n wrapper.282 /// A \c fill_n wrapper.
161 _LIBCPP_HIDE_FROM_ABI void __fill(size_t __n, _CharT __value) {283 _LIBCPP_HIDE_FROM_ABI void __fill(size_t __n, _CharT __value) {
162 __flush_on_overflow(__n);284 if (__max_output_size_) {
163 if (__n < __capacity_) { // push_back requires the buffer to have room for at least one character (so use <).285 __n = __max_output_size_->__write_request(__n);
164 std::fill_n(std::addressof(__ptr_[__size_]), __n, __value);286 if (__n == 0)
165 __size_ += __n;287 return;
166 return;
167 }288 }
168289
169 // The output doesn't fit in the internal buffer.
170 // Fill the buffer in "__capacity_" sized chunks.
171 _LIBCPP_ASSERT_INTERNAL(__size_ == 0, "the buffer should be flushed by __flush_on_overflow");
172 do {290 do {
173 size_t __chunk = std::min(__n, __capacity_);291 __prepare_write(__n);
292 size_t __chunk = std::min(__n, __available());
174 std::fill_n(std::addressof(__ptr_[__size_]), __chunk, __value);293 std::fill_n(std::addressof(__ptr_[__size_]), __chunk, __value);
175 __size_ = __chunk;294 __size_ += __chunk;
176 __n -= __chunk;295 __n -= __chunk;
177 __flush();
178 } while (__n);296 } while (__n);
179 }297 }
180298
181 _LIBCPP_HIDE_FROM_ABI void __flush() {299 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __capacity() const { return __capacity_; }
182 __flush_(__ptr_, __size_, __obj_);300 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __size() const { return __size_; }
183 __size_ = 0;
184 }
185301
186private:302private:
187 _CharT* __ptr_;303 _CharT* __ptr_;
188 size_t __capacity_;304 size_t __capacity_;
189 size_t __size_{0};305 size_t __size_{0};
190 void (*__flush_)(_CharT*, size_t, void*);306 void (*__prepare_write_)(__output_buffer<_CharT>&, size_t);
191 void* __obj_;307 __max_output_size* __max_output_size_;
192308
193 /// Flushes the buffer when the output operation would overflow the buffer.309 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __available() const { return __capacity_ - __size_; }
194 ///
195 /// A simple approach for the overflow detection would be something along the
196 /// lines:
197 /// \code
198 /// // The internal buffer is large enough.
199 /// if (__n <= __capacity_) {
200 /// // Flush when we really would overflow.
201 /// if (__size_ + __n >= __capacity_)
202 /// __flush();
203 /// ...
204 /// }
205 /// \endcode
206 ///
207 /// This approach works for all cases but one:
208 /// A __format_to_n_buffer_base where \ref __enable_direct_output is true.
209 /// In that case the \ref __capacity_ of the buffer changes during the first
210 /// \ref __flush. During that operation the output buffer switches from its
211 /// __writer_ to its __storage_. The \ref __capacity_ of the former depends
212 /// on the value of n, of the latter is a fixed size. For example:
213 /// - a format_to_n call with a 10'000 char buffer,
214 /// - the buffer is filled with 9'500 chars,
215 /// - adding 1'000 elements would overflow the buffer so the buffer gets
216 /// changed and the \ref __capacity_ decreases from 10'000 to
217 /// __buffer_size (256 at the time of writing).
218 ///
219 /// This means that the \ref __flush for this class may need to copy a part of
220 /// the internal buffer to the proper output. In this example there will be
221 /// 500 characters that need this copy operation.
222 ///
223 /// Note it would be more efficient to write 500 chars directly and then swap
224 /// the buffers. This would make the code more complex and \ref format_to_n is
225 /// not the most common use case. Therefore the optimization isn't done.
226 _LIBCPP_HIDE_FROM_ABI void __flush_on_overflow(size_t __n) {
227 if (__size_ + __n >= __capacity_)
228 __flush();
229 }
230};
231
232/// A storage using an internal buffer.
233///
234/// This storage is used when writing a single element to the output iterator
235/// is expensive.
236template <__fmt_char_type _CharT>
237class _LIBCPP_TEMPLATE_VIS __internal_storage {
238public:
239 _LIBCPP_HIDE_FROM_ABI _CharT* __begin() { return __buffer_; }
240
241 static constexpr size_t __buffer_size = 256 / sizeof(_CharT);
242310
243private:311 _LIBCPP_HIDE_FROM_ABI void __prepare_write(size_t __code_units) {
244 _CharT __buffer_[__buffer_size];312 // Always have space for one additional code unit. This is a precondition of the push_back function.
313 __code_units += 1;
314 if (__available() < __code_units)
315 __prepare_write_(*this, __code_units + 1);
316 }
245};317};
246318
247/// A storage writing directly to the storage.
248///
249/// This requires the storage to be a contiguous buffer of \a _CharT.
250/// Since the output is directly written to the underlying storage this class
251/// is just an empty class.
252template <__fmt_char_type _CharT>
253class _LIBCPP_TEMPLATE_VIS __direct_storage {};
254
255template <class _OutIt, class _CharT>319template <class _OutIt, class _CharT>
256concept __enable_direct_output =320concept __enable_direct_output =
257 __fmt_char_type<_CharT> &&321 __fmt_char_type<_CharT> &&
...@@ -260,40 +324,6 @@ concept __enable_direct_output =...@@ -260,40 +324,6 @@ concept __enable_direct_output =
260 // `#ifdef`.324 // `#ifdef`.
261 || same_as<_OutIt, __wrap_iter<_CharT*>>);325 || same_as<_OutIt, __wrap_iter<_CharT*>>);
262326
263/// Write policy for directly writing to the underlying output.
264template <class _OutIt, __fmt_char_type _CharT>
265class _LIBCPP_TEMPLATE_VIS __writer_direct {
266public:
267 _LIBCPP_HIDE_FROM_ABI explicit __writer_direct(_OutIt __out_it) : __out_it_(__out_it) {}
268
269 _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() { return __out_it_; }
270
271 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT*, size_t __n) {
272 // _OutIt can be a __wrap_iter<CharT*>. Therefore the original iterator
273 // is adjusted.
274 __out_it_ += __n;
275 }
276
277private:
278 _OutIt __out_it_;
279};
280
281/// Write policy for copying the buffer to the output.
282template <class _OutIt, __fmt_char_type _CharT>
283class _LIBCPP_TEMPLATE_VIS __writer_iterator {
284public:
285 _LIBCPP_HIDE_FROM_ABI explicit __writer_iterator(_OutIt __out_it) : __out_it_{std::move(__out_it)} {}
286
287 _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() && { return std::move(__out_it_); }
288
289 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
290 __out_it_ = std::ranges::copy_n(__ptr, __n, std::move(__out_it_)).out;
291 }
292
293private:
294 _OutIt __out_it_;
295};
296
297/// Concept to see whether a \a _Container is insertable.327/// Concept to see whether a \a _Container is insertable.
298///328///
299/// The concept is used to validate whether multiple calls to a329/// The concept is used to validate whether multiple calls to a
...@@ -311,196 +341,220 @@ concept __insertable =...@@ -311,196 +341,220 @@ concept __insertable =
311/// Extract the container type of a \ref back_insert_iterator.341/// Extract the container type of a \ref back_insert_iterator.
312template <class _It>342template <class _It>
313struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container {343struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container {
314 using type = void;344 using type _LIBCPP_NODEBUG = void;
315};345};
316346
317template <__insertable _Container>347template <__insertable _Container>
318struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container<back_insert_iterator<_Container>> {348struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container<back_insert_iterator<_Container>> {
319 using type = _Container;349 using type _LIBCPP_NODEBUG = _Container;
320};350};
321351
322/// Write policy for inserting the buffer in a container.352// A dynamically growing buffer.
323template <class _Container>353template <__fmt_char_type _CharT>
324class _LIBCPP_TEMPLATE_VIS __writer_container {354class _LIBCPP_TEMPLATE_VIS __allocating_buffer : public __output_buffer<_CharT> {
325public:355public:
326 using _CharT = typename _Container::value_type;356 __allocating_buffer(const __allocating_buffer&) = delete;
357 __allocating_buffer& operator=(const __allocating_buffer&) = delete;
327358
328 _LIBCPP_HIDE_FROM_ABI explicit __writer_container(back_insert_iterator<_Container> __out_it)359 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __allocating_buffer() : __allocating_buffer{nullptr} {}
329 : __container_{__out_it.__get_container()} {}
330360
331 _LIBCPP_HIDE_FROM_ABI auto __out_it() { return std::back_inserter(*__container_); }361 [[nodiscard]]
362 _LIBCPP_HIDE_FROM_ABI explicit __allocating_buffer(__max_output_size* __max_output_size)
363 : __output_buffer<_CharT>{__small_buffer_, __buffer_size_, __prepare_write, __max_output_size} {}
332364
333 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {365 _LIBCPP_HIDE_FROM_ABI ~__allocating_buffer() {
334 __container_->insert(__container_->end(), __ptr, __ptr + __n);366 if (__ptr_ != __small_buffer_)
367 _Alloc{}.deallocate(__ptr_, this->__capacity());
335 }368 }
336369
337private:370 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string_view<_CharT> __view() { return {__ptr_, this->__size()}; }
338 _Container* __container_;
339};
340371
341/// Selects the type of the writer used for the output iterator.372private:
342template <class _OutIt, class _CharT>373 using _Alloc _LIBCPP_NODEBUG = allocator<_CharT>;
343class _LIBCPP_TEMPLATE_VIS __writer_selector {
344 using _Container = typename __back_insert_iterator_container<_OutIt>::type;
345374
346public:375 // Since allocating is expensive the class has a small internal buffer. When
347 using type =376 // its capacity is exceeded a dynamic buffer will be allocated.
348 conditional_t<!same_as<_Container, void>,377 static constexpr size_t __buffer_size_ = 256;
349 __writer_container<_Container>,378 _CharT __small_buffer_[__buffer_size_];
350 conditional_t<__enable_direct_output<_OutIt, _CharT>,
351 __writer_direct<_OutIt, _CharT>,
352 __writer_iterator<_OutIt, _CharT>>>;
353};
354379
355/// The generic formatting buffer.380 _CharT* __ptr_{__small_buffer_};
356template <class _OutIt, __fmt_char_type _CharT>
357 requires(output_iterator<_OutIt, const _CharT&>)
358class _LIBCPP_TEMPLATE_VIS __format_buffer {
359 using _Storage =
360 conditional_t<__enable_direct_output<_OutIt, _CharT>, __direct_storage<_CharT>, __internal_storage<_CharT>>;
361381
362public:382 _LIBCPP_HIDE_FROM_ABI void __grow_buffer(size_t __capacity) {
363 _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it)383 if (__capacity < __buffer_size_)
364 requires(same_as<_Storage, __internal_storage<_CharT>>)384 return;
365 : __output_(__storage_.__begin(), __storage_.__buffer_size, this), __writer_(std::move(__out_it)) {}
366385
367 _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it)386 _LIBCPP_ASSERT_INTERNAL(__capacity > this->__capacity(), "the buffer must grow");
368 requires(same_as<_Storage, __direct_storage<_CharT>>)
369 : __output_(std::__unwrap_iter(__out_it), size_t(-1), this), __writer_(std::move(__out_it)) {}
370387
371 _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return __output_.__make_output_iterator(); }388 // _CharT is an implicit lifetime type so can be used without explicit
389 // construction or destruction.
390 _Alloc __alloc;
391 auto __result = std::__allocate_at_least(__alloc, __capacity);
392 std::copy_n(__ptr_, this->__size(), __result.ptr);
393 if (__ptr_ != __small_buffer_)
394 __alloc.deallocate(__ptr_, this->__capacity());
372395
373 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) { __writer_.__flush(__ptr, __n); }396 __ptr_ = __result.ptr;
397 this->__buffer_moved(__ptr_, __result.count);
398 }
374399
375 _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() && {400 _LIBCPP_HIDE_FROM_ABI void __prepare_write(size_t __size_hint) {
376 __output_.__flush();401 __grow_buffer(std::max<size_t>(this->__capacity() + __size_hint, this->__capacity() * 1.6));
377 return std::move(__writer_).__out_it();
378 }402 }
379403
380private:404 _LIBCPP_HIDE_FROM_ABI static void __prepare_write(__output_buffer<_CharT>& __buffer, size_t __size_hint) {
381 _LIBCPP_NO_UNIQUE_ADDRESS _Storage __storage_;405 static_cast<__allocating_buffer<_CharT>&>(__buffer).__prepare_write(__size_hint);
382 __output_buffer<_CharT> __output_;406 }
383 typename __writer_selector<_OutIt, _CharT>::type __writer_;
384};407};
385408
386/// A buffer that counts the number of insertions.409// A buffer that directly writes to the underlying buffer.
387///410template <class _OutIt, __fmt_char_type _CharT>
388/// Since \ref formatted_size only needs to know the size, the output itself is411class _LIBCPP_TEMPLATE_VIS __direct_iterator_buffer : public __output_buffer<_CharT> {
389/// discarded.
390template <__fmt_char_type _CharT>
391class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer {
392public:412public:
393 _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return __output_.__make_output_iterator(); }413 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __direct_iterator_buffer(_OutIt __out_it)
414 : __direct_iterator_buffer{__out_it, nullptr} {}
394415
395 _LIBCPP_HIDE_FROM_ABI void __flush(const _CharT*, size_t __n) { __size_ += __n; }416 [[nodiscard]]
417 _LIBCPP_HIDE_FROM_ABI explicit __direct_iterator_buffer(_OutIt __out_it, __max_output_size* __max_output_size)
418 : __output_buffer<_CharT>{std::__unwrap_iter(__out_it), __buffer_size, __prepare_write, __max_output_size},
419 __out_it_(__out_it) {}
396420
397 _LIBCPP_HIDE_FROM_ABI size_t __result() && {421 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() && { return __out_it_ + this->__size(); }
398 __output_.__flush();
399 return __size_;
400 }
401422
402private:423private:
403 __internal_storage<_CharT> __storage_;424 // The function format_to expects a buffer large enough for the output. The
404 __output_buffer<_CharT> __output_{__storage_.__begin(), __storage_.__buffer_size, this};425 // function format_to_n has its own helper class that restricts the number of
405 size_t __size_{0};426 // write options. So this function class can pretend to have an infinite
406};427 // buffer.
428 static constexpr size_t __buffer_size = -1;
429
430 _OutIt __out_it_;
407431
408/// The base of a buffer that counts and limits the number of insertions.432 _LIBCPP_HIDE_FROM_ABI static void
409template <class _OutIt, __fmt_char_type _CharT, bool>433 __prepare_write([[maybe_unused]] __output_buffer<_CharT>& __buffer, [[maybe_unused]] size_t __size_hint) {
410 requires(output_iterator<_OutIt, const _CharT&>)434 std::__throw_length_error("__direct_iterator_buffer");
411struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base {435 }
412 using _Size = iter_difference_t<_OutIt>;436};
413437
438// A buffer that writes its output to the end of a container.
439template <class _OutIt, __fmt_char_type _CharT>
440class _LIBCPP_TEMPLATE_VIS __container_inserter_buffer : public __output_buffer<_CharT> {
414public:441public:
415 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __max_size)442 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __container_inserter_buffer(_OutIt __out_it)
416 : __writer_(std::move(__out_it)), __max_size_(std::max(_Size(0), __max_size)) {}443 : __container_inserter_buffer{__out_it, nullptr} {}
417444
418 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {445 [[nodiscard]]
419 if (_Size(__size_) <= __max_size_)446 _LIBCPP_HIDE_FROM_ABI explicit __container_inserter_buffer(_OutIt __out_it, __max_output_size* __max_output_size)
420 __writer_.__flush(__ptr, std::min(_Size(__n), __max_size_ - __size_));447 : __output_buffer<_CharT>{__small_buffer_, __buffer_size, __prepare_write, __max_output_size},
421 __size_ += __n;448 __container_{__out_it.__get_container()} {}
449
450 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto __out_it() && {
451 __container_->insert(__container_->end(), __small_buffer_, __small_buffer_ + this->__size());
452 return std::back_inserter(*__container_);
422 }453 }
423454
424protected:455private:
425 __internal_storage<_CharT> __storage_;456 typename __back_insert_iterator_container<_OutIt>::type* __container_;
426 __output_buffer<_CharT> __output_{__storage_.__begin(), __storage_.__buffer_size, this};457
427 typename __writer_selector<_OutIt, _CharT>::type __writer_;458 // This class uses a fixed size buffer and appends the elements in
459 // __buffer_size chunks. An alternative would be to use an allocating buffer
460 // and append the output in a single write operation. Benchmarking showed no
461 // performance difference.
462 static constexpr size_t __buffer_size = 256;
463 _CharT __small_buffer_[__buffer_size];
464
465 _LIBCPP_HIDE_FROM_ABI void __prepare_write() {
466 __container_->insert(__container_->end(), __small_buffer_, __small_buffer_ + this->__size());
467 this->__buffer_flushed();
468 }
428469
429 _Size __max_size_;470 _LIBCPP_HIDE_FROM_ABI static void
430 _Size __size_{0};471 __prepare_write(__output_buffer<_CharT>& __buffer, [[maybe_unused]] size_t __size_hint) {
472 static_cast<__container_inserter_buffer<_OutIt, _CharT>&>(__buffer).__prepare_write();
473 }
431};474};
432475
433/// The base of a buffer that counts and limits the number of insertions.476// A buffer that writes to an iterator.
434///477//
435/// This version is used when \c __enable_direct_output<_OutIt, _CharT> == true.478// Unlike the __container_inserter_buffer this class' performance does benefit
436///479// from allocating and then inserting.
437/// This class limits the size available to the direct writer so it will not
438/// exceed the maximum number of code units.
439template <class _OutIt, __fmt_char_type _CharT>480template <class _OutIt, __fmt_char_type _CharT>
440 requires(output_iterator<_OutIt, const _CharT&>)481class _LIBCPP_TEMPLATE_VIS __iterator_buffer : public __allocating_buffer<_CharT> {
441class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base<_OutIt, _CharT, true> {
442 using _Size = iter_difference_t<_OutIt>;
443
444public:482public:
445 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __max_size)483 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __iterator_buffer(_OutIt __out_it)
446 : __output_(std::__unwrap_iter(__out_it), __max_size, this),484 : __allocating_buffer<_CharT>{}, __out_it_{std::move(__out_it)} {}
447 __writer_(std::move(__out_it)),
448 __max_size_(__max_size) {
449 if (__max_size <= 0) [[unlikely]]
450 __output_.__reset(__storage_.__begin(), __storage_.__buffer_size);
451 }
452485
453 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {486 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __iterator_buffer(_OutIt __out_it, __max_output_size* __max_output_size)
454 // A __flush to the direct writer happens in the following occasions:487 : __allocating_buffer<_CharT>{__max_output_size}, __out_it_{std::move(__out_it)} {}
455 // - The format function has written the maximum number of allowed code
456 // units. At this point it's no longer valid to write to this writer. So
457 // switch to the internal storage. This internal storage doesn't need to
458 // be written anywhere so the __flush for that storage writes no output.
459 // - Like above, but the next "mass write" operation would overflow the
460 // buffer. In that case the buffer is pre-emptively switched. The still
461 // valid code units will be written separately.
462 // - The format_to_n function is finished. In this case there's no need to
463 // switch the buffer, but for simplicity the buffers are still switched.
464 // When the __max_size <= 0 the constructor already switched the buffers.
465 if (__size_ == 0 && __ptr != __storage_.__begin()) {
466 __writer_.__flush(__ptr, __n);
467 __output_.__reset(__storage_.__begin(), __storage_.__buffer_size);
468 } else if (__size_ < __max_size_) {
469 // Copies a part of the internal buffer to the output up to n characters.
470 // See __output_buffer<_CharT>::__flush_on_overflow for more information.
471 _Size __s = std::min(_Size(__n), __max_size_ - __size_);
472 std::copy_n(__ptr, __s, __writer_.__out_it());
473 __writer_.__flush(__ptr, __s);
474 }
475488
476 __size_ += __n;489 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto __out_it() && {
490 return std::ranges::copy(this->__view(), std::move(__out_it_)).out;
477 }491 }
478492
479protected:493private:
480 __internal_storage<_CharT> __storage_;494 _OutIt __out_it_;
481 __output_buffer<_CharT> __output_;495};
482 __writer_direct<_OutIt, _CharT> __writer_;496
497// Selects the type of the buffer used for the output iterator.
498template <class _OutIt, __fmt_char_type _CharT>
499class _LIBCPP_TEMPLATE_VIS __buffer_selector {
500 using _Container _LIBCPP_NODEBUG = __back_insert_iterator_container<_OutIt>::type;
483501
484 _Size __max_size_;502public:
485 _Size __size_{0};503 using type _LIBCPP_NODEBUG =
504 conditional_t<!same_as<_Container, void>,
505 __container_inserter_buffer<_OutIt, _CharT>,
506 conditional_t<__enable_direct_output<_OutIt, _CharT>,
507 __direct_iterator_buffer<_OutIt, _CharT>,
508 __iterator_buffer<_OutIt, _CharT>>>;
486};509};
487510
488/// The buffer that counts and limits the number of insertions.511// A buffer that counts and limits the number of insertions.
489template <class _OutIt, __fmt_char_type _CharT>512template <class _OutIt, __fmt_char_type _CharT>
490 requires(output_iterator<_OutIt, const _CharT&>)513class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer : private __buffer_selector<_OutIt, _CharT>::type {
491struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final514public:
492 : public __format_to_n_buffer_base< _OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>> {515 using _Base _LIBCPP_NODEBUG = __buffer_selector<_OutIt, _CharT>::type;
493 using _Base = __format_to_n_buffer_base<_OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>>;516
494 using _Size = iter_difference_t<_OutIt>;517 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __format_to_n_buffer(_OutIt __out_it, iter_difference_t<_OutIt> __n)
518 : _Base{std::move(__out_it), std::addressof(__max_output_size_)},
519 __max_output_size_{__n < 0 ? size_t{0} : static_cast<size_t>(__n)} {}
520
521 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return _Base::__make_output_iterator(); }
522
523 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __result() && {
524 return {static_cast<_Base&&>(*this).__out_it(),
525 static_cast<iter_difference_t<_OutIt>>(__max_output_size_.__code_units_written())};
526 }
527
528private:
529 __max_output_size __max_output_size_;
530};
495531
532// A buffer that counts the number of insertions.
533//
534// Since formatted_size only needs to know the size, the output itself is
535// discarded.
536template <__fmt_char_type _CharT>
537class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer : private __output_buffer<_CharT> {
496public:538public:
497 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer(_OutIt __out_it, _Size __max_size)539 using _Base _LIBCPP_NODEBUG = __output_buffer<_CharT>;
498 : _Base(std::move(__out_it), __max_size) {}540
499 _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return this->__output_.__make_output_iterator(); }541 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __formatted_size_buffer()
542 : _Base{nullptr, 0, __prepare_write, std::addressof(__max_output_size_)} {}
543
544 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return _Base::__make_output_iterator(); }
545
546 // This function does not need to be r-value qualified, however this is
547 // consistent with similar objects.
548 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __result() && { return __max_output_size_.__code_units_written(); }
549
550private:
551 __max_output_size __max_output_size_{0};
500552
501 _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __result() && {553 _LIBCPP_HIDE_FROM_ABI static void
502 this->__output_.__flush();554 __prepare_write([[maybe_unused]] __output_buffer<_CharT>& __buffer, [[maybe_unused]] size_t __size_hint) {
503 return {std::move(this->__writer_).__out_it(), this->__size_};555 // Note this function does not satisfy the requirement of giving a 1 code unit buffer.
556 _LIBCPP_ASSERT_INTERNAL(
557 false, "Since __max_output_size_.__max_size_ == 0 there should never be call to this function.");
504 }558 }
505};559};
506560
...@@ -524,14 +578,14 @@ public:...@@ -524,14 +578,14 @@ public:
524// would lead to a circular include with formatter for vector<bool>.578// would lead to a circular include with formatter for vector<bool>.
525template <__fmt_char_type _CharT>579template <__fmt_char_type _CharT>
526class _LIBCPP_TEMPLATE_VIS __retarget_buffer {580class _LIBCPP_TEMPLATE_VIS __retarget_buffer {
527 using _Alloc = allocator<_CharT>;581 using _Alloc _LIBCPP_NODEBUG = allocator<_CharT>;
528582
529public:583public:
530 using value_type = _CharT;584 using value_type _LIBCPP_NODEBUG = _CharT;
531585
532 struct __iterator {586 struct __iterator {
533 using difference_type = ptrdiff_t;587 using difference_type _LIBCPP_NODEBUG = ptrdiff_t;
534 using value_type = _CharT;588 using value_type _LIBCPP_NODEBUG = _CharT;
535589
536 _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(__retarget_buffer& __buffer)590 _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(__retarget_buffer& __buffer)
537 : __buffer_(std::addressof(__buffer)) {}591 : __buffer_(std::addressof(__buffer)) {}
...@@ -646,7 +700,7 @@ private:...@@ -646,7 +700,7 @@ private:
646700
647} // namespace __format701} // namespace __format
648702
649#endif //_LIBCPP_STD_VER >= 20703#endif // _LIBCPP_STD_VER >= 20
650704
651_LIBCPP_END_NAMESPACE_STD705_LIBCPP_END_NAMESPACE_STD
652706
lib/libcxx/include/__format/concepts.h+4-4
...@@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
34template <class _CharT>34template <class _CharT>
35concept __fmt_char_type =35concept __fmt_char_type =
36 same_as<_CharT, char>36 same_as<_CharT, char>
37# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS37# if _LIBCPP_HAS_WIDE_CHARACTERS
38 || same_as<_CharT, wchar_t>38 || same_as<_CharT, wchar_t>
39# endif39# endif
40 ;40 ;
...@@ -44,7 +44,7 @@ concept __fmt_char_type =...@@ -44,7 +44,7 @@ concept __fmt_char_type =
44// (Note testing for (w)format_context would be a valid choice, but requires44// (Note testing for (w)format_context would be a valid choice, but requires
45// selecting the proper one depending on the type of _CharT.)45// selecting the proper one depending on the type of _CharT.)
46template <class _CharT>46template <class _CharT>
47using __fmt_iter_for = _CharT*;47using __fmt_iter_for _LIBCPP_NODEBUG = _CharT*;
4848
49template <class _Tp, class _Context, class _Formatter = typename _Context::template formatter_type<remove_const_t<_Tp>>>49template <class _Tp, class _Context, class _Formatter = typename _Context::template formatter_type<remove_const_t<_Tp>>>
50concept __formattable_with =50concept __formattable_with =
...@@ -75,8 +75,8 @@ template <class _Tp>...@@ -75,8 +75,8 @@ template <class _Tp>
75concept __fmt_pair_like =75concept __fmt_pair_like =
76 __is_specialization_v<_Tp, pair> || (__is_specialization_v<_Tp, tuple> && tuple_size_v<_Tp> == 2);76 __is_specialization_v<_Tp, pair> || (__is_specialization_v<_Tp, tuple> && tuple_size_v<_Tp> == 2);
7777
78# endif //_LIBCPP_STD_VER >= 2378# endif // _LIBCPP_STD_VER >= 23
79#endif //_LIBCPP_STD_VER >= 2079#endif // _LIBCPP_STD_VER >= 20
8080
81_LIBCPP_END_NAMESPACE_STD81_LIBCPP_END_NAMESPACE_STD
8282
lib/libcxx/include/__format/container_adaptor.h+3-3
...@@ -37,8 +37,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -37,8 +37,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
37template <class _Adaptor, class _CharT>37template <class _Adaptor, class _CharT>
38struct _LIBCPP_TEMPLATE_VIS __formatter_container_adaptor {38struct _LIBCPP_TEMPLATE_VIS __formatter_container_adaptor {
39private:39private:
40 using __maybe_const_container = __fmt_maybe_const<typename _Adaptor::container_type, _CharT>;40 using __maybe_const_container _LIBCPP_NODEBUG = __fmt_maybe_const<typename _Adaptor::container_type, _CharT>;
41 using __maybe_const_adaptor = __maybe_const<is_const_v<__maybe_const_container>, _Adaptor>;41 using __maybe_const_adaptor _LIBCPP_NODEBUG = __maybe_const<is_const_v<__maybe_const_container>, _Adaptor>;
42 formatter<ranges::ref_view<__maybe_const_container>, _CharT> __underlying_;42 formatter<ranges::ref_view<__maybe_const_container>, _CharT> __underlying_;
4343
44public:44public:
...@@ -66,7 +66,7 @@ template <class _CharT, class _Tp, formattable<_CharT> _Container>...@@ -66,7 +66,7 @@ template <class _CharT, class _Tp, formattable<_CharT> _Container>
66struct _LIBCPP_TEMPLATE_VIS formatter<stack<_Tp, _Container>, _CharT>66struct _LIBCPP_TEMPLATE_VIS formatter<stack<_Tp, _Container>, _CharT>
67 : public __formatter_container_adaptor<stack<_Tp, _Container>, _CharT> {};67 : public __formatter_container_adaptor<stack<_Tp, _Container>, _CharT> {};
6868
69#endif //_LIBCPP_STD_VER >= 2369#endif // _LIBCPP_STD_VER >= 23
7070
71_LIBCPP_END_NAMESPACE_STD71_LIBCPP_END_NAMESPACE_STD
7272
lib/libcxx/include/__format/enable_insertable.h+1-1
...@@ -28,7 +28,7 @@ inline constexpr bool __enable_insertable = false;...@@ -28,7 +28,7 @@ inline constexpr bool __enable_insertable = false;
2828
29} // namespace __format29} // namespace __format
3030
31#endif //_LIBCPP_STD_VER >= 2031#endif // _LIBCPP_STD_VER >= 20
3232
33_LIBCPP_END_NAMESPACE_STD33_LIBCPP_END_NAMESPACE_STD
3434
lib/libcxx/include/__format/escaped_output_table.h+2-2
...@@ -63,7 +63,7 @@...@@ -63,7 +63,7 @@
6363
64#include <__algorithm/ranges_upper_bound.h>64#include <__algorithm/ranges_upper_bound.h>
65#include <__config>65#include <__config>
66#include <cstddef>66#include <__cstddef/ptrdiff_t.h>
67#include <cstdint>67#include <cstdint>
6868
69#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)69#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -856,7 +856,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -856,7 +856,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
856// clang-format on856// clang-format on
857} // namespace __escaped_output_table857} // namespace __escaped_output_table
858858
859#endif //_LIBCPP_STD_VER >= 23859#endif // _LIBCPP_STD_VER >= 23
860860
861_LIBCPP_END_NAMESPACE_STD861_LIBCPP_END_NAMESPACE_STD
862862
lib/libcxx/include/__format/extended_grapheme_cluster_table.h+2-2
...@@ -63,8 +63,8 @@...@@ -63,8 +63,8 @@
6363
64#include <__algorithm/ranges_upper_bound.h>64#include <__algorithm/ranges_upper_bound.h>
65#include <__config>65#include <__config>
66#include <__cstddef/ptrdiff_t.h>
66#include <__iterator/access.h>67#include <__iterator/access.h>
67#include <cstddef>
68#include <cstdint>68#include <cstdint>
6969
70#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)70#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -1656,7 +1656,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -1656,7 +1656,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
16561656
1657} // namespace __extended_grapheme_custer_property_boundary1657} // namespace __extended_grapheme_custer_property_boundary
16581658
1659#endif //_LIBCPP_STD_VER >= 201659#endif // _LIBCPP_STD_VER >= 20
16601660
1661_LIBCPP_END_NAMESPACE_STD1661_LIBCPP_END_NAMESPACE_STD
16621662
lib/libcxx/include/__format/format_arg.h+19-18
...@@ -13,6 +13,7 @@...@@ -13,6 +13,7 @@
13#include <__assert>13#include <__assert>
14#include <__concepts/arithmetic.h>14#include <__concepts/arithmetic.h>
15#include <__config>15#include <__config>
16#include <__cstddef/size_t.h>
16#include <__format/concepts.h>17#include <__format/concepts.h>
17#include <__format/format_parse_context.h>18#include <__format/format_parse_context.h>
18#include <__functional/invoke.h>19#include <__functional/invoke.h>
...@@ -113,7 +114,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_...@@ -113,7 +114,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_
113 case __format::__arg_t::__long_long:114 case __format::__arg_t::__long_long:
114 return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__long_long_);115 return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__long_long_);
115 case __format::__arg_t::__i128:116 case __format::__arg_t::__i128:
116# ifndef _LIBCPP_HAS_NO_INT128117# if _LIBCPP_HAS_INT128
117 return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__i128_);118 return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__i128_);
118# else119# else
119 __libcpp_unreachable();120 __libcpp_unreachable();
...@@ -123,7 +124,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_...@@ -123,7 +124,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_
123 case __format::__arg_t::__unsigned_long_long:124 case __format::__arg_t::__unsigned_long_long:
124 return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_);125 return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_);
125 case __format::__arg_t::__u128:126 case __format::__arg_t::__u128:
126# ifndef _LIBCPP_HAS_NO_INT128127# if _LIBCPP_HAS_INT128
127 return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__u128_);128 return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__u128_);
128# else129# else
129 __libcpp_unreachable();130 __libcpp_unreachable();
...@@ -148,7 +149,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_...@@ -148,7 +149,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_
148 __libcpp_unreachable();149 __libcpp_unreachable();
149}150}
150151
151# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)152# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
152153
153template <class _Rp, class _Visitor, class _Context>154template <class _Rp, class _Visitor, class _Context>
154_LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {155_LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
...@@ -164,7 +165,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<...@@ -164,7 +165,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<
164 case __format::__arg_t::__long_long:165 case __format::__arg_t::__long_long:
165 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__long_long_);166 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__long_long_);
166 case __format::__arg_t::__i128:167 case __format::__arg_t::__i128:
167# ifndef _LIBCPP_HAS_NO_INT128168# if _LIBCPP_HAS_INT128
168 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__i128_);169 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__i128_);
169# else170# else
170 __libcpp_unreachable();171 __libcpp_unreachable();
...@@ -174,7 +175,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<...@@ -174,7 +175,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<
174 case __format::__arg_t::__unsigned_long_long:175 case __format::__arg_t::__unsigned_long_long:
175 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_);176 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_);
176 case __format::__arg_t::__u128:177 case __format::__arg_t::__u128:
177# ifndef _LIBCPP_HAS_NO_INT128178# if _LIBCPP_HAS_INT128
178 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__u128_);179 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__u128_);
179# else180# else
180 __libcpp_unreachable();181 __libcpp_unreachable();
...@@ -199,7 +200,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<...@@ -199,7 +200,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<
199 __libcpp_unreachable();200 __libcpp_unreachable();
200}201}
201202
202# endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)203# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
203204
204/// Contains the values used in basic_format_arg.205/// Contains the values used in basic_format_arg.
205///206///
...@@ -207,7 +208,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<...@@ -207,7 +208,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<
207/// separate arrays.208/// separate arrays.
208template <class _Context>209template <class _Context>
209class __basic_format_arg_value {210class __basic_format_arg_value {
210 using _CharT = typename _Context::char_type;211 using _CharT _LIBCPP_NODEBUG = typename _Context::char_type;
211212
212public:213public:
213 /// Contains the implementation for basic_format_arg::handle.214 /// Contains the implementation for basic_format_arg::handle.
...@@ -237,7 +238,7 @@ public:...@@ -237,7 +238,7 @@ public:
237 unsigned __unsigned_;238 unsigned __unsigned_;
238 long long __long_long_;239 long long __long_long_;
239 unsigned long long __unsigned_long_long_;240 unsigned long long __unsigned_long_long_;
240# ifndef _LIBCPP_HAS_NO_INT128241# if _LIBCPP_HAS_INT128
241 __int128_t __i128_;242 __int128_t __i128_;
242 __uint128_t __u128_;243 __uint128_t __u128_;
243# endif244# endif
...@@ -261,7 +262,7 @@ public:...@@ -261,7 +262,7 @@ public:
261 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long long __value) noexcept : __long_long_(__value) {}262 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long long __value) noexcept : __long_long_(__value) {}
262 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned long long __value) noexcept263 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned long long __value) noexcept
263 : __unsigned_long_long_(__value) {}264 : __unsigned_long_long_(__value) {}
264# ifndef _LIBCPP_HAS_NO_INT128265# if _LIBCPP_HAS_INT128
265 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__int128_t __value) noexcept : __i128_(__value) {}266 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__int128_t __value) noexcept : __i128_(__value) {}
266 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__uint128_t __value) noexcept : __u128_(__value) {}267 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__uint128_t __value) noexcept : __u128_(__value) {}
267# endif268# endif
...@@ -276,7 +277,7 @@ public:...@@ -276,7 +277,7 @@ public:
276};277};
277278
278template <class _Context>279template <class _Context>
279class _LIBCPP_TEMPLATE_VIS basic_format_arg {280class _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS basic_format_arg {
280public:281public:
281 class _LIBCPP_TEMPLATE_VIS handle;282 class _LIBCPP_TEMPLATE_VIS handle;
282283
...@@ -284,14 +285,14 @@ public:...@@ -284,14 +285,14 @@ public:
284285
285 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { return __type_ != __format::__arg_t::__none; }286 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { return __type_ != __format::__arg_t::__none; }
286287
287# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)288# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
288289
289 // This function is user facing, so it must wrap the non-standard types of290 // This function is user facing, so it must wrap the non-standard types of
290 // the "variant" in a handle to stay conforming. See __arg_t for more details.291 // the "variant" in a handle to stay conforming. See __arg_t for more details.
291 template <class _Visitor>292 template <class _Visitor>
292 _LIBCPP_HIDE_FROM_ABI decltype(auto) visit(this basic_format_arg __arg, _Visitor&& __vis) {293 _LIBCPP_HIDE_FROM_ABI decltype(auto) visit(this basic_format_arg __arg, _Visitor&& __vis) {
293 switch (__arg.__type_) {294 switch (__arg.__type_) {
294# ifndef _LIBCPP_HAS_NO_INT128295# if _LIBCPP_HAS_INT128
295 case __format::__arg_t::__i128: {296 case __format::__arg_t::__i128: {
296 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_};297 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_};
297 return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});298 return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
...@@ -312,7 +313,7 @@ public:...@@ -312,7 +313,7 @@ public:
312 template <class _Rp, class _Visitor>313 template <class _Rp, class _Visitor>
313 _LIBCPP_HIDE_FROM_ABI _Rp visit(this basic_format_arg __arg, _Visitor&& __vis) {314 _LIBCPP_HIDE_FROM_ABI _Rp visit(this basic_format_arg __arg, _Visitor&& __vis) {
314 switch (__arg.__type_) {315 switch (__arg.__type_) {
315# ifndef _LIBCPP_HAS_NO_INT128316# if _LIBCPP_HAS_INT128
316 case __format::__arg_t::__i128: {317 case __format::__arg_t::__i128: {
317 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_};318 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_};
318 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});319 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
...@@ -328,7 +329,7 @@ public:...@@ -328,7 +329,7 @@ public:
328 }329 }
329 }330 }
330331
331# endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)332# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
332333
333private:334private:
334 using char_type = typename _Context::char_type;335 using char_type = typename _Context::char_type;
...@@ -370,13 +371,13 @@ private:...@@ -370,13 +371,13 @@ private:
370// This function is user facing, so it must wrap the non-standard types of371// This function is user facing, so it must wrap the non-standard types of
371// the "variant" in a handle to stay conforming. See __arg_t for more details.372// the "variant" in a handle to stay conforming. See __arg_t for more details.
372template <class _Visitor, class _Context>373template <class _Visitor, class _Context>
373# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)374# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
374_LIBCPP_DEPRECATED_IN_CXX26375_LIBCPP_DEPRECATED_IN_CXX26
375# endif376# endif
376 _LIBCPP_HIDE_FROM_ABI decltype(auto)377 _LIBCPP_HIDE_FROM_ABI decltype(auto)
377 visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {378 visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
378 switch (__arg.__type_) {379 switch (__arg.__type_) {
379# ifndef _LIBCPP_HAS_NO_INT128380# if _LIBCPP_HAS_INT128
380 case __format::__arg_t::__i128: {381 case __format::__arg_t::__i128: {
381 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_};382 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_};
382 return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});383 return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
...@@ -386,13 +387,13 @@ _LIBCPP_DEPRECATED_IN_CXX26...@@ -386,13 +387,13 @@ _LIBCPP_DEPRECATED_IN_CXX26
386 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_};387 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_};
387 return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});388 return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
388 }389 }
389# endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)390# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
390 default:391 default:
391 return std::__visit_format_arg(std::forward<_Visitor>(__vis), __arg);392 return std::__visit_format_arg(std::forward<_Visitor>(__vis), __arg);
392 }393 }
393}394}
394395
395#endif //_LIBCPP_STD_VER >= 20396#endif // _LIBCPP_STD_VER >= 20
396397
397_LIBCPP_END_NAMESPACE_STD398_LIBCPP_END_NAMESPACE_STD
398399
lib/libcxx/include/__format/format_arg_store.h+12-6
...@@ -22,6 +22,7 @@...@@ -22,6 +22,7 @@
22#include <__type_traits/conditional.h>22#include <__type_traits/conditional.h>
23#include <__type_traits/extent.h>23#include <__type_traits/extent.h>
24#include <__type_traits/remove_const.h>24#include <__type_traits/remove_const.h>
25#include <cstdint>
25#include <string>26#include <string>
26#include <string_view>27#include <string_view>
2728
...@@ -48,7 +49,7 @@ template <class _Context, same_as<typename _Context::char_type> _Tp>...@@ -48,7 +49,7 @@ template <class _Context, same_as<typename _Context::char_type> _Tp>
48consteval __arg_t __determine_arg_t() {49consteval __arg_t __determine_arg_t() {
49 return __arg_t::__char_type;50 return __arg_t::__char_type;
50}51}
51# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS52# if _LIBCPP_HAS_WIDE_CHARACTERS
52template <class _Context, class _CharT>53template <class _Context, class _CharT>
53 requires(same_as<typename _Context::char_type, wchar_t> && same_as<_CharT, char>)54 requires(same_as<typename _Context::char_type, wchar_t> && same_as<_CharT, char>)
54consteval __arg_t __determine_arg_t() {55consteval __arg_t __determine_arg_t() {
...@@ -63,7 +64,7 @@ consteval __arg_t __determine_arg_t() {...@@ -63,7 +64,7 @@ consteval __arg_t __determine_arg_t() {
63 return __arg_t::__int;64 return __arg_t::__int;
64 else if constexpr (sizeof(_Tp) <= sizeof(long long))65 else if constexpr (sizeof(_Tp) <= sizeof(long long))
65 return __arg_t::__long_long;66 return __arg_t::__long_long;
66# ifndef _LIBCPP_HAS_NO_INT12867# if _LIBCPP_HAS_INT128
67 else if constexpr (sizeof(_Tp) == sizeof(__int128_t))68 else if constexpr (sizeof(_Tp) == sizeof(__int128_t))
68 return __arg_t::__i128;69 return __arg_t::__i128;
69# endif70# endif
...@@ -78,7 +79,7 @@ consteval __arg_t __determine_arg_t() {...@@ -78,7 +79,7 @@ consteval __arg_t __determine_arg_t() {
78 return __arg_t::__unsigned;79 return __arg_t::__unsigned;
79 else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long))80 else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long))
80 return __arg_t::__unsigned_long_long;81 return __arg_t::__unsigned_long_long;
81# ifndef _LIBCPP_HAS_NO_INT12882# if _LIBCPP_HAS_INT128
82 else if constexpr (sizeof(_Tp) == sizeof(__uint128_t))83 else if constexpr (sizeof(_Tp) == sizeof(__uint128_t))
83 return __arg_t::__u128;84 return __arg_t::__u128;
84# endif85# endif
...@@ -172,7 +173,7 @@ _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __valu...@@ -172,7 +173,7 @@ _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __valu
172 // final else requires no adjustment.173 // final else requires no adjustment.
173 if constexpr (__arg == __arg_t::__char_type)174 if constexpr (__arg == __arg_t::__char_type)
174175
175# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS176# if _LIBCPP_HAS_WIDE_CHARACTERS
176 if constexpr (same_as<typename _Context::char_type, wchar_t> && same_as<_Dp, char>)177 if constexpr (same_as<typename _Context::char_type, wchar_t> && same_as<_Dp, char>)
177 return basic_format_arg<_Context>{__arg, static_cast<wchar_t>(static_cast<unsigned char>(__value))};178 return basic_format_arg<_Context>{__arg, static_cast<wchar_t>(static_cast<unsigned char>(__value))};
178 else179 else
...@@ -233,6 +234,11 @@ struct __packed_format_arg_store {...@@ -233,6 +234,11 @@ struct __packed_format_arg_store {
233 uint64_t __types_ = 0;234 uint64_t __types_ = 0;
234};235};
235236
237template <class _Context>
238struct __packed_format_arg_store<_Context, 0> {
239 uint64_t __types_ = 0;
240};
241
236template <class _Context, size_t _Np>242template <class _Context, size_t _Np>
237struct __unpacked_format_arg_store {243struct __unpacked_format_arg_store {
238 basic_format_arg<_Context> __args_[_Np];244 basic_format_arg<_Context> __args_[_Np];
...@@ -251,7 +257,7 @@ struct _LIBCPP_TEMPLATE_VIS __format_arg_store {...@@ -251,7 +257,7 @@ struct _LIBCPP_TEMPLATE_VIS __format_arg_store {
251 }257 }
252 }258 }
253259
254 using _Storage =260 using _Storage _LIBCPP_NODEBUG =
255 conditional_t<__format::__use_packed_format_arg_store(sizeof...(_Args)),261 conditional_t<__format::__use_packed_format_arg_store(sizeof...(_Args)),
256 __format::__packed_format_arg_store<_Context, sizeof...(_Args)>,262 __format::__packed_format_arg_store<_Context, sizeof...(_Args)>,
257 __format::__unpacked_format_arg_store<_Context, sizeof...(_Args)>>;263 __format::__unpacked_format_arg_store<_Context, sizeof...(_Args)>>;
...@@ -259,7 +265,7 @@ struct _LIBCPP_TEMPLATE_VIS __format_arg_store {...@@ -259,7 +265,7 @@ struct _LIBCPP_TEMPLATE_VIS __format_arg_store {
259 _Storage __storage;265 _Storage __storage;
260};266};
261267
262#endif //_LIBCPP_STD_VER >= 20268#endif // _LIBCPP_STD_VER >= 20
263269
264_LIBCPP_END_NAMESPACE_STD270_LIBCPP_END_NAMESPACE_STD
265271
lib/libcxx/include/__format/format_args.h+2-2
...@@ -11,10 +11,10 @@...@@ -11,10 +11,10 @@
11#define _LIBCPP___FORMAT_FORMAT_ARGS_H11#define _LIBCPP___FORMAT_FORMAT_ARGS_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/size_t.h>
14#include <__format/format_arg.h>15#include <__format/format_arg.h>
15#include <__format/format_arg_store.h>16#include <__format/format_arg_store.h>
16#include <__fwd/format.h>17#include <__fwd/format.h>
17#include <cstddef>
18#include <cstdint>18#include <cstdint>
1919
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -71,7 +71,7 @@ private:...@@ -71,7 +71,7 @@ private:
71template <class _Context, class... _Args>71template <class _Context, class... _Args>
72basic_format_args(__format_arg_store<_Context, _Args...>) -> basic_format_args<_Context>;72basic_format_args(__format_arg_store<_Context, _Args...>) -> basic_format_args<_Context>;
7373
74#endif //_LIBCPP_STD_VER >= 2074#endif // _LIBCPP_STD_VER >= 20
7575
76_LIBCPP_END_NAMESPACE_STD76_LIBCPP_END_NAMESPACE_STD
7777
lib/libcxx/include/__format/format_context.h+12-12
...@@ -23,9 +23,8 @@...@@ -23,9 +23,8 @@
23#include <__memory/addressof.h>23#include <__memory/addressof.h>
24#include <__utility/move.h>24#include <__utility/move.h>
25#include <__variant/monostate.h>25#include <__variant/monostate.h>
26#include <cstddef>
2726
28#ifndef _LIBCPP_HAS_NO_LOCALIZATION27#if _LIBCPP_HAS_LOCALIZATION
29# include <__locale>28# include <__locale>
30# include <optional>29# include <optional>
31#endif30#endif
...@@ -45,7 +44,7 @@ template <class _OutIt, class _CharT>...@@ -45,7 +44,7 @@ template <class _OutIt, class _CharT>
45 requires output_iterator<_OutIt, const _CharT&>44 requires output_iterator<_OutIt, const _CharT&>
46class _LIBCPP_TEMPLATE_VIS basic_format_context;45class _LIBCPP_TEMPLATE_VIS basic_format_context;
4746
48# ifndef _LIBCPP_HAS_NO_LOCALIZATION47# if _LIBCPP_HAS_LOCALIZATION
49/**48/**
50 * Helper to create a basic_format_context.49 * Helper to create a basic_format_context.
51 *50 *
...@@ -67,7 +66,7 @@ __format_context_create(_OutIt __out_it, basic_format_args<basic_format_context<...@@ -67,7 +66,7 @@ __format_context_create(_OutIt __out_it, basic_format_args<basic_format_context<
67# endif66# endif
6867
69using format_context = basic_format_context<back_insert_iterator<__format::__output_buffer<char>>, char>;68using format_context = basic_format_context<back_insert_iterator<__format::__output_buffer<char>>, char>;
70# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS69# if _LIBCPP_HAS_WIDE_CHARACTERS
71using wformat_context = basic_format_context< back_insert_iterator<__format::__output_buffer<wchar_t>>, wchar_t>;70using wformat_context = basic_format_context< back_insert_iterator<__format::__output_buffer<wchar_t>>, wchar_t>;
72# endif71# endif
7372
...@@ -89,7 +88,7 @@ public:...@@ -89,7 +88,7 @@ public:
89 _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> arg(size_t __id) const noexcept {88 _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> arg(size_t __id) const noexcept {
90 return __args_.get(__id);89 return __args_.get(__id);
91 }90 }
92# ifndef _LIBCPP_HAS_NO_LOCALIZATION91# if _LIBCPP_HAS_LOCALIZATION
93 _LIBCPP_HIDE_FROM_ABI std::locale locale() {92 _LIBCPP_HIDE_FROM_ABI std::locale locale() {
94 if (!__loc_)93 if (!__loc_)
95 __loc_ = std::locale{};94 __loc_ = std::locale{};
...@@ -102,7 +101,7 @@ public:...@@ -102,7 +101,7 @@ public:
102private:101private:
103 iterator __out_it_;102 iterator __out_it_;
104 basic_format_args<basic_format_context> __args_;103 basic_format_args<basic_format_context> __args_;
105# ifndef _LIBCPP_HAS_NO_LOCALIZATION104# if _LIBCPP_HAS_LOCALIZATION
106105
107 // The Standard doesn't specify how the locale is stored.106 // The Standard doesn't specify how the locale is stored.
108 // [format.context]/6107 // [format.context]/6
...@@ -132,6 +131,7 @@ private:...@@ -132,6 +131,7 @@ private:
132 : __out_it_(std::move(__out_it)), __args_(__args) {}131 : __out_it_(std::move(__out_it)), __args_(__args) {}
133# endif132# endif
134133
134public:
135 basic_format_context(const basic_format_context&) = delete;135 basic_format_context(const basic_format_context&) = delete;
136 basic_format_context& operator=(const basic_format_context&) = delete;136 basic_format_context& operator=(const basic_format_context&) = delete;
137};137};
...@@ -163,7 +163,7 @@ public:...@@ -163,7 +163,7 @@ public:
163 template <class _Context>163 template <class _Context>
164 _LIBCPP_HIDE_FROM_ABI explicit basic_format_context(iterator __out_it, _Context& __ctx)164 _LIBCPP_HIDE_FROM_ABI explicit basic_format_context(iterator __out_it, _Context& __ctx)
165 : __out_it_(std::move(__out_it)),165 : __out_it_(std::move(__out_it)),
166# ifndef _LIBCPP_HAS_NO_LOCALIZATION166# if _LIBCPP_HAS_LOCALIZATION
167 __loc_([](void* __c) { return static_cast<_Context*>(__c)->locale(); }),167 __loc_([](void* __c) { return static_cast<_Context*>(__c)->locale(); }),
168# endif168# endif
169 __ctx_(std::addressof(__ctx)),169 __ctx_(std::addressof(__ctx)),
...@@ -180,20 +180,20 @@ public:...@@ -180,20 +180,20 @@ public:
180 __format::__determine_arg_t<basic_format_context, decltype(__arg)>(),180 __format::__determine_arg_t<basic_format_context, decltype(__arg)>(),
181 __basic_format_arg_value<basic_format_context>(__arg)};181 __basic_format_arg_value<basic_format_context>(__arg)};
182 };182 };
183# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)183# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
184 return static_cast<_Context*>(__c)->arg(__id).visit(std::move(__visitor));184 return static_cast<_Context*>(__c)->arg(__id).visit(std::move(__visitor));
185# else185# else
186 _LIBCPP_SUPPRESS_DEPRECATED_PUSH186 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
187 return std::visit_format_arg(std::move(__visitor), static_cast<_Context*>(__c)->arg(__id));187 return std::visit_format_arg(std::move(__visitor), static_cast<_Context*>(__c)->arg(__id));
188 _LIBCPP_SUPPRESS_DEPRECATED_POP188 _LIBCPP_SUPPRESS_DEPRECATED_POP
189# endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)189# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
190 }) {190 }) {
191 }191 }
192192
193 _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> arg(size_t __id) const noexcept {193 _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> arg(size_t __id) const noexcept {
194 return __arg_(__ctx_, __id);194 return __arg_(__ctx_, __id);
195 }195 }
196# ifndef _LIBCPP_HAS_NO_LOCALIZATION196# if _LIBCPP_HAS_LOCALIZATION
197 _LIBCPP_HIDE_FROM_ABI std::locale locale() { return __loc_(__ctx_); }197 _LIBCPP_HIDE_FROM_ABI std::locale locale() { return __loc_(__ctx_); }
198# endif198# endif
199 _LIBCPP_HIDE_FROM_ABI iterator out() { return std::move(__out_it_); }199 _LIBCPP_HIDE_FROM_ABI iterator out() { return std::move(__out_it_); }
...@@ -202,7 +202,7 @@ public:...@@ -202,7 +202,7 @@ public:
202private:202private:
203 iterator __out_it_;203 iterator __out_it_;
204204
205# ifndef _LIBCPP_HAS_NO_LOCALIZATION205# if _LIBCPP_HAS_LOCALIZATION
206 std::locale (*__loc_)(void* __ctx);206 std::locale (*__loc_)(void* __ctx);
207# endif207# endif
208208
...@@ -211,7 +211,7 @@ private:...@@ -211,7 +211,7 @@ private:
211};211};
212212
213_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_context);213_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_context);
214#endif //_LIBCPP_STD_VER >= 20214#endif // _LIBCPP_STD_VER >= 20
215215
216_LIBCPP_END_NAMESPACE_STD216_LIBCPP_END_NAMESPACE_STD
217217
lib/libcxx/include/__format/format_error.h+3-3
...@@ -35,15 +35,15 @@ public:...@@ -35,15 +35,15 @@ public:
35};35};
36_LIBCPP_DIAGNOSTIC_POP36_LIBCPP_DIAGNOSTIC_POP
3737
38_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_format_error(const char* __s) {38[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_format_error(const char* __s) {
39# ifndef _LIBCPP_HAS_NO_EXCEPTIONS39# if _LIBCPP_HAS_EXCEPTIONS
40 throw format_error(__s);40 throw format_error(__s);
41# else41# else
42 _LIBCPP_VERBOSE_ABORT("format_error was thrown in -fno-exceptions mode with message \"%s\"", __s);42 _LIBCPP_VERBOSE_ABORT("format_error was thrown in -fno-exceptions mode with message \"%s\"", __s);
43# endif43# endif
44}44}
4545
46#endif //_LIBCPP_STD_VER >= 2046#endif // _LIBCPP_STD_VER >= 20
4747
48_LIBCPP_END_NAMESPACE_STD48_LIBCPP_END_NAMESPACE_STD
4949
lib/libcxx/include/__format/format_functions.h+38-39
...@@ -31,7 +31,6 @@...@@ -31,7 +31,6 @@
31#include <__format/formatter_pointer.h>31#include <__format/formatter_pointer.h>
32#include <__format/formatter_string.h>32#include <__format/formatter_string.h>
33#include <__format/parser_std_format_spec.h>33#include <__format/parser_std_format_spec.h>
34#include <__iterator/back_insert_iterator.h>
35#include <__iterator/concepts.h>34#include <__iterator/concepts.h>
36#include <__iterator/incrementable_traits.h>35#include <__iterator/incrementable_traits.h>
37#include <__iterator/iterator_traits.h> // iter_value_t36#include <__iterator/iterator_traits.h> // iter_value_t
...@@ -40,7 +39,7 @@...@@ -40,7 +39,7 @@
40#include <string>39#include <string>
41#include <string_view>40#include <string_view>
4241
43#ifndef _LIBCPP_HAS_NO_LOCALIZATION42#if _LIBCPP_HAS_LOCALIZATION
44# include <__locale>43# include <__locale>
45#endif44#endif
4645
...@@ -61,7 +60,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -61,7 +60,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
61// to do this optimization now.60// to do this optimization now.
6261
63using format_args = basic_format_args<format_context>;62using format_args = basic_format_args<format_context>;
64# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS63# if _LIBCPP_HAS_WIDE_CHARACTERS
65using wformat_args = basic_format_args<wformat_context>;64using wformat_args = basic_format_args<wformat_context>;
66# endif65# endif
6766
...@@ -70,7 +69,7 @@ template <class _Context = format_context, class... _Args>...@@ -70,7 +69,7 @@ template <class _Context = format_context, class... _Args>
70 return std::__format_arg_store<_Context, _Args...>(__args...);69 return std::__format_arg_store<_Context, _Args...>(__args...);
71}70}
7271
73# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS72# if _LIBCPP_HAS_WIDE_CHARACTERS
74template <class... _Args>73template <class... _Args>
75[[nodiscard]] _LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&... __args) {74[[nodiscard]] _LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&... __args) {
76 return std::__format_arg_store<wformat_context, _Args...>(__args...);75 return std::__format_arg_store<wformat_context, _Args...>(__args...);
...@@ -206,7 +205,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg(...@@ -206,7 +205,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg(
206 case __arg_t::__long_long:205 case __arg_t::__long_long:
207 return __format::__compile_time_validate_argument<_CharT, long long>(__parse_ctx, __ctx);206 return __format::__compile_time_validate_argument<_CharT, long long>(__parse_ctx, __ctx);
208 case __arg_t::__i128:207 case __arg_t::__i128:
209# ifndef _LIBCPP_HAS_NO_INT128208# if _LIBCPP_HAS_INT128
210 return __format::__compile_time_validate_argument<_CharT, __int128_t>(__parse_ctx, __ctx);209 return __format::__compile_time_validate_argument<_CharT, __int128_t>(__parse_ctx, __ctx);
211# else210# else
212 std::__throw_format_error("Invalid argument");211 std::__throw_format_error("Invalid argument");
...@@ -217,7 +216,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg(...@@ -217,7 +216,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg(
217 case __arg_t::__unsigned_long_long:216 case __arg_t::__unsigned_long_long:
218 return __format::__compile_time_validate_argument<_CharT, unsigned long long>(__parse_ctx, __ctx);217 return __format::__compile_time_validate_argument<_CharT, unsigned long long>(__parse_ctx, __ctx);
219 case __arg_t::__u128:218 case __arg_t::__u128:
220# ifndef _LIBCPP_HAS_NO_INT128219# if _LIBCPP_HAS_INT128
221 return __format::__compile_time_validate_argument<_CharT, __uint128_t>(__parse_ctx, __ctx);220 return __format::__compile_time_validate_argument<_CharT, __uint128_t>(__parse_ctx, __ctx);
222# else221# else
223 std::__throw_format_error("Invalid argument");222 std::__throw_format_error("Invalid argument");
...@@ -355,12 +354,12 @@ public:...@@ -355,12 +354,12 @@ public:
355};354};
356355
357_LIBCPP_HIDE_FROM_ABI inline __runtime_format_string<char> runtime_format(string_view __fmt) noexcept { return __fmt; }356_LIBCPP_HIDE_FROM_ABI inline __runtime_format_string<char> runtime_format(string_view __fmt) noexcept { return __fmt; }
358# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS357# if _LIBCPP_HAS_WIDE_CHARACTERS
359_LIBCPP_HIDE_FROM_ABI inline __runtime_format_string<wchar_t> runtime_format(wstring_view __fmt) noexcept {358_LIBCPP_HIDE_FROM_ABI inline __runtime_format_string<wchar_t> runtime_format(wstring_view __fmt) noexcept {
360 return __fmt;359 return __fmt;
361}360}
362# endif361# endif
363# endif //_LIBCPP_STD_VER >= 26362# endif // _LIBCPP_STD_VER >= 26
364363
365template <class _CharT, class... _Args>364template <class _CharT, class... _Args>
366struct _LIBCPP_TEMPLATE_VIS basic_format_string {365struct _LIBCPP_TEMPLATE_VIS basic_format_string {
...@@ -379,7 +378,7 @@ struct _LIBCPP_TEMPLATE_VIS basic_format_string {...@@ -379,7 +378,7 @@ struct _LIBCPP_TEMPLATE_VIS basic_format_string {
379private:378private:
380 basic_string_view<_CharT> __str_;379 basic_string_view<_CharT> __str_;
381380
382 using _Context = __format::__compile_time_basic_format_context<_CharT>;381 using _Context _LIBCPP_NODEBUG = __format::__compile_time_basic_format_context<_CharT>;
383382
384 static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{383 static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{
385 __format::__determine_arg_t<_Context, remove_cvref_t<_Args>>()...};384 __format::__determine_arg_t<_Context, remove_cvref_t<_Args>>()...};
...@@ -397,7 +396,7 @@ private:...@@ -397,7 +396,7 @@ private:
397template <class... _Args>396template <class... _Args>
398using format_string = basic_format_string<char, type_identity_t<_Args>...>;397using format_string = basic_format_string<char, type_identity_t<_Args>...>;
399398
400# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS399# if _LIBCPP_HAS_WIDE_CHARACTERS
401template <class... _Args>400template <class... _Args>
402using wformat_string = basic_format_string<wchar_t, type_identity_t<_Args>...>;401using wformat_string = basic_format_string<wchar_t, type_identity_t<_Args>...>;
403# endif402# endif
...@@ -411,7 +410,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __vformat_to(_OutIt __out_it,...@@ -411,7 +410,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __vformat_to(_OutIt __out_it,
411 return std::__format::__vformat_to(410 return std::__format::__vformat_to(
412 basic_format_parse_context{__fmt, __args.__size()}, std::__format_context_create(std::move(__out_it), __args));411 basic_format_parse_context{__fmt, __args.__size()}, std::__format_context_create(std::move(__out_it), __args));
413 else {412 else {
414 __format::__format_buffer<_OutIt, _CharT> __buffer{std::move(__out_it)};413 typename __format::__buffer_selector<_OutIt, _CharT>::type __buffer{std::move(__out_it)};
415 std::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},414 std::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
416 std::__format_context_create(__buffer.__make_output_iterator(), __args));415 std::__format_context_create(__buffer.__make_output_iterator(), __args));
417 return std::move(__buffer).__out_it();416 return std::move(__buffer).__out_it();
...@@ -426,7 +425,7 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt vformat_to(_OutIt __out_it, s...@@ -426,7 +425,7 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt vformat_to(_OutIt __out_it, s
426 return std::__vformat_to(std::move(__out_it), __fmt, __args);425 return std::__vformat_to(std::move(__out_it), __fmt, __args);
427}426}
428427
429# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS428# if _LIBCPP_HAS_WIDE_CHARACTERS
430template <output_iterator<const wchar_t&> _OutIt>429template <output_iterator<const wchar_t&> _OutIt>
431_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt430_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt
432vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) {431vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) {
...@@ -440,7 +439,7 @@ format_to(_OutIt __out_it, format_string<_Args...> __fmt, _Args&&... __args) {...@@ -440,7 +439,7 @@ format_to(_OutIt __out_it, format_string<_Args...> __fmt, _Args&&... __args) {
440 return std::vformat_to(std::move(__out_it), __fmt.get(), std::make_format_args(__args...));439 return std::vformat_to(std::move(__out_it), __fmt.get(), std::make_format_args(__args...));
441}440}
442441
443# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS442# if _LIBCPP_HAS_WIDE_CHARACTERS
444template <output_iterator<const wchar_t&> _OutIt, class... _Args>443template <output_iterator<const wchar_t&> _OutIt, class... _Args>
445_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt444_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt
446format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {445format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {
...@@ -452,20 +451,20 @@ format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {...@@ -452,20 +451,20 @@ format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {
452// fires too eagerly, see http://llvm.org/PR61563.451// fires too eagerly, see http://llvm.org/PR61563.
453template <class = void>452template <class = void>
454[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string vformat(string_view __fmt, format_args __args) {453[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string vformat(string_view __fmt, format_args __args) {
455 string __res;454 __format::__allocating_buffer<char> __buffer;
456 std::vformat_to(std::back_inserter(__res), __fmt, __args);455 std::vformat_to(__buffer.__make_output_iterator(), __fmt, __args);
457 return __res;456 return string{__buffer.__view()};
458}457}
459458
460# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS459# if _LIBCPP_HAS_WIDE_CHARACTERS
461// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup460// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup
462// fires too eagerly, see http://llvm.org/PR61563.461// fires too eagerly, see http://llvm.org/PR61563.
463template <class = void>462template <class = void>
464[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring463[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring
465vformat(wstring_view __fmt, wformat_args __args) {464vformat(wstring_view __fmt, wformat_args __args) {
466 wstring __res;465 __format::__allocating_buffer<wchar_t> __buffer;
467 std::vformat_to(std::back_inserter(__res), __fmt, __args);466 std::vformat_to(__buffer.__make_output_iterator(), __fmt, __args);
468 return __res;467 return wstring{__buffer.__view()};
469}468}
470# endif469# endif
471470
...@@ -475,7 +474,7 @@ format(format_string<_Args...> __fmt, _Args&&... __args) {...@@ -475,7 +474,7 @@ format(format_string<_Args...> __fmt, _Args&&... __args) {
475 return std::vformat(__fmt.get(), std::make_format_args(__args...));474 return std::vformat(__fmt.get(), std::make_format_args(__args...));
476}475}
477476
478# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS477# if _LIBCPP_HAS_WIDE_CHARACTERS
479template <class... _Args>478template <class... _Args>
480[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring479[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring
481format(wformat_string<_Args...> __fmt, _Args&&... __args) {480format(wformat_string<_Args...> __fmt, _Args&&... __args) {
...@@ -501,7 +500,7 @@ format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, format_string<_Args....@@ -501,7 +500,7 @@ format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, format_string<_Args.
501 return std::__vformat_to_n<format_context>(std::move(__out_it), __n, __fmt.get(), std::make_format_args(__args...));500 return std::__vformat_to_n<format_context>(std::move(__out_it), __n, __fmt.get(), std::make_format_args(__args...));
502}501}
503502
504# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS503# if _LIBCPP_HAS_WIDE_CHARACTERS
505template <output_iterator<const wchar_t&> _OutIt, class... _Args>504template <output_iterator<const wchar_t&> _OutIt, class... _Args>
506_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt>505_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt>
507format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wformat_string<_Args...> __fmt, _Args&&... __args) {506format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wformat_string<_Args...> __fmt, _Args&&... __args) {
...@@ -523,7 +522,7 @@ formatted_size(format_string<_Args...> __fmt, _Args&&... __args) {...@@ -523,7 +522,7 @@ formatted_size(format_string<_Args...> __fmt, _Args&&... __args) {
523 return std::__vformatted_size(__fmt.get(), basic_format_args{std::make_format_args(__args...)});522 return std::__vformatted_size(__fmt.get(), basic_format_args{std::make_format_args(__args...)});
524}523}
525524
526# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS525# if _LIBCPP_HAS_WIDE_CHARACTERS
527template <class... _Args>526template <class... _Args>
528[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t527[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
529formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) {528formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) {
...@@ -531,7 +530,7 @@ formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) {...@@ -531,7 +530,7 @@ formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) {
531}530}
532# endif531# endif
533532
534# ifndef _LIBCPP_HAS_NO_LOCALIZATION533# if _LIBCPP_HAS_LOCALIZATION
535534
536template <class _OutIt, class _CharT, class _FormatOutIt>535template <class _OutIt, class _CharT, class _FormatOutIt>
537 requires(output_iterator<_OutIt, const _CharT&>)536 requires(output_iterator<_OutIt, const _CharT&>)
...@@ -544,7 +543,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __vformat_to(...@@ -544,7 +543,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __vformat_to(
544 return std::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},543 return std::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
545 std::__format_context_create(std::move(__out_it), __args, std::move(__loc)));544 std::__format_context_create(std::move(__out_it), __args, std::move(__loc)));
546 else {545 else {
547 __format::__format_buffer<_OutIt, _CharT> __buffer{std::move(__out_it)};546 typename __format::__buffer_selector<_OutIt, _CharT>::type __buffer{std::move(__out_it)};
548 std::__format::__vformat_to(547 std::__format::__vformat_to(
549 basic_format_parse_context{__fmt, __args.__size()},548 basic_format_parse_context{__fmt, __args.__size()},
550 std::__format_context_create(__buffer.__make_output_iterator(), __args, std::move(__loc)));549 std::__format_context_create(__buffer.__make_output_iterator(), __args, std::move(__loc)));
...@@ -558,7 +557,7 @@ vformat_to(_OutIt __out_it, locale __loc, string_view __fmt, format_args __args)...@@ -558,7 +557,7 @@ vformat_to(_OutIt __out_it, locale __loc, string_view __fmt, format_args __args)
558 return std::__vformat_to(std::move(__out_it), std::move(__loc), __fmt, __args);557 return std::__vformat_to(std::move(__out_it), std::move(__loc), __fmt, __args);
559}558}
560559
561# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS560# if _LIBCPP_HAS_WIDE_CHARACTERS
562template <output_iterator<const wchar_t&> _OutIt>561template <output_iterator<const wchar_t&> _OutIt>
563_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt562_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt
564vformat_to(_OutIt __out_it, locale __loc, wstring_view __fmt, wformat_args __args) {563vformat_to(_OutIt __out_it, locale __loc, wstring_view __fmt, wformat_args __args) {
...@@ -572,7 +571,7 @@ format_to(_OutIt __out_it, locale __loc, format_string<_Args...> __fmt, _Args&&....@@ -572,7 +571,7 @@ format_to(_OutIt __out_it, locale __loc, format_string<_Args...> __fmt, _Args&&.
572 return std::vformat_to(std::move(__out_it), std::move(__loc), __fmt.get(), std::make_format_args(__args...));571 return std::vformat_to(std::move(__out_it), std::move(__loc), __fmt.get(), std::make_format_args(__args...));
573}572}
574573
575# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS574# if _LIBCPP_HAS_WIDE_CHARACTERS
576template <output_iterator<const wchar_t&> _OutIt, class... _Args>575template <output_iterator<const wchar_t&> _OutIt, class... _Args>
577_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt576_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt
578format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {577format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
...@@ -585,20 +584,20 @@ format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&...@@ -585,20 +584,20 @@ format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&
585template <class = void>584template <class = void>
586[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string585[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string
587vformat(locale __loc, string_view __fmt, format_args __args) {586vformat(locale __loc, string_view __fmt, format_args __args) {
588 string __res;587 __format::__allocating_buffer<char> __buffer;
589 std::vformat_to(std::back_inserter(__res), std::move(__loc), __fmt, __args);588 std::vformat_to(__buffer.__make_output_iterator(), std::move(__loc), __fmt, __args);
590 return __res;589 return string{__buffer.__view()};
591}590}
592591
593# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS592# if _LIBCPP_HAS_WIDE_CHARACTERS
594// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup593// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup
595// fires too eagerly, see http://llvm.org/PR61563.594// fires too eagerly, see http://llvm.org/PR61563.
596template <class = void>595template <class = void>
597[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring596[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring
598vformat(locale __loc, wstring_view __fmt, wformat_args __args) {597vformat(locale __loc, wstring_view __fmt, wformat_args __args) {
599 wstring __res;598 __format::__allocating_buffer<wchar_t> __buffer;
600 std::vformat_to(std::back_inserter(__res), std::move(__loc), __fmt, __args);599 std::vformat_to(__buffer.__make_output_iterator(), std::move(__loc), __fmt, __args);
601 return __res;600 return wstring{__buffer.__view()};
602}601}
603# endif602# endif
604603
...@@ -608,7 +607,7 @@ format(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {...@@ -608,7 +607,7 @@ format(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
608 return std::vformat(std::move(__loc), __fmt.get(), std::make_format_args(__args...));607 return std::vformat(std::move(__loc), __fmt.get(), std::make_format_args(__args...));
609}608}
610609
611# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS610# if _LIBCPP_HAS_WIDE_CHARACTERS
612template <class... _Args>611template <class... _Args>
613[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring612[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring
614format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {613format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
...@@ -637,7 +636,7 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> format_to...@@ -637,7 +636,7 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> format_to
637 std::move(__out_it), __n, std::move(__loc), __fmt.get(), std::make_format_args(__args...));636 std::move(__out_it), __n, std::move(__loc), __fmt.get(), std::make_format_args(__args...));
638}637}
639638
640# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS639# if _LIBCPP_HAS_WIDE_CHARACTERS
641template <output_iterator<const wchar_t&> _OutIt, class... _Args>640template <output_iterator<const wchar_t&> _OutIt, class... _Args>
642_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> format_to_n(641_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> format_to_n(
643 _OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {642 _OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
...@@ -661,7 +660,7 @@ formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {...@@ -661,7 +660,7 @@ formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
661 return std::__vformatted_size(std::move(__loc), __fmt.get(), basic_format_args{std::make_format_args(__args...)});660 return std::__vformatted_size(std::move(__loc), __fmt.get(), basic_format_args{std::make_format_args(__args...)});
662}661}
663662
664# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS663# if _LIBCPP_HAS_WIDE_CHARACTERS
665template <class... _Args>664template <class... _Args>
666[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t665[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
667formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {666formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
...@@ -669,9 +668,9 @@ formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args)...@@ -669,9 +668,9 @@ formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args)
669}668}
670# endif669# endif
671670
672# endif // _LIBCPP_HAS_NO_LOCALIZATION671# endif // _LIBCPP_HAS_LOCALIZATION
673672
674#endif //_LIBCPP_STD_VER >= 20673#endif // _LIBCPP_STD_VER >= 20
675674
676_LIBCPP_END_NAMESPACE_STD675_LIBCPP_END_NAMESPACE_STD
677676
lib/libcxx/include/__format/format_parse_context.h+2-2
...@@ -94,11 +94,11 @@ private:...@@ -94,11 +94,11 @@ private:
94_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_parse_context);94_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_parse_context);
9595
96using format_parse_context = basic_format_parse_context<char>;96using format_parse_context = basic_format_parse_context<char>;
97# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS97# if _LIBCPP_HAS_WIDE_CHARACTERS
98using wformat_parse_context = basic_format_parse_context<wchar_t>;98using wformat_parse_context = basic_format_parse_context<wchar_t>;
99# endif99# endif
100100
101#endif //_LIBCPP_STD_VER >= 20101#endif // _LIBCPP_STD_VER >= 20
102102
103_LIBCPP_END_NAMESPACE_STD103_LIBCPP_END_NAMESPACE_STD
104104
lib/libcxx/include/__format/format_string.h+2-2
...@@ -12,10 +12,10 @@...@@ -12,10 +12,10 @@
1212
13#include <__assert>13#include <__assert>
14#include <__config>14#include <__config>
15#include <__cstddef/size_t.h>
15#include <__format/format_error.h>16#include <__format/format_error.h>
16#include <__iterator/concepts.h>17#include <__iterator/concepts.h>
17#include <__iterator/iterator_traits.h> // iter_value_t18#include <__iterator/iterator_traits.h> // iter_value_t
18#include <cstddef>
19#include <cstdint>19#include <cstdint>
2020
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -153,7 +153,7 @@ __parse_arg_id(_Iterator __begin, _Iterator __end, auto& __parse_ctx) {...@@ -153,7 +153,7 @@ __parse_arg_id(_Iterator __begin, _Iterator __end, auto& __parse_ctx) {
153153
154} // namespace __format154} // namespace __format
155155
156#endif //_LIBCPP_STD_VER >= 20156#endif // _LIBCPP_STD_VER >= 20
157157
158_LIBCPP_END_NAMESPACE_STD158_LIBCPP_END_NAMESPACE_STD
159159
lib/libcxx/include/__format/format_to_n_result.h+1-1
...@@ -28,7 +28,7 @@ struct _LIBCPP_TEMPLATE_VIS format_to_n_result {...@@ -28,7 +28,7 @@ struct _LIBCPP_TEMPLATE_VIS format_to_n_result {
28};28};
29_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(format_to_n_result);29_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(format_to_n_result);
3030
31#endif //_LIBCPP_STD_VER >= 2031#endif // _LIBCPP_STD_VER >= 20
3232
33_LIBCPP_END_NAMESPACE_STD33_LIBCPP_END_NAMESPACE_STD
3434
lib/libcxx/include/__format/formatter.h+3
...@@ -39,6 +39,9 @@ struct _LIBCPP_TEMPLATE_VIS formatter {...@@ -39,6 +39,9 @@ struct _LIBCPP_TEMPLATE_VIS formatter {
3939
40# if _LIBCPP_STD_VER >= 2340# if _LIBCPP_STD_VER >= 23
4141
42template <class _Tp>
43constexpr bool enable_nonlocking_formatter_optimization = false;
44
42template <class _Tp>45template <class _Tp>
43_LIBCPP_HIDE_FROM_ABI constexpr void __set_debug_format(_Tp& __formatter) {46_LIBCPP_HIDE_FROM_ABI constexpr void __set_debug_format(_Tp& __formatter) {
44 if constexpr (requires { __formatter.set_debug_format(); })47 if constexpr (requires { __formatter.set_debug_format(); })
lib/libcxx/include/__format/formatter_bool.h+6-2
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20#include <__format/parser_std_format_spec.h>20#include <__format/parser_std_format_spec.h>
21#include <__utility/unreachable.h>21#include <__utility/unreachable.h>
2222
23#ifndef _LIBCPP_HAS_NO_LOCALIZATION23#if _LIBCPP_HAS_LOCALIZATION
24# include <__locale>24# include <__locale>
25#endif25#endif
2626
...@@ -69,7 +69,11 @@ public:...@@ -69,7 +69,11 @@ public:
69 __format_spec::__parser<_CharT> __parser_;69 __format_spec::__parser<_CharT> __parser_;
70};70};
7171
72#endif //_LIBCPP_STD_VER >= 2072# if _LIBCPP_STD_VER >= 23
73template <>
74inline constexpr bool enable_nonlocking_formatter_optimization<bool> = true;
75# endif // _LIBCPP_STD_VER >= 23
76#endif // _LIBCPP_STD_VER >= 20
7377
74_LIBCPP_END_NAMESPACE_STD78_LIBCPP_END_NAMESPACE_STD
7579
lib/libcxx/include/__format/formatter_char.h+11-3
...@@ -77,16 +77,24 @@ public:...@@ -77,16 +77,24 @@ public:
77template <>77template <>
78struct _LIBCPP_TEMPLATE_VIS formatter<char, char> : public __formatter_char<char> {};78struct _LIBCPP_TEMPLATE_VIS formatter<char, char> : public __formatter_char<char> {};
7979
80# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS80# if _LIBCPP_HAS_WIDE_CHARACTERS
81template <>81template <>
82struct _LIBCPP_TEMPLATE_VIS formatter<char, wchar_t> : public __formatter_char<wchar_t> {};82struct _LIBCPP_TEMPLATE_VIS formatter<char, wchar_t> : public __formatter_char<wchar_t> {};
8383
84template <>84template <>
85struct _LIBCPP_TEMPLATE_VIS formatter<wchar_t, wchar_t> : public __formatter_char<wchar_t> {};85struct _LIBCPP_TEMPLATE_VIS formatter<wchar_t, wchar_t> : public __formatter_char<wchar_t> {};
86# endif // _LIBCPP_HAS_WIDE_CHARACTERS
8687
87# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS88# if _LIBCPP_STD_VER >= 23
89template <>
90inline constexpr bool enable_nonlocking_formatter_optimization<char> = true;
91# if _LIBCPP_HAS_WIDE_CHARACTERS
92template <>
93inline constexpr bool enable_nonlocking_formatter_optimization<wchar_t> = true;
94# endif // _LIBCPP_HAS_WIDE_CHARACTERS
95# endif // _LIBCPP_STD_VER >= 23
8896
89#endif //_LIBCPP_STD_VER >= 2097#endif // _LIBCPP_STD_VER >= 20
9098
91_LIBCPP_END_NAMESPACE_STD99_LIBCPP_END_NAMESPACE_STD
92100
lib/libcxx/include/__format/formatter_floating_point.h+15-7
...@@ -23,6 +23,7 @@...@@ -23,6 +23,7 @@
23#include <__concepts/arithmetic.h>23#include <__concepts/arithmetic.h>
24#include <__concepts/same_as.h>24#include <__concepts/same_as.h>
25#include <__config>25#include <__config>
26#include <__cstddef/ptrdiff_t.h>
26#include <__format/concepts.h>27#include <__format/concepts.h>
27#include <__format/format_parse_context.h>28#include <__format/format_parse_context.h>
28#include <__format/formatter.h>29#include <__format/formatter.h>
...@@ -36,9 +37,8 @@...@@ -36,9 +37,8 @@
36#include <__utility/move.h>37#include <__utility/move.h>
37#include <__utility/unreachable.h>38#include <__utility/unreachable.h>
38#include <cmath>39#include <cmath>
39#include <cstddef>
4040
41#ifndef _LIBCPP_HAS_NO_LOCALIZATION41#if _LIBCPP_HAS_LOCALIZATION
42# include <__locale>42# include <__locale>
43#endif43#endif
4444
...@@ -141,7 +141,7 @@ struct __traits<double> {...@@ -141,7 +141,7 @@ struct __traits<double> {
141/// on the stack or the heap.141/// on the stack or the heap.
142template <floating_point _Fp>142template <floating_point _Fp>
143class _LIBCPP_TEMPLATE_VIS __float_buffer {143class _LIBCPP_TEMPLATE_VIS __float_buffer {
144 using _Traits = __traits<_Fp>;144 using _Traits _LIBCPP_NODEBUG = __traits<_Fp>;
145145
146public:146public:
147 // TODO FMT Improve this constructor to do a better estimate.147 // TODO FMT Improve this constructor to do a better estimate.
...@@ -491,7 +491,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer(...@@ -491,7 +491,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer(
491 }491 }
492}492}
493493
494# ifndef _LIBCPP_HAS_NO_LOCALIZATION494# if _LIBCPP_HAS_LOCALIZATION
495template <class _OutIt, class _Fp, class _CharT>495template <class _OutIt, class _Fp, class _CharT>
496_LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(496_LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
497 _OutIt __out_it,497 _OutIt __out_it,
...@@ -576,7 +576,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(...@@ -576,7 +576,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
576 // alignment576 // alignment
577 return __formatter::__fill(std::move(__out_it), __padding.__after_, __specs.__fill_);577 return __formatter::__fill(std::move(__out_it), __padding.__after_, __specs.__fill_);
578}578}
579# endif // _LIBCPP_HAS_NO_LOCALIZATION579# endif // _LIBCPP_HAS_LOCALIZATION
580580
581template <class _OutIt, class _CharT>581template <class _OutIt, class _CharT>
582_LIBCPP_HIDE_FROM_ABI _OutIt __format_floating_point_non_finite(582_LIBCPP_HIDE_FROM_ABI _OutIt __format_floating_point_non_finite(
...@@ -705,7 +705,7 @@ __format_floating_point(_Tp __value, _FormatContext& __ctx, __format_spec::__par...@@ -705,7 +705,7 @@ __format_floating_point(_Tp __value, _FormatContext& __ctx, __format_spec::__par
705 }705 }
706 }706 }
707707
708# ifndef _LIBCPP_HAS_NO_LOCALIZATION708# if _LIBCPP_HAS_LOCALIZATION
709 if (__specs.__std_.__locale_specific_form_)709 if (__specs.__std_.__locale_specific_form_)
710 return __formatter::__format_locale_specific_form(__ctx.out(), __buffer, __result, __ctx.locale(), __specs);710 return __formatter::__format_locale_specific_form(__ctx.out(), __buffer, __result, __ctx.locale(), __specs);
711# endif711# endif
...@@ -774,7 +774,15 @@ struct _LIBCPP_TEMPLATE_VIS formatter<double, _CharT> : public __formatter_float...@@ -774,7 +774,15 @@ struct _LIBCPP_TEMPLATE_VIS formatter<double, _CharT> : public __formatter_float
774template <__fmt_char_type _CharT>774template <__fmt_char_type _CharT>
775struct _LIBCPP_TEMPLATE_VIS formatter<long double, _CharT> : public __formatter_floating_point<_CharT> {};775struct _LIBCPP_TEMPLATE_VIS formatter<long double, _CharT> : public __formatter_floating_point<_CharT> {};
776776
777#endif //_LIBCPP_STD_VER >= 20777# if _LIBCPP_STD_VER >= 23
778template <>
779inline constexpr bool enable_nonlocking_formatter_optimization<float> = true;
780template <>
781inline constexpr bool enable_nonlocking_formatter_optimization<double> = true;
782template <>
783inline constexpr bool enable_nonlocking_formatter_optimization<long double> = true;
784# endif // _LIBCPP_STD_VER >= 23
785#endif // _LIBCPP_STD_VER >= 20
778786
779_LIBCPP_END_NAMESPACE_STD787_LIBCPP_END_NAMESPACE_STD
780788
lib/libcxx/include/__format/formatter_integer.h+34-3
...@@ -67,7 +67,7 @@ template <__fmt_char_type _CharT>...@@ -67,7 +67,7 @@ template <__fmt_char_type _CharT>
67struct _LIBCPP_TEMPLATE_VIS formatter<long, _CharT> : public __formatter_integer<_CharT> {};67struct _LIBCPP_TEMPLATE_VIS formatter<long, _CharT> : public __formatter_integer<_CharT> {};
68template <__fmt_char_type _CharT>68template <__fmt_char_type _CharT>
69struct _LIBCPP_TEMPLATE_VIS formatter<long long, _CharT> : public __formatter_integer<_CharT> {};69struct _LIBCPP_TEMPLATE_VIS formatter<long long, _CharT> : public __formatter_integer<_CharT> {};
70# ifndef _LIBCPP_HAS_NO_INT12870# if _LIBCPP_HAS_INT128
71template <__fmt_char_type _CharT>71template <__fmt_char_type _CharT>
72struct _LIBCPP_TEMPLATE_VIS formatter<__int128_t, _CharT> : public __formatter_integer<_CharT> {};72struct _LIBCPP_TEMPLATE_VIS formatter<__int128_t, _CharT> : public __formatter_integer<_CharT> {};
73# endif73# endif
...@@ -83,12 +83,43 @@ template <__fmt_char_type _CharT>...@@ -83,12 +83,43 @@ template <__fmt_char_type _CharT>
83struct _LIBCPP_TEMPLATE_VIS formatter<unsigned long, _CharT> : public __formatter_integer<_CharT> {};83struct _LIBCPP_TEMPLATE_VIS formatter<unsigned long, _CharT> : public __formatter_integer<_CharT> {};
84template <__fmt_char_type _CharT>84template <__fmt_char_type _CharT>
85struct _LIBCPP_TEMPLATE_VIS formatter<unsigned long long, _CharT> : public __formatter_integer<_CharT> {};85struct _LIBCPP_TEMPLATE_VIS formatter<unsigned long long, _CharT> : public __formatter_integer<_CharT> {};
86# ifndef _LIBCPP_HAS_NO_INT12886# if _LIBCPP_HAS_INT128
87template <__fmt_char_type _CharT>87template <__fmt_char_type _CharT>
88struct _LIBCPP_TEMPLATE_VIS formatter<__uint128_t, _CharT> : public __formatter_integer<_CharT> {};88struct _LIBCPP_TEMPLATE_VIS formatter<__uint128_t, _CharT> : public __formatter_integer<_CharT> {};
89# endif89# endif
9090
91#endif //_LIBCPP_STD_VER >= 2091# if _LIBCPP_STD_VER >= 23
92template <>
93inline constexpr bool enable_nonlocking_formatter_optimization<signed char> = true;
94template <>
95inline constexpr bool enable_nonlocking_formatter_optimization<short> = true;
96template <>
97inline constexpr bool enable_nonlocking_formatter_optimization<int> = true;
98template <>
99inline constexpr bool enable_nonlocking_formatter_optimization<long> = true;
100template <>
101inline constexpr bool enable_nonlocking_formatter_optimization<long long> = true;
102# if _LIBCPP_HAS_INT128
103template <>
104inline constexpr bool enable_nonlocking_formatter_optimization<__int128_t> = true;
105# endif
106
107template <>
108inline constexpr bool enable_nonlocking_formatter_optimization<unsigned char> = true;
109template <>
110inline constexpr bool enable_nonlocking_formatter_optimization<unsigned short> = true;
111template <>
112inline constexpr bool enable_nonlocking_formatter_optimization<unsigned> = true;
113template <>
114inline constexpr bool enable_nonlocking_formatter_optimization<unsigned long> = true;
115template <>
116inline constexpr bool enable_nonlocking_formatter_optimization<unsigned long long> = true;
117# if _LIBCPP_HAS_INT128
118template <>
119inline constexpr bool enable_nonlocking_formatter_optimization<__uint128_t> = true;
120# endif
121# endif // _LIBCPP_STD_VER >= 23
122#endif // _LIBCPP_STD_VER >= 20
92123
93_LIBCPP_END_NAMESPACE_STD124_LIBCPP_END_NAMESPACE_STD
94125
lib/libcxx/include/__format/formatter_integral.h+6-5
...@@ -27,11 +27,12 @@...@@ -27,11 +27,12 @@
27#include <__type_traits/make_unsigned.h>27#include <__type_traits/make_unsigned.h>
28#include <__utility/unreachable.h>28#include <__utility/unreachable.h>
29#include <array>29#include <array>
30#include <cstdint>
30#include <limits>31#include <limits>
31#include <string>32#include <string>
32#include <string_view>33#include <string_view>
3334
34#ifndef _LIBCPP_HAS_NO_LOCALIZATION35#if _LIBCPP_HAS_LOCALIZATION
35# include <__locale>36# include <__locale>
36#endif37#endif
3738
...@@ -297,7 +298,7 @@ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator __format_integer(...@@ -297,7 +298,7 @@ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator __format_integer(
297298
298 _Iterator __last = __formatter::__to_buffer(__first, __end, __value, __base);299 _Iterator __last = __formatter::__to_buffer(__first, __end, __value, __base);
299300
300# ifndef _LIBCPP_HAS_NO_LOCALIZATION301# if _LIBCPP_HAS_LOCALIZATION
301 if (__specs.__std_.__locale_specific_form_) {302 if (__specs.__std_.__locale_specific_form_) {
302 const auto& __np = std::use_facet<numpunct<_CharT>>(__ctx.locale());303 const auto& __np = std::use_facet<numpunct<_CharT>>(__ctx.locale());
303 string __grouping = __np.grouping();304 string __grouping = __np.grouping();
...@@ -411,7 +412,7 @@ struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> {...@@ -411,7 +412,7 @@ struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> {
411 static constexpr string_view __false{"false"};412 static constexpr string_view __false{"false"};
412};413};
413414
414# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS415# if _LIBCPP_HAS_WIDE_CHARACTERS
415template <>416template <>
416struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> {417struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> {
417 static constexpr wstring_view __true{L"true"};418 static constexpr wstring_view __true{L"true"};
...@@ -422,7 +423,7 @@ struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> {...@@ -422,7 +423,7 @@ struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> {
422template <class _CharT, class _FormatContext>423template <class _CharT, class _FormatContext>
423_LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator424_LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
424__format_bool(bool __value, _FormatContext& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) {425__format_bool(bool __value, _FormatContext& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) {
425# ifndef _LIBCPP_HAS_NO_LOCALIZATION426# if _LIBCPP_HAS_LOCALIZATION
426 if (__specs.__std_.__locale_specific_form_) {427 if (__specs.__std_.__locale_specific_form_) {
427 const auto& __np = std::use_facet<numpunct<_CharT>>(__ctx.locale());428 const auto& __np = std::use_facet<numpunct<_CharT>>(__ctx.locale());
428 basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename();429 basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename();
...@@ -436,7 +437,7 @@ __format_bool(bool __value, _FormatContext& __ctx, __format_spec::__parsed_speci...@@ -436,7 +437,7 @@ __format_bool(bool __value, _FormatContext& __ctx, __format_spec::__parsed_speci
436437
437} // namespace __formatter438} // namespace __formatter
438439
439#endif //_LIBCPP_STD_VER >= 20440#endif // _LIBCPP_STD_VER >= 20
440441
441_LIBCPP_END_NAMESPACE_STD442_LIBCPP_END_NAMESPACE_STD
442443
lib/libcxx/include/__format/formatter_output.h+9-9
...@@ -16,6 +16,8 @@...@@ -16,6 +16,8 @@
16#include <__bit/countl.h>16#include <__bit/countl.h>
17#include <__concepts/same_as.h>17#include <__concepts/same_as.h>
18#include <__config>18#include <__config>
19#include <__cstddef/ptrdiff_t.h>
20#include <__cstddef/size_t.h>
19#include <__format/buffer.h>21#include <__format/buffer.h>
20#include <__format/concepts.h>22#include <__format/concepts.h>
21#include <__format/formatter.h>23#include <__format/formatter.h>
...@@ -28,7 +30,6 @@...@@ -28,7 +30,6 @@
28#include <__memory/pointer_traits.h>30#include <__memory/pointer_traits.h>
29#include <__utility/move.h>31#include <__utility/move.h>
30#include <__utility/unreachable.h>32#include <__utility/unreachable.h>
31#include <cstddef>
32#include <string_view>33#include <string_view>
3334
34#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)35#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -168,7 +169,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, _CharT __value)...@@ -168,7 +169,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, _CharT __value)
168 }169 }
169}170}
170171
171# ifndef _LIBCPP_HAS_NO_UNICODE172# if _LIBCPP_HAS_UNICODE
172template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>173template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>
173 requires(same_as<_CharT, char>)174 requires(same_as<_CharT, char>)
174_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) {175_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) {
...@@ -182,7 +183,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::...@@ -182,7 +183,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::
182 return __out_it;183 return __out_it;
183}184}
184185
185# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS186# if _LIBCPP_HAS_WIDE_CHARACTERS
186template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>187template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>
187 requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2)188 requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2)
188_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) {189_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) {
...@@ -200,13 +201,13 @@ template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>...@@ -200,13 +201,13 @@ template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>
200_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) {201_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) {
201 return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]);202 return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]);
202}203}
203# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS204# endif // _LIBCPP_HAS_WIDE_CHARACTERS
204# else // _LIBCPP_HAS_NO_UNICODE205# else // _LIBCPP_HAS_UNICODE
205template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>206template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>
206_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) {207_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) {
207 return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]);208 return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]);
208}209}
209# endif // _LIBCPP_HAS_NO_UNICODE210# endif // _LIBCPP_HAS_UNICODE
210211
211/// Writes the input to the output with the required padding.212/// Writes the input to the output with the required padding.
212///213///
...@@ -294,8 +295,7 @@ _LIBCPP_HIDE_FROM_ABI auto __write_transformed(...@@ -294,8 +295,7 @@ _LIBCPP_HIDE_FROM_ABI auto __write_transformed(
294///295///
295/// \pre !__specs.__has_precision()296/// \pre !__specs.__has_precision()
296///297///
297/// \note When \c _LIBCPP_HAS_NO_UNICODE is defined the function assumes the298/// \note When \c _LIBCPP_HAS_UNICODE is false the function assumes the input is ASCII.
298/// input is ASCII.
299template <class _CharT>299template <class _CharT>
300_LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision(300_LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision(
301 basic_string_view<_CharT> __str,301 basic_string_view<_CharT> __str,
...@@ -326,7 +326,7 @@ _LIBCPP_HIDE_FROM_ABI int __truncate(basic_string_view<_CharT>& __str, int __pre...@@ -326,7 +326,7 @@ _LIBCPP_HIDE_FROM_ABI int __truncate(basic_string_view<_CharT>& __str, int __pre
326326
327} // namespace __formatter327} // namespace __formatter
328328
329#endif //_LIBCPP_STD_VER >= 20329#endif // _LIBCPP_STD_VER >= 20
330330
331_LIBCPP_END_NAMESPACE_STD331_LIBCPP_END_NAMESPACE_STD
332332
lib/libcxx/include/__format/formatter_pointer.h+10-2
...@@ -11,13 +11,13 @@...@@ -11,13 +11,13 @@
11#define _LIBCPP___FORMAT_FORMATTER_POINTER_H11#define _LIBCPP___FORMAT_FORMATTER_POINTER_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/nullptr_t.h>
14#include <__format/concepts.h>15#include <__format/concepts.h>
15#include <__format/format_parse_context.h>16#include <__format/format_parse_context.h>
16#include <__format/formatter.h>17#include <__format/formatter.h>
17#include <__format/formatter_integral.h>18#include <__format/formatter_integral.h>
18#include <__format/formatter_output.h>19#include <__format/formatter_output.h>
19#include <__format/parser_std_format_spec.h>20#include <__format/parser_std_format_spec.h>
20#include <cstddef>
21#include <cstdint>21#include <cstdint>
2222
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -65,7 +65,15 @@ struct _LIBCPP_TEMPLATE_VIS formatter<void*, _CharT> : public __formatter_pointe...@@ -65,7 +65,15 @@ struct _LIBCPP_TEMPLATE_VIS formatter<void*, _CharT> : public __formatter_pointe
65template <__fmt_char_type _CharT>65template <__fmt_char_type _CharT>
66struct _LIBCPP_TEMPLATE_VIS formatter<const void*, _CharT> : public __formatter_pointer<_CharT> {};66struct _LIBCPP_TEMPLATE_VIS formatter<const void*, _CharT> : public __formatter_pointer<_CharT> {};
6767
68#endif //_LIBCPP_STD_VER >= 2068# if _LIBCPP_STD_VER >= 23
69template <>
70inline constexpr bool enable_nonlocking_formatter_optimization<nullptr_t> = true;
71template <>
72inline constexpr bool enable_nonlocking_formatter_optimization<void*> = true;
73template <>
74inline constexpr bool enable_nonlocking_formatter_optimization<const void*> = true;
75# endif // _LIBCPP_STD_VER >= 23
76#endif // _LIBCPP_STD_VER >= 20
6977
70_LIBCPP_END_NAMESPACE_STD78_LIBCPP_END_NAMESPACE_STD
7179
lib/libcxx/include/__format/formatter_string.h+38-31
...@@ -59,44 +59,26 @@ public:...@@ -59,44 +59,26 @@ public:
59// Formatter const char*.59// Formatter const char*.
60template <__fmt_char_type _CharT>60template <__fmt_char_type _CharT>
61struct _LIBCPP_TEMPLATE_VIS formatter<const _CharT*, _CharT> : public __formatter_string<_CharT> {61struct _LIBCPP_TEMPLATE_VIS formatter<const _CharT*, _CharT> : public __formatter_string<_CharT> {
62 using _Base = __formatter_string<_CharT>;62 using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>;
6363
64 template <class _FormatContext>64 template <class _FormatContext>
65 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _CharT* __str, _FormatContext& __ctx) const {65 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _CharT* __str, _FormatContext& __ctx) const {
66 _LIBCPP_ASSERT_INTERNAL(__str, "The basic_format_arg constructor should have prevented an invalid pointer.");66 _LIBCPP_ASSERT_INTERNAL(__str, "The basic_format_arg constructor should have prevented an invalid pointer.");
6767 // Converting the input to a basic_string_view means the data is looped over twice;
68 __format_spec::__parsed_specifications<_CharT> __specs = _Base::__parser_.__get_parsed_std_specifications(__ctx);68 // - once to determine the length, and
69# if _LIBCPP_STD_VER >= 2369 // - once to process the data.
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
74 // When using a center or right alignment and the width option the length
75 // of __str must be known to add the padding upfront. This case is handled
76 // by the base class by converting the argument to a basic_string_view.
77 //70 //
78 // When using left alignment and the width option the padding is added71 // This sounds slower than writing the output directly. However internally
79 // after outputting __str so the length can be determined while outputting72 // the output algorithms have optimizations for "bulk" operations, which
80 // __str. The same holds true for the precision, during outputting __str it73 // makes this faster than a single-pass character-by-character output.
81 // can be validated whether the precision threshold has been reached. For74 return _Base::format(basic_string_view<_CharT>(__str), __ctx);
82 // now these optimizations aren't implemented. Instead the base class
83 // handles these options.
84 // TODO FMT Implement these improvements.
85 if (__specs.__has_width() || __specs.__has_precision())
86 return __formatter::__write_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
87
88 // No formatting required, copy the string to the output.
89 auto __out_it = __ctx.out();
90 while (*__str)
91 *__out_it++ = *__str++;
92 return __out_it;
93 }75 }
94};76};
9577
96// Formatter char*.78// Formatter char*.
97template <__fmt_char_type _CharT>79template <__fmt_char_type _CharT>
98struct _LIBCPP_TEMPLATE_VIS formatter<_CharT*, _CharT> : public formatter<const _CharT*, _CharT> {80struct _LIBCPP_TEMPLATE_VIS formatter<_CharT*, _CharT> : public formatter<const _CharT*, _CharT> {
99 using _Base = formatter<const _CharT*, _CharT>;81 using _Base _LIBCPP_NODEBUG = formatter<const _CharT*, _CharT>;
10082
101 template <class _FormatContext>83 template <class _FormatContext>
102 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(_CharT* __str, _FormatContext& __ctx) const {84 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(_CharT* __str, _FormatContext& __ctx) const {
...@@ -107,7 +89,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<_CharT*, _CharT> : public formatter<const...@@ -107,7 +89,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<_CharT*, _CharT> : public formatter<const
107// Formatter char[].89// Formatter char[].
108template <__fmt_char_type _CharT, size_t _Size>90template <__fmt_char_type _CharT, size_t _Size>
109struct _LIBCPP_TEMPLATE_VIS formatter<_CharT[_Size], _CharT> : public __formatter_string<_CharT> {91struct _LIBCPP_TEMPLATE_VIS formatter<_CharT[_Size], _CharT> : public __formatter_string<_CharT> {
110 using _Base = __formatter_string<_CharT>;92 using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>;
11193
112 template <class _FormatContext>94 template <class _FormatContext>
113 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator95 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
...@@ -120,7 +102,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<_CharT[_Size], _CharT> : public __formatte...@@ -120,7 +102,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<_CharT[_Size], _CharT> : public __formatte
120template <__fmt_char_type _CharT, class _Traits, class _Allocator>102template <__fmt_char_type _CharT, class _Traits, class _Allocator>
121struct _LIBCPP_TEMPLATE_VIS formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>103struct _LIBCPP_TEMPLATE_VIS formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>
122 : public __formatter_string<_CharT> {104 : public __formatter_string<_CharT> {
123 using _Base = __formatter_string<_CharT>;105 using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>;
124106
125 template <class _FormatContext>107 template <class _FormatContext>
126 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator108 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
...@@ -133,7 +115,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string<_CharT, _Traits, _Allocator>,...@@ -133,7 +115,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string<_CharT, _Traits, _Allocator>,
133// Formatter std::string_view.115// Formatter std::string_view.
134template <__fmt_char_type _CharT, class _Traits>116template <__fmt_char_type _CharT, class _Traits>
135struct _LIBCPP_TEMPLATE_VIS formatter<basic_string_view<_CharT, _Traits>, _CharT> : public __formatter_string<_CharT> {117struct _LIBCPP_TEMPLATE_VIS formatter<basic_string_view<_CharT, _Traits>, _CharT> : public __formatter_string<_CharT> {
136 using _Base = __formatter_string<_CharT>;118 using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>;
137119
138 template <class _FormatContext>120 template <class _FormatContext>
139 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator121 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
...@@ -143,7 +125,32 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string_view<_CharT, _Traits>, _CharT...@@ -143,7 +125,32 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string_view<_CharT, _Traits>, _CharT
143 }125 }
144};126};
145127
146#endif //_LIBCPP_STD_VER >= 20128# if _LIBCPP_STD_VER >= 23
129template <>
130inline constexpr bool enable_nonlocking_formatter_optimization<char*> = true;
131template <>
132inline constexpr bool enable_nonlocking_formatter_optimization<const char*> = true;
133template <size_t _Size>
134inline constexpr bool enable_nonlocking_formatter_optimization<char[_Size]> = true;
135template <class _Traits, class _Allocator>
136inline constexpr bool enable_nonlocking_formatter_optimization<basic_string<char, _Traits, _Allocator>> = true;
137template <class _Traits>
138inline constexpr bool enable_nonlocking_formatter_optimization<basic_string_view<char, _Traits>> = true;
139
140# if _LIBCPP_HAS_WIDE_CHARACTERS
141template <>
142inline constexpr bool enable_nonlocking_formatter_optimization<wchar_t*> = true;
143template <>
144inline constexpr bool enable_nonlocking_formatter_optimization<const wchar_t*> = true;
145template <size_t _Size>
146inline constexpr bool enable_nonlocking_formatter_optimization<wchar_t[_Size]> = true;
147template <class _Traits, class _Allocator>
148inline constexpr bool enable_nonlocking_formatter_optimization<basic_string<wchar_t, _Traits, _Allocator>> = true;
149template <class _Traits>
150inline constexpr bool enable_nonlocking_formatter_optimization<basic_string_view<wchar_t, _Traits>> = true;
151# endif // _LIBCPP_HAS_WIDE_CHARACTERS
152# endif // _LIBCPP_STD_VER >= 23
153#endif // _LIBCPP_STD_VER >= 20
147154
148_LIBCPP_END_NAMESPACE_STD155_LIBCPP_END_NAMESPACE_STD
149156
lib/libcxx/include/__format/formatter_tuple.h+1-1
...@@ -143,7 +143,7 @@ template <__fmt_char_type _CharT, formattable<_CharT>... _Args>...@@ -143,7 +143,7 @@ template <__fmt_char_type _CharT, formattable<_CharT>... _Args>
143struct _LIBCPP_TEMPLATE_VIS formatter<tuple<_Args...>, _CharT>143struct _LIBCPP_TEMPLATE_VIS formatter<tuple<_Args...>, _CharT>
144 : public __formatter_tuple<_CharT, tuple<_Args...>, _Args...> {};144 : public __formatter_tuple<_CharT, tuple<_Args...>, _Args...> {};
145145
146#endif //_LIBCPP_STD_VER >= 23146#endif // _LIBCPP_STD_VER >= 23
147147
148_LIBCPP_END_NAMESPACE_STD148_LIBCPP_END_NAMESPACE_STD
149149
lib/libcxx/include/__format/indic_conjunct_break_table.h+2-2
...@@ -63,8 +63,8 @@...@@ -63,8 +63,8 @@
6363
64#include <__algorithm/ranges_upper_bound.h>64#include <__algorithm/ranges_upper_bound.h>
65#include <__config>65#include <__config>
66#include <__cstddef/ptrdiff_t.h>
66#include <__iterator/access.h>67#include <__iterator/access.h>
67#include <cstddef>
68#include <cstdint>68#include <cstdint>
6969
70#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)70#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -343,7 +343,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = {...@@ -343,7 +343,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = {
343343
344} // namespace __indic_conjunct_break344} // namespace __indic_conjunct_break
345345
346#endif //_LIBCPP_STD_VER >= 20346#endif // _LIBCPP_STD_VER >= 20
347347
348_LIBCPP_END_NAMESPACE_STD348_LIBCPP_END_NAMESPACE_STD
349349
lib/libcxx/include/__format/parser_std_format_spec.h+15-15
...@@ -52,13 +52,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -52,13 +52,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
5252
53namespace __format_spec {53namespace __format_spec {
5454
55_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void55[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void
56__throw_invalid_option_format_error(const char* __id, const char* __option) {56__throw_invalid_option_format_error(const char* __id, const char* __option) {
57 std::__throw_format_error(57 std::__throw_format_error(
58 (string("The format specifier for ") + __id + " does not allow the " + __option + " option").c_str());58 (string("The format specifier for ") + __id + " does not allow the " + __option + " option").c_str());
59}59}
6060
61_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __throw_invalid_type_format_error(const char* __id) {61[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void __throw_invalid_type_format_error(const char* __id) {
62 std::__throw_format_error(62 std::__throw_format_error(
63 (string("The type option contains an invalid value for ") + __id + " formatting argument").c_str());63 (string("The type option contains an invalid value for ") + __id + " formatting argument").c_str());
64}64}
...@@ -268,7 +268,7 @@ struct __code_point<char> {...@@ -268,7 +268,7 @@ struct __code_point<char> {
268 char __data[4] = {' '};268 char __data[4] = {' '};
269};269};
270270
271# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS271# if _LIBCPP_HAS_WIDE_CHARACTERS
272template <>272template <>
273struct __code_point<wchar_t> {273struct __code_point<wchar_t> {
274 wchar_t __data[4 / sizeof(wchar_t)] = {L' '};274 wchar_t __data[4 / sizeof(wchar_t)] = {L' '};
...@@ -321,7 +321,7 @@ struct __parsed_specifications {...@@ -321,7 +321,7 @@ struct __parsed_specifications {
321// value in formatting functions.321// value in formatting functions.
322static_assert(sizeof(__parsed_specifications<char>) == 16);322static_assert(sizeof(__parsed_specifications<char>) == 16);
323static_assert(is_trivially_copyable_v<__parsed_specifications<char>>);323static_assert(is_trivially_copyable_v<__parsed_specifications<char>>);
324# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS324# if _LIBCPP_HAS_WIDE_CHARACTERS
325static_assert(sizeof(__parsed_specifications<wchar_t>) == 16);325static_assert(sizeof(__parsed_specifications<wchar_t>) == 16);
326static_assert(is_trivially_copyable_v<__parsed_specifications<wchar_t>>);326static_assert(is_trivially_copyable_v<__parsed_specifications<wchar_t>>);
327# endif327# endif
...@@ -580,11 +580,11 @@ private:...@@ -580,11 +580,11 @@ private:
580 std::__throw_format_error("The fill option contains an invalid value");580 std::__throw_format_error("The fill option contains an invalid value");
581 }581 }
582582
583# ifndef _LIBCPP_HAS_NO_UNICODE583# if _LIBCPP_HAS_UNICODE
584 // range-fill and tuple-fill are identical584 // range-fill and tuple-fill are identical
585 template <contiguous_iterator _Iterator>585 template <contiguous_iterator _Iterator>
586 requires same_as<_CharT, char>586 requires same_as<_CharT, char>
587# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS587# if _LIBCPP_HAS_WIDE_CHARACTERS
588 || (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2)588 || (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2)
589# endif589# endif
590 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) {590 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) {
...@@ -617,7 +617,7 @@ private:...@@ -617,7 +617,7 @@ private:
617 return true;617 return true;
618 }618 }
619619
620# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS620# if _LIBCPP_HAS_WIDE_CHARACTERS
621 template <contiguous_iterator _Iterator>621 template <contiguous_iterator _Iterator>
622 requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4)622 requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4)
623 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) {623 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) {
...@@ -643,9 +643,9 @@ private:...@@ -643,9 +643,9 @@ private:
643 return true;643 return true;
644 }644 }
645645
646# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS646# endif // _LIBCPP_HAS_WIDE_CHARACTERS
647647
648# else // _LIBCPP_HAS_NO_UNICODE648# else // _LIBCPP_HAS_UNICODE
649 // range-fill and tuple-fill are identical649 // range-fill and tuple-fill are identical
650 template <contiguous_iterator _Iterator>650 template <contiguous_iterator _Iterator>
651 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) {651 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) {
...@@ -670,7 +670,7 @@ private:...@@ -670,7 +670,7 @@ private:
670 return true;670 return true;
671 }671 }
672672
673# endif // _LIBCPP_HAS_NO_UNICODE673# endif // _LIBCPP_HAS_UNICODE
674674
675 template <contiguous_iterator _Iterator>675 template <contiguous_iterator _Iterator>
676 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_sign(_Iterator& __begin) {676 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_sign(_Iterator& __begin) {
...@@ -874,7 +874,7 @@ private:...@@ -874,7 +874,7 @@ private:
874874
875// Validates whether the reserved bitfields don't change the size.875// Validates whether the reserved bitfields don't change the size.
876static_assert(sizeof(__parser<char>) == 16);876static_assert(sizeof(__parser<char>) == 16);
877# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS877# if _LIBCPP_HAS_WIDE_CHARACTERS
878static_assert(sizeof(__parser<wchar_t>) == 16);878static_assert(sizeof(__parser<wchar_t>) == 16);
879# endif879# endif
880880
...@@ -1026,7 +1026,7 @@ __column_width_result(size_t, _Iterator) -> __column_width_result<_Iterator>;...@@ -1026,7 +1026,7 @@ __column_width_result(size_t, _Iterator) -> __column_width_result<_Iterator>;
1026/// "rounded up".1026/// "rounded up".
1027enum class __column_width_rounding { __down, __up };1027enum class __column_width_rounding { __down, __up };
10281028
1029# ifndef _LIBCPP_HAS_NO_UNICODE1029# if _LIBCPP_HAS_UNICODE
10301030
1031namespace __detail {1031namespace __detail {
1032template <contiguous_iterator _Iterator>1032template <contiguous_iterator _Iterator>
...@@ -1148,7 +1148,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_Iterator> __estimate_colu...@@ -1148,7 +1148,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_Iterator> __estimate_colu
1148 __result.__width_ += __ascii_size;1148 __result.__width_ += __ascii_size;
1149 return __result;1149 return __result;
1150}1150}
1151# else // !defined(_LIBCPP_HAS_NO_UNICODE)1151# else // _LIBCPP_HAS_UNICODE
1152template <class _CharT>1152template <class _CharT>
1153_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<typename basic_string_view<_CharT>::const_iterator>1153_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<typename basic_string_view<_CharT>::const_iterator>
1154__estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __column_width_rounding) noexcept {1154__estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __column_width_rounding) noexcept {
...@@ -1159,11 +1159,11 @@ __estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __col...@@ -1159,11 +1159,11 @@ __estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __col
1159 return {__width, __str.begin() + __width};1159 return {__width, __str.begin() + __width};
1160}1160}
11611161
1162# endif // !defined(_LIBCPP_HAS_NO_UNICODE)1162# endif // _LIBCPP_HAS_UNICODE
11631163
1164} // namespace __format_spec1164} // namespace __format_spec
11651165
1166#endif //_LIBCPP_STD_VER >= 201166#endif // _LIBCPP_STD_VER >= 20
11671167
1168_LIBCPP_END_NAMESPACE_STD1168_LIBCPP_END_NAMESPACE_STD
11691169
lib/libcxx/include/__format/range_default_formatter.h+7-7
...@@ -40,7 +40,7 @@ concept __const_formattable_range =...@@ -40,7 +40,7 @@ concept __const_formattable_range =
40 ranges::input_range<const _Rp> && formattable<ranges::range_reference_t<const _Rp>, _CharT>;40 ranges::input_range<const _Rp> && formattable<ranges::range_reference_t<const _Rp>, _CharT>;
4141
42template <class _Rp, class _CharT>42template <class _Rp, class _CharT>
43using __fmt_maybe_const = conditional_t<__const_formattable_range<_Rp, _CharT>, const _Rp, _Rp>;43using __fmt_maybe_const _LIBCPP_NODEBUG = conditional_t<__const_formattable_range<_Rp, _CharT>, const _Rp, _Rp>;
4444
45_LIBCPP_DIAGNOSTIC_PUSH45_LIBCPP_DIAGNOSTIC_PUSH
46_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wshadow")46_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wshadow")
...@@ -95,7 +95,7 @@ struct _LIBCPP_TEMPLATE_VIS __range_default_formatter;...@@ -95,7 +95,7 @@ struct _LIBCPP_TEMPLATE_VIS __range_default_formatter;
95template <ranges::input_range _Rp, class _CharT>95template <ranges::input_range _Rp, class _CharT>
96struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::sequence, _Rp, _CharT> {96struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::sequence, _Rp, _CharT> {
97private:97private:
98 using __maybe_const_r = __fmt_maybe_const<_Rp, _CharT>;98 using __maybe_const_r _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>;
99 range_formatter<remove_cvref_t<ranges::range_reference_t<__maybe_const_r>>, _CharT> __underlying_;99 range_formatter<remove_cvref_t<ranges::range_reference_t<__maybe_const_r>>, _CharT> __underlying_;
100100
101public:101public:
...@@ -122,8 +122,8 @@ public:...@@ -122,8 +122,8 @@ public:
122template <ranges::input_range _Rp, class _CharT>122template <ranges::input_range _Rp, class _CharT>
123struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::map, _Rp, _CharT> {123struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::map, _Rp, _CharT> {
124private:124private:
125 using __maybe_const_map = __fmt_maybe_const<_Rp, _CharT>;125 using __maybe_const_map _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>;
126 using __element_type = remove_cvref_t<ranges::range_reference_t<__maybe_const_map>>;126 using __element_type _LIBCPP_NODEBUG = remove_cvref_t<ranges::range_reference_t<__maybe_const_map>>;
127 range_formatter<__element_type, _CharT> __underlying_;127 range_formatter<__element_type, _CharT> __underlying_;
128128
129public:129public:
...@@ -150,8 +150,8 @@ public:...@@ -150,8 +150,8 @@ public:
150template <ranges::input_range _Rp, class _CharT>150template <ranges::input_range _Rp, class _CharT>
151struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::set, _Rp, _CharT> {151struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::set, _Rp, _CharT> {
152private:152private:
153 using __maybe_const_set = __fmt_maybe_const<_Rp, _CharT>;153 using __maybe_const_set _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>;
154 using __element_type = remove_cvref_t<ranges::range_reference_t<__maybe_const_set>>;154 using __element_type _LIBCPP_NODEBUG = remove_cvref_t<ranges::range_reference_t<__maybe_const_set>>;
155 range_formatter<__element_type, _CharT> __underlying_;155 range_formatter<__element_type, _CharT> __underlying_;
156156
157public:157public:
...@@ -207,7 +207,7 @@ template <ranges::input_range _Rp, class _CharT>...@@ -207,7 +207,7 @@ template <ranges::input_range _Rp, class _CharT>
207 requires(format_kind<_Rp> != range_format::disabled && formattable<ranges::range_reference_t<_Rp>, _CharT>)207 requires(format_kind<_Rp> != range_format::disabled && formattable<ranges::range_reference_t<_Rp>, _CharT>)
208struct _LIBCPP_TEMPLATE_VIS formatter<_Rp, _CharT> : __range_default_formatter<format_kind<_Rp>, _Rp, _CharT> {};208struct _LIBCPP_TEMPLATE_VIS formatter<_Rp, _CharT> : __range_default_formatter<format_kind<_Rp>, _Rp, _CharT> {};
209209
210#endif //_LIBCPP_STD_VER >= 23210#endif // _LIBCPP_STD_VER >= 23
211211
212_LIBCPP_END_NAMESPACE_STD212_LIBCPP_END_NAMESPACE_STD
213213
lib/libcxx/include/__format/range_formatter.h+1-1
...@@ -257,7 +257,7 @@ private:...@@ -257,7 +257,7 @@ private:
257 basic_string_view<_CharT> __closing_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, "]");257 basic_string_view<_CharT> __closing_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, "]");
258};258};
259259
260#endif //_LIBCPP_STD_VER >= 23260#endif // _LIBCPP_STD_VER >= 23
261261
262_LIBCPP_END_NAMESPACE_STD262_LIBCPP_END_NAMESPACE_STD
263263
lib/libcxx/include/__format/unicode.h+13-13
...@@ -54,7 +54,7 @@ struct __consume_result {...@@ -54,7 +54,7 @@ struct __consume_result {
54};54};
55static_assert(sizeof(__consume_result) == sizeof(char32_t));55static_assert(sizeof(__consume_result) == sizeof(char32_t));
5656
57# ifndef _LIBCPP_HAS_NO_UNICODE57# if _LIBCPP_HAS_UNICODE
5858
59/// Implements the grapheme cluster boundary rules59/// Implements the grapheme cluster boundary rules
60///60///
...@@ -123,7 +123,7 @@ class __code_point_view;...@@ -123,7 +123,7 @@ class __code_point_view;
123/// UTF-8 specialization.123/// UTF-8 specialization.
124template <>124template <>
125class __code_point_view<char> {125class __code_point_view<char> {
126 using _Iterator = basic_string_view<char>::const_iterator;126 using _Iterator _LIBCPP_NODEBUG = basic_string_view<char>::const_iterator;
127127
128public:128public:
129 _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(_Iterator __first, _Iterator __last)129 _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(_Iterator __first, _Iterator __last)
...@@ -235,7 +235,7 @@ private:...@@ -235,7 +235,7 @@ private:
235 _Iterator __last_;235 _Iterator __last_;
236};236};
237237
238# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS238# if _LIBCPP_HAS_WIDE_CHARACTERS
239_LIBCPP_HIDE_FROM_ABI constexpr bool __is_surrogate_pair_high(wchar_t __value) {239_LIBCPP_HIDE_FROM_ABI constexpr bool __is_surrogate_pair_high(wchar_t __value) {
240 return __value >= 0xd800 && __value <= 0xdbff;240 return __value >= 0xd800 && __value <= 0xdbff;
241}241}
...@@ -249,7 +249,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __is_surrogate_pair_low(wchar_t __value) {...@@ -249,7 +249,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __is_surrogate_pair_low(wchar_t __value) {
249/// - 4 UTF-32 (for example Linux)249/// - 4 UTF-32 (for example Linux)
250template <>250template <>
251class __code_point_view<wchar_t> {251class __code_point_view<wchar_t> {
252 using _Iterator = typename basic_string_view<wchar_t>::const_iterator;252 using _Iterator _LIBCPP_NODEBUG = typename basic_string_view<wchar_t>::const_iterator;
253253
254public:254public:
255 static_assert(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4, "sizeof(wchar_t) has a not implemented value");255 static_assert(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4, "sizeof(wchar_t) has a not implemented value");
...@@ -292,7 +292,7 @@ private:...@@ -292,7 +292,7 @@ private:
292 _Iterator __first_;292 _Iterator __first_;
293 _Iterator __last_;293 _Iterator __last_;
294};294};
295# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS295# endif // _LIBCPP_HAS_WIDE_CHARACTERS
296296
297// State machine to implement the Extended Grapheme Cluster Boundary297// State machine to implement the Extended Grapheme Cluster Boundary
298//298//
...@@ -300,8 +300,8 @@ private:...@@ -300,8 +300,8 @@ private:
300// This implements the extended rules see300// This implements the extended rules see
301// https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries301// https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries
302class __extended_grapheme_cluster_break {302class __extended_grapheme_cluster_break {
303 using __EGC_property = __extended_grapheme_custer_property_boundary::__property;303 using __EGC_property _LIBCPP_NODEBUG = __extended_grapheme_custer_property_boundary::__property;
304 using __inCB_property = __indic_conjunct_break::__property;304 using __inCB_property _LIBCPP_NODEBUG = __indic_conjunct_break::__property;
305305
306public:306public:
307 _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_break(char32_t __first_code_point)307 _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_break(char32_t __first_code_point)
...@@ -527,7 +527,7 @@ private:...@@ -527,7 +527,7 @@ private:
527/// Therefore only this code point is extracted.527/// Therefore only this code point is extracted.
528template <class _CharT>528template <class _CharT>
529class __extended_grapheme_cluster_view {529class __extended_grapheme_cluster_view {
530 using _Iterator = typename basic_string_view<_CharT>::const_iterator;530 using _Iterator _LIBCPP_NODEBUG = typename basic_string_view<_CharT>::const_iterator;
531531
532public:532public:
533 _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_view(_Iterator __first, _Iterator __last)533 _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_view(_Iterator __first, _Iterator __last)
...@@ -566,13 +566,13 @@ private:...@@ -566,13 +566,13 @@ private:
566template <contiguous_iterator _Iterator>566template <contiguous_iterator _Iterator>
567__extended_grapheme_cluster_view(_Iterator, _Iterator) -> __extended_grapheme_cluster_view<iter_value_t<_Iterator>>;567__extended_grapheme_cluster_view(_Iterator, _Iterator) -> __extended_grapheme_cluster_view<iter_value_t<_Iterator>>;
568568
569# else // _LIBCPP_HAS_NO_UNICODE569# else // _LIBCPP_HAS_UNICODE
570570
571// For ASCII every character is a "code point".571// For ASCII every character is a "code point".
572// This makes it easier to write code agnostic of the _LIBCPP_HAS_NO_UNICODE define.572// This makes it easier to write code agnostic of the _LIBCPP_HAS_UNICODE define.
573template <class _CharT>573template <class _CharT>
574class __code_point_view {574class __code_point_view {
575 using _Iterator = typename basic_string_view<_CharT>::const_iterator;575 using _Iterator _LIBCPP_NODEBUG = typename basic_string_view<_CharT>::const_iterator;
576576
577public:577public:
578 _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(_Iterator __first, _Iterator __last)578 _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(_Iterator __first, _Iterator __last)
...@@ -591,11 +591,11 @@ private:...@@ -591,11 +591,11 @@ private:
591 _Iterator __last_;591 _Iterator __last_;
592};592};
593593
594# endif // _LIBCPP_HAS_NO_UNICODE594# endif // _LIBCPP_HAS_UNICODE
595595
596} // namespace __unicode596} // namespace __unicode
597597
598#endif //_LIBCPP_STD_VER >= 20598#endif // _LIBCPP_STD_VER >= 20
599599
600_LIBCPP_END_NAMESPACE_STD600_LIBCPP_END_NAMESPACE_STD
601601
lib/libcxx/include/__format/width_estimation_table.h+2-2
...@@ -63,7 +63,7 @@...@@ -63,7 +63,7 @@
6363
64#include <__algorithm/ranges_upper_bound.h>64#include <__algorithm/ranges_upper_bound.h>
65#include <__config>65#include <__config>
66#include <cstddef>66#include <__cstddef/ptrdiff_t.h>
67#include <cstdint>67#include <cstdint>
6868
69#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)69#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -263,7 +263,7 @@ inline constexpr uint32_t __table_upper_bound = 0x0003fffd;...@@ -263,7 +263,7 @@ inline constexpr uint32_t __table_upper_bound = 0x0003fffd;
263263
264} // namespace __width_estimation_table264} // namespace __width_estimation_table
265265
266#endif //_LIBCPP_STD_VER >= 20266#endif // _LIBCPP_STD_VER >= 20
267267
268_LIBCPP_END_NAMESPACE_STD268_LIBCPP_END_NAMESPACE_STD
269269
lib/libcxx/include/__format/write_escaped.h+3-3
...@@ -16,6 +16,7 @@...@@ -16,6 +16,7 @@
16#include <__charconv/to_chars_result.h>16#include <__charconv/to_chars_result.h>
17#include <__chrono/statically_widen.h>17#include <__chrono/statically_widen.h>
18#include <__format/escaped_output_table.h>18#include <__format/escaped_output_table.h>
19#include <__format/extended_grapheme_cluster_table.h>
19#include <__format/formatter_output.h>20#include <__format/formatter_output.h>
20#include <__format/parser_std_format_spec.h>21#include <__format/parser_std_format_spec.h>
21#include <__format/unicode.h>22#include <__format/unicode.h>
...@@ -41,8 +42,7 @@ namespace __formatter {...@@ -41,8 +42,7 @@ namespace __formatter {
4142
42/// Writes a string using format's width estimation algorithm.43/// Writes a string using format's width estimation algorithm.
43///44///
44/// \note When \c _LIBCPP_HAS_NO_UNICODE is defined the function assumes the45/// \note When \c _LIBCPP_HAS_UNICODE is false the function assumes the input is ASCII.
45/// input is ASCII.
46template <class _CharT>46template <class _CharT>
47_LIBCPP_HIDE_FROM_ABI auto47_LIBCPP_HIDE_FROM_ABI auto
48__write_string(basic_string_view<_CharT> __str,48__write_string(basic_string_view<_CharT> __str,
...@@ -103,7 +103,7 @@ _LIBCPP_HIDE_FROM_ABI void __write_escape_ill_formed_code_unit(basic_string<_Cha...@@ -103,7 +103,7 @@ _LIBCPP_HIDE_FROM_ABI void __write_escape_ill_formed_code_unit(basic_string<_Cha
103template <class _CharT>103template <class _CharT>
104[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool104[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
105__is_escaped_sequence_written(basic_string<_CharT>& __str, bool __last_escaped, char32_t __value) {105__is_escaped_sequence_written(basic_string<_CharT>& __str, bool __last_escaped, char32_t __value) {
106# ifdef _LIBCPP_HAS_NO_UNICODE106# if !_LIBCPP_HAS_UNICODE
107 // For ASCII assume everything above 127 is printable.107 // For ASCII assume everything above 127 is printable.
108 if (__value > 127)108 if (__value > 127)
109 return false;109 return false;
lib/libcxx/include/__functional/binary_function.h+2-2
...@@ -42,11 +42,11 @@ struct __binary_function_keep_layout_base {...@@ -42,11 +42,11 @@ struct __binary_function_keep_layout_base {
42_LIBCPP_DIAGNOSTIC_PUSH42_LIBCPP_DIAGNOSTIC_PUSH
43_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")43_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
44template <class _Arg1, class _Arg2, class _Result>44template <class _Arg1, class _Arg2, class _Result>
45using __binary_function = binary_function<_Arg1, _Arg2, _Result>;45using __binary_function _LIBCPP_NODEBUG = binary_function<_Arg1, _Arg2, _Result>;
46_LIBCPP_DIAGNOSTIC_POP46_LIBCPP_DIAGNOSTIC_POP
47#else47#else
48template <class _Arg1, class _Arg2, class _Result>48template <class _Arg1, class _Arg2, class _Result>
49using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;49using __binary_function _LIBCPP_NODEBUG = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
50#endif50#endif
5151
52_LIBCPP_END_NAMESPACE_STD52_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__functional/bind.h+12-15
...@@ -11,13 +11,12 @@...@@ -11,13 +11,12 @@
11#define _LIBCPP___FUNCTIONAL_BIND_H11#define _LIBCPP___FUNCTIONAL_BIND_H
1212
13#include <__config>13#include <__config>
14#include <__functional/invoke.h>
15#include <__functional/weak_result_type.h>14#include <__functional/weak_result_type.h>
16#include <__fwd/functional.h>15#include <__fwd/functional.h>
17#include <__type_traits/decay.h>16#include <__type_traits/decay.h>
17#include <__type_traits/invoke.h>
18#include <__type_traits/is_reference_wrapper.h>18#include <__type_traits/is_reference_wrapper.h>
19#include <__type_traits/is_void.h>19#include <__type_traits/is_void.h>
20#include <cstddef>
21#include <tuple>20#include <tuple>
2221
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -83,13 +82,13 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __mu(reference_w...@@ -83,13 +82,13 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __mu(reference_w
83}82}
8483
85template <class _Ti, class... _Uj, size_t... _Indx>84template <class _Ti, class... _Uj, size_t... _Indx>
86inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<_Ti&, _Uj...>::type85inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<_Ti&, _Uj...>
87__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) {86__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) {
88 return __ti(std::forward<_Uj>(std::get<_Indx>(__uj))...);87 return __ti(std::forward<_Uj>(std::get<_Indx>(__uj))...);
89}88}
9089
91template <class _Ti, class... _Uj, __enable_if_t<is_bind_expression<_Ti>::value, int> = 0>90template <class _Ti, class... _Uj, __enable_if_t<is_bind_expression<_Ti>::value, int> = 0>
92inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<_Ti&, _Uj...>::type91inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<_Ti&, _Uj...>
93__mu(_Ti& __ti, tuple<_Uj...>& __uj) {92__mu(_Ti& __ti, tuple<_Uj...>& __uj) {
94 typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;93 typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
95 return std::__mu_expand(__ti, __uj, __indices());94 return std::__mu_expand(__ti, __uj, __indices());
...@@ -131,12 +130,12 @@ struct __mu_return_invokable // false...@@ -131,12 +130,12 @@ struct __mu_return_invokable // false
131130
132template <class _Ti, class... _Uj>131template <class _Ti, class... _Uj>
133struct __mu_return_invokable<true, _Ti, _Uj...> {132struct __mu_return_invokable<true, _Ti, _Uj...> {
134 typedef typename __invoke_of<_Ti&, _Uj...>::type type;133 using type = __invoke_result_t<_Ti&, _Uj...>;
135};134};
136135
137template <class _Ti, class... _Uj>136template <class _Ti, class... _Uj>
138struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> >137struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> >
139 : public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> {};138 : public __mu_return_invokable<__is_invocable_v<_Ti&, _Uj...>, _Ti, _Uj...> {};
140139
141template <class _Ti, class _TupleUj>140template <class _Ti, class _TupleUj>
142struct __mu_return_impl<_Ti, false, false, true, _TupleUj> {141struct __mu_return_impl<_Ti, false, false, true, _TupleUj> {
...@@ -169,12 +168,12 @@ struct __is_valid_bind_return {...@@ -169,12 +168,12 @@ struct __is_valid_bind_return {
169168
170template <class _Fp, class... _BoundArgs, class _TupleUj>169template <class _Fp, class... _BoundArgs, class _TupleUj>
171struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> {170struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> {
172 static const bool value = __invokable<_Fp, typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;171 static const bool value = __is_invocable_v<_Fp, typename __mu_return<_BoundArgs, _TupleUj>::type...>;
173};172};
174173
175template <class _Fp, class... _BoundArgs, class _TupleUj>174template <class _Fp, class... _BoundArgs, class _TupleUj>
176struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> {175struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> {
177 static const bool value = __invokable<_Fp, typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;176 static const bool value = __is_invocable_v<_Fp, typename __mu_return<const _BoundArgs, _TupleUj>::type...>;
178};177};
179178
180template <class _Fp, class _BoundArgs, class _TupleUj, bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>179template <class _Fp, class _BoundArgs, class _TupleUj, bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
...@@ -182,12 +181,12 @@ struct __bind_return;...@@ -182,12 +181,12 @@ struct __bind_return;
182181
183template <class _Fp, class... _BoundArgs, class _TupleUj>182template <class _Fp, class... _BoundArgs, class _TupleUj>
184struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> {183struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> {
185 typedef typename __invoke_of< _Fp&, typename __mu_return< _BoundArgs, _TupleUj >::type... >::type type;184 using type = __invoke_result_t< _Fp&, typename __mu_return< _BoundArgs, _TupleUj >::type... >;
186};185};
187186
188template <class _Fp, class... _BoundArgs, class _TupleUj>187template <class _Fp, class... _BoundArgs, class _TupleUj>
189struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> {188struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> {
190 typedef typename __invoke_of< _Fp&, typename __mu_return< const _BoundArgs, _TupleUj >::type... >::type type;189 using type = __invoke_result_t< _Fp&, typename __mu_return< const _BoundArgs, _TupleUj >::type... >;
191};190};
192191
193template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args>192template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args>
...@@ -199,7 +198,7 @@ __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, _...@@ -199,7 +198,7 @@ __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, _
199template <class _Fp, class... _BoundArgs>198template <class _Fp, class... _BoundArgs>
200class __bind : public __weak_result_type<__decay_t<_Fp> > {199class __bind : public __weak_result_type<__decay_t<_Fp> > {
201protected:200protected:
202 using _Fd = __decay_t<_Fp>;201 using _Fd _LIBCPP_NODEBUG = __decay_t<_Fp>;
203 typedef tuple<__decay_t<_BoundArgs>...> _Td;202 typedef tuple<__decay_t<_BoundArgs>...> _Td;
204203
205private:204private:
...@@ -257,8 +256,7 @@ public:...@@ -257,8 +256,7 @@ public:
257 is_void<_Rp>::value,256 is_void<_Rp>::value,
258 int> = 0>257 int> = 0>
259 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) {258 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) {
260 typedef __invoke_void_return_wrapper<_Rp> _Invoker;259 return std::__invoke_r<_Rp>(static_cast<base&>(*this), std::forward<_Args>(__args)...);
261 return _Invoker::__call(static_cast<base&>(*this), std::forward<_Args>(__args)...);
262 }260 }
263261
264 template <class... _Args,262 template <class... _Args,
...@@ -267,8 +265,7 @@ public:...@@ -267,8 +265,7 @@ public:
267 is_void<_Rp>::value,265 is_void<_Rp>::value,
268 int> = 0>266 int> = 0>
269 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) const {267 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) const {
270 typedef __invoke_void_return_wrapper<_Rp> _Invoker;268 return std::__invoke_r<_Rp>(static_cast<base const&>(*this), std::forward<_Args>(__args)...);
271 return _Invoker::__call(static_cast<base const&>(*this), std::forward<_Args>(__args)...);
272 }269 }
273};270};
274271
lib/libcxx/include/__functional/boyer_moore_searcher.h+4-3
...@@ -22,9 +22,10 @@...@@ -22,9 +22,10 @@
22#include <__memory/shared_ptr.h>22#include <__memory/shared_ptr.h>
23#include <__type_traits/make_unsigned.h>23#include <__type_traits/make_unsigned.h>
24#include <__utility/pair.h>24#include <__utility/pair.h>
25#include <__vector/vector.h>
25#include <array>26#include <array>
27#include <limits>
26#include <unordered_map>28#include <unordered_map>
27#include <vector>
2829
29#if _LIBCPP_STD_VER >= 1730#if _LIBCPP_STD_VER >= 17
3031
...@@ -91,7 +92,7 @@ class _LIBCPP_TEMPLATE_VIS boyer_moore_searcher {...@@ -91,7 +92,7 @@ class _LIBCPP_TEMPLATE_VIS boyer_moore_searcher {
91private:92private:
92 using difference_type = typename std::iterator_traits<_RandomAccessIterator1>::difference_type;93 using difference_type = typename std::iterator_traits<_RandomAccessIterator1>::difference_type;
93 using value_type = typename std::iterator_traits<_RandomAccessIterator1>::value_type;94 using value_type = typename std::iterator_traits<_RandomAccessIterator1>::value_type;
94 using __skip_table_type =95 using __skip_table_type _LIBCPP_NODEBUG =
95 _BMSkipTable<value_type,96 _BMSkipTable<value_type,
96 difference_type,97 difference_type,
97 _Hash,98 _Hash,
...@@ -222,7 +223,7 @@ class _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher {...@@ -222,7 +223,7 @@ class _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher {
222private:223private:
223 using difference_type = typename iterator_traits<_RandomAccessIterator1>::difference_type;224 using difference_type = typename iterator_traits<_RandomAccessIterator1>::difference_type;
224 using value_type = typename iterator_traits<_RandomAccessIterator1>::value_type;225 using value_type = typename iterator_traits<_RandomAccessIterator1>::value_type;
225 using __skip_table_type =226 using __skip_table_type _LIBCPP_NODEBUG =
226 _BMSkipTable<value_type,227 _BMSkipTable<value_type,
227 difference_type,228 difference_type,
228 _Hash,229 _Hash,
lib/libcxx/include/__functional/function.h+63-57
...@@ -12,6 +12,7 @@...@@ -12,6 +12,7 @@
1212
13#include <__assert>13#include <__assert>
14#include <__config>14#include <__config>
15#include <__cstddef/nullptr_t.h>
15#include <__exception/exception.h>16#include <__exception/exception.h>
16#include <__functional/binary_function.h>17#include <__functional/binary_function.h>
17#include <__functional/invoke.h>18#include <__functional/invoke.h>
...@@ -21,7 +22,6 @@...@@ -21,7 +22,6 @@
21#include <__memory/allocator.h>22#include <__memory/allocator.h>
22#include <__memory/allocator_destructor.h>23#include <__memory/allocator_destructor.h>
23#include <__memory/allocator_traits.h>24#include <__memory/allocator_traits.h>
24#include <__memory/builtin_new_allocator.h>
25#include <__memory/compressed_pair.h>25#include <__memory/compressed_pair.h>
26#include <__memory/unique_ptr.h>26#include <__memory/unique_ptr.h>
27#include <__type_traits/aligned_storage.h>27#include <__type_traits/aligned_storage.h>
...@@ -37,7 +37,6 @@...@@ -37,7 +37,6 @@
37#include <__utility/piecewise_construct.h>37#include <__utility/piecewise_construct.h>
38#include <__utility/swap.h>38#include <__utility/swap.h>
39#include <__verbose_abort>39#include <__verbose_abort>
40#include <new>
41#include <tuple>40#include <tuple>
42#include <typeinfo>41#include <typeinfo>
4342
...@@ -78,8 +77,8 @@ public:...@@ -78,8 +77,8 @@ public:
78};77};
79_LIBCPP_DIAGNOSTIC_POP78_LIBCPP_DIAGNOSTIC_POP
8079
81_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_function_call() {80[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_function_call() {
82# ifndef _LIBCPP_HAS_NO_EXCEPTIONS81# if _LIBCPP_HAS_EXCEPTIONS
83 throw bad_function_call();82 throw bad_function_call();
84# else83# else
85 _LIBCPP_VERBOSE_ABORT("bad_function_call was thrown in -fno-exceptions mode");84 _LIBCPP_VERBOSE_ABORT("bad_function_call was thrown in -fno-exceptions mode");
...@@ -123,7 +122,7 @@ _LIBCPP_HIDE_FROM_ABI bool __not_null(function<_Fp> const& __f) {...@@ -123,7 +122,7 @@ _LIBCPP_HIDE_FROM_ABI bool __not_null(function<_Fp> const& __f) {
123 return !!__f;122 return !!__f;
124}123}
125124
126# ifdef _LIBCPP_HAS_EXTENSION_BLOCKS125# if _LIBCPP_HAS_EXTENSION_BLOCKS
127template <class _Rp, class... _Args>126template <class _Rp, class... _Args>
128_LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) {127_LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) {
129 return __p;128 return __p;
...@@ -143,45 +142,45 @@ class __default_alloc_func;...@@ -143,45 +142,45 @@ class __default_alloc_func;
143142
144template <class _Fp, class _Ap, class _Rp, class... _ArgTypes>143template <class _Fp, class _Ap, class _Rp, class... _ArgTypes>
145class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> {144class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> {
146 __compressed_pair<_Fp, _Ap> __f_;145 _LIBCPP_COMPRESSED_PAIR(_Fp, __func_, _Ap, __alloc_);
147146
148public:147public:
149 typedef _LIBCPP_NODEBUG _Fp _Target;148 using _Target _LIBCPP_NODEBUG = _Fp;
150 typedef _LIBCPP_NODEBUG _Ap _Alloc;149 using _Alloc _LIBCPP_NODEBUG = _Ap;
151150
152 _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __f_.first(); }151 _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __func_; }
153152
154 // WIN32 APIs may define __allocator, so use __get_allocator instead.153 // WIN32 APIs may define __allocator, so use __get_allocator instead.
155 _LIBCPP_HIDE_FROM_ABI const _Alloc& __get_allocator() const { return __f_.second(); }154 _LIBCPP_HIDE_FROM_ABI const _Alloc& __get_allocator() const { return __alloc_; }
156155
157 _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f)156 _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f) : __func_(std::move(__f)), __alloc_() {}
158 : __f_(piecewise_construct, std::forward_as_tuple(std::move(__f)), std::forward_as_tuple()) {}
159157
160 _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, const _Alloc& __a)158 _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, const _Alloc& __a) : __func_(__f), __alloc_(__a) {}
161 : __f_(piecewise_construct, std::forward_as_tuple(__f), std::forward_as_tuple(__a)) {}
162159
163 _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, _Alloc&& __a)160 _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, _Alloc&& __a)
164 : __f_(piecewise_construct, std::forward_as_tuple(__f), std::forward_as_tuple(std::move(__a))) {}161 : __func_(__f), __alloc_(std::move(__a)) {}
165162
166 _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f, _Alloc&& __a)163 _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f, _Alloc&& __a)
167 : __f_(piecewise_construct, std::forward_as_tuple(std::move(__f)), std::forward_as_tuple(std::move(__a))) {}164 : __func_(std::move(__f)), __alloc_(std::move(__a)) {}
168165
169 _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) {166 _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) {
170 typedef __invoke_void_return_wrapper<_Rp> _Invoker;167 return std::__invoke_r<_Rp>(__func_, std::forward<_ArgTypes>(__arg)...);
171 return _Invoker::__call(__f_.first(), std::forward<_ArgTypes>(__arg)...);
172 }168 }
173169
174 _LIBCPP_HIDE_FROM_ABI __alloc_func* __clone() const {170 _LIBCPP_HIDE_FROM_ABI __alloc_func* __clone() const {
175 typedef allocator_traits<_Alloc> __alloc_traits;171 typedef allocator_traits<_Alloc> __alloc_traits;
176 typedef __rebind_alloc<__alloc_traits, __alloc_func> _AA;172 typedef __rebind_alloc<__alloc_traits, __alloc_func> _AA;
177 _AA __a(__f_.second());173 _AA __a(__alloc_);
178 typedef __allocator_destructor<_AA> _Dp;174 typedef __allocator_destructor<_AA> _Dp;
179 unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));175 unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
180 ::new ((void*)__hold.get()) __alloc_func(__f_.first(), _Alloc(__a));176 ::new ((void*)__hold.get()) __alloc_func(__func_, _Alloc(__a));
181 return __hold.release();177 return __hold.release();
182 }178 }
183179
184 _LIBCPP_HIDE_FROM_ABI void destroy() _NOEXCEPT { __f_.~__compressed_pair<_Target, _Alloc>(); }180 _LIBCPP_HIDE_FROM_ABI void destroy() _NOEXCEPT {
181 __func_.~_Fp();
182 __alloc_.~_Alloc();
183 }
185184
186 _LIBCPP_HIDE_FROM_ABI static void __destroy_and_delete(__alloc_func* __f) {185 _LIBCPP_HIDE_FROM_ABI static void __destroy_and_delete(__alloc_func* __f) {
187 typedef allocator_traits<_Alloc> __alloc_traits;186 typedef allocator_traits<_Alloc> __alloc_traits;
...@@ -192,12 +191,19 @@ public:...@@ -192,12 +191,19 @@ public:
192 }191 }
193};192};
194193
194template <class _Tp>
195struct __deallocating_deleter {
196 _LIBCPP_HIDE_FROM_ABI void operator()(void* __p) const {
197 std::__libcpp_deallocate<_Tp>(static_cast<_Tp*>(__p), __element_count(1));
198 }
199};
200
195template <class _Fp, class _Rp, class... _ArgTypes>201template <class _Fp, class _Rp, class... _ArgTypes>
196class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> {202class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> {
197 _Fp __f_;203 _Fp __f_;
198204
199public:205public:
200 typedef _LIBCPP_NODEBUG _Fp _Target;206 using _Target _LIBCPP_NODEBUG = _Fp;
201207
202 _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __f_; }208 _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __f_; }
203209
...@@ -206,13 +212,13 @@ public:...@@ -206,13 +212,13 @@ public:
206 _LIBCPP_HIDE_FROM_ABI explicit __default_alloc_func(const _Target& __f) : __f_(__f) {}212 _LIBCPP_HIDE_FROM_ABI explicit __default_alloc_func(const _Target& __f) : __f_(__f) {}
207213
208 _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) {214 _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) {
209 typedef __invoke_void_return_wrapper<_Rp> _Invoker;215 return std::__invoke_r<_Rp>(__f_, std::forward<_ArgTypes>(__arg)...);
210 return _Invoker::__call(__f_, std::forward<_ArgTypes>(__arg)...);
211 }216 }
212217
213 _LIBCPP_HIDE_FROM_ABI __default_alloc_func* __clone() const {218 _LIBCPP_HIDE_FROM_ABI __default_alloc_func* __clone() const {
214 __builtin_new_allocator::__holder_t __hold = __builtin_new_allocator::__allocate_type<__default_alloc_func>(1);219 using _Self = __default_alloc_func;
215 __default_alloc_func* __res = ::new ((void*)__hold.get()) __default_alloc_func(__f_);220 unique_ptr<_Self, __deallocating_deleter<_Self>> __hold(std::__libcpp_allocate<_Self>(__element_count(1)));
221 _Self* __res = ::new ((void*)__hold.get()) _Self(__f_);
216 (void)__hold.release();222 (void)__hold.release();
217 return __res;223 return __res;
218 }224 }
...@@ -221,7 +227,7 @@ public:...@@ -221,7 +227,7 @@ public:
221227
222 _LIBCPP_HIDE_FROM_ABI static void __destroy_and_delete(__default_alloc_func* __f) {228 _LIBCPP_HIDE_FROM_ABI static void __destroy_and_delete(__default_alloc_func* __f) {
223 __f->destroy();229 __f->destroy();
224 __builtin_new_allocator::__deallocate_type<__default_alloc_func>(__f, 1);230 std::__libcpp_deallocate<__default_alloc_func>(__f, __element_count(1));
225 }231 }
226};232};
227233
...@@ -243,10 +249,10 @@ public:...@@ -243,10 +249,10 @@ public:
243 virtual void destroy() _NOEXCEPT = 0;249 virtual void destroy() _NOEXCEPT = 0;
244 virtual void destroy_deallocate() _NOEXCEPT = 0;250 virtual void destroy_deallocate() _NOEXCEPT = 0;
245 virtual _Rp operator()(_ArgTypes&&...) = 0;251 virtual _Rp operator()(_ArgTypes&&...) = 0;
246# ifndef _LIBCPP_HAS_NO_RTTI252# if _LIBCPP_HAS_RTTI
247 virtual const void* target(const type_info&) const _NOEXCEPT = 0;253 virtual const void* target(const type_info&) const _NOEXCEPT = 0;
248 virtual const std::type_info& target_type() const _NOEXCEPT = 0;254 virtual const std::type_info& target_type() const _NOEXCEPT = 0;
249# endif // _LIBCPP_HAS_NO_RTTI255# endif // _LIBCPP_HAS_RTTI
250};256};
251257
252// __func implements __base for a given functor type.258// __func implements __base for a given functor type.
...@@ -272,10 +278,10 @@ public:...@@ -272,10 +278,10 @@ public:
272 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT;278 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT;
273 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate() _NOEXCEPT;279 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate() _NOEXCEPT;
274 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual _Rp operator()(_ArgTypes&&... __arg);280 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual _Rp operator()(_ArgTypes&&... __arg);
275# ifndef _LIBCPP_HAS_NO_RTTI281# if _LIBCPP_HAS_RTTI
276 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(const type_info&) const _NOEXCEPT;282 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(const type_info&) const _NOEXCEPT;
277 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT;283 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT;
278# endif // _LIBCPP_HAS_NO_RTTI284# endif // _LIBCPP_HAS_RTTI
279};285};
280286
281template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>287template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
...@@ -313,7 +319,7 @@ _Rp __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&&... __arg) {...@@ -313,7 +319,7 @@ _Rp __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&&... __arg) {
313 return __f_(std::forward<_ArgTypes>(__arg)...);319 return __f_(std::forward<_ArgTypes>(__arg)...);
314}320}
315321
316# ifndef _LIBCPP_HAS_NO_RTTI322# if _LIBCPP_HAS_RTTI
317323
318template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>324template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
319const void* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT {325const void* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT {
...@@ -327,7 +333,7 @@ const std::type_info& __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() cons...@@ -327,7 +333,7 @@ const std::type_info& __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() cons
327 return typeid(_Fp);333 return typeid(_Fp);
328}334}
329335
330# endif // _LIBCPP_HAS_NO_RTTI336# endif // _LIBCPP_HAS_RTTI
331337
332// __value_func creates a value-type from a __func.338// __value_func creates a value-type from a __func.
333339
...@@ -464,7 +470,7 @@ public:...@@ -464,7 +470,7 @@ public:
464470
465 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __f_ != nullptr; }471 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __f_ != nullptr; }
466472
467# ifndef _LIBCPP_HAS_NO_RTTI473# if _LIBCPP_HAS_RTTI
468 _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT {474 _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT {
469 if (__f_ == nullptr)475 if (__f_ == nullptr)
470 return typeid(void);476 return typeid(void);
...@@ -477,7 +483,7 @@ public:...@@ -477,7 +483,7 @@ public:
477 return nullptr;483 return nullptr;
478 return (const _Tp*)__f_->target(typeid(_Tp));484 return (const _Tp*)__f_->target(typeid(_Tp));
479 }485 }
480# endif // _LIBCPP_HAS_NO_RTTI486# endif // _LIBCPP_HAS_RTTI
481};487};
482488
483// Storage for a functor object, to be used with __policy to manage copy and489// Storage for a functor object, to be used with __policy to manage copy and
...@@ -520,7 +526,7 @@ struct __policy {...@@ -520,7 +526,7 @@ struct __policy {
520 nullptr,526 nullptr,
521 nullptr,527 nullptr,
522 true,528 true,
523# ifndef _LIBCPP_HAS_NO_RTTI529# if _LIBCPP_HAS_RTTI
524 &typeid(void)530 &typeid(void)
525# else531# else
526 nullptr532 nullptr
...@@ -547,7 +553,7 @@ private:...@@ -547,7 +553,7 @@ private:
547 &__large_clone<_Fun>,553 &__large_clone<_Fun>,
548 &__large_destroy<_Fun>,554 &__large_destroy<_Fun>,
549 false,555 false,
550# ifndef _LIBCPP_HAS_NO_RTTI556# if _LIBCPP_HAS_RTTI
551 &typeid(typename _Fun::_Target)557 &typeid(typename _Fun::_Target)
552# else558# else
553 nullptr559 nullptr
...@@ -562,7 +568,7 @@ private:...@@ -562,7 +568,7 @@ private:
562 nullptr,568 nullptr,
563 nullptr,569 nullptr,
564 false,570 false,
565# ifndef _LIBCPP_HAS_NO_RTTI571# if _LIBCPP_HAS_RTTI
566 &typeid(typename _Fun::_Target)572 &typeid(typename _Fun::_Target)
567# else573# else
568 nullptr574 nullptr
...@@ -575,7 +581,7 @@ private:...@@ -575,7 +581,7 @@ private:
575// Used to choose between perfect forwarding or pass-by-value. Pass-by-value is581// Used to choose between perfect forwarding or pass-by-value. Pass-by-value is
576// faster for types that can be passed in registers.582// faster for types that can be passed in registers.
577template <typename _Tp>583template <typename _Tp>
578using __fast_forward = __conditional_t<is_scalar<_Tp>::value, _Tp, _Tp&&>;584using __fast_forward _LIBCPP_NODEBUG = __conditional_t<is_scalar<_Tp>::value, _Tp, _Tp&&>;
579585
580// __policy_invoker calls an instance of __alloc_func held in __policy_storage.586// __policy_invoker calls an instance of __alloc_func held in __policy_storage.
581587
...@@ -667,8 +673,8 @@ public:...@@ -667,8 +673,8 @@ public:
667 if (__use_small_storage<_Fun>()) {673 if (__use_small_storage<_Fun>()) {
668 ::new ((void*)&__buf_.__small) _Fun(std::move(__f));674 ::new ((void*)&__buf_.__small) _Fun(std::move(__f));
669 } else {675 } else {
670 __builtin_new_allocator::__holder_t __hold = __builtin_new_allocator::__allocate_type<_Fun>(1);676 unique_ptr<_Fun, __deallocating_deleter<_Fun>> __hold(std::__libcpp_allocate<_Fun>(__element_count(1)));
671 __buf_.__large = ::new ((void*)__hold.get()) _Fun(std::move(__f));677 __buf_.__large = ::new ((void*)__hold.get()) _Fun(std::move(__f));
672 (void)__hold.release();678 (void)__hold.release();
673 }679 }
674 }680 }
...@@ -724,7 +730,7 @@ public:...@@ -724,7 +730,7 @@ public:
724730
725 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return !__policy_->__is_null; }731 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return !__policy_->__is_null; }
726732
727# ifndef _LIBCPP_HAS_NO_RTTI733# if _LIBCPP_HAS_RTTI
728 _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT { return *__policy_->__type_info; }734 _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT { return *__policy_->__type_info; }
729735
730 template <typename _Tp>736 template <typename _Tp>
...@@ -736,10 +742,10 @@ public:...@@ -736,10 +742,10 @@ public:
736 else742 else
737 return reinterpret_cast<const _Tp*>(&__buf_.__small);743 return reinterpret_cast<const _Tp*>(&__buf_.__small);
738 }744 }
739# endif // _LIBCPP_HAS_NO_RTTI745# endif // _LIBCPP_HAS_RTTI
740};746};
741747
742# if defined(_LIBCPP_HAS_BLOCKS_RUNTIME)748# if _LIBCPP_HAS_BLOCKS_RUNTIME
743749
744extern "C" void* _Block_copy(const void*);750extern "C" void* _Block_copy(const void*);
745extern "C" void _Block_release(const void*);751extern "C" void _Block_release(const void*);
...@@ -751,7 +757,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base...@@ -751,7 +757,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base
751757
752public:758public:
753 _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type const& __f)759 _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type const& __f)
754# ifdef _LIBCPP_HAS_OBJC_ARC760# if _LIBCPP_HAS_OBJC_ARC
755 : __f_(__f)761 : __f_(__f)
756# else762# else
757 : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))763 : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
...@@ -762,7 +768,7 @@ public:...@@ -762,7 +768,7 @@ public:
762 // [TODO] add && to save on a retain768 // [TODO] add && to save on a retain
763769
764 _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type __f, const _Alloc& /* unused */)770 _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type __f, const _Alloc& /* unused */)
765# ifdef _LIBCPP_HAS_OBJC_ARC771# if _LIBCPP_HAS_OBJC_ARC
766 : __f_(__f)772 : __f_(__f)
767# else773# else
768 : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))774 : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
...@@ -784,7 +790,7 @@ public:...@@ -784,7 +790,7 @@ public:
784 }790 }
785791
786 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT {792 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT {
787# ifndef _LIBCPP_HAS_OBJC_ARC793# if !_LIBCPP_HAS_OBJC_ARC
788 if (__f_)794 if (__f_)
789 _Block_release(__f_);795 _Block_release(__f_);
790# endif796# endif
...@@ -803,7 +809,7 @@ public:...@@ -803,7 +809,7 @@ public:
803 return std::__invoke(__f_, std::forward<_ArgTypes>(__arg)...);809 return std::__invoke(__f_, std::forward<_ArgTypes>(__arg)...);
804 }810 }
805811
806# ifndef _LIBCPP_HAS_NO_RTTI812# if _LIBCPP_HAS_RTTI
807 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(type_info const& __ti) const _NOEXCEPT {813 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(type_info const& __ti) const _NOEXCEPT {
808 if (__ti == typeid(__func::__block_type))814 if (__ti == typeid(__func::__block_type))
809 return &__f_;815 return &__f_;
...@@ -813,7 +819,7 @@ public:...@@ -813,7 +819,7 @@ public:
813 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT {819 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT {
814 return typeid(__func::__block_type);820 return typeid(__func::__block_type);
815 }821 }
816# endif // _LIBCPP_HAS_NO_RTTI822# endif // _LIBCPP_HAS_RTTI
817};823};
818824
819# endif // _LIBCPP_HAS_EXTENSION_BLOCKS825# endif // _LIBCPP_HAS_EXTENSION_BLOCKS
...@@ -833,12 +839,12 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>...@@ -833,12 +839,12 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
833 __func __f_;839 __func __f_;
834840
835 template <class _Fp,841 template <class _Fp,
836 bool = _And< _IsNotSame<__remove_cvref_t<_Fp>, function>, __invokable<_Fp, _ArgTypes...> >::value>842 bool = _And<_IsNotSame<__remove_cvref_t<_Fp>, function>, __is_invocable<_Fp, _ArgTypes...> >::value>
837 struct __callable;843 struct __callable;
838 template <class _Fp>844 template <class _Fp>
839 struct __callable<_Fp, true> {845 struct __callable<_Fp, true> {
840 static const bool value =846 static const bool value =
841 is_void<_Rp>::value || __is_core_convertible<typename __invoke_of<_Fp, _ArgTypes...>::type, _Rp>::value;847 is_void<_Rp>::value || __is_core_convertible<__invoke_result_t<_Fp, _ArgTypes...>, _Rp>::value;
842 };848 };
843 template <class _Fp>849 template <class _Fp>
844 struct __callable<_Fp, false> {850 struct __callable<_Fp, false> {
...@@ -846,14 +852,14 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>...@@ -846,14 +852,14 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
846 };852 };
847853
848 template <class _Fp>854 template <class _Fp>
849 using _EnableIfLValueCallable = __enable_if_t<__callable<_Fp&>::value>;855 using _EnableIfLValueCallable _LIBCPP_NODEBUG = __enable_if_t<__callable<_Fp&>::value>;
850856
851public:857public:
852 typedef _Rp result_type;858 typedef _Rp result_type;
853859
854 // construct/copy/destroy:860 // construct/copy/destroy:
855 _LIBCPP_HIDE_FROM_ABI function() _NOEXCEPT {}861 _LIBCPP_HIDE_FROM_ABI function() _NOEXCEPT {}
856 _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDE_FROM_ABI function(nullptr_t) _NOEXCEPT {}862 _LIBCPP_HIDE_FROM_ABI function(nullptr_t) _NOEXCEPT {}
857 _LIBCPP_HIDE_FROM_ABI function(const function&);863 _LIBCPP_HIDE_FROM_ABI function(const function&);
858 _LIBCPP_HIDE_FROM_ABI function(function&&) _NOEXCEPT;864 _LIBCPP_HIDE_FROM_ABI function(function&&) _NOEXCEPT;
859 template <class _Fp, class = _EnableIfLValueCallable<_Fp>>865 template <class _Fp, class = _EnableIfLValueCallable<_Fp>>
...@@ -905,14 +911,14 @@ public:...@@ -905,14 +911,14 @@ public:
905 // function invocation:911 // function invocation:
906 _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes...) const;912 _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes...) const;
907913
908# ifndef _LIBCPP_HAS_NO_RTTI914# if _LIBCPP_HAS_RTTI
909 // function target access:915 // function target access:
910 _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT;916 _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT;
911 template <typename _Tp>917 template <typename _Tp>
912 _LIBCPP_HIDE_FROM_ABI _Tp* target() _NOEXCEPT;918 _LIBCPP_HIDE_FROM_ABI _Tp* target() _NOEXCEPT;
913 template <typename _Tp>919 template <typename _Tp>
914 _LIBCPP_HIDE_FROM_ABI const _Tp* target() const _NOEXCEPT;920 _LIBCPP_HIDE_FROM_ABI const _Tp* target() const _NOEXCEPT;
915# endif // _LIBCPP_HAS_NO_RTTI921# endif // _LIBCPP_HAS_RTTI
916};922};
917923
918# if _LIBCPP_STD_VER >= 17924# if _LIBCPP_STD_VER >= 17
...@@ -989,7 +995,7 @@ _Rp function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const {...@@ -989,7 +995,7 @@ _Rp function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const {
989 return __f_(std::forward<_ArgTypes>(__arg)...);995 return __f_(std::forward<_ArgTypes>(__arg)...);
990}996}
991997
992# ifndef _LIBCPP_HAS_NO_RTTI998# if _LIBCPP_HAS_RTTI
993999
994template <class _Rp, class... _ArgTypes>1000template <class _Rp, class... _ArgTypes>
995const std::type_info& function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT {1001const std::type_info& function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT {
...@@ -1008,7 +1014,7 @@ const _Tp* function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT {...@@ -1008,7 +1014,7 @@ const _Tp* function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT {
1008 return __f_.template target<_Tp>();1014 return __f_.template target<_Tp>();
1009}1015}
10101016
1011# endif // _LIBCPP_HAS_NO_RTTI1017# endif // _LIBCPP_HAS_RTTI
10121018
1013template <class _Rp, class... _ArgTypes>1019template <class _Rp, class... _ArgTypes>
1014inline _LIBCPP_HIDE_FROM_ABI bool operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {1020inline _LIBCPP_HIDE_FROM_ABI bool operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {
lib/libcxx/include/__functional/hash.h+13-8
...@@ -10,16 +10,17 @@...@@ -10,16 +10,17 @@
10#define _LIBCPP___FUNCTIONAL_HASH_H10#define _LIBCPP___FUNCTIONAL_HASH_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/nullptr_t.h>
13#include <__functional/unary_function.h>14#include <__functional/unary_function.h>
14#include <__fwd/functional.h>15#include <__fwd/functional.h>
15#include <__type_traits/conjunction.h>16#include <__type_traits/conjunction.h>
17#include <__type_traits/enable_if.h>
16#include <__type_traits/invoke.h>18#include <__type_traits/invoke.h>
17#include <__type_traits/is_constructible.h>19#include <__type_traits/is_constructible.h>
18#include <__type_traits/is_enum.h>20#include <__type_traits/is_enum.h>
19#include <__type_traits/underlying_type.h>21#include <__type_traits/underlying_type.h>
20#include <__utility/pair.h>22#include <__utility/pair.h>
21#include <__utility/swap.h>23#include <__utility/swap.h>
22#include <cstddef>
23#include <cstdint>24#include <cstdint>
24#include <cstring>25#include <cstring>
2526
...@@ -355,12 +356,12 @@ struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> : public __unary_function<unsign...@@ -355,12 +356,12 @@ struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> : public __unary_function<unsign
355 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned char __v) const _NOEXCEPT { return static_cast<size_t>(__v); }356 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned char __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
356};357};
357358
358#ifndef _LIBCPP_HAS_NO_CHAR8_T359#if _LIBCPP_HAS_CHAR8_T
359template <>360template <>
360struct _LIBCPP_TEMPLATE_VIS hash<char8_t> : public __unary_function<char8_t, size_t> {361struct _LIBCPP_TEMPLATE_VIS hash<char8_t> : public __unary_function<char8_t, size_t> {
361 _LIBCPP_HIDE_FROM_ABI size_t operator()(char8_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); }362 _LIBCPP_HIDE_FROM_ABI size_t operator()(char8_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
362};363};
363#endif // !_LIBCPP_HAS_NO_CHAR8_T364#endif // _LIBCPP_HAS_CHAR8_T
364365
365template <>366template <>
366struct _LIBCPP_TEMPLATE_VIS hash<char16_t> : public __unary_function<char16_t, size_t> {367struct _LIBCPP_TEMPLATE_VIS hash<char16_t> : public __unary_function<char16_t, size_t> {
...@@ -372,12 +373,12 @@ struct _LIBCPP_TEMPLATE_VIS hash<char32_t> : public __unary_function<char32_t, s...@@ -372,12 +373,12 @@ struct _LIBCPP_TEMPLATE_VIS hash<char32_t> : public __unary_function<char32_t, s
372 _LIBCPP_HIDE_FROM_ABI size_t operator()(char32_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); }373 _LIBCPP_HIDE_FROM_ABI size_t operator()(char32_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
373};374};
374375
375#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS376#if _LIBCPP_HAS_WIDE_CHARACTERS
376template <>377template <>
377struct _LIBCPP_TEMPLATE_VIS hash<wchar_t> : public __unary_function<wchar_t, size_t> {378struct _LIBCPP_TEMPLATE_VIS hash<wchar_t> : public __unary_function<wchar_t, size_t> {
378 _LIBCPP_HIDE_FROM_ABI size_t operator()(wchar_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); }379 _LIBCPP_HIDE_FROM_ABI size_t operator()(wchar_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
379};380};
380#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS381#endif // _LIBCPP_HAS_WIDE_CHARACTERS
381382
382template <>383template <>
383struct _LIBCPP_TEMPLATE_VIS hash<short> : public __unary_function<short, size_t> {384struct _LIBCPP_TEMPLATE_VIS hash<short> : public __unary_function<short, size_t> {
...@@ -406,7 +407,11 @@ struct _LIBCPP_TEMPLATE_VIS hash<long> : public __unary_function<long, size_t> {...@@ -406,7 +407,11 @@ struct _LIBCPP_TEMPLATE_VIS hash<long> : public __unary_function<long, size_t> {
406407
407template <>408template <>
408struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> : public __unary_function<unsigned long, size_t> {409struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> : public __unary_function<unsigned long, size_t> {
409 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned long __v) const _NOEXCEPT { return static_cast<size_t>(__v); }410 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned long __v) const _NOEXCEPT {
411 static_assert(sizeof(size_t) >= sizeof(unsigned long),
412 "This would be a terrible hash function on a platform where size_t is smaller than unsigned long");
413 return static_cast<size_t>(__v);
414 }
410};415};
411416
412template <>417template <>
...@@ -415,7 +420,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<long long> : public __scalar_hash<long long> {}...@@ -415,7 +420,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<long long> : public __scalar_hash<long long> {}
415template <>420template <>
416struct _LIBCPP_TEMPLATE_VIS hash<unsigned long long> : public __scalar_hash<unsigned long long> {};421struct _LIBCPP_TEMPLATE_VIS hash<unsigned long long> : public __scalar_hash<unsigned long long> {};
417422
418#ifndef _LIBCPP_HAS_NO_INT128423#if _LIBCPP_HAS_INT128
419424
420template <>425template <>
421struct _LIBCPP_TEMPLATE_VIS hash<__int128_t> : public __scalar_hash<__int128_t> {};426struct _LIBCPP_TEMPLATE_VIS hash<__int128_t> : public __scalar_hash<__int128_t> {};
...@@ -517,7 +522,7 @@ template <class _Key, class _Hash>...@@ -517,7 +522,7 @@ template <class _Key, class _Hash>
517using __check_hash_requirements _LIBCPP_NODEBUG =522using __check_hash_requirements _LIBCPP_NODEBUG =
518 integral_constant<bool,523 integral_constant<bool,
519 is_copy_constructible<_Hash>::value && is_move_constructible<_Hash>::value &&524 is_copy_constructible<_Hash>::value && is_move_constructible<_Hash>::value &&
520 __invokable_r<size_t, _Hash, _Key const&>::value >;525 __is_invocable_r_v<size_t, _Hash, _Key const&> >;
521526
522template <class _Key, class _Hash = hash<_Key> >527template <class _Key, class _Hash = hash<_Key> >
523using __has_enabled_hash _LIBCPP_NODEBUG =528using __has_enabled_hash _LIBCPP_NODEBUG =
lib/libcxx/include/__functional/identity.h+1-1
...@@ -26,7 +26,7 @@ struct __is_identity : false_type {};...@@ -26,7 +26,7 @@ struct __is_identity : false_type {};
2626
27struct __identity {27struct __identity {
28 template <class _Tp>28 template <class _Tp>
29 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& operator()(_Tp&& __t) const _NOEXCEPT {29 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& operator()(_Tp&& __t) const _NOEXCEPT {
30 return std::forward<_Tp>(__t);30 return std::forward<_Tp>(__t);
31 }31 }
3232
lib/libcxx/include/__functional/invoke.h+1
...@@ -12,6 +12,7 @@...@@ -12,6 +12,7 @@
1212
13#include <__config>13#include <__config>
14#include <__type_traits/invoke.h>14#include <__type_traits/invoke.h>
15#include <__type_traits/is_void.h>
15#include <__utility/forward.h>16#include <__utility/forward.h>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__functional/is_transparent.h+3-3
...@@ -21,11 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,11 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if _LIBCPP_STD_VER >= 1422#if _LIBCPP_STD_VER >= 14
2323
24template <class _Tp, class, class = void>24template <class _Tp, class _Key = void, class = void>
25inline const bool __is_transparent_v = false;25inline const bool __is_transparent_v = false;
2626
27template <class _Tp, class _Up>27template <class _Tp, class _Key>
28inline const bool __is_transparent_v<_Tp, _Up, __void_t<typename _Tp::is_transparent> > = true;28inline const bool __is_transparent_v<_Tp, _Key, __void_t<typename _Tp::is_transparent> > = true;
2929
30#endif30#endif
3131
lib/libcxx/include/__functional/mem_fn.h+3-5
...@@ -12,8 +12,8 @@...@@ -12,8 +12,8 @@
1212
13#include <__config>13#include <__config>
14#include <__functional/binary_function.h>14#include <__functional/binary_function.h>
15#include <__functional/invoke.h>
16#include <__functional/weak_result_type.h>15#include <__functional/weak_result_type.h>
16#include <__type_traits/invoke.h>
17#include <__utility/forward.h>17#include <__utility/forward.h>
1818
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -36,10 +36,8 @@ public:...@@ -36,10 +36,8 @@ public:
3636
37 // invoke37 // invoke
38 template <class... _ArgTypes>38 template <class... _ArgTypes>
39 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX2039 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<const _Tp&, _ArgTypes...>
4040 operator()(_ArgTypes&&... __args) const _NOEXCEPT_(__is_nothrow_invocable_v<const _Tp&, _ArgTypes...>) {
41 typename __invoke_return<type, _ArgTypes...>::type
42 operator()(_ArgTypes&&... __args) const {
43 return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...);41 return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...);
44 }42 }
45};43};
lib/libcxx/include/__functional/not_fn.h+23
...@@ -16,6 +16,8 @@...@@ -16,6 +16,8 @@
16#include <__type_traits/decay.h>16#include <__type_traits/decay.h>
17#include <__type_traits/enable_if.h>17#include <__type_traits/enable_if.h>
18#include <__type_traits/is_constructible.h>18#include <__type_traits/is_constructible.h>
19#include <__type_traits/is_member_pointer.h>
20#include <__type_traits/is_pointer.h>
19#include <__utility/forward.h>21#include <__utility/forward.h>
2022
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -48,6 +50,27 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto not_fn(_Fn&& __f) {...@@ -48,6 +50,27 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto not_fn(_Fn&& __f) {
4850
49#endif // _LIBCPP_STD_VER >= 1751#endif // _LIBCPP_STD_VER >= 17
5052
53#if _LIBCPP_STD_VER >= 26
54
55template <auto _Fn>
56struct __nttp_not_fn_t {
57 template <class... _Args>
58 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const
59 noexcept(noexcept(!std::invoke(_Fn, std::forward<_Args>(__args)...)))
60 -> decltype(!std::invoke(_Fn, std::forward<_Args>(__args)...)) {
61 return !std::invoke(_Fn, std::forward<_Args>(__args)...);
62 }
63};
64
65template <auto _Fn>
66[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr auto not_fn() noexcept {
67 if constexpr (using _Ty = decltype(_Fn); is_pointer_v<_Ty> || is_member_pointer_v<_Ty>)
68 static_assert(_Fn != nullptr, "f cannot be equal to nullptr");
69 return __nttp_not_fn_t<_Fn>();
70}
71
72#endif // _LIBCPP_STD_VER >= 26
73
51_LIBCPP_END_NAMESPACE_STD74_LIBCPP_END_NAMESPACE_STD
5275
53#endif // _LIBCPP___FUNCTIONAL_NOT_FN_H76#endif // _LIBCPP___FUNCTIONAL_NOT_FN_H
lib/libcxx/include/__functional/operations.h+14-1
...@@ -14,6 +14,7 @@...@@ -14,6 +14,7 @@
14#include <__functional/binary_function.h>14#include <__functional/binary_function.h>
15#include <__functional/unary_function.h>15#include <__functional/unary_function.h>
16#include <__type_traits/desugars_to.h>16#include <__type_traits/desugars_to.h>
17#include <__type_traits/is_integral.h>
17#include <__utility/forward.h>18#include <__utility/forward.h>
1819
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -364,6 +365,9 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);...@@ -364,6 +365,9 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
364template <class _Tp>365template <class _Tp>
365inline const bool __desugars_to_v<__less_tag, less<_Tp>, _Tp, _Tp> = true;366inline const bool __desugars_to_v<__less_tag, less<_Tp>, _Tp, _Tp> = true;
366367
368template <class _Tp>
369inline const bool __desugars_to_v<__totally_ordered_less_tag, less<_Tp>, _Tp, _Tp> = is_integral<_Tp>::value;
370
367#if _LIBCPP_STD_VER >= 14371#if _LIBCPP_STD_VER >= 14
368template <>372template <>
369struct _LIBCPP_TEMPLATE_VIS less<void> {373struct _LIBCPP_TEMPLATE_VIS less<void> {
...@@ -376,8 +380,11 @@ struct _LIBCPP_TEMPLATE_VIS less<void> {...@@ -376,8 +380,11 @@ struct _LIBCPP_TEMPLATE_VIS less<void> {
376 typedef void is_transparent;380 typedef void is_transparent;
377};381};
378382
383template <class _Tp, class _Up>
384inline const bool __desugars_to_v<__less_tag, less<>, _Tp, _Up> = true;
385
379template <class _Tp>386template <class _Tp>
380inline const bool __desugars_to_v<__less_tag, less<>, _Tp, _Tp> = true;387inline const bool __desugars_to_v<__totally_ordered_less_tag, less<>, _Tp, _Tp> = is_integral<_Tp>::value;
381#endif388#endif
382389
383#if _LIBCPP_STD_VER >= 14390#if _LIBCPP_STD_VER >= 14
...@@ -445,6 +452,9 @@ struct _LIBCPP_TEMPLATE_VIS greater : __binary_function<_Tp, _Tp, bool> {...@@ -445,6 +452,9 @@ struct _LIBCPP_TEMPLATE_VIS greater : __binary_function<_Tp, _Tp, bool> {
445};452};
446_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);453_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);
447454
455template <class _Tp>
456inline const bool __desugars_to_v<__greater_tag, greater<_Tp>, _Tp, _Tp> = true;
457
448#if _LIBCPP_STD_VER >= 14458#if _LIBCPP_STD_VER >= 14
449template <>459template <>
450struct _LIBCPP_TEMPLATE_VIS greater<void> {460struct _LIBCPP_TEMPLATE_VIS greater<void> {
...@@ -456,6 +466,9 @@ struct _LIBCPP_TEMPLATE_VIS greater<void> {...@@ -456,6 +466,9 @@ struct _LIBCPP_TEMPLATE_VIS greater<void> {
456 }466 }
457 typedef void is_transparent;467 typedef void is_transparent;
458};468};
469
470template <class _Tp, class _Up>
471inline const bool __desugars_to_v<__greater_tag, greater<>, _Tp, _Up> = true;
459#endif472#endif
460473
461// Logical operations474// Logical operations
lib/libcxx/include/__functional/perfect_forward.h+2-1
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
11#define _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H11#define _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/size_t.h>
14#include <__type_traits/enable_if.h>15#include <__type_traits/enable_if.h>
15#include <__type_traits/invoke.h>16#include <__type_traits/invoke.h>
16#include <__type_traits/is_constructible.h>17#include <__type_traits/is_constructible.h>
...@@ -93,7 +94,7 @@ public:...@@ -93,7 +94,7 @@ public:
9394
94// __perfect_forward implements a perfect-forwarding call wrapper as explained in [func.require].95// __perfect_forward implements a perfect-forwarding call wrapper as explained in [func.require].
95template <class _Op, class... _Args>96template <class _Op, class... _Args>
96using __perfect_forward = __perfect_forward_impl<_Op, index_sequence_for<_Args...>, _Args...>;97using __perfect_forward _LIBCPP_NODEBUG = __perfect_forward_impl<_Op, index_sequence_for<_Args...>, _Args...>;
9798
98#endif // _LIBCPP_STD_VER >= 1799#endif // _LIBCPP_STD_VER >= 17
99100
lib/libcxx/include/__functional/ranges_operations.h+6
...@@ -99,9 +99,15 @@ struct greater_equal {...@@ -99,9 +99,15 @@ struct greater_equal {
99template <class _Tp, class _Up>99template <class _Tp, class _Up>
100inline const bool __desugars_to_v<__equal_tag, ranges::equal_to, _Tp, _Up> = true;100inline const bool __desugars_to_v<__equal_tag, ranges::equal_to, _Tp, _Up> = true;
101101
102template <class _Tp, class _Up>
103inline const bool __desugars_to_v<__totally_ordered_less_tag, ranges::less, _Tp, _Up> = true;
104
102template <class _Tp, class _Up>105template <class _Tp, class _Up>
103inline const bool __desugars_to_v<__less_tag, ranges::less, _Tp, _Up> = true;106inline const bool __desugars_to_v<__less_tag, ranges::less, _Tp, _Up> = true;
104107
108template <class _Tp, class _Up>
109inline const bool __desugars_to_v<__greater_tag, ranges::greater, _Tp, _Up> = true;
110
105#endif // _LIBCPP_STD_VER >= 20111#endif // _LIBCPP_STD_VER >= 20
106112
107_LIBCPP_END_NAMESPACE_STD113_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__functional/reference_wrapper.h+2-2
...@@ -13,10 +13,10 @@...@@ -13,10 +13,10 @@
13#include <__compare/synth_three_way.h>13#include <__compare/synth_three_way.h>
14#include <__concepts/boolean_testable.h>14#include <__concepts/boolean_testable.h>
15#include <__config>15#include <__config>
16#include <__functional/invoke.h>
17#include <__functional/weak_result_type.h>16#include <__functional/weak_result_type.h>
18#include <__memory/addressof.h>17#include <__memory/addressof.h>
19#include <__type_traits/enable_if.h>18#include <__type_traits/enable_if.h>
19#include <__type_traits/invoke.h>
20#include <__type_traits/is_const.h>20#include <__type_traits/is_const.h>
21#include <__type_traits/remove_cvref.h>21#include <__type_traits/remove_cvref.h>
22#include <__type_traits/void_t.h>22#include <__type_traits/void_t.h>
...@@ -57,7 +57,7 @@ public:...@@ -57,7 +57,7 @@ public:
5757
58 // invoke58 // invoke
59 template <class... _ArgTypes>59 template <class... _ArgTypes>
60 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<type&, _ArgTypes...>::type60 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<type&, _ArgTypes...>
61 operator()(_ArgTypes&&... __args) const61 operator()(_ArgTypes&&... __args) const
62#if _LIBCPP_STD_VER >= 1762#if _LIBCPP_STD_VER >= 17
63 // Since is_nothrow_invocable requires C++17 LWG3764 is not backported63 // Since is_nothrow_invocable requires C++17 LWG3764 is not backported
lib/libcxx/include/__functional/unary_function.h+2-2
...@@ -39,11 +39,11 @@ struct __unary_function_keep_layout_base {...@@ -39,11 +39,11 @@ struct __unary_function_keep_layout_base {
39_LIBCPP_DIAGNOSTIC_PUSH39_LIBCPP_DIAGNOSTIC_PUSH
40_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")40_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
41template <class _Arg, class _Result>41template <class _Arg, class _Result>
42using __unary_function = unary_function<_Arg, _Result>;42using __unary_function _LIBCPP_NODEBUG = unary_function<_Arg, _Result>;
43_LIBCPP_DIAGNOSTIC_POP43_LIBCPP_DIAGNOSTIC_POP
44#else44#else
45template <class _Arg, class _Result>45template <class _Arg, class _Result>
46using __unary_function = __unary_function_keep_layout_base<_Arg, _Result>;46using __unary_function _LIBCPP_NODEBUG = __unary_function_keep_layout_base<_Arg, _Result>;
47#endif47#endif
4848
49_LIBCPP_END_NAMESPACE_STD49_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__functional/weak_result_type.h+1-6
...@@ -12,9 +12,9 @@...@@ -12,9 +12,9 @@
1212
13#include <__config>13#include <__config>
14#include <__functional/binary_function.h>14#include <__functional/binary_function.h>
15#include <__functional/invoke.h>
16#include <__functional/unary_function.h>15#include <__functional/unary_function.h>
17#include <__type_traits/integral_constant.h>16#include <__type_traits/integral_constant.h>
17#include <__type_traits/invoke.h>
18#include <__type_traits/is_same.h>18#include <__type_traits/is_same.h>
19#include <__utility/declval.h>19#include <__utility/declval.h>
2020
...@@ -221,11 +221,6 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile> {...@@ -221,11 +221,6 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile> {
221#endif221#endif
222};222};
223223
224template <class _Tp, class... _Args>
225struct __invoke_return {
226 typedef decltype(std::__invoke(std::declval<_Tp>(), std::declval<_Args>()...)) type;
227};
228
229_LIBCPP_END_NAMESPACE_STD224_LIBCPP_END_NAMESPACE_STD
230225
231#endif // _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H226#endif // _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H
lib/libcxx/include/__fwd/array.h+5-4
...@@ -10,7 +10,8 @@...@@ -10,7 +10,8 @@
10#define _LIBCPP___FWD_ARRAY_H10#define _LIBCPP___FWD_ARRAY_H
1111
12#include <__config>12#include <__config>
13#include <cstddef>13#include <__cstddef/size_t.h>
14#include <__type_traits/integral_constant.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
...@@ -35,11 +36,11 @@ template <size_t _Ip, class _Tp, size_t _Size>...@@ -35,11 +36,11 @@ template <size_t _Ip, class _Tp, size_t _Size>
35_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&&) _NOEXCEPT;36_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&&) _NOEXCEPT;
36#endif37#endif
3738
38template <class>39template <class _Tp>
39struct __is_std_array : false_type {};40inline const bool __is_std_array_v = false;
4041
41template <class _Tp, size_t _Size>42template <class _Tp, size_t _Size>
42struct __is_std_array<array<_Tp, _Size> > : true_type {};43inline const bool __is_std_array_v<array<_Tp, _Size> > = true;
4344
44_LIBCPP_END_NAMESPACE_STD45_LIBCPP_END_NAMESPACE_STD
4546
lib/libcxx/include/__fwd/bit_reference.h+3
...@@ -20,6 +20,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -20,6 +20,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
20template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0>20template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0>
21class __bit_iterator;21class __bit_iterator;
2222
23template <class, class = void>
24struct __size_difference_type_traits;
25
23_LIBCPP_END_NAMESPACE_STD26_LIBCPP_END_NAMESPACE_STD
2427
25#endif // _LIBCPP___FWD_BIT_REFERENCE_H28#endif // _LIBCPP___FWD_BIT_REFERENCE_H
lib/libcxx/include/__fwd/byte.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_BYTE_H
10#define _LIBCPP___FWD_BYTE_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
19namespace std { // purposefully not versioned
20
21enum class byte : unsigned char;
22
23} // namespace std
24#endif // _LIBCPP_STD_VER >= 17
25
26#endif // _LIBCPP___FWD_BYTE_H
lib/libcxx/include/__fwd/complex.h+1-1
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#define _LIBCPP___FWD_COMPLEX_H10#define _LIBCPP___FWD_COMPLEX_H
1111
12#include <__config>12#include <__config>
13#include <cstddef>13#include <__cstddef/size_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
lib/libcxx/include/__fwd/format.h+1-1
...@@ -31,7 +31,7 @@ class _LIBCPP_TEMPLATE_VIS basic_format_context;...@@ -31,7 +31,7 @@ class _LIBCPP_TEMPLATE_VIS basic_format_context;
31template <class _Tp, class _CharT = char>31template <class _Tp, class _CharT = char>
32struct _LIBCPP_TEMPLATE_VIS formatter;32struct _LIBCPP_TEMPLATE_VIS formatter;
3333
34#endif //_LIBCPP_STD_VER >= 2034#endif // _LIBCPP_STD_VER >= 20
3535
36_LIBCPP_END_NAMESPACE_STD36_LIBCPP_END_NAMESPACE_STD
3737
lib/libcxx/include/__fwd/fstream.h+1-1
...@@ -32,7 +32,7 @@ using ifstream = basic_ifstream<char>;...@@ -32,7 +32,7 @@ using ifstream = basic_ifstream<char>;
32using ofstream = basic_ofstream<char>;32using ofstream = basic_ofstream<char>;
33using fstream = basic_fstream<char>;33using fstream = basic_fstream<char>;
3434
35#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS35#if _LIBCPP_HAS_WIDE_CHARACTERS
36using wfilebuf = basic_filebuf<wchar_t>;36using wfilebuf = basic_filebuf<wchar_t>;
37using wifstream = basic_ifstream<wchar_t>;37using wifstream = basic_ifstream<wchar_t>;
38using wofstream = basic_ofstream<wchar_t>;38using wofstream = basic_ofstream<wchar_t>;
lib/libcxx/include/__fwd/get.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___FWD_GET_H
10#define _LIBCPP___FWD_GET_H
11
12#include <__config>
13#include <__fwd/array.h>
14#include <__fwd/complex.h>
15#include <__fwd/pair.h>
16#include <__fwd/subrange.h>
17#include <__fwd/tuple.h>
18#include <__fwd/variant.h>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24#endif // _LIBCPP___FWD_GET_H
lib/libcxx/include/__fwd/ios.h+1-1
...@@ -24,7 +24,7 @@ template <class _CharT, class _Traits = char_traits<_CharT> >...@@ -24,7 +24,7 @@ template <class _CharT, class _Traits = char_traits<_CharT> >
24class _LIBCPP_TEMPLATE_VIS basic_ios;24class _LIBCPP_TEMPLATE_VIS basic_ios;
2525
26using ios = basic_ios<char>;26using ios = basic_ios<char>;
27#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS27#if _LIBCPP_HAS_WIDE_CHARACTERS
28using wios = basic_ios<wchar_t>;28using wios = basic_ios<wchar_t>;
29#endif29#endif
3030
lib/libcxx/include/__fwd/istream.h+1-1
...@@ -27,7 +27,7 @@ class _LIBCPP_TEMPLATE_VIS basic_iostream;...@@ -27,7 +27,7 @@ class _LIBCPP_TEMPLATE_VIS basic_iostream;
27using istream = basic_istream<char>;27using istream = basic_istream<char>;
28using iostream = basic_iostream<char>;28using iostream = basic_iostream<char>;
2929
30#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS30#if _LIBCPP_HAS_WIDE_CHARACTERS
31using wistream = basic_istream<wchar_t>;31using wistream = basic_istream<wchar_t>;
32using wiostream = basic_iostream<wchar_t>;32using wiostream = basic_iostream<wchar_t>;
33#endif33#endif
lib/libcxx/include/__fwd/memory.h+3
...@@ -20,6 +20,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -20,6 +20,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
20template <class _Tp>20template <class _Tp>
21class _LIBCPP_TEMPLATE_VIS allocator;21class _LIBCPP_TEMPLATE_VIS allocator;
2222
23template <class _Tp>
24class _LIBCPP_TEMPLATE_VIS shared_ptr;
25
23_LIBCPP_END_NAMESPACE_STD26_LIBCPP_END_NAMESPACE_STD
2427
25#endif // _LIBCPP___FWD_MEMORY_H28#endif // _LIBCPP___FWD_MEMORY_H
lib/libcxx/include/__fwd/memory_resource.h+4
...@@ -15,6 +15,8 @@...@@ -15,6 +15,8 @@
15# pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18#if _LIBCPP_STD_VER >= 17
19
18_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
1921
20namespace pmr {22namespace pmr {
...@@ -24,4 +26,6 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TEMPLATE_VIS polymorphic_allocator;...@@ -24,4 +26,6 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TEMPLATE_VIS polymorphic_allocator;
2426
25_LIBCPP_END_NAMESPACE_STD27_LIBCPP_END_NAMESPACE_STD
2628
29#endif // _LIBCPP_STD_VER >= 17
30
27#endif // _LIBCPP___FWD_MEMORY_RESOURCE_H31#endif // _LIBCPP___FWD_MEMORY_RESOURCE_H
lib/libcxx/include/__fwd/ostream.h+1-1
...@@ -23,7 +23,7 @@ class _LIBCPP_TEMPLATE_VIS basic_ostream;...@@ -23,7 +23,7 @@ class _LIBCPP_TEMPLATE_VIS basic_ostream;
2323
24using ostream = basic_ostream<char>;24using ostream = basic_ostream<char>;
2525
26#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS26#if _LIBCPP_HAS_WIDE_CHARACTERS
27using wostream = basic_ostream<wchar_t>;27using wostream = basic_ostream<wchar_t>;
28#endif28#endif
2929
lib/libcxx/include/__fwd/pair.h+1-1
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___FWD_PAIR_H10#define _LIBCPP___FWD_PAIR_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__fwd/tuple.h>14#include <__fwd/tuple.h>
14#include <cstddef>
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/__fwd/span.h+1-1
...@@ -11,7 +11,7 @@...@@ -11,7 +11,7 @@
11#define _LIBCPP___FWD_SPAN_H11#define _LIBCPP___FWD_SPAN_H
1212
13#include <__config>13#include <__config>
14#include <cstddef>14#include <__cstddef/size_t.h>
15#include <limits>15#include <limits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__fwd/sstream.h+1-1
...@@ -34,7 +34,7 @@ using istringstream = basic_istringstream<char>;...@@ -34,7 +34,7 @@ using istringstream = basic_istringstream<char>;
34using ostringstream = basic_ostringstream<char>;34using ostringstream = basic_ostringstream<char>;
35using stringstream = basic_stringstream<char>;35using stringstream = basic_stringstream<char>;
3636
37#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS37#if _LIBCPP_HAS_WIDE_CHARACTERS
38using wstringbuf = basic_stringbuf<wchar_t>;38using wstringbuf = basic_stringbuf<wchar_t>;
39using wistringstream = basic_istringstream<wchar_t>;39using wistringstream = basic_istringstream<wchar_t>;
40using wostringstream = basic_ostringstream<wchar_t>;40using wostringstream = basic_ostringstream<wchar_t>;
lib/libcxx/include/__fwd/streambuf.h+1-1
...@@ -23,7 +23,7 @@ class _LIBCPP_TEMPLATE_VIS basic_streambuf;...@@ -23,7 +23,7 @@ class _LIBCPP_TEMPLATE_VIS basic_streambuf;
2323
24using streambuf = basic_streambuf<char>;24using streambuf = basic_streambuf<char>;
2525
26#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS26#if _LIBCPP_HAS_WIDE_CHARACTERS
27using wstreambuf = basic_streambuf<wchar_t>;27using wstreambuf = basic_streambuf<wchar_t>;
28#endif28#endif
2929
lib/libcxx/include/__fwd/string.h+10-10
...@@ -24,7 +24,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits;...@@ -24,7 +24,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits;
24template <>24template <>
25struct char_traits<char>;25struct char_traits<char>;
2626
27#ifndef _LIBCPP_HAS_NO_CHAR8_T27#if _LIBCPP_HAS_CHAR8_T
28template <>28template <>
29struct char_traits<char8_t>;29struct char_traits<char8_t>;
30#endif30#endif
...@@ -34,7 +34,7 @@ struct char_traits<char16_t>;...@@ -34,7 +34,7 @@ struct char_traits<char16_t>;
34template <>34template <>
35struct char_traits<char32_t>;35struct char_traits<char32_t>;
3636
37#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS37#if _LIBCPP_HAS_WIDE_CHARACTERS
38template <>38template <>
39struct char_traits<wchar_t>;39struct char_traits<wchar_t>;
40#endif40#endif
...@@ -44,11 +44,11 @@ class _LIBCPP_TEMPLATE_VIS basic_string;...@@ -44,11 +44,11 @@ class _LIBCPP_TEMPLATE_VIS basic_string;
4444
45using string = basic_string<char>;45using string = basic_string<char>;
4646
47#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS47#if _LIBCPP_HAS_WIDE_CHARACTERS
48using wstring = basic_string<wchar_t>;48using wstring = basic_string<wchar_t>;
49#endif49#endif
5050
51#ifndef _LIBCPP_HAS_NO_CHAR8_T51#if _LIBCPP_HAS_CHAR8_T
52using u8string = basic_string<char8_t>;52using u8string = basic_string<char8_t>;
53#endif53#endif
5454
...@@ -63,11 +63,11 @@ using basic_string _LIBCPP_AVAILABILITY_PMR = std::basic_string<_CharT, _Traits,...@@ -63,11 +63,11 @@ using basic_string _LIBCPP_AVAILABILITY_PMR = std::basic_string<_CharT, _Traits,
6363
64using string _LIBCPP_AVAILABILITY_PMR = basic_string<char>;64using string _LIBCPP_AVAILABILITY_PMR = basic_string<char>;
6565
66# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS66# if _LIBCPP_HAS_WIDE_CHARACTERS
67using wstring _LIBCPP_AVAILABILITY_PMR = basic_string<wchar_t>;67using wstring _LIBCPP_AVAILABILITY_PMR = basic_string<wchar_t>;
68# endif68# endif
6969
70# ifndef _LIBCPP_HAS_NO_CHAR8_T70# if _LIBCPP_HAS_CHAR8_T
71using u8string _LIBCPP_AVAILABILITY_PMR = basic_string<char8_t>;71using u8string _LIBCPP_AVAILABILITY_PMR = basic_string<char8_t>;
72# endif72# endif
7373
...@@ -80,20 +80,20 @@ using u32string _LIBCPP_AVAILABILITY_PMR = basic_string<char32_t>;...@@ -80,20 +80,20 @@ using u32string _LIBCPP_AVAILABILITY_PMR = basic_string<char32_t>;
80// clang-format off80// clang-format off
81template <class _CharT, class _Traits, class _Allocator>81template <class _CharT, class _Traits, class _Allocator>
82class _LIBCPP_PREFERRED_NAME(string)82class _LIBCPP_PREFERRED_NAME(string)
83#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS83#if _LIBCPP_HAS_WIDE_CHARACTERS
84 _LIBCPP_PREFERRED_NAME(wstring)84 _LIBCPP_PREFERRED_NAME(wstring)
85#endif85#endif
86#ifndef _LIBCPP_HAS_NO_CHAR8_T86#if _LIBCPP_HAS_CHAR8_T
87 _LIBCPP_PREFERRED_NAME(u8string)87 _LIBCPP_PREFERRED_NAME(u8string)
88#endif88#endif
89 _LIBCPP_PREFERRED_NAME(u16string)89 _LIBCPP_PREFERRED_NAME(u16string)
90 _LIBCPP_PREFERRED_NAME(u32string)90 _LIBCPP_PREFERRED_NAME(u32string)
91#if _LIBCPP_STD_VER >= 1791#if _LIBCPP_STD_VER >= 17
92 _LIBCPP_PREFERRED_NAME(pmr::string)92 _LIBCPP_PREFERRED_NAME(pmr::string)
93# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS93# if _LIBCPP_HAS_WIDE_CHARACTERS
94 _LIBCPP_PREFERRED_NAME(pmr::wstring)94 _LIBCPP_PREFERRED_NAME(pmr::wstring)
95# endif95# endif
96# ifndef _LIBCPP_HAS_NO_CHAR8_T96# if _LIBCPP_HAS_CHAR8_T
97 _LIBCPP_PREFERRED_NAME(pmr::u8string)97 _LIBCPP_PREFERRED_NAME(pmr::u8string)
98# endif98# endif
99 _LIBCPP_PREFERRED_NAME(pmr::u16string)99 _LIBCPP_PREFERRED_NAME(pmr::u16string)
lib/libcxx/include/__fwd/string_view.h+4-4
...@@ -23,22 +23,22 @@ template <class _CharT, class _Traits = char_traits<_CharT> >...@@ -23,22 +23,22 @@ template <class _CharT, class _Traits = char_traits<_CharT> >
23class _LIBCPP_TEMPLATE_VIS basic_string_view;23class _LIBCPP_TEMPLATE_VIS basic_string_view;
2424
25typedef basic_string_view<char> string_view;25typedef basic_string_view<char> string_view;
26#ifndef _LIBCPP_HAS_NO_CHAR8_T26#if _LIBCPP_HAS_CHAR8_T
27typedef basic_string_view<char8_t> u8string_view;27typedef basic_string_view<char8_t> u8string_view;
28#endif28#endif
29typedef basic_string_view<char16_t> u16string_view;29typedef basic_string_view<char16_t> u16string_view;
30typedef basic_string_view<char32_t> u32string_view;30typedef basic_string_view<char32_t> u32string_view;
31#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS31#if _LIBCPP_HAS_WIDE_CHARACTERS
32typedef basic_string_view<wchar_t> wstring_view;32typedef basic_string_view<wchar_t> wstring_view;
33#endif33#endif
3434
35// clang-format off35// clang-format off
36template <class _CharT, class _Traits>36template <class _CharT, class _Traits>
37class _LIBCPP_PREFERRED_NAME(string_view)37class _LIBCPP_PREFERRED_NAME(string_view)
38#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS38#if _LIBCPP_HAS_WIDE_CHARACTERS
39 _LIBCPP_PREFERRED_NAME(wstring_view)39 _LIBCPP_PREFERRED_NAME(wstring_view)
40#endif40#endif
41#ifndef _LIBCPP_HAS_NO_CHAR8_T41#if _LIBCPP_HAS_CHAR8_T
42 _LIBCPP_PREFERRED_NAME(u8string_view)42 _LIBCPP_PREFERRED_NAME(u8string_view)
43#endif43#endif
44 _LIBCPP_PREFERRED_NAME(u16string_view)44 _LIBCPP_PREFERRED_NAME(u16string_view)
lib/libcxx/include/__fwd/subrange.h+1-1
...@@ -11,8 +11,8 @@...@@ -11,8 +11,8 @@
1111
12#include <__concepts/copyable.h>12#include <__concepts/copyable.h>
13#include <__config>13#include <__config>
14#include <__cstddef/size_t.h>
14#include <__iterator/concepts.h>15#include <__iterator/concepts.h>
15#include <cstddef>
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/__fwd/tuple.h+1-1
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#define _LIBCPP___FWD_TUPLE_H10#define _LIBCPP___FWD_TUPLE_H
1111
12#include <__config>12#include <__config>
13#include <cstddef>13#include <__cstddef/size_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
lib/libcxx/include/__fwd/variant.h created+77
...@@ -0,0 +1,77 @@
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_VARIANT_H
10#define _LIBCPP___FWD_VARIANT_H
11
12#include <__config>
13#include <__cstddef/size_t.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#if _LIBCPP_STD_VER >= 17
22
23template <class... _Types>
24class _LIBCPP_TEMPLATE_VIS variant;
25
26template <class _Tp>
27struct _LIBCPP_TEMPLATE_VIS variant_size;
28
29template <class _Tp>
30inline constexpr size_t variant_size_v = variant_size<_Tp>::value;
31
32template <size_t _Ip, class _Tp>
33struct _LIBCPP_TEMPLATE_VIS variant_alternative;
34
35template <size_t _Ip, class _Tp>
36using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type;
37
38inline constexpr size_t variant_npos = static_cast<size_t>(-1);
39
40template <size_t _Ip, class... _Types>
41_LIBCPP_HIDE_FROM_ABI
42_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&
43get(variant<_Types...>&);
44
45template <size_t _Ip, class... _Types>
46_LIBCPP_HIDE_FROM_ABI
47_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&&
48get(variant<_Types...>&&);
49
50template <size_t _Ip, class... _Types>
51_LIBCPP_HIDE_FROM_ABI
52_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&
53get(const variant<_Types...>&);
54
55template <size_t _Ip, class... _Types>
56_LIBCPP_HIDE_FROM_ABI
57_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&&
58get(const variant<_Types...>&&);
59
60template <class _Tp, class... _Types>
61_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp& get(variant<_Types...>&);
62
63template <class _Tp, class... _Types>
64_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp&& get(variant<_Types...>&&);
65
66template <class _Tp, class... _Types>
67_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp& get(const variant<_Types...>&);
68
69template <class _Tp, class... _Types>
70_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp&&
71get(const variant<_Types...>&&);
72
73#endif // _LIBCPP_STD_VER >= 17
74
75_LIBCPP_END_NAMESPACE_STD
76
77#endif // _LIBCPP___FWD_VARIANT_H
lib/libcxx/include/__fwd/vector.h+3
...@@ -21,6 +21,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,6 +21,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
21template <class _Tp, class _Alloc = allocator<_Tp> >21template <class _Tp, class _Alloc = allocator<_Tp> >
22class _LIBCPP_TEMPLATE_VIS vector;22class _LIBCPP_TEMPLATE_VIS vector;
2323
24template <class _Allocator>
25class vector<bool, _Allocator>;
26
24_LIBCPP_END_NAMESPACE_STD27_LIBCPP_END_NAMESPACE_STD
2528
26#endif // _LIBCPP___FWD_VECTOR_H29#endif // _LIBCPP___FWD_VECTOR_H
lib/libcxx/include/__hash_table+130-103
...@@ -15,9 +15,11 @@...@@ -15,9 +15,11 @@
15#include <__assert>15#include <__assert>
16#include <__bit/countl.h>16#include <__bit/countl.h>
17#include <__config>17#include <__config>
18#include <__cstddef/ptrdiff_t.h>
19#include <__cstddef/size_t.h>
18#include <__functional/hash.h>20#include <__functional/hash.h>
19#include <__functional/invoke.h>
20#include <__iterator/iterator_traits.h>21#include <__iterator/iterator_traits.h>
22#include <__math/rounding_functions.h>
21#include <__memory/addressof.h>23#include <__memory/addressof.h>
22#include <__memory/allocator_traits.h>24#include <__memory/allocator_traits.h>
23#include <__memory/compressed_pair.h>25#include <__memory/compressed_pair.h>
...@@ -25,14 +27,16 @@...@@ -25,14 +27,16 @@
25#include <__memory/pointer_traits.h>27#include <__memory/pointer_traits.h>
26#include <__memory/swap_allocator.h>28#include <__memory/swap_allocator.h>
27#include <__memory/unique_ptr.h>29#include <__memory/unique_ptr.h>
30#include <__new/launder.h>
28#include <__type_traits/can_extract_key.h>31#include <__type_traits/can_extract_key.h>
29#include <__type_traits/conditional.h>32#include <__type_traits/enable_if.h>
33#include <__type_traits/invoke.h>
30#include <__type_traits/is_const.h>34#include <__type_traits/is_const.h>
31#include <__type_traits/is_constructible.h>35#include <__type_traits/is_constructible.h>
32#include <__type_traits/is_nothrow_assignable.h>36#include <__type_traits/is_nothrow_assignable.h>
33#include <__type_traits/is_nothrow_constructible.h>37#include <__type_traits/is_nothrow_constructible.h>
34#include <__type_traits/is_pointer.h>
35#include <__type_traits/is_reference.h>38#include <__type_traits/is_reference.h>
39#include <__type_traits/is_same.h>
36#include <__type_traits/is_swappable.h>40#include <__type_traits/is_swappable.h>
37#include <__type_traits/remove_const.h>41#include <__type_traits/remove_const.h>
38#include <__type_traits/remove_cvref.h>42#include <__type_traits/remove_cvref.h>
...@@ -40,10 +44,7 @@...@@ -40,10 +44,7 @@
40#include <__utility/move.h>44#include <__utility/move.h>
41#include <__utility/pair.h>45#include <__utility/pair.h>
42#include <__utility/swap.h>46#include <__utility/swap.h>
43#include <cmath>47#include <limits>
44#include <cstring>
45#include <initializer_list>
46#include <new> // __launder
4748
48#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)49#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
49# pragma GCC system_header50# pragma GCC system_header
...@@ -77,11 +78,18 @@ struct __hash_node_base {...@@ -77,11 +78,18 @@ struct __hash_node_base {
77 typedef __hash_node_base __first_node;78 typedef __hash_node_base __first_node;
78 typedef __rebind_pointer_t<_NodePtr, __first_node> __node_base_pointer;79 typedef __rebind_pointer_t<_NodePtr, __first_node> __node_base_pointer;
79 typedef _NodePtr __node_pointer;80 typedef _NodePtr __node_pointer;
80
81#if defined(_LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB)
82 typedef __node_base_pointer __next_pointer;81 typedef __node_base_pointer __next_pointer;
83#else82
84 typedef __conditional_t<is_pointer<__node_pointer>::value, __node_base_pointer, __node_pointer> __next_pointer;83// TODO(LLVM 22): Remove this check
84#ifndef _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
85 static_assert(sizeof(__node_base_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) ==
86 _LIBCPP_ALIGNOF(__node_pointer),
87 "It looks like you are using std::__hash_table (an implementation detail for the unordered containers) "
88 "with a fancy pointer type that thas a different representation depending on whether it points to a "
89 "__hash_table base pointer or a __hash_table node pointer (both of which are implementation details of "
90 "the standard library). This means that your ABI is being broken between LLVM 19 and LLVM 20. If you "
91 "don't care about your ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to "
92 "silence this diagnostic.");
85#endif93#endif
8694
87 __next_pointer __next_;95 __next_pointer __next_;
...@@ -103,8 +111,8 @@ struct __hash_node_base {...@@ -103,8 +111,8 @@ struct __hash_node_base {
103template <class _Tp, class _VoidPtr>111template <class _Tp, class _VoidPtr>
104struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > > {112struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > > {
105 typedef _Tp __node_value_type;113 typedef _Tp __node_value_type;
106 using _Base = __hash_node_base<__rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > >;114 using _Base _LIBCPP_NODEBUG = __hash_node_base<__rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > >;
107 using __next_pointer = typename _Base::__next_pointer;115 using __next_pointer _LIBCPP_NODEBUG = typename _Base::__next_pointer;
108116
109 size_t __hash_;117 size_t __hash_;
110118
...@@ -554,29 +562,29 @@ class __bucket_list_deallocator {...@@ -554,29 +562,29 @@ class __bucket_list_deallocator {
554 typedef allocator_traits<allocator_type> __alloc_traits;562 typedef allocator_traits<allocator_type> __alloc_traits;
555 typedef typename __alloc_traits::size_type size_type;563 typedef typename __alloc_traits::size_type size_type;
556564
557 __compressed_pair<size_type, allocator_type> __data_;565 _LIBCPP_COMPRESSED_PAIR(size_type, __size_, allocator_type, __alloc_);
558566
559public:567public:
560 typedef typename __alloc_traits::pointer pointer;568 typedef typename __alloc_traits::pointer pointer;
561569
562 _LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)570 _LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
563 : __data_(0, __default_init_tag()) {}571 : __size_(0) {}
564572
565 _LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator(const allocator_type& __a, size_type __size)573 _LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator(const allocator_type& __a, size_type __size)
566 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)574 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
567 : __data_(__size, __a) {}575 : __size_(__size), __alloc_(__a) {}
568576
569 _LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator(__bucket_list_deallocator&& __x)577 _LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator(__bucket_list_deallocator&& __x)
570 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)578 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
571 : __data_(std::move(__x.__data_)) {579 : __size_(std::move(__x.__size_)), __alloc_(std::move(__x.__alloc_)) {
572 __x.size() = 0;580 __x.size() = 0;
573 }581 }
574582
575 _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __data_.first(); }583 _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; }
576 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __data_.first(); }584 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; }
577585
578 _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __data_.second(); }586 _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __alloc_; }
579 _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __data_.second(); }587 _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __alloc_; }
580588
581 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { __alloc_traits::deallocate(__alloc(), __p, size()); }589 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { __alloc_traits::deallocate(__alloc(), __p, size()); }
582};590};
...@@ -642,9 +650,9 @@ struct __enforce_unordered_container_requirements {...@@ -642,9 +650,9 @@ struct __enforce_unordered_container_requirements {
642650
643template <class _Key, class _Hash, class _Equal>651template <class _Key, class _Hash, class _Equal>
644#ifndef _LIBCPP_CXX03_LANG652#ifndef _LIBCPP_CXX03_LANG
645_LIBCPP_DIAGNOSE_WARNING(!__invokable<_Equal const&, _Key const&, _Key const&>::value,653_LIBCPP_DIAGNOSE_WARNING(!__is_invocable_v<_Equal const&, _Key const&, _Key const&>,
646 "the specified comparator type does not provide a viable const call operator")654 "the specified comparator type does not provide a viable const call operator")
647_LIBCPP_DIAGNOSE_WARNING(!__invokable<_Hash const&, _Key const&>::value,655_LIBCPP_DIAGNOSE_WARNING(!__is_invocable_v<_Hash const&, _Key const&>,
648 "the specified hash functor does not provide a viable const call operator")656 "the specified hash functor does not provide a viable const call operator")
649#endif657#endif
650 typename __enforce_unordered_container_requirements<_Key, _Hash, _Equal>::type658 typename __enforce_unordered_container_requirements<_Key, _Hash, _Equal>::type
...@@ -716,27 +724,27 @@ private:...@@ -716,27 +724,27 @@ private:
716724
717 // --- Member data begin ---725 // --- Member data begin ---
718 __bucket_list __bucket_list_;726 __bucket_list __bucket_list_;
719 __compressed_pair<__first_node, __node_allocator> __p1_;727 _LIBCPP_COMPRESSED_PAIR(__first_node, __first_node_, __node_allocator, __node_alloc_);
720 __compressed_pair<size_type, hasher> __p2_;728 _LIBCPP_COMPRESSED_PAIR(size_type, __size_, hasher, __hasher_);
721 __compressed_pair<float, key_equal> __p3_;729 _LIBCPP_COMPRESSED_PAIR(float, __max_load_factor_, key_equal, __key_eq_);
722 // --- Member data end ---730 // --- Member data end ---
723731
724 _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __p2_.first(); }732 _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; }
725733
726public:734public:
727 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __p2_.first(); }735 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; }
728736
729 _LIBCPP_HIDE_FROM_ABI hasher& hash_function() _NOEXCEPT { return __p2_.second(); }737 _LIBCPP_HIDE_FROM_ABI hasher& hash_function() _NOEXCEPT { return __hasher_; }
730 _LIBCPP_HIDE_FROM_ABI const hasher& hash_function() const _NOEXCEPT { return __p2_.second(); }738 _LIBCPP_HIDE_FROM_ABI const hasher& hash_function() const _NOEXCEPT { return __hasher_; }
731739
732 _LIBCPP_HIDE_FROM_ABI float& max_load_factor() _NOEXCEPT { return __p3_.first(); }740 _LIBCPP_HIDE_FROM_ABI float& max_load_factor() _NOEXCEPT { return __max_load_factor_; }
733 _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __p3_.first(); }741 _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __max_load_factor_; }
734742
735 _LIBCPP_HIDE_FROM_ABI key_equal& key_eq() _NOEXCEPT { return __p3_.second(); }743 _LIBCPP_HIDE_FROM_ABI key_equal& key_eq() _NOEXCEPT { return __key_eq_; }
736 _LIBCPP_HIDE_FROM_ABI const key_equal& key_eq() const _NOEXCEPT { return __p3_.second(); }744 _LIBCPP_HIDE_FROM_ABI const key_equal& key_eq() const _NOEXCEPT { return __key_eq_; }
737745
738 _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __p1_.second(); }746 _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; }
739 _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __p1_.second(); }747 _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; }
740748
741public:749public:
742 typedef __hash_iterator<__node_pointer> iterator;750 typedef __hash_iterator<__node_pointer> iterator;
...@@ -875,10 +883,10 @@ public:...@@ -875,10 +883,10 @@ public:
875 _LIBCPP_HIDE_FROM_ABI void __rehash_unique(size_type __n) { __rehash<true>(__n); }883 _LIBCPP_HIDE_FROM_ABI void __rehash_unique(size_type __n) { __rehash<true>(__n); }
876 _LIBCPP_HIDE_FROM_ABI void __rehash_multi(size_type __n) { __rehash<false>(__n); }884 _LIBCPP_HIDE_FROM_ABI void __rehash_multi(size_type __n) { __rehash<false>(__n); }
877 _LIBCPP_HIDE_FROM_ABI void __reserve_unique(size_type __n) {885 _LIBCPP_HIDE_FROM_ABI void __reserve_unique(size_type __n) {
878 __rehash_unique(static_cast<size_type>(std::ceil(__n / max_load_factor())));886 __rehash_unique(static_cast<size_type>(__math::ceil(__n / max_load_factor())));
879 }887 }
880 _LIBCPP_HIDE_FROM_ABI void __reserve_multi(size_type __n) {888 _LIBCPP_HIDE_FROM_ABI void __reserve_multi(size_type __n) {
881 __rehash_multi(static_cast<size_type>(std::ceil(__n / max_load_factor())));889 __rehash_multi(static_cast<size_type>(__math::ceil(__n / max_load_factor())));
882 }890 }
883891
884 _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __bucket_list_.get_deleter().size(); }892 _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __bucket_list_.get_deleter().size(); }
...@@ -1022,26 +1030,34 @@ inline __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table() _NOEXCEPT_(...@@ -1022,26 +1030,34 @@ inline __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table() _NOEXCEPT_(
1022 is_nothrow_default_constructible<__bucket_list>::value&& is_nothrow_default_constructible<__first_node>::value&&1030 is_nothrow_default_constructible<__bucket_list>::value&& is_nothrow_default_constructible<__first_node>::value&&
1023 is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_default_constructible<hasher>::value&&1031 is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_default_constructible<hasher>::value&&
1024 is_nothrow_default_constructible<key_equal>::value)1032 is_nothrow_default_constructible<key_equal>::value)
1025 : __p2_(0, __default_init_tag()), __p3_(1.0f, __default_init_tag()) {}1033 : __size_(0), __max_load_factor_(1.0f) {}
10261034
1027template <class _Tp, class _Hash, class _Equal, class _Alloc>1035template <class _Tp, class _Hash, class _Equal, class _Alloc>
1028inline __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, const key_equal& __eql)1036inline __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, const key_equal& __eql)
1029 : __bucket_list_(nullptr, __bucket_list_deleter()), __p1_(), __p2_(0, __hf), __p3_(1.0f, __eql) {}1037 : __bucket_list_(nullptr, __bucket_list_deleter()),
1038 __first_node_(),
1039 __node_alloc_(),
1040 __size_(0),
1041 __hasher_(__hf),
1042 __max_load_factor_(1.0f),
1043 __key_eq_(__eql) {}
10301044
1031template <class _Tp, class _Hash, class _Equal, class _Alloc>1045template <class _Tp, class _Hash, class _Equal, class _Alloc>
1032__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(1046__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(
1033 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)1047 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1034 : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),1048 : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
1035 __p1_(__default_init_tag(), __node_allocator(__a)),1049 __node_alloc_(__node_allocator(__a)),
1036 __p2_(0, __hf),1050 __size_(0),
1037 __p3_(1.0f, __eql) {}1051 __hasher_(__hf),
1052 __max_load_factor_(1.0f),
1053 __key_eq_(__eql) {}
10381054
1039template <class _Tp, class _Hash, class _Equal, class _Alloc>1055template <class _Tp, class _Hash, class _Equal, class _Alloc>
1040__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a)1056__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a)
1041 : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),1057 : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
1042 __p1_(__default_init_tag(), __node_allocator(__a)),1058 __node_alloc_(__node_allocator(__a)),
1043 __p2_(0, __default_init_tag()),1059 __size_(0),
1044 __p3_(1.0f, __default_init_tag()) {}1060 __max_load_factor_(1.0f) {}
10451061
1046template <class _Tp, class _Hash, class _Equal, class _Alloc>1062template <class _Tp, class _Hash, class _Equal, class _Alloc>
1047__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u)1063__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u)
...@@ -1049,17 +1065,20 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u)...@@ -1049,17 +1065,20 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u)
1049 __bucket_list_deleter(allocator_traits<__pointer_allocator>::select_on_container_copy_construction(1065 __bucket_list_deleter(allocator_traits<__pointer_allocator>::select_on_container_copy_construction(
1050 __u.__bucket_list_.get_deleter().__alloc()),1066 __u.__bucket_list_.get_deleter().__alloc()),
1051 0)),1067 0)),
1052 __p1_(__default_init_tag(),1068 __node_alloc_(allocator_traits<__node_allocator>::select_on_container_copy_construction(__u.__node_alloc())),
1053 allocator_traits<__node_allocator>::select_on_container_copy_construction(__u.__node_alloc())),1069 __size_(0),
1054 __p2_(0, __u.hash_function()),1070 __hasher_(__u.hash_function()),
1055 __p3_(__u.__p3_) {}1071 __max_load_factor_(__u.__max_load_factor_),
1072 __key_eq_(__u.__key_eq_) {}
10561073
1057template <class _Tp, class _Hash, class _Equal, class _Alloc>1074template <class _Tp, class _Hash, class _Equal, class _Alloc>
1058__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u, const allocator_type& __a)1075__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u, const allocator_type& __a)
1059 : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),1076 : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
1060 __p1_(__default_init_tag(), __node_allocator(__a)),1077 __node_alloc_(__node_allocator(__a)),
1061 __p2_(0, __u.hash_function()),1078 __size_(0),
1062 __p3_(__u.__p3_) {}1079 __hasher_(__u.hash_function()),
1080 __max_load_factor_(__u.__max_load_factor_),
1081 __key_eq_(__u.__key_eq_) {}
10631082
1064template <class _Tp, class _Hash, class _Equal, class _Alloc>1083template <class _Tp, class _Hash, class _Equal, class _Alloc>
1065__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEXCEPT_(1084__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEXCEPT_(
...@@ -1067,12 +1086,15 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEX...@@ -1067,12 +1086,15 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEX
1067 is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<hasher>::value&&1086 is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<hasher>::value&&
1068 is_nothrow_move_constructible<key_equal>::value)1087 is_nothrow_move_constructible<key_equal>::value)
1069 : __bucket_list_(std::move(__u.__bucket_list_)),1088 : __bucket_list_(std::move(__u.__bucket_list_)),
1070 __p1_(std::move(__u.__p1_)),1089 __first_node_(std::move(__u.__first_node_)),
1071 __p2_(std::move(__u.__p2_)),1090 __node_alloc_(std::move(__u.__node_alloc_)),
1072 __p3_(std::move(__u.__p3_)) {1091 __size_(std::move(__u.__size_)),
1092 __hasher_(std::move(__u.__hasher_)),
1093 __max_load_factor_(__u.__max_load_factor_),
1094 __key_eq_(std::move(__u.__key_eq_)) {
1073 if (size() > 0) {1095 if (size() > 0) {
1074 __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = __p1_.first().__ptr();1096 __bucket_list_[std::__constrain_hash(__first_node_.__next_->__hash(), bucket_count())] = __first_node_.__ptr();
1075 __u.__p1_.first().__next_ = nullptr;1097 __u.__first_node_.__next_ = nullptr;
1076 __u.size() = 0;1098 __u.size() = 0;
1077 }1099 }
1078}1100}
...@@ -1080,17 +1102,19 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEX...@@ -1080,17 +1102,19 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEX
1080template <class _Tp, class _Hash, class _Equal, class _Alloc>1102template <class _Tp, class _Hash, class _Equal, class _Alloc>
1081__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, const allocator_type& __a)1103__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, const allocator_type& __a)
1082 : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),1104 : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
1083 __p1_(__default_init_tag(), __node_allocator(__a)),1105 __node_alloc_(__node_allocator(__a)),
1084 __p2_(0, std::move(__u.hash_function())),1106 __size_(0),
1085 __p3_(std::move(__u.__p3_)) {1107 __hasher_(std::move(__u.__hasher_)),
1108 __max_load_factor_(__u.__max_load_factor_),
1109 __key_eq_(std::move(__u.__key_eq_)) {
1086 if (__a == allocator_type(__u.__node_alloc())) {1110 if (__a == allocator_type(__u.__node_alloc())) {
1087 __bucket_list_.reset(__u.__bucket_list_.release());1111 __bucket_list_.reset(__u.__bucket_list_.release());
1088 __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size();1112 __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size();
1089 __u.__bucket_list_.get_deleter().size() = 0;1113 __u.__bucket_list_.get_deleter().size() = 0;
1090 if (__u.size() > 0) {1114 if (__u.size() > 0) {
1091 __p1_.first().__next_ = __u.__p1_.first().__next_;1115 __first_node_.__next_ = __u.__first_node_.__next_;
1092 __u.__p1_.first().__next_ = nullptr;1116 __u.__first_node_.__next_ = nullptr;
1093 __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = __p1_.first().__ptr();1117 __bucket_list_[std::__constrain_hash(__first_node_.__next_->__hash(), bucket_count())] = __first_node_.__ptr();
1094 size() = __u.size();1118 size() = __u.size();
1095 __u.size() = 0;1119 __u.size() = 0;
1096 }1120 }
...@@ -1104,7 +1128,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() {...@@ -1104,7 +1128,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() {
1104 static_assert(is_copy_constructible<hasher>::value, "Hasher must be copy-constructible.");1128 static_assert(is_copy_constructible<hasher>::value, "Hasher must be copy-constructible.");
1105#endif1129#endif
11061130
1107 __deallocate_node(__p1_.first().__next_);1131 __deallocate_node(__first_node_.__next_);
1108}1132}
11091133
1110template <class _Tp, class _Hash, class _Equal, class _Alloc>1134template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -1150,8 +1174,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT {...@@ -1150,8 +1174,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT {
1150 for (size_type __i = 0; __i < __bc; ++__i)1174 for (size_type __i = 0; __i < __bc; ++__i)
1151 __bucket_list_[__i] = nullptr;1175 __bucket_list_[__i] = nullptr;
1152 size() = 0;1176 size() = 0;
1153 __next_pointer __cache = __p1_.first().__next_;1177 __next_pointer __cache = __first_node_.__next_;
1154 __p1_.first().__next_ = nullptr;1178 __first_node_.__next_ = nullptr;
1155 return __cache;1179 return __cache;
1156}1180}
11571181
...@@ -1168,10 +1192,10 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u,...@@ -1168,10 +1192,10 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u,
1168 hash_function() = std::move(__u.hash_function());1192 hash_function() = std::move(__u.hash_function());
1169 max_load_factor() = __u.max_load_factor();1193 max_load_factor() = __u.max_load_factor();
1170 key_eq() = std::move(__u.key_eq());1194 key_eq() = std::move(__u.key_eq());
1171 __p1_.first().__next_ = __u.__p1_.first().__next_;1195 __first_node_.__next_ = __u.__first_node_.__next_;
1172 if (size() > 0) {1196 if (size() > 0) {
1173 __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = __p1_.first().__ptr();1197 __bucket_list_[std::__constrain_hash(__first_node_.__next_->__hash(), bucket_count())] = __first_node_.__ptr();
1174 __u.__p1_.first().__next_ = nullptr;1198 __u.__first_node_.__next_ = nullptr;
1175 __u.size() = 0;1199 __u.size() = 0;
1176 }1200 }
1177}1201}
...@@ -1186,9 +1210,9 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u,...@@ -1186,9 +1210,9 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u,
1186 max_load_factor() = __u.max_load_factor();1210 max_load_factor() = __u.max_load_factor();
1187 if (bucket_count() != 0) {1211 if (bucket_count() != 0) {
1188 __next_pointer __cache = __detach();1212 __next_pointer __cache = __detach();
1189#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1213#if _LIBCPP_HAS_EXCEPTIONS
1190 try {1214 try {
1191#endif // _LIBCPP_HAS_NO_EXCEPTIONS1215#endif // _LIBCPP_HAS_EXCEPTIONS
1192 const_iterator __i = __u.begin();1216 const_iterator __i = __u.begin();
1193 while (__cache != nullptr && __u.size() != 0) {1217 while (__cache != nullptr && __u.size() != 0) {
1194 __cache->__upcast()->__get_value() = std::move(__u.remove(__i++)->__get_value());1218 __cache->__upcast()->__get_value() = std::move(__u.remove(__i++)->__get_value());
...@@ -1196,12 +1220,12 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u,...@@ -1196,12 +1220,12 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u,
1196 __node_insert_multi(__cache->__upcast());1220 __node_insert_multi(__cache->__upcast());
1197 __cache = __next;1221 __cache = __next;
1198 }1222 }
1199#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1223#if _LIBCPP_HAS_EXCEPTIONS
1200 } catch (...) {1224 } catch (...) {
1201 __deallocate_node(__cache);1225 __deallocate_node(__cache);
1202 throw;1226 throw;
1203 }1227 }
1204#endif // _LIBCPP_HAS_NO_EXCEPTIONS1228#endif // _LIBCPP_HAS_EXCEPTIONS
1205 __deallocate_node(__cache);1229 __deallocate_node(__cache);
1206 }1230 }
1207 const_iterator __i = __u.begin();1231 const_iterator __i = __u.begin();
...@@ -1232,21 +1256,21 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __...@@ -1232,21 +1256,21 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __
12321256
1233 if (bucket_count() != 0) {1257 if (bucket_count() != 0) {
1234 __next_pointer __cache = __detach();1258 __next_pointer __cache = __detach();
1235#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1259#if _LIBCPP_HAS_EXCEPTIONS
1236 try {1260 try {
1237#endif // _LIBCPP_HAS_NO_EXCEPTIONS1261#endif // _LIBCPP_HAS_EXCEPTIONS
1238 for (; __cache != nullptr && __first != __last; ++__first) {1262 for (; __cache != nullptr && __first != __last; ++__first) {
1239 __cache->__upcast()->__get_value() = *__first;1263 __cache->__upcast()->__get_value() = *__first;
1240 __next_pointer __next = __cache->__next_;1264 __next_pointer __next = __cache->__next_;
1241 __node_insert_unique(__cache->__upcast());1265 __node_insert_unique(__cache->__upcast());
1242 __cache = __next;1266 __cache = __next;
1243 }1267 }
1244#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1268#if _LIBCPP_HAS_EXCEPTIONS
1245 } catch (...) {1269 } catch (...) {
1246 __deallocate_node(__cache);1270 __deallocate_node(__cache);
1247 throw;1271 throw;
1248 }1272 }
1249#endif // _LIBCPP_HAS_NO_EXCEPTIONS1273#endif // _LIBCPP_HAS_EXCEPTIONS
1250 __deallocate_node(__cache);1274 __deallocate_node(__cache);
1251 }1275 }
1252 for (; __first != __last; ++__first)1276 for (; __first != __last; ++__first)
...@@ -1264,21 +1288,21 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f...@@ -1264,21 +1288,21 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f
1264 " or the nodes value type");1288 " or the nodes value type");
1265 if (bucket_count() != 0) {1289 if (bucket_count() != 0) {
1266 __next_pointer __cache = __detach();1290 __next_pointer __cache = __detach();
1267#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1291#if _LIBCPP_HAS_EXCEPTIONS
1268 try {1292 try {
1269#endif // _LIBCPP_HAS_NO_EXCEPTIONS1293#endif // _LIBCPP_HAS_EXCEPTIONS
1270 for (; __cache != nullptr && __first != __last; ++__first) {1294 for (; __cache != nullptr && __first != __last; ++__first) {
1271 __cache->__upcast()->__get_value() = *__first;1295 __cache->__upcast()->__get_value() = *__first;
1272 __next_pointer __next = __cache->__next_;1296 __next_pointer __next = __cache->__next_;
1273 __node_insert_multi(__cache->__upcast());1297 __node_insert_multi(__cache->__upcast());
1274 __cache = __next;1298 __cache = __next;
1275 }1299 }
1276#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1300#if _LIBCPP_HAS_EXCEPTIONS
1277 } catch (...) {1301 } catch (...) {
1278 __deallocate_node(__cache);1302 __deallocate_node(__cache);
1279 throw;1303 throw;
1280 }1304 }
1281#endif // _LIBCPP_HAS_NO_EXCEPTIONS1305#endif // _LIBCPP_HAS_EXCEPTIONS
1282 __deallocate_node(__cache);1306 __deallocate_node(__cache);
1283 }1307 }
1284 for (; __first != __last; ++__first)1308 for (; __first != __last; ++__first)
...@@ -1288,7 +1312,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f...@@ -1288,7 +1312,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f
1288template <class _Tp, class _Hash, class _Equal, class _Alloc>1312template <class _Tp, class _Hash, class _Equal, class _Alloc>
1289inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator1313inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
1290__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT {1314__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT {
1291 return iterator(__p1_.first().__next_);1315 return iterator(__first_node_.__next_);
1292}1316}
12931317
1294template <class _Tp, class _Hash, class _Equal, class _Alloc>1318template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -1300,7 +1324,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT {...@@ -1300,7 +1324,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT {
1300template <class _Tp, class _Hash, class _Equal, class _Alloc>1324template <class _Tp, class _Hash, class _Equal, class _Alloc>
1301inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator1325inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
1302__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT {1326__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT {
1303 return const_iterator(__p1_.first().__next_);1327 return const_iterator(__first_node_.__next_);
1304}1328}
13051329
1306template <class _Tp, class _Hash, class _Equal, class _Alloc>1330template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -1312,8 +1336,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT {...@@ -1312,8 +1336,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT {
1312template <class _Tp, class _Hash, class _Equal, class _Alloc>1336template <class _Tp, class _Hash, class _Equal, class _Alloc>
1313void __hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT {1337void __hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT {
1314 if (size() > 0) {1338 if (size() > 0) {
1315 __deallocate_node(__p1_.first().__next_);1339 __deallocate_node(__first_node_.__next_);
1316 __p1_.first().__next_ = nullptr;1340 __first_node_.__next_ = nullptr;
1317 size_type __bc = bucket_count();1341 size_type __bc = bucket_count();
1318 for (size_type __i = 0; __i < __bc; ++__i)1342 for (size_type __i = 0; __i < __bc; ++__i)
1319 __bucket_list_[__i] = nullptr;1343 __bucket_list_[__i] = nullptr;
...@@ -1348,7 +1372,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(size_t __...@@ -1348,7 +1372,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(size_t __
1348 }1372 }
1349 if (size() + 1 > __bc * max_load_factor() || __bc == 0) {1373 if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
1350 __rehash_unique(std::max<size_type>(1374 __rehash_unique(std::max<size_type>(
1351 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor()))));1375 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor()))));
1352 }1376 }
1353 return nullptr;1377 return nullptr;
1354}1378}
...@@ -1365,7 +1389,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform(__node_po...@@ -1365,7 +1389,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform(__node_po
1365 // insert_after __bucket_list_[__chash], or __first_node if bucket is null1389 // insert_after __bucket_list_[__chash], or __first_node if bucket is null
1366 __next_pointer __pn = __bucket_list_[__chash];1390 __next_pointer __pn = __bucket_list_[__chash];
1367 if (__pn == nullptr) {1391 if (__pn == nullptr) {
1368 __pn = __p1_.first().__ptr();1392 __pn = __first_node_.__ptr();
1369 __nd->__next_ = __pn->__next_;1393 __nd->__next_ = __pn->__next_;
1370 __pn->__next_ = __nd->__ptr();1394 __pn->__next_ = __nd->__ptr();
1371 // fix up __bucket_list_1395 // fix up __bucket_list_
...@@ -1408,7 +1432,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(size_t __c...@@ -1408,7 +1432,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(size_t __c
1408 size_type __bc = bucket_count();1432 size_type __bc = bucket_count();
1409 if (size() + 1 > __bc * max_load_factor() || __bc == 0) {1433 if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
1410 __rehash_multi(std::max<size_type>(1434 __rehash_multi(std::max<size_type>(
1411 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor()))));1435 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor()))));
1412 __bc = bucket_count();1436 __bc = bucket_count();
1413 }1437 }
1414 size_t __chash = std::__constrain_hash(__cp_hash, __bc);1438 size_t __chash = std::__constrain_hash(__cp_hash, __bc);
...@@ -1445,7 +1469,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(...@@ -1445,7 +1469,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(
1445 size_type __bc = bucket_count();1469 size_type __bc = bucket_count();
1446 size_t __chash = std::__constrain_hash(__cp->__hash_, __bc);1470 size_t __chash = std::__constrain_hash(__cp->__hash_, __bc);
1447 if (__pn == nullptr) {1471 if (__pn == nullptr) {
1448 __pn = __p1_.first().__ptr();1472 __pn = __first_node_.__ptr();
1449 __cp->__next_ = __pn->__next_;1473 __cp->__next_ = __pn->__next_;
1450 __pn->__next_ = __cp->__ptr();1474 __pn->__next_ = __cp->__ptr();
1451 // fix up __bucket_list_1475 // fix up __bucket_list_
...@@ -1483,7 +1507,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(const_iterator __p...@@ -1483,7 +1507,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(const_iterator __p
1483 size_type __bc = bucket_count();1507 size_type __bc = bucket_count();
1484 if (size() + 1 > __bc * max_load_factor() || __bc == 0) {1508 if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
1485 __rehash_multi(std::max<size_type>(1509 __rehash_multi(std::max<size_type>(
1486 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor()))));1510 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor()))));
1487 __bc = bucket_count();1511 __bc = bucket_count();
1488 }1512 }
1489 size_t __chash = std::__constrain_hash(__cp->__hash_, __bc);1513 size_t __chash = std::__constrain_hash(__cp->__hash_, __bc);
...@@ -1523,14 +1547,14 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&...@@ -1523,14 +1547,14 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
1523 __node_holder __h = __construct_node_hash(__hash, std::forward<_Args>(__args)...);1547 __node_holder __h = __construct_node_hash(__hash, std::forward<_Args>(__args)...);
1524 if (size() + 1 > __bc * max_load_factor() || __bc == 0) {1548 if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
1525 __rehash_unique(std::max<size_type>(1549 __rehash_unique(std::max<size_type>(
1526 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor()))));1550 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor()))));
1527 __bc = bucket_count();1551 __bc = bucket_count();
1528 __chash = std::__constrain_hash(__hash, __bc);1552 __chash = std::__constrain_hash(__hash, __bc);
1529 }1553 }
1530 // insert_after __bucket_list_[__chash], or __first_node if bucket is null1554 // insert_after __bucket_list_[__chash], or __first_node if bucket is null
1531 __next_pointer __pn = __bucket_list_[__chash];1555 __next_pointer __pn = __bucket_list_[__chash];
1532 if (__pn == nullptr) {1556 if (__pn == nullptr) {
1533 __pn = __p1_.first().__ptr();1557 __pn = __first_node_.__ptr();
1534 __h->__next_ = __pn->__next_;1558 __h->__next_ = __pn->__next_;
1535 __pn->__next_ = __h.get()->__ptr();1559 __pn->__next_ = __h.get()->__ptr();
1536 // fix up __bucket_list_1560 // fix up __bucket_list_
...@@ -1692,8 +1716,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) _LIBCPP_D...@@ -1692,8 +1716,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) _LIBCPP_D
1692 else if (__n < __bc) {1716 else if (__n < __bc) {
1693 __n = std::max<size_type>(1717 __n = std::max<size_type>(
1694 __n,1718 __n,
1695 std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(std::ceil(float(size()) / max_load_factor())))1719 std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(__math::ceil(float(size()) / max_load_factor())))
1696 : std::__next_prime(size_t(std::ceil(float(size()) / max_load_factor()))));1720 : std::__next_prime(size_t(__math::ceil(float(size()) / max_load_factor()))));
1697 if (__n < __bc)1721 if (__n < __bc)
1698 __do_rehash<_UniqueKeys>(__n);1722 __do_rehash<_UniqueKeys>(__n);
1699 }1723 }
...@@ -1708,7 +1732,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc) {...@@ -1708,7 +1732,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc) {
1708 if (__nbc > 0) {1732 if (__nbc > 0) {
1709 for (size_type __i = 0; __i < __nbc; ++__i)1733 for (size_type __i = 0; __i < __nbc; ++__i)
1710 __bucket_list_[__i] = nullptr;1734 __bucket_list_[__i] = nullptr;
1711 __next_pointer __pp = __p1_.first().__ptr();1735 __next_pointer __pp = __first_node_.__ptr();
1712 __next_pointer __cp = __pp->__next_;1736 __next_pointer __cp = __pp->__next_;
1713 if (__cp != nullptr) {1737 if (__cp != nullptr) {
1714 size_type __chash = std::__constrain_hash(__cp->__hash(), __nbc);1738 size_type __chash = std::__constrain_hash(__cp->__hash(), __nbc);
...@@ -1885,7 +1909,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT {...@@ -1885,7 +1909,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT {
1885 // Fix up __bucket_list_1909 // Fix up __bucket_list_
1886 // if __pn is not in same bucket (before begin is not in same bucket) &&1910 // if __pn is not in same bucket (before begin is not in same bucket) &&
1887 // if __cn->__next_ is not in same bucket (nullptr is not in same bucket)1911 // if __cn->__next_ is not in same bucket (nullptr is not in same bucket)
1888 if (__pn == __p1_.first().__ptr() || std::__constrain_hash(__pn->__hash(), __bc) != __chash) {1912 if (__pn == __first_node_.__ptr() || std::__constrain_hash(__pn->__hash(), __bc) != __chash) {
1889 if (__cn->__next_ == nullptr || std::__constrain_hash(__cn->__next_->__hash(), __bc) != __chash)1913 if (__cn->__next_ == nullptr || std::__constrain_hash(__cn->__next_->__hash(), __bc) != __chash)
1890 __bucket_list_[__chash] = nullptr;1914 __bucket_list_[__chash] = nullptr;
1891 }1915 }
...@@ -2004,14 +2028,17 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)...@@ -2004,14 +2028,17 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
2004 std::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size());2028 std::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size());
2005 std::__swap_allocator(__bucket_list_.get_deleter().__alloc(), __u.__bucket_list_.get_deleter().__alloc());2029 std::__swap_allocator(__bucket_list_.get_deleter().__alloc(), __u.__bucket_list_.get_deleter().__alloc());
2006 std::__swap_allocator(__node_alloc(), __u.__node_alloc());2030 std::__swap_allocator(__node_alloc(), __u.__node_alloc());
2007 std::swap(__p1_.first().__next_, __u.__p1_.first().__next_);2031 std::swap(__first_node_.__next_, __u.__first_node_.__next_);
2008 __p2_.swap(__u.__p2_);2032 using std::swap;
2009 __p3_.swap(__u.__p3_);2033 swap(__size_, __u.__size_);
2034 swap(__hasher_, __u.__hasher_);
2035 swap(__max_load_factor_, __u.__max_load_factor_);
2036 swap(__key_eq_, __u.__key_eq_);
2010 if (size() > 0)2037 if (size() > 0)
2011 __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = __p1_.first().__ptr();2038 __bucket_list_[std::__constrain_hash(__first_node_.__next_->__hash(), bucket_count())] = __first_node_.__ptr();
2012 if (__u.size() > 0)2039 if (__u.size() > 0)
2013 __u.__bucket_list_[std::__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] =2040 __u.__bucket_list_[std::__constrain_hash(__u.__first_node_.__next_->__hash(), __u.bucket_count())] =
2014 __u.__p1_.first().__ptr();2041 __u.__first_node_.__ptr();
2015}2042}
20162043
2017template <class _Tp, class _Hash, class _Equal, class _Alloc>2044template <class _Tp, class _Hash, class _Equal, class _Alloc>
lib/libcxx/include/__iterator/access.h+1-1
...@@ -11,7 +11,7 @@...@@ -11,7 +11,7 @@
11#define _LIBCPP___ITERATOR_ACCESS_H11#define _LIBCPP___ITERATOR_ACCESS_H
1212
13#include <__config>13#include <__config>
14#include <cstddef>14#include <__cstddef/size_t.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/__iterator/advance.h+2-6
...@@ -76,9 +76,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i...@@ -76,9 +76,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i
76// [range.iter.op.advance]76// [range.iter.op.advance]
7777
78namespace ranges {78namespace ranges {
79namespace __advance {79struct __advance {
80
81struct __fn {
82private:80private:
83 template <class _Ip>81 template <class _Ip>
84 _LIBCPP_HIDE_FROM_ABI static constexpr void __advance_forward(_Ip& __i, iter_difference_t<_Ip> __n) {82 _LIBCPP_HIDE_FROM_ABI static constexpr void __advance_forward(_Ip& __i, iter_difference_t<_Ip> __n) {
...@@ -189,10 +187,8 @@ public:...@@ -189,10 +187,8 @@ public:
189 }187 }
190};188};
191189
192} // namespace __advance
193
194inline namespace __cpo {190inline namespace __cpo {
195inline constexpr auto advance = __advance::__fn{};191inline constexpr auto advance = __advance{};
196} // namespace __cpo192} // namespace __cpo
197} // namespace ranges193} // namespace ranges
198194
lib/libcxx/include/__iterator/aliasing_iterator.h+4-4
...@@ -10,10 +10,10 @@...@@ -10,10 +10,10 @@
10#define _LIBCPP___ITERATOR_ALIASING_ITERATOR_H10#define _LIBCPP___ITERATOR_ALIASING_ITERATOR_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/ptrdiff_t.h>
13#include <__iterator/iterator_traits.h>14#include <__iterator/iterator_traits.h>
14#include <__memory/pointer_traits.h>15#include <__memory/pointer_traits.h>
15#include <__type_traits/is_trivial.h>16#include <__type_traits/is_trivial.h>
16#include <cstddef>
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
...@@ -31,8 +31,8 @@ struct __aliasing_iterator_wrapper {...@@ -31,8 +31,8 @@ struct __aliasing_iterator_wrapper {
31 class __iterator {31 class __iterator {
32 _BaseIter __base_ = nullptr;32 _BaseIter __base_ = nullptr;
3333
34 using __iter_traits = iterator_traits<_BaseIter>;34 using __iter_traits _LIBCPP_NODEBUG = iterator_traits<_BaseIter>;
35 using __base_value_type = typename __iter_traits::value_type;35 using __base_value_type _LIBCPP_NODEBUG = typename __iter_traits::value_type;
3636
37 static_assert(__has_random_access_iterator_category<_BaseIter>::value,37 static_assert(__has_random_access_iterator_category<_BaseIter>::value,
38 "The base iterator has to be a random access iterator!");38 "The base iterator has to be a random access iterator!");
...@@ -120,7 +120,7 @@ struct __aliasing_iterator_wrapper {...@@ -120,7 +120,7 @@ struct __aliasing_iterator_wrapper {
120120
121// This is required to avoid ADL instantiations on _BaseT121// This is required to avoid ADL instantiations on _BaseT
122template <class _BaseT, class _Alias>122template <class _BaseT, class _Alias>
123using __aliasing_iterator = typename __aliasing_iterator_wrapper<_BaseT, _Alias>::__iterator;123using __aliasing_iterator _LIBCPP_NODEBUG = typename __aliasing_iterator_wrapper<_BaseT, _Alias>::__iterator;
124124
125_LIBCPP_END_NAMESPACE_STD125_LIBCPP_END_NAMESPACE_STD
126126
lib/libcxx/include/__iterator/back_insert_iterator.h+1-1
...@@ -11,11 +11,11 @@...@@ -11,11 +11,11 @@
11#define _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H11#define _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
14#include <__iterator/iterator.h>15#include <__iterator/iterator.h>
15#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
16#include <__memory/addressof.h>17#include <__memory/addressof.h>
17#include <__utility/move.h>18#include <__utility/move.h>
18#include <cstddef>
1919
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header21# pragma GCC system_header
lib/libcxx/include/__iterator/bounded_iter.h+18-8
...@@ -16,9 +16,13 @@...@@ -16,9 +16,13 @@
16#include <__config>16#include <__config>
17#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
18#include <__memory/pointer_traits.h>18#include <__memory/pointer_traits.h>
19#include <__type_traits/conjunction.h>
20#include <__type_traits/disjunction.h>
19#include <__type_traits/enable_if.h>21#include <__type_traits/enable_if.h>
20#include <__type_traits/integral_constant.h>22#include <__type_traits/integral_constant.h>
21#include <__type_traits/is_convertible.h>23#include <__type_traits/is_convertible.h>
24#include <__type_traits/is_same.h>
25#include <__type_traits/make_const_lvalue_ref.h>
22#include <__utility/move.h>26#include <__utility/move.h>
2327
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -47,8 +51,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -47,8 +51,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
47// pointer, it is undefined at the language level (see [expr.add]). If51// pointer, it is undefined at the language level (see [expr.add]). If
48// bounded iterators exhibited this undefined behavior, we risk compiler52// bounded iterators exhibited this undefined behavior, we risk compiler
49// optimizations deleting non-redundant bounds checks.53// optimizations deleting non-redundant bounds checks.
50template <class _Iterator, class = __enable_if_t< __libcpp_is_contiguous_iterator<_Iterator>::value > >54template <class _Iterator>
51struct __bounded_iter {55struct __bounded_iter {
56 static_assert(__libcpp_is_contiguous_iterator<_Iterator>::value,
57 "Only contiguous iterators can be adapted by __bounded_iter.");
58
52 using value_type = typename iterator_traits<_Iterator>::value_type;59 using value_type = typename iterator_traits<_Iterator>::value_type;
53 using difference_type = typename iterator_traits<_Iterator>::difference_type;60 using difference_type = typename iterator_traits<_Iterator>::difference_type;
54 using pointer = typename iterator_traits<_Iterator>::pointer;61 using pointer = typename iterator_traits<_Iterator>::pointer;
...@@ -60,14 +67,19 @@ struct __bounded_iter {...@@ -60,14 +67,19 @@ struct __bounded_iter {
6067
61 // Create a singular iterator.68 // Create a singular iterator.
62 //69 //
63 // Such an iterator points past the end of an empty span, so it is not dereferenceable.70 // Such an iterator points past the end of an empty range, so it is not dereferenceable.
64 // Observing operations like comparison and assignment are valid.71 // Operations like comparison and assignment are valid.
65 _LIBCPP_HIDE_FROM_ABI __bounded_iter() = default;72 _LIBCPP_HIDE_FROM_ABI __bounded_iter() = default;
6673
67 _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter const&) = default;74 _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter const&) = default;
68 _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter&&) = default;75 _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter&&) = default;
6976
70 template <class _OtherIterator, __enable_if_t< is_convertible<_OtherIterator, _Iterator>::value, int> = 0>77 template < class _OtherIterator,
78 __enable_if_t<
79 _And< is_convertible<const _OtherIterator&, _Iterator>,
80 _Or<is_same<reference, __iter_reference<_OtherIterator> >,
81 is_same<reference, __make_const_lvalue_ref<__iter_reference<_OtherIterator> > > > >::value,
82 int> = 0>
71 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter(__bounded_iter<_OtherIterator> const& __other) _NOEXCEPT83 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter(__bounded_iter<_OtherIterator> const& __other) _NOEXCEPT
72 : __current_(__other.__current_),84 : __current_(__other.__current_),
73 __begin_(__other.__begin_),85 __begin_(__other.__begin_),
...@@ -209,9 +221,7 @@ public:...@@ -209,9 +221,7 @@ public:
209 operator!=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {221 operator!=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
210 return __x.__current_ != __y.__current_;222 return __x.__current_ != __y.__current_;
211 }223 }
212#endif
213224
214 // TODO(mordante) disable these overloads in the LLVM 20 release.
215 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool225 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
216 operator<(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {226 operator<(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
217 return __x.__current_ < __y.__current_;227 return __x.__current_ < __y.__current_;
...@@ -229,7 +239,7 @@ public:...@@ -229,7 +239,7 @@ public:
229 return __x.__current_ >= __y.__current_;239 return __x.__current_ >= __y.__current_;
230 }240 }
231241
232#if _LIBCPP_STD_VER >= 20242#else
233 _LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering243 _LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering
234 operator<=>(__bounded_iter const& __x, __bounded_iter const& __y) noexcept {244 operator<=>(__bounded_iter const& __x, __bounded_iter const& __y) noexcept {
235 if constexpr (three_way_comparable<_Iterator, strong_ordering>) {245 if constexpr (three_way_comparable<_Iterator, strong_ordering>) {
...@@ -249,7 +259,7 @@ public:...@@ -249,7 +259,7 @@ public:
249private:259private:
250 template <class>260 template <class>
251 friend struct pointer_traits;261 friend struct pointer_traits;
252 template <class, class>262 template <class>
253 friend struct __bounded_iter;263 friend struct __bounded_iter;
254 _Iterator __current_; // current iterator264 _Iterator __current_; // current iterator
255 _Iterator __begin_, __end_; // valid range represented as [begin, end]265 _Iterator __begin_, __end_; // valid range represented as [begin, end]
lib/libcxx/include/__iterator/common_iterator.h+2-1
...@@ -26,6 +26,7 @@...@@ -26,6 +26,7 @@
26#include <__iterator/iterator_traits.h>26#include <__iterator/iterator_traits.h>
27#include <__iterator/readable_traits.h>27#include <__iterator/readable_traits.h>
28#include <__memory/addressof.h>28#include <__memory/addressof.h>
29#include <__type_traits/conditional.h>
29#include <__type_traits/is_pointer.h>30#include <__type_traits/is_pointer.h>
30#include <__utility/declval.h>31#include <__utility/declval.h>
31#include <variant>32#include <variant>
...@@ -235,7 +236,7 @@ public:...@@ -235,7 +236,7 @@ public:
235 return std::__unchecked_get<_Sent>(__x.__hold_) - std::__unchecked_get<_I2>(__y.__hold_);236 return std::__unchecked_get<_Sent>(__x.__hold_) - std::__unchecked_get<_I2>(__y.__hold_);
236 }237 }
237238
238 _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter>239 _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto)
239 iter_move(const common_iterator& __i) noexcept(noexcept(ranges::iter_move(std::declval<const _Iter&>())))240 iter_move(const common_iterator& __i) noexcept(noexcept(ranges::iter_move(std::declval<const _Iter&>())))
240 requires input_iterator<_Iter>241 requires input_iterator<_Iter>
241 {242 {
lib/libcxx/include/__iterator/concepts.h+46-17
...@@ -26,7 +26,6 @@...@@ -26,7 +26,6 @@
26#include <__concepts/semiregular.h>26#include <__concepts/semiregular.h>
27#include <__concepts/totally_ordered.h>27#include <__concepts/totally_ordered.h>
28#include <__config>28#include <__config>
29#include <__functional/invoke.h>
30#include <__iterator/incrementable_traits.h>29#include <__iterator/incrementable_traits.h>
31#include <__iterator/iter_move.h>30#include <__iterator/iter_move.h>
32#include <__iterator/iterator_traits.h>31#include <__iterator/iterator_traits.h>
...@@ -34,7 +33,10 @@...@@ -34,7 +33,10 @@
34#include <__memory/pointer_traits.h>33#include <__memory/pointer_traits.h>
35#include <__type_traits/add_pointer.h>34#include <__type_traits/add_pointer.h>
36#include <__type_traits/common_reference.h>35#include <__type_traits/common_reference.h>
36#include <__type_traits/integral_constant.h>
37#include <__type_traits/invoke.h>
37#include <__type_traits/is_pointer.h>38#include <__type_traits/is_pointer.h>
39#include <__type_traits/is_primary_template.h>
38#include <__type_traits/is_reference.h>40#include <__type_traits/is_reference.h>
39#include <__type_traits/remove_cv.h>41#include <__type_traits/remove_cv.h>
40#include <__type_traits/remove_cvref.h>42#include <__type_traits/remove_cvref.h>
...@@ -64,8 +66,33 @@ concept __indirectly_readable_impl =...@@ -64,8 +66,33 @@ concept __indirectly_readable_impl =
64template <class _In>66template <class _In>
65concept indirectly_readable = __indirectly_readable_impl<remove_cvref_t<_In>>;67concept indirectly_readable = __indirectly_readable_impl<remove_cvref_t<_In>>;
6668
69template <class _Tp>
70using __projected_iterator_t _LIBCPP_NODEBUG = typename _Tp::__projected_iterator;
71
72template <class _Tp>
73using __projected_projection_t _LIBCPP_NODEBUG = typename _Tp::__projected_projection;
74
75template <class _Tp>
76concept __specialization_of_projected = requires {
77 typename __projected_iterator_t<_Tp>;
78 typename __projected_projection_t<_Tp>;
79} && __is_primary_template<_Tp>::value;
80
81template <class _Tp>
82struct __indirect_value_t_impl {
83 using type = iter_value_t<_Tp>&;
84};
85template <__specialization_of_projected _Tp>
86struct __indirect_value_t_impl<_Tp> {
87 using type = invoke_result_t<__projected_projection_t<_Tp>&,
88 typename __indirect_value_t_impl<__projected_iterator_t<_Tp>>::type>;
89};
90
91template <indirectly_readable _Tp>
92using __indirect_value_t _LIBCPP_NODEBUG = typename __indirect_value_t_impl<_Tp>::type;
93
67template <indirectly_readable _Tp>94template <indirectly_readable _Tp>
68using iter_common_reference_t = common_reference_t<iter_reference_t<_Tp>, iter_value_t<_Tp>&>;95using iter_common_reference_t = common_reference_t<iter_reference_t<_Tp>, __indirect_value_t<_Tp>>;
6996
70// [iterator.concept.writable]97// [iterator.concept.writable]
71template <class _Out, class _Tp>98template <class _Out, class _Tp>
...@@ -176,43 +203,45 @@ concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip...@@ -176,43 +203,45 @@ concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip
176// [indirectcallable.indirectinvocable]203// [indirectcallable.indirectinvocable]
177template <class _Fp, class _It>204template <class _Fp, class _It>
178concept indirectly_unary_invocable =205concept indirectly_unary_invocable =
179 indirectly_readable<_It> && copy_constructible<_Fp> && invocable<_Fp&, iter_value_t<_It>&> &&206 indirectly_readable<_It> && copy_constructible<_Fp> && invocable<_Fp&, __indirect_value_t<_It>> &&
180 invocable<_Fp&, iter_reference_t<_It>> &&207 invocable<_Fp&, iter_reference_t<_It>> &&
181 common_reference_with< invoke_result_t<_Fp&, iter_value_t<_It>&>, invoke_result_t<_Fp&, iter_reference_t<_It>>>;208 common_reference_with< invoke_result_t<_Fp&, __indirect_value_t<_It>>,
209 invoke_result_t<_Fp&, iter_reference_t<_It>>>;
182210
183template <class _Fp, class _It>211template <class _Fp, class _It>
184concept indirectly_regular_unary_invocable =212concept indirectly_regular_unary_invocable =
185 indirectly_readable<_It> && copy_constructible<_Fp> && regular_invocable<_Fp&, iter_value_t<_It>&> &&213 indirectly_readable<_It> && copy_constructible<_Fp> && regular_invocable<_Fp&, __indirect_value_t<_It>> &&
186 regular_invocable<_Fp&, iter_reference_t<_It>> &&214 regular_invocable<_Fp&, iter_reference_t<_It>> &&
187 common_reference_with< invoke_result_t<_Fp&, iter_value_t<_It>&>, invoke_result_t<_Fp&, iter_reference_t<_It>>>;215 common_reference_with< invoke_result_t<_Fp&, __indirect_value_t<_It>>,
216 invoke_result_t<_Fp&, iter_reference_t<_It>>>;
188217
189template <class _Fp, class _It>218template <class _Fp, class _It>
190concept indirect_unary_predicate =219concept indirect_unary_predicate =
191 indirectly_readable<_It> && copy_constructible<_Fp> && predicate<_Fp&, iter_value_t<_It>&> &&220 indirectly_readable<_It> && copy_constructible<_Fp> && predicate<_Fp&, __indirect_value_t<_It>> &&
192 predicate<_Fp&, iter_reference_t<_It>>;221 predicate<_Fp&, iter_reference_t<_It>>;
193222
194template <class _Fp, class _It1, class _It2>223template <class _Fp, class _It1, class _It2>
195concept indirect_binary_predicate =224concept indirect_binary_predicate =
196 indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> &&225 indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> &&
197 predicate<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> &&226 predicate<_Fp&, __indirect_value_t<_It1>, __indirect_value_t<_It2>> &&
198 predicate<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> &&227 predicate<_Fp&, __indirect_value_t<_It1>, iter_reference_t<_It2>> &&
199 predicate<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> &&228 predicate<_Fp&, iter_reference_t<_It1>, __indirect_value_t<_It2>> &&
200 predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>;229 predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>;
201230
202template <class _Fp, class _It1, class _It2 = _It1>231template <class _Fp, class _It1, class _It2 = _It1>
203concept indirect_equivalence_relation =232concept indirect_equivalence_relation =
204 indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> &&233 indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> &&
205 equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> &&234 equivalence_relation<_Fp&, __indirect_value_t<_It1>, __indirect_value_t<_It2>> &&
206 equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> &&235 equivalence_relation<_Fp&, __indirect_value_t<_It1>, iter_reference_t<_It2>> &&
207 equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> &&236 equivalence_relation<_Fp&, iter_reference_t<_It1>, __indirect_value_t<_It2>> &&
208 equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>;237 equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>;
209238
210template <class _Fp, class _It1, class _It2 = _It1>239template <class _Fp, class _It1, class _It2 = _It1>
211concept indirect_strict_weak_order =240concept indirect_strict_weak_order =
212 indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> &&241 indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> &&
213 strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> &&242 strict_weak_order<_Fp&, __indirect_value_t<_It1>, __indirect_value_t<_It2>> &&
214 strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> &&243 strict_weak_order<_Fp&, __indirect_value_t<_It1>, iter_reference_t<_It2>> &&
215 strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> &&244 strict_weak_order<_Fp&, iter_reference_t<_It1>, __indirect_value_t<_It2>> &&
216 strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>;245 strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>;
217246
218template <class _Fp, class... _Its>247template <class _Fp, class... _Its>
...@@ -245,7 +274,7 @@ concept indirectly_copyable_storable =...@@ -245,7 +274,7 @@ concept indirectly_copyable_storable =
245#endif // _LIBCPP_STD_VER >= 20274#endif // _LIBCPP_STD_VER >= 20
246275
247template <class _Tp>276template <class _Tp>
248using __has_random_access_iterator_category_or_concept277using __has_random_access_iterator_category_or_concept _LIBCPP_NODEBUG
249#if _LIBCPP_STD_VER >= 20278#if _LIBCPP_STD_VER >= 20
250 = integral_constant<bool, random_access_iterator<_Tp>>;279 = integral_constant<bool, random_access_iterator<_Tp>>;
251#else // _LIBCPP_STD_VER < 20280#else // _LIBCPP_STD_VER < 20
lib/libcxx/include/__iterator/counted_iterator.h+4-4
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
11#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H11#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
1212
13#include <__assert>13#include <__assert>
14#include <__compare/ordering.h>
14#include <__concepts/assignable.h>15#include <__concepts/assignable.h>
15#include <__concepts/common_with.h>16#include <__concepts/common_with.h>
16#include <__concepts/constructible.h>17#include <__concepts/constructible.h>
...@@ -28,7 +29,6 @@...@@ -28,7 +29,6 @@
28#include <__type_traits/add_pointer.h>29#include <__type_traits/add_pointer.h>
29#include <__type_traits/conditional.h>30#include <__type_traits/conditional.h>
30#include <__utility/move.h>31#include <__utility/move.h>
31#include <compare>
3232
33#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)33#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
34# pragma GCC system_header34# pragma GCC system_header
...@@ -132,7 +132,7 @@ public:...@@ -132,7 +132,7 @@ public:
132 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator++(int) {132 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator++(int) {
133 _LIBCPP_ASSERT_UNCATEGORIZED(__count_ > 0, "Iterator already at or past end.");133 _LIBCPP_ASSERT_UNCATEGORIZED(__count_ > 0, "Iterator already at or past end.");
134 --__count_;134 --__count_;
135# ifndef _LIBCPP_HAS_NO_EXCEPTIONS135# if _LIBCPP_HAS_EXCEPTIONS
136 try {136 try {
137 return __current_++;137 return __current_++;
138 } catch (...) {138 } catch (...) {
...@@ -141,7 +141,7 @@ public:...@@ -141,7 +141,7 @@ public:
141 }141 }
142# else142# else
143 return __current_++;143 return __current_++;
144# endif // _LIBCPP_HAS_NO_EXCEPTIONS144# endif // _LIBCPP_HAS_EXCEPTIONS
145 }145 }
146146
147 _LIBCPP_HIDE_FROM_ABI constexpr counted_iterator operator++(int)147 _LIBCPP_HIDE_FROM_ABI constexpr counted_iterator operator++(int)
...@@ -249,7 +249,7 @@ public:...@@ -249,7 +249,7 @@ public:
249 return __rhs.__count_ <=> __lhs.__count_;249 return __rhs.__count_ <=> __lhs.__count_;
250 }250 }
251251
252 _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter>252 _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto)
253 iter_move(const counted_iterator& __i) noexcept(noexcept(ranges::iter_move(__i.__current_)))253 iter_move(const counted_iterator& __i) noexcept(noexcept(ranges::iter_move(__i.__current_)))
254 requires input_iterator<_Iter>254 requires input_iterator<_Iter>
255 {255 {
lib/libcxx/include/__iterator/data.h-1
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
11#define _LIBCPP___ITERATOR_DATA_H11#define _LIBCPP___ITERATOR_DATA_H
1212
13#include <__config>13#include <__config>
14#include <cstddef>
15#include <initializer_list>14#include <initializer_list>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__iterator/distance.h+2-6
...@@ -52,9 +52,7 @@ distance(_InputIter __first, _InputIter __last) {...@@ -52,9 +52,7 @@ distance(_InputIter __first, _InputIter __last) {
52// [range.iter.op.distance]52// [range.iter.op.distance]
5353
54namespace ranges {54namespace ranges {
55namespace __distance {55struct __distance {
56
57struct __fn {
58 template <class _Ip, sentinel_for<_Ip> _Sp>56 template <class _Ip, sentinel_for<_Ip> _Sp>
59 requires(!sized_sentinel_for<_Sp, _Ip>)57 requires(!sized_sentinel_for<_Sp, _Ip>)
60 _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const {58 _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const {
...@@ -85,10 +83,8 @@ struct __fn {...@@ -85,10 +83,8 @@ struct __fn {
85 }83 }
86};84};
8785
88} // namespace __distance
89
90inline namespace __cpo {86inline namespace __cpo {
91inline constexpr auto distance = __distance::__fn{};87inline constexpr auto distance = __distance{};
92} // namespace __cpo88} // namespace __cpo
93} // namespace ranges89} // namespace ranges
9490
lib/libcxx/include/__iterator/empty.h-1
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
11#define _LIBCPP___ITERATOR_EMPTY_H11#define _LIBCPP___ITERATOR_EMPTY_H
1212
13#include <__config>13#include <__config>
14#include <cstddef>
15#include <initializer_list>14#include <initializer_list>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__iterator/front_insert_iterator.h+1-1
...@@ -11,11 +11,11 @@...@@ -11,11 +11,11 @@
11#define _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H11#define _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
14#include <__iterator/iterator.h>15#include <__iterator/iterator.h>
15#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
16#include <__memory/addressof.h>17#include <__memory/addressof.h>
17#include <__utility/move.h>18#include <__utility/move.h>
18#include <cstddef>
1919
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header21# pragma GCC system_header
lib/libcxx/include/__iterator/incrementable_traits.h+1-1
...@@ -12,13 +12,13 @@...@@ -12,13 +12,13 @@
1212
13#include <__concepts/arithmetic.h>13#include <__concepts/arithmetic.h>
14#include <__config>14#include <__config>
15#include <__cstddef/ptrdiff_t.h>
15#include <__type_traits/conditional.h>16#include <__type_traits/conditional.h>
16#include <__type_traits/is_object.h>17#include <__type_traits/is_object.h>
17#include <__type_traits/is_primary_template.h>18#include <__type_traits/is_primary_template.h>
18#include <__type_traits/make_signed.h>19#include <__type_traits/make_signed.h>
19#include <__type_traits/remove_cvref.h>20#include <__type_traits/remove_cvref.h>
20#include <__utility/declval.h>21#include <__utility/declval.h>
21#include <cstddef>
2222
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header24# pragma GCC system_header
lib/libcxx/include/__iterator/insert_iterator.h+3-3
...@@ -11,12 +11,12 @@...@@ -11,12 +11,12 @@
11#define _LIBCPP___ITERATOR_INSERT_ITERATOR_H11#define _LIBCPP___ITERATOR_INSERT_ITERATOR_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
14#include <__iterator/iterator.h>15#include <__iterator/iterator.h>
15#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
16#include <__memory/addressof.h>17#include <__memory/addressof.h>
17#include <__ranges/access.h>18#include <__ranges/access.h>
18#include <__utility/move.h>19#include <__utility/move.h>
19#include <cstddef>
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
...@@ -29,10 +29,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,10 +29,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929
30#if _LIBCPP_STD_VER >= 2030#if _LIBCPP_STD_VER >= 20
31template <class _Container>31template <class _Container>
32using __insert_iterator_iter_t = ranges::iterator_t<_Container>;32using __insert_iterator_iter_t _LIBCPP_NODEBUG = ranges::iterator_t<_Container>;
33#else33#else
34template <class _Container>34template <class _Container>
35using __insert_iterator_iter_t = typename _Container::iterator;35using __insert_iterator_iter_t _LIBCPP_NODEBUG = typename _Container::iterator;
36#endif36#endif
3737
38_LIBCPP_SUPPRESS_DEPRECATED_PUSH38_LIBCPP_SUPPRESS_DEPRECATED_PUSH
lib/libcxx/include/__iterator/istream_iterator.h+1-1
...@@ -11,13 +11,13 @@...@@ -11,13 +11,13 @@
11#define _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H11#define _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
14#include <__fwd/istream.h>15#include <__fwd/istream.h>
15#include <__fwd/string.h>16#include <__fwd/string.h>
16#include <__iterator/default_sentinel.h>17#include <__iterator/default_sentinel.h>
17#include <__iterator/iterator.h>18#include <__iterator/iterator.h>
18#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
19#include <__memory/addressof.h>20#include <__memory/addressof.h>
20#include <cstddef>
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
lib/libcxx/include/__iterator/istreambuf_iterator.h+2
...@@ -16,6 +16,8 @@...@@ -16,6 +16,8 @@
16#include <__iterator/default_sentinel.h>16#include <__iterator/default_sentinel.h>
17#include <__iterator/iterator.h>17#include <__iterator/iterator.h>
18#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
19#include <__string/char_traits.h>
20#include <iosfwd>
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
lib/libcxx/include/__iterator/iterator.h+1-1
...@@ -11,7 +11,7 @@...@@ -11,7 +11,7 @@
11#define _LIBCPP___ITERATOR_ITERATOR_H11#define _LIBCPP___ITERATOR_ITERATOR_H
1212
13#include <__config>13#include <__config>
14#include <cstddef>14#include <__cstddef/ptrdiff_t.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/__iterator/iterator_traits.h+31-24
...@@ -18,12 +18,15 @@...@@ -18,12 +18,15 @@
18#include <__concepts/same_as.h>18#include <__concepts/same_as.h>
19#include <__concepts/totally_ordered.h>19#include <__concepts/totally_ordered.h>
20#include <__config>20#include <__config>
21#include <__cstddef/ptrdiff_t.h>
21#include <__fwd/pair.h>22#include <__fwd/pair.h>
22#include <__iterator/incrementable_traits.h>23#include <__iterator/incrementable_traits.h>
23#include <__iterator/readable_traits.h>24#include <__iterator/readable_traits.h>
24#include <__type_traits/common_reference.h>25#include <__type_traits/common_reference.h>
25#include <__type_traits/conditional.h>26#include <__type_traits/conditional.h>
26#include <__type_traits/disjunction.h>27#include <__type_traits/disjunction.h>
28#include <__type_traits/enable_if.h>
29#include <__type_traits/integral_constant.h>
27#include <__type_traits/is_convertible.h>30#include <__type_traits/is_convertible.h>
28#include <__type_traits/is_object.h>31#include <__type_traits/is_object.h>
29#include <__type_traits/is_primary_template.h>32#include <__type_traits/is_primary_template.h>
...@@ -34,7 +37,6 @@...@@ -34,7 +37,6 @@
34#include <__type_traits/remove_cvref.h>37#include <__type_traits/remove_cvref.h>
35#include <__type_traits/void_t.h>38#include <__type_traits/void_t.h>
36#include <__utility/declval.h>39#include <__utility/declval.h>
37#include <cstddef>
3840
39#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)41#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
40# pragma GCC system_header42# pragma GCC system_header
...@@ -45,7 +47,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -45,7 +47,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
45#if _LIBCPP_STD_VER >= 2047#if _LIBCPP_STD_VER >= 20
4648
47template <class _Tp>49template <class _Tp>
48using __with_reference = _Tp&;50using __with_reference _LIBCPP_NODEBUG = _Tp&;
4951
50template <class _Tp>52template <class _Tp>
51concept __can_reference = requires { typename __with_reference<_Tp>; };53concept __can_reference = requires { typename __with_reference<_Tp>; };
...@@ -78,19 +80,20 @@ struct __iter_traits_cache {...@@ -78,19 +80,20 @@ struct __iter_traits_cache {
78 using type = _If< __is_primary_template<iterator_traits<_Iter> >::value, _Iter, iterator_traits<_Iter> >;80 using type = _If< __is_primary_template<iterator_traits<_Iter> >::value, _Iter, iterator_traits<_Iter> >;
79};81};
80template <class _Iter>82template <class _Iter>
81using _ITER_TRAITS = typename __iter_traits_cache<_Iter>::type;83using _ITER_TRAITS _LIBCPP_NODEBUG = typename __iter_traits_cache<_Iter>::type;
8284
83struct __iter_concept_concept_test {85struct __iter_concept_concept_test {
84 template <class _Iter>86 template <class _Iter>
85 using _Apply = typename _ITER_TRAITS<_Iter>::iterator_concept;87 using _Apply _LIBCPP_NODEBUG = typename _ITER_TRAITS<_Iter>::iterator_concept;
86};88};
87struct __iter_concept_category_test {89struct __iter_concept_category_test {
88 template <class _Iter>90 template <class _Iter>
89 using _Apply = typename _ITER_TRAITS<_Iter>::iterator_category;91 using _Apply _LIBCPP_NODEBUG = typename _ITER_TRAITS<_Iter>::iterator_category;
90};92};
91struct __iter_concept_random_fallback {93struct __iter_concept_random_fallback {
92 template <class _Iter>94 template <class _Iter>
93 using _Apply = __enable_if_t< __is_primary_template<iterator_traits<_Iter> >::value, random_access_iterator_tag >;95 using _Apply _LIBCPP_NODEBUG =
96 __enable_if_t<__is_primary_template<iterator_traits<_Iter> >::value, random_access_iterator_tag>;
94};97};
9598
96template <class _Iter, class _Tester>99template <class _Iter, class _Tester>
...@@ -104,7 +107,7 @@ struct __iter_concept_cache {...@@ -104,7 +107,7 @@ struct __iter_concept_cache {
104};107};
105108
106template <class _Iter>109template <class _Iter>
107using _ITER_CONCEPT = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>;110using _ITER_CONCEPT _LIBCPP_NODEBUG = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>;
108111
109template <class _Tp>112template <class _Tp>
110struct __has_iterator_typedefs {113struct __has_iterator_typedefs {
...@@ -362,7 +365,7 @@ struct __iterator_traits<_Ip> {...@@ -362,7 +365,7 @@ struct __iterator_traits<_Ip> {
362365
363template <class _Ip>366template <class _Ip>
364struct iterator_traits : __iterator_traits<_Ip> {367struct iterator_traits : __iterator_traits<_Ip> {
365 using __primary_template = iterator_traits;368 using __primary_template _LIBCPP_NODEBUG = iterator_traits;
366};369};
367370
368#else // _LIBCPP_STD_VER >= 20371#else // _LIBCPP_STD_VER >= 20
...@@ -395,7 +398,7 @@ struct __iterator_traits<_Iter, true>...@@ -395,7 +398,7 @@ struct __iterator_traits<_Iter, true>
395398
396template <class _Iter>399template <class _Iter>
397struct _LIBCPP_TEMPLATE_VIS iterator_traits : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> {400struct _LIBCPP_TEMPLATE_VIS iterator_traits : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> {
398 using __primary_template = iterator_traits;401 using __primary_template _LIBCPP_NODEBUG = iterator_traits;
399};402};
400#endif // _LIBCPP_STD_VER >= 20403#endif // _LIBCPP_STD_VER >= 20
401404
...@@ -428,16 +431,19 @@ template <class _Tp, class _Up>...@@ -428,16 +431,19 @@ template <class _Tp, class _Up>
428struct __has_iterator_concept_convertible_to<_Tp, _Up, false> : false_type {};431struct __has_iterator_concept_convertible_to<_Tp, _Up, false> : false_type {};
429432
430template <class _Tp>433template <class _Tp>
431using __has_input_iterator_category = __has_iterator_category_convertible_to<_Tp, input_iterator_tag>;434using __has_input_iterator_category _LIBCPP_NODEBUG = __has_iterator_category_convertible_to<_Tp, input_iterator_tag>;
432435
433template <class _Tp>436template <class _Tp>
434using __has_forward_iterator_category = __has_iterator_category_convertible_to<_Tp, forward_iterator_tag>;437using __has_forward_iterator_category _LIBCPP_NODEBUG =
438 __has_iterator_category_convertible_to<_Tp, forward_iterator_tag>;
435439
436template <class _Tp>440template <class _Tp>
437using __has_bidirectional_iterator_category = __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>;441using __has_bidirectional_iterator_category _LIBCPP_NODEBUG =
442 __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>;
438443
439template <class _Tp>444template <class _Tp>
440using __has_random_access_iterator_category = __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag>;445using __has_random_access_iterator_category _LIBCPP_NODEBUG =
446 __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag>;
441447
442// __libcpp_is_contiguous_iterator determines if an iterator is known by448// __libcpp_is_contiguous_iterator determines if an iterator is known by
443// libc++ to be contiguous, either because it advertises itself as such449// libc++ to be contiguous, either because it advertises itself as such
...@@ -464,48 +470,49 @@ template <class _Iter>...@@ -464,48 +470,49 @@ template <class _Iter>
464class __wrap_iter;470class __wrap_iter;
465471
466template <class _Tp>472template <class _Tp>
467using __has_exactly_input_iterator_category =473using __has_exactly_input_iterator_category _LIBCPP_NODEBUG =
468 integral_constant<bool,474 integral_constant<bool,
469 __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value &&475 __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value &&
470 !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value>;476 !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value>;
471477
472template <class _Tp>478template <class _Tp>
473using __has_exactly_forward_iterator_category =479using __has_exactly_forward_iterator_category _LIBCPP_NODEBUG =
474 integral_constant<bool,480 integral_constant<bool,
475 __has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value &&481 __has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value &&
476 !__has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>::value>;482 !__has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>::value>;
477483
478template <class _Tp>484template <class _Tp>
479using __has_exactly_bidirectional_iterator_category =485using __has_exactly_bidirectional_iterator_category _LIBCPP_NODEBUG =
480 integral_constant<bool,486 integral_constant<bool,
481 __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>::value &&487 __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>::value &&
482 !__has_iterator_category_convertible_to<_Tp, random_access_iterator_tag>::value>;488 !__has_iterator_category_convertible_to<_Tp, random_access_iterator_tag>::value>;
483489
484template <class _InputIterator>490template <class _InputIterator>
485using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;491using __iter_value_type _LIBCPP_NODEBUG = typename iterator_traits<_InputIterator>::value_type;
486492
487template <class _InputIterator>493template <class _InputIterator>
488using __iter_key_type = __remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>;494using __iter_key_type _LIBCPP_NODEBUG =
495 __remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>;
489496
490template <class _InputIterator>497template <class _InputIterator>
491using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type;498using __iter_mapped_type _LIBCPP_NODEBUG = typename iterator_traits<_InputIterator>::value_type::second_type;
492499
493template <class _InputIterator>500template <class _InputIterator>
494using __iter_to_alloc_type =501using __iter_to_alloc_type _LIBCPP_NODEBUG =
495 pair<const typename iterator_traits<_InputIterator>::value_type::first_type,502 pair<const typename iterator_traits<_InputIterator>::value_type::first_type,
496 typename iterator_traits<_InputIterator>::value_type::second_type>;503 typename iterator_traits<_InputIterator>::value_type::second_type>;
497504
498template <class _Iter>505template <class _Iter>
499using __iterator_category_type = typename iterator_traits<_Iter>::iterator_category;506using __iterator_category_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::iterator_category;
500507
501template <class _Iter>508template <class _Iter>
502using __iterator_pointer_type = typename iterator_traits<_Iter>::pointer;509using __iterator_pointer_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::pointer;
503510
504template <class _Iter>511template <class _Iter>
505using __iter_diff_t = typename iterator_traits<_Iter>::difference_type;512using __iter_diff_t _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::difference_type;
506513
507template <class _Iter>514template <class _Iter>
508using __iter_reference = typename iterator_traits<_Iter>::reference;515using __iter_reference _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::reference;
509516
510#if _LIBCPP_STD_VER >= 20517#if _LIBCPP_STD_VER >= 20
511518
lib/libcxx/include/__iterator/next.h+8-11
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>27template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
28inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter28[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter
29next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) {29next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) {
30 // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation.30 // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation.
31 // Note that this check duplicates the similar check in `std::advance`.31 // Note that this check duplicates the similar check in `std::advance`.
...@@ -41,38 +41,35 @@ next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n =...@@ -41,38 +41,35 @@ next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n =
41// [range.iter.op.next]41// [range.iter.op.next]
4242
43namespace ranges {43namespace ranges {
44namespace __next {44struct __next {
45
46struct __fn {
47 template <input_or_output_iterator _Ip>45 template <input_or_output_iterator _Ip>
48 _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const {46 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const {
49 ++__x;47 ++__x;
50 return __x;48 return __x;
51 }49 }
5250
53 template <input_or_output_iterator _Ip>51 template <input_or_output_iterator _Ip>
54 _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const {52 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const {
55 ranges::advance(__x, __n);53 ranges::advance(__x, __n);
56 return __x;54 return __x;
57 }55 }
5856
59 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>57 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
60 _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, _Sp __bound_sentinel) const {58 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, _Sp __bound_sentinel) const {
61 ranges::advance(__x, __bound_sentinel);59 ranges::advance(__x, __bound_sentinel);
62 return __x;60 return __x;
63 }61 }
6462
65 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>63 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
66 _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const {64 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip
65 operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const {
67 ranges::advance(__x, __n, __bound_sentinel);66 ranges::advance(__x, __n, __bound_sentinel);
68 return __x;67 return __x;
69 }68 }
70};69};
7170
72} // namespace __next
73
74inline namespace __cpo {71inline namespace __cpo {
75inline constexpr auto next = __next::__fn{};72inline constexpr auto next = __next{};
76} // namespace __cpo73} // namespace __cpo
77} // namespace ranges74} // namespace ranges
7875
lib/libcxx/include/__iterator/ostream_iterator.h+1-1
...@@ -11,12 +11,12 @@...@@ -11,12 +11,12 @@
11#define _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H11#define _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
14#include <__fwd/ostream.h>15#include <__fwd/ostream.h>
15#include <__fwd/string.h>16#include <__fwd/string.h>
16#include <__iterator/iterator.h>17#include <__iterator/iterator.h>
17#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
18#include <__memory/addressof.h>19#include <__memory/addressof.h>
19#include <cstddef>
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
lib/libcxx/include/__iterator/ostreambuf_iterator.h+7-2
...@@ -11,10 +11,13 @@...@@ -11,10 +11,13 @@
11#define _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H11#define _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
15#include <__fwd/ios.h>
16#include <__fwd/ostream.h>
17#include <__fwd/streambuf.h>
14#include <__iterator/iterator.h>18#include <__iterator/iterator.h>
15#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
16#include <cstddef>20#include <iosfwd> // for forward declaration of ostreambuf_iterator
17#include <iosfwd> // for forward declaration of basic_streambuf
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
...@@ -62,9 +65,11 @@ public:...@@ -62,9 +65,11 @@ public:
62 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator++(int) { return *this; }65 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator++(int) { return *this; }
63 _LIBCPP_HIDE_FROM_ABI bool failed() const _NOEXCEPT { return __sbuf_ == nullptr; }66 _LIBCPP_HIDE_FROM_ABI bool failed() const _NOEXCEPT { return __sbuf_ == nullptr; }
6467
68#if _LIBCPP_HAS_LOCALIZATION
65 template <class _Ch, class _Tr>69 template <class _Ch, class _Tr>
66 friend _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_Ch, _Tr> __pad_and_output(70 friend _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_Ch, _Tr> __pad_and_output(
67 ostreambuf_iterator<_Ch, _Tr> __s, const _Ch* __ob, const _Ch* __op, const _Ch* __oe, ios_base& __iob, _Ch __fl);71 ostreambuf_iterator<_Ch, _Tr> __s, const _Ch* __ob, const _Ch* __op, const _Ch* __oe, ios_base& __iob, _Ch __fl);
72#endif // _LIBCPP_HAS_LOCALIZATION
68};73};
6974
70_LIBCPP_END_NAMESPACE_STD75_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/prev.h+24-11
...@@ -17,16 +17,20 @@...@@ -17,16 +17,20 @@
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/enable_if.h>19#include <__type_traits/enable_if.h>
20#include <__utility/move.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
23#endif24#endif
2425
26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>
28
25_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
2630
27template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>31template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
28inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter32[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter
29prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) {33prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n) {
30 // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation.34 // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation.
31 // Note that this check duplicates the similar check in `std::advance`.35 // Note that this check duplicates the similar check in `std::advance`.
32 _LIBCPP_ASSERT_PEDANTIC(__n <= 0 || __has_bidirectional_iterator_category<_InputIter>::value,36 _LIBCPP_ASSERT_PEDANTIC(__n <= 0 || __has_bidirectional_iterator_category<_InputIter>::value,
...@@ -35,37 +39,44 @@ prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n =...@@ -35,37 +39,44 @@ prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n =
35 return __x;39 return __x;
36}40}
3741
42// LWG 3197
43// It is unclear what the implications of "BidirectionalIterator" in the standard are.
44// However, calling std::prev(non-bidi-iterator) is obviously an error and we should catch it at compile time.
45template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
46[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter prev(_InputIter __it) {
47 static_assert(__has_bidirectional_iterator_category<_InputIter>::value,
48 "Attempt to prev(it) with a non-bidirectional iterator");
49 return std::prev(std::move(__it), 1);
50}
51
38#if _LIBCPP_STD_VER >= 2052#if _LIBCPP_STD_VER >= 20
3953
40// [range.iter.op.prev]54// [range.iter.op.prev]
4155
42namespace ranges {56namespace ranges {
43namespace __prev {57struct __prev {
44
45struct __fn {
46 template <bidirectional_iterator _Ip>58 template <bidirectional_iterator _Ip>
47 _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const {59 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const {
48 --__x;60 --__x;
49 return __x;61 return __x;
50 }62 }
5163
52 template <bidirectional_iterator _Ip>64 template <bidirectional_iterator _Ip>
53 _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const {65 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const {
54 ranges::advance(__x, -__n);66 ranges::advance(__x, -__n);
55 return __x;67 return __x;
56 }68 }
5769
58 template <bidirectional_iterator _Ip>70 template <bidirectional_iterator _Ip>
59 _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound_iter) const {71 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip
72 operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound_iter) const {
60 ranges::advance(__x, -__n, __bound_iter);73 ranges::advance(__x, -__n, __bound_iter);
61 return __x;74 return __x;
62 }75 }
63};76};
6477
65} // namespace __prev
66
67inline namespace __cpo {78inline namespace __cpo {
68inline constexpr auto prev = __prev::__fn{};79inline constexpr auto prev = __prev{};
69} // namespace __cpo80} // namespace __cpo
70} // namespace ranges81} // namespace ranges
7182
...@@ -73,4 +84,6 @@ inline constexpr auto prev = __prev::__fn{};...@@ -73,4 +84,6 @@ inline constexpr auto prev = __prev::__fn{};
7384
74_LIBCPP_END_NAMESPACE_STD85_LIBCPP_END_NAMESPACE_STD
7586
87_LIBCPP_POP_MACROS
88
76#endif // _LIBCPP___ITERATOR_PREV_H89#endif // _LIBCPP___ITERATOR_PREV_H
lib/libcxx/include/__iterator/projected.h+8
...@@ -26,6 +26,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,6 +26,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
26template <class _It, class _Proj>26template <class _It, class _Proj>
27struct __projected_impl {27struct __projected_impl {
28 struct __type {28 struct __type {
29 using __primary_template _LIBCPP_NODEBUG = __type;
30 using __projected_iterator _LIBCPP_NODEBUG = _It;
31 using __projected_projection _LIBCPP_NODEBUG = _Proj;
32
29 using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>;33 using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>;
30 indirect_result_t<_Proj&, _It> operator*() const; // not defined34 indirect_result_t<_Proj&, _It> operator*() const; // not defined
31 };35 };
...@@ -34,6 +38,10 @@ struct __projected_impl {...@@ -34,6 +38,10 @@ struct __projected_impl {
34template <weakly_incrementable _It, class _Proj>38template <weakly_incrementable _It, class _Proj>
35struct __projected_impl<_It, _Proj> {39struct __projected_impl<_It, _Proj> {
36 struct __type {40 struct __type {
41 using __primary_template _LIBCPP_NODEBUG = __type;
42 using __projected_iterator _LIBCPP_NODEBUG = _It;
43 using __projected_projection _LIBCPP_NODEBUG = _Proj;
44
37 using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>;45 using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>;
38 using difference_type = iter_difference_t<_It>;46 using difference_type = iter_difference_t<_It>;
39 indirect_result_t<_Proj&, _It> operator*() const; // not defined47 indirect_result_t<_Proj&, _It> operator*() const; // not defined
lib/libcxx/include/__iterator/ranges_iterator_traits.h+3-3
...@@ -24,13 +24,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,13 +24,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
24#if _LIBCPP_STD_VER >= 2324#if _LIBCPP_STD_VER >= 23
2525
26template <ranges::input_range _Range>26template <ranges::input_range _Range>
27using __range_key_type = __remove_const_t<typename ranges::range_value_t<_Range>::first_type>;27using __range_key_type _LIBCPP_NODEBUG = __remove_const_t<typename ranges::range_value_t<_Range>::first_type>;
2828
29template <ranges::input_range _Range>29template <ranges::input_range _Range>
30using __range_mapped_type = typename ranges::range_value_t<_Range>::second_type;30using __range_mapped_type _LIBCPP_NODEBUG = typename ranges::range_value_t<_Range>::second_type;
3131
32template <ranges::input_range _Range>32template <ranges::input_range _Range>
33using __range_to_alloc_type =33using __range_to_alloc_type _LIBCPP_NODEBUG =
34 pair<const typename ranges::range_value_t<_Range>::first_type, typename ranges::range_value_t<_Range>::second_type>;34 pair<const typename ranges::range_value_t<_Range>::first_type, typename ranges::range_value_t<_Range>::second_type>;
3535
36#endif36#endif
lib/libcxx/include/__iterator/reverse_access.h-1
...@@ -12,7 +12,6 @@...@@ -12,7 +12,6 @@
1212
13#include <__config>13#include <__config>
14#include <__iterator/reverse_iterator.h>14#include <__iterator/reverse_iterator.h>
15#include <cstddef>
16#include <initializer_list>15#include <initializer_list>
1716
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__iterator/reverse_iterator.h+6-4
...@@ -136,10 +136,12 @@ public:...@@ -136,10 +136,12 @@ public:
136 _LIBCPP_HIDE_FROM_ABI constexpr pointer operator->() const136 _LIBCPP_HIDE_FROM_ABI constexpr pointer operator->() const
137 requires is_pointer_v<_Iter> || requires(const _Iter __i) { __i.operator->(); }137 requires is_pointer_v<_Iter> || requires(const _Iter __i) { __i.operator->(); }
138 {138 {
139 _Iter __tmp = current;
140 --__tmp;
139 if constexpr (is_pointer_v<_Iter>) {141 if constexpr (is_pointer_v<_Iter>) {
140 return std::prev(current);142 return __tmp;
141 } else {143 } else {
142 return std::prev(current).operator->();144 return __tmp.operator->();
143 }145 }
144 }146 }
145#else147#else
...@@ -327,8 +329,8 @@ __reverse_range(_Range&& __range) {...@@ -327,8 +329,8 @@ __reverse_range(_Range&& __range) {
327329
328template <class _Iter, bool __b>330template <class _Iter, bool __b>
329struct __unwrap_iter_impl<reverse_iterator<reverse_iterator<_Iter> >, __b> {331struct __unwrap_iter_impl<reverse_iterator<reverse_iterator<_Iter> >, __b> {
330 using _UnwrappedIter = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>()));332 using _UnwrappedIter _LIBCPP_NODEBUG = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>()));
331 using _ReverseWrapper = reverse_iterator<reverse_iterator<_Iter> >;333 using _ReverseWrapper _LIBCPP_NODEBUG = reverse_iterator<reverse_iterator<_Iter> >;
332334
333 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ReverseWrapper335 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ReverseWrapper
334 __rewrap(_ReverseWrapper __orig_iter, _UnwrappedIter __unwrapped_iter) {336 __rewrap(_ReverseWrapper __orig_iter, _UnwrappedIter __unwrapped_iter) {
lib/libcxx/include/__iterator/segmented_iterator.h+2-2
...@@ -41,8 +41,8 @@...@@ -41,8 +41,8 @@
41// Returns the iterator composed of the segment iterator and local iterator.41// Returns the iterator composed of the segment iterator and local iterator.
4242
43#include <__config>43#include <__config>
44#include <__cstddef/size_t.h>
44#include <__type_traits/integral_constant.h>45#include <__type_traits/integral_constant.h>
45#include <cstddef>
4646
47#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)47#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
48# pragma GCC system_header48# pragma GCC system_header
...@@ -72,7 +72,7 @@ template <class _Tp>...@@ -72,7 +72,7 @@ template <class _Tp>
72struct __has_specialization<_Tp, sizeof(_Tp) * 0> : true_type {};72struct __has_specialization<_Tp, sizeof(_Tp) * 0> : true_type {};
7373
74template <class _Iterator>74template <class _Iterator>
75using __is_segmented_iterator = __has_specialization<__segmented_iterator_traits<_Iterator> >;75using __is_segmented_iterator _LIBCPP_NODEBUG = __has_specialization<__segmented_iterator_traits<_Iterator> >;
7676
77_LIBCPP_END_NAMESPACE_STD77_LIBCPP_END_NAMESPACE_STD
7878
lib/libcxx/include/__iterator/size.h+2-1
...@@ -11,9 +11,10 @@...@@ -11,9 +11,10 @@
11#define _LIBCPP___ITERATOR_SIZE_H11#define _LIBCPP___ITERATOR_SIZE_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
15#include <__cstddef/size_t.h>
14#include <__type_traits/common_type.h>16#include <__type_traits/common_type.h>
15#include <__type_traits/make_signed.h>17#include <__type_traits/make_signed.h>
16#include <cstddef>
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/__iterator/static_bounded_iter.h created+318
...@@ -0,0 +1,318 @@
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___ITERATOR_STATIC_BOUNDED_ITER_H
11#define _LIBCPP___ITERATOR_STATIC_BOUNDED_ITER_H
12
13#include <__assert>
14#include <__compare/ordering.h>
15#include <__compare/three_way_comparable.h>
16#include <__config>
17#include <__cstddef/size_t.h>
18#include <__iterator/iterator_traits.h>
19#include <__memory/pointer_traits.h>
20#include <__type_traits/conjunction.h>
21#include <__type_traits/disjunction.h>
22#include <__type_traits/enable_if.h>
23#include <__type_traits/integral_constant.h>
24#include <__type_traits/is_convertible.h>
25#include <__type_traits/is_same.h>
26#include <__type_traits/make_const_lvalue_ref.h>
27#include <__utility/move.h>
28
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header
31#endif
32
33_LIBCPP_PUSH_MACROS
34#include <__undef_macros>
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37
38template <class _Iterator, size_t _Size>
39struct __static_bounded_iter_storage {
40 _LIBCPP_HIDE_FROM_ABI __static_bounded_iter_storage() = default;
41 _LIBCPP_HIDE_FROM_ABI
42 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __static_bounded_iter_storage(_Iterator __current, _Iterator __begin)
43 : __current_(__current), __begin_(__begin) {}
44
45 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator& __current() _NOEXCEPT { return __current_; }
46 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __current() const _NOEXCEPT { return __current_; }
47 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __begin() const _NOEXCEPT { return __begin_; }
48 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __end() const _NOEXCEPT { return __begin_ + _Size; }
49
50private:
51 _Iterator __current_; // current iterator
52 _Iterator __begin_; // start of the valid range, which is [__begin_, __begin_ + _Size)
53};
54
55template <class _Iterator>
56struct __static_bounded_iter_storage<_Iterator, 0> {
57 _LIBCPP_HIDE_FROM_ABI __static_bounded_iter_storage() = default;
58 _LIBCPP_HIDE_FROM_ABI
59 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __static_bounded_iter_storage(_Iterator __current, _Iterator /* __begin */)
60 : __current_(__current) {}
61
62 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator& __current() _NOEXCEPT { return __current_; }
63 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __current() const _NOEXCEPT { return __current_; }
64 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __begin() const _NOEXCEPT { return __current_; }
65 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __end() const _NOEXCEPT { return __current_; }
66
67private:
68 _Iterator __current_; // current iterator
69};
70
71// This is an iterator wrapper for contiguous iterators that points within a range
72// whose size is known at compile-time. This is very similar to `__bounded_iter`,
73// except that we don't have to store the end of the range in physical memory since
74// it can be computed from the start of the range.
75//
76// The operations on which this iterator wrapper traps are the same as `__bounded_iter`.
77template <class _Iterator, size_t _Size>
78struct __static_bounded_iter {
79 static_assert(__libcpp_is_contiguous_iterator<_Iterator>::value,
80 "Only contiguous iterators can be adapted by __static_bounded_iter.");
81
82 using value_type = typename iterator_traits<_Iterator>::value_type;
83 using difference_type = typename iterator_traits<_Iterator>::difference_type;
84 using pointer = typename iterator_traits<_Iterator>::pointer;
85 using reference = typename iterator_traits<_Iterator>::reference;
86 using iterator_category = typename iterator_traits<_Iterator>::iterator_category;
87#if _LIBCPP_STD_VER >= 20
88 using iterator_concept = contiguous_iterator_tag;
89#endif
90
91 // Create a singular iterator.
92 //
93 // Such an iterator points past the end of an empty range, so it is not dereferenceable.
94 // Operations like comparison and assignment are valid.
95 _LIBCPP_HIDE_FROM_ABI __static_bounded_iter() = default;
96
97 _LIBCPP_HIDE_FROM_ABI __static_bounded_iter(__static_bounded_iter const&) = default;
98 _LIBCPP_HIDE_FROM_ABI __static_bounded_iter(__static_bounded_iter&&) = default;
99
100 template <class _OtherIterator,
101 __enable_if_t<
102 _And< is_convertible<const _OtherIterator&, _Iterator>,
103 _Or<is_same<reference, __iter_reference<_OtherIterator> >,
104 is_same<reference, __make_const_lvalue_ref<__iter_reference<_OtherIterator> > > > >::value,
105 int> = 0>
106 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
107 __static_bounded_iter(__static_bounded_iter<_OtherIterator, _Size> const& __other) _NOEXCEPT
108 : __storage_(__other.__storage_.__current(), __other.__storage_.__begin()) {}
109
110 // Assign a bounded iterator to another one, rebinding the bounds of the iterator as well.
111 _LIBCPP_HIDE_FROM_ABI __static_bounded_iter& operator=(__static_bounded_iter const&) = default;
112 _LIBCPP_HIDE_FROM_ABI __static_bounded_iter& operator=(__static_bounded_iter&&) = default;
113
114private:
115 // Create an iterator wrapping the given iterator, and whose bounds are described
116 // by the provided [begin, begin + _Size] range.
117 _LIBCPP_HIDE_FROM_ABI
118 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __static_bounded_iter(_Iterator __current, _Iterator __begin)
119 : __storage_(__current, __begin) {
120 _LIBCPP_ASSERT_INTERNAL(
121 __begin <= __current, "__static_bounded_iter(current, begin): current and begin are inconsistent");
122 _LIBCPP_ASSERT_INTERNAL(
123 __current <= __end(), "__static_bounded_iter(current, begin): current and (begin + Size) are inconsistent");
124 }
125
126 template <size_t _Sz, class _It>
127 friend _LIBCPP_CONSTEXPR __static_bounded_iter<_It, _Sz> __make_static_bounded_iter(_It, _It);
128
129public:
130 // Dereference and indexing operations.
131 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT {
132 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
133 __current() != __end(), "__static_bounded_iter::operator*: Attempt to dereference an iterator at the end");
134 return *__current();
135 }
136
137 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT {
138 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
139 __current() != __end(), "__static_bounded_iter::operator->: Attempt to dereference an iterator at the end");
140 return std::__to_address(__current());
141 }
142
143 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT {
144 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
145 __n >= __begin() - __current(),
146 "__static_bounded_iter::operator[]: Attempt to index an iterator past the start");
147 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
148 __n < __end() - __current(),
149 "__static_bounded_iter::operator[]: Attempt to index an iterator at or past the end");
150 return __current()[__n];
151 }
152
153 // Arithmetic operations.
154 //
155 // These operations check that the iterator remains within `[begin, end]`.
156 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __static_bounded_iter& operator++() _NOEXCEPT {
157 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
158 __current() != __end(), "__static_bounded_iter::operator++: Attempt to advance an iterator past the end");
159 ++__current();
160 return *this;
161 }
162 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __static_bounded_iter operator++(int) _NOEXCEPT {
163 __static_bounded_iter __tmp(*this);
164 ++*this;
165 return __tmp;
166 }
167
168 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __static_bounded_iter& operator--() _NOEXCEPT {
169 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
170 __current() != __begin(), "__static_bounded_iter::operator--: Attempt to rewind an iterator past the start");
171 --__current();
172 return *this;
173 }
174 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __static_bounded_iter operator--(int) _NOEXCEPT {
175 __static_bounded_iter __tmp(*this);
176 --*this;
177 return __tmp;
178 }
179
180 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __static_bounded_iter& operator+=(difference_type __n) _NOEXCEPT {
181 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
182 __n >= __begin() - __current(),
183 "__static_bounded_iter::operator+=: Attempt to rewind an iterator past the start");
184 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
185 __n <= __end() - __current(), "__static_bounded_iter::operator+=: Attempt to advance an iterator past the end");
186 __current() += __n;
187 return *this;
188 }
189 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __static_bounded_iter
190 operator+(__static_bounded_iter const& __self, difference_type __n) _NOEXCEPT {
191 __static_bounded_iter __tmp(__self);
192 __tmp += __n;
193 return __tmp;
194 }
195 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __static_bounded_iter
196 operator+(difference_type __n, __static_bounded_iter const& __self) _NOEXCEPT {
197 __static_bounded_iter __tmp(__self);
198 __tmp += __n;
199 return __tmp;
200 }
201
202 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __static_bounded_iter& operator-=(difference_type __n) _NOEXCEPT {
203 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
204 __n <= __current() - __begin(),
205 "__static_bounded_iter::operator-=: Attempt to rewind an iterator past the start");
206 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
207 __n >= __current() - __end(), "__static_bounded_iter::operator-=: Attempt to advance an iterator past the end");
208 __current() -= __n;
209 return *this;
210 }
211 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __static_bounded_iter
212 operator-(__static_bounded_iter const& __self, difference_type __n) _NOEXCEPT {
213 __static_bounded_iter __tmp(__self);
214 __tmp -= __n;
215 return __tmp;
216 }
217 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend difference_type
218 operator-(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT {
219 return __x.__current() - __y.__current();
220 }
221
222 // Comparison operations.
223 //
224 // These operations do not check whether the iterators are within their bounds.
225 // The valid range for each iterator is also not considered as part of the comparison,
226 // i.e. two iterators pointing to the same location will be considered equal even
227 // if they have different validity ranges.
228 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
229 operator==(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT {
230 return __x.__current() == __y.__current();
231 }
232
233#if _LIBCPP_STD_VER <= 17
234 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
235 operator!=(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT {
236 return __x.__current() != __y.__current();
237 }
238
239 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
240 operator<(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT {
241 return __x.__current() < __y.__current();
242 }
243 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
244 operator>(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT {
245 return __x.__current() > __y.__current();
246 }
247 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
248 operator<=(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT {
249 return __x.__current() <= __y.__current();
250 }
251 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
252 operator>=(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT {
253 return __x.__current() >= __y.__current();
254 }
255
256#else
257 _LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering
258 operator<=>(__static_bounded_iter const& __x, __static_bounded_iter const& __y) noexcept {
259 if constexpr (three_way_comparable<_Iterator, strong_ordering>) {
260 return __x.__current() <=> __y.__current();
261 } else {
262 if (__x.__current() < __y.__current())
263 return strong_ordering::less;
264
265 if (__x.__current() == __y.__current())
266 return strong_ordering::equal;
267
268 return strong_ordering::greater;
269 }
270 }
271#endif // _LIBCPP_STD_VER >= 20
272
273private:
274 template <class>
275 friend struct pointer_traits;
276 template <class, size_t>
277 friend struct __static_bounded_iter;
278 __static_bounded_iter_storage<_Iterator, _Size> __storage_;
279
280 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator& __current() _NOEXCEPT {
281 return __storage_.__current();
282 }
283 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __current() const _NOEXCEPT {
284 return __storage_.__current();
285 }
286 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __begin() const _NOEXCEPT {
287 return __storage_.__begin();
288 }
289 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __end() const _NOEXCEPT { return __storage_.__end(); }
290};
291
292template <size_t _Size, class _It>
293_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __static_bounded_iter<_It, _Size>
294__make_static_bounded_iter(_It __it, _It __begin) {
295 return __static_bounded_iter<_It, _Size>(std::move(__it), std::move(__begin));
296}
297
298#if _LIBCPP_STD_VER <= 17
299template <class _Iterator, size_t _Size>
300struct __libcpp_is_contiguous_iterator<__static_bounded_iter<_Iterator, _Size> > : true_type {};
301#endif
302
303template <class _Iterator, size_t _Size>
304struct pointer_traits<__static_bounded_iter<_Iterator, _Size> > {
305 using pointer = __static_bounded_iter<_Iterator, _Size>;
306 using element_type = typename pointer_traits<_Iterator>::element_type;
307 using difference_type = typename pointer_traits<_Iterator>::difference_type;
308
309 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static element_type* to_address(pointer __it) _NOEXCEPT {
310 return std::__to_address(__it.__current());
311 }
312};
313
314_LIBCPP_END_NAMESPACE_STD
315
316_LIBCPP_POP_MACROS
317
318#endif // _LIBCPP___ITERATOR_STATIC_BOUNDED_ITER_H
lib/libcxx/include/__iterator/wrap_iter.h+15-8
...@@ -13,12 +13,17 @@...@@ -13,12 +13,17 @@
13#include <__compare/ordering.h>13#include <__compare/ordering.h>
14#include <__compare/three_way_comparable.h>14#include <__compare/three_way_comparable.h>
15#include <__config>15#include <__config>
16#include <__cstddef/size_t.h>
16#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
17#include <__memory/addressof.h>18#include <__memory/addressof.h>
18#include <__memory/pointer_traits.h>19#include <__memory/pointer_traits.h>
20#include <__type_traits/conjunction.h>
21#include <__type_traits/disjunction.h>
19#include <__type_traits/enable_if.h>22#include <__type_traits/enable_if.h>
23#include <__type_traits/integral_constant.h>
20#include <__type_traits/is_convertible.h>24#include <__type_traits/is_convertible.h>
21#include <cstddef>25#include <__type_traits/is_same.h>
26#include <__type_traits/make_const_lvalue_ref.h>
2227
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header29# pragma GCC system_header
...@@ -44,9 +49,14 @@ private:...@@ -44,9 +49,14 @@ private:
4449
45public:50public:
46 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter() _NOEXCEPT : __i_() {}51 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter() _NOEXCEPT : __i_() {}
47 template <class _Up, __enable_if_t<is_convertible<_Up, iterator_type>::value, int> = 0>52 template <
48 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter(const __wrap_iter<_Up>& __u) _NOEXCEPT53 class _OtherIter,
49 : __i_(__u.base()) {}54 __enable_if_t< _And< is_convertible<const _OtherIter&, _Iter>,
55 _Or<is_same<reference, __iter_reference<_OtherIter> >,
56 is_same<reference, __make_const_lvalue_ref<__iter_reference<_OtherIter> > > > >::value,
57 int> = 0>
58 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter(const __wrap_iter<_OtherIter>& __u) _NOEXCEPT
59 : __i_(__u.__i_) {}
50 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT { return *__i_; }60 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT { return *__i_; }
51 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT {61 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT {
52 return std::__to_address(__i_);62 return std::__to_address(__i_);
...@@ -145,9 +155,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool...@@ -145,9 +155,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
145operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {155operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
146 return !(__x == __y);156 return !(__x == __y);
147}157}
148#endif
149
150// TODO(mordante) disable these overloads in the LLVM 20 release.
151template <class _Iter1>158template <class _Iter1>
152_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool159_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
153operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT {160operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT {
...@@ -184,7 +191,7 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX...@@ -184,7 +191,7 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX
184 return !(__y < __x);191 return !(__y < __x);
185}192}
186193
187#if _LIBCPP_STD_VER >= 20194#else
188template <class _Iter1, class _Iter2>195template <class _Iter1, class _Iter2>
189_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering196_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
190operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept {197operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept {
lib/libcxx/include/__locale+34-31
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
1212
13#include <__config>13#include <__config>
14#include <__locale_dir/locale_base_api.h>14#include <__locale_dir/locale_base_api.h>
15#include <__memory/shared_ptr.h> // __shared_count15#include <__memory/shared_count.h>
16#include <__mutex/once_flag.h>16#include <__mutex/once_flag.h>
17#include <__type_traits/make_unsigned.h>17#include <__type_traits/make_unsigned.h>
18#include <__utility/no_destroy.h>18#include <__utility/no_destroy.h>
...@@ -27,7 +27,7 @@...@@ -27,7 +27,7 @@
27#include <cstddef>27#include <cstddef>
28#include <cstring>28#include <cstring>
2929
30#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS30#if _LIBCPP_HAS_WIDE_CHARACTERS
31# include <cwchar>31# include <cwchar>
32#else32#else
33# include <__std_mbstate_t.h>33# include <__std_mbstate_t.h>
...@@ -50,7 +50,7 @@ _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&);...@@ -50,7 +50,7 @@ _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&);
50class _LIBCPP_EXPORTED_FROM_ABI locale {50class _LIBCPP_EXPORTED_FROM_ABI locale {
51public:51public:
52 // locale is essentially a shared_ptr that doesn't support weak_ptrs and never got a move constructor.52 // locale is essentially a shared_ptr that doesn't support weak_ptrs and never got a move constructor.
53 using __trivially_relocatable = locale;53 using __trivially_relocatable _LIBCPP_NODEBUG = locale;
5454
55 // types:55 // types:
56 class _LIBCPP_EXPORTED_FROM_ABI facet;56 class _LIBCPP_EXPORTED_FROM_ABI facet;
...@@ -60,8 +60,9 @@ public:...@@ -60,8 +60,9 @@ public:
6060
61 static const category // values assigned here are for exposition only61 static const category // values assigned here are for exposition only
62 none = 0,62 none = 0,
63 collate = LC_COLLATE_MASK, ctype = LC_CTYPE_MASK, monetary = LC_MONETARY_MASK, numeric = LC_NUMERIC_MASK,63 collate = _LIBCPP_COLLATE_MASK, ctype = _LIBCPP_CTYPE_MASK, monetary = _LIBCPP_MONETARY_MASK,
64 time = LC_TIME_MASK, messages = LC_MESSAGES_MASK, all = collate | ctype | monetary | numeric | time | messages;64 numeric = _LIBCPP_NUMERIC_MASK, time = _LIBCPP_TIME_MASK, messages = _LIBCPP_MESSAGES_MASK,
65 all = collate | ctype | monetary | numeric | time | messages;
6566
66 // construct/copy/destroy:67 // construct/copy/destroy:
67 locale() _NOEXCEPT;68 locale() _NOEXCEPT;
...@@ -236,7 +237,7 @@ long collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) cons...@@ -236,7 +237,7 @@ long collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) cons
236}237}
237238
238extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>;239extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>;
239#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS240#if _LIBCPP_HAS_WIDE_CHARACTERS
240extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>;241extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>;
241#endif242#endif
242243
...@@ -247,7 +248,7 @@ class _LIBCPP_TEMPLATE_VIS collate_byname;...@@ -247,7 +248,7 @@ class _LIBCPP_TEMPLATE_VIS collate_byname;
247248
248template <>249template <>
249class _LIBCPP_EXPORTED_FROM_ABI collate_byname<char> : public collate<char> {250class _LIBCPP_EXPORTED_FROM_ABI collate_byname<char> : public collate<char> {
250 locale_t __l_;251 __locale::__locale_t __l_;
251252
252public:253public:
253 typedef char char_type;254 typedef char char_type;
...@@ -263,10 +264,10 @@ protected:...@@ -263,10 +264,10 @@ protected:
263 string_type do_transform(const char_type* __lo, const char_type* __hi) const override;264 string_type do_transform(const char_type* __lo, const char_type* __hi) const override;
264};265};
265266
266#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS267#if _LIBCPP_HAS_WIDE_CHARACTERS
267template <>268template <>
268class _LIBCPP_EXPORTED_FROM_ABI collate_byname<wchar_t> : public collate<wchar_t> {269class _LIBCPP_EXPORTED_FROM_ABI collate_byname<wchar_t> : public collate<wchar_t> {
269 locale_t __l_;270 __locale::__locale_t __l_;
270271
271public:272public:
272 typedef wchar_t char_type;273 typedef wchar_t char_type;
...@@ -348,7 +349,7 @@ public:...@@ -348,7 +349,7 @@ public:
348# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA349# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
349#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)350#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
350# ifdef __APPLE__351# ifdef __APPLE__
351 typedef __uint32_t mask;352 typedef uint32_t mask;
352# elif defined(__FreeBSD__)353# elif defined(__FreeBSD__)
353 typedef unsigned long mask;354 typedef unsigned long mask;
354# elif defined(__NetBSD__)355# elif defined(__NetBSD__)
...@@ -449,7 +450,7 @@ public:...@@ -449,7 +450,7 @@ public:
449template <class _CharT>450template <class _CharT>
450class _LIBCPP_TEMPLATE_VIS ctype;451class _LIBCPP_TEMPLATE_VIS ctype;
451452
452#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS453#if _LIBCPP_HAS_WIDE_CHARACTERS
453template <>454template <>
454class _LIBCPP_EXPORTED_FROM_ABI ctype<wchar_t> : public locale::facet, public ctype_base {455class _LIBCPP_EXPORTED_FROM_ABI ctype<wchar_t> : public locale::facet, public ctype_base {
455public:456public:
...@@ -514,7 +515,9 @@ protected:...@@ -514,7 +515,9 @@ protected:
514 virtual const char_type*515 virtual const char_type*
515 do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;516 do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
516};517};
517#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS518#endif // _LIBCPP_HAS_WIDE_CHARACTERS
519
520inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_isascii(int __c) { return (__c & ~0x7F) == 0; }
518521
519template <>522template <>
520class _LIBCPP_EXPORTED_FROM_ABI ctype<char> : public locale::facet, public ctype_base {523class _LIBCPP_EXPORTED_FROM_ABI ctype<char> : public locale::facet, public ctype_base {
...@@ -527,25 +530,25 @@ public:...@@ -527,25 +530,25 @@ public:
527 explicit ctype(const mask* __tab = nullptr, bool __del = false, size_t __refs = 0);530 explicit ctype(const mask* __tab = nullptr, bool __del = false, size_t __refs = 0);
528531
529 _LIBCPP_HIDE_FROM_ABI bool is(mask __m, char_type __c) const {532 _LIBCPP_HIDE_FROM_ABI bool is(mask __m, char_type __c) const {
530 return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) != 0 : false;533 return std::__libcpp_isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) != 0 : false;
531 }534 }
532535
533 _LIBCPP_HIDE_FROM_ABI const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const {536 _LIBCPP_HIDE_FROM_ABI const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const {
534 for (; __low != __high; ++__low, ++__vec)537 for (; __low != __high; ++__low, ++__vec)
535 *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0;538 *__vec = std::__libcpp_isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0;
536 return __low;539 return __low;
537 }540 }
538541
539 _LIBCPP_HIDE_FROM_ABI const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const {542 _LIBCPP_HIDE_FROM_ABI const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const {
540 for (; __low != __high; ++__low)543 for (; __low != __high; ++__low)
541 if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))544 if (std::__libcpp_isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))
542 break;545 break;
543 return __low;546 return __low;
544 }547 }
545548
546 _LIBCPP_HIDE_FROM_ABI const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const {549 _LIBCPP_HIDE_FROM_ABI const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const {
547 for (; __low != __high; ++__low)550 for (; __low != __high; ++__low)
548 if (!isascii(*__low) || !(__tab_[static_cast<int>(*__low)] & __m))551 if (!std::__libcpp_isascii(*__low) || !(__tab_[static_cast<int>(*__low)] & __m))
549 break;552 break;
550 return __low;553 return __low;
551 }554 }
...@@ -616,7 +619,7 @@ class _LIBCPP_TEMPLATE_VIS ctype_byname;...@@ -616,7 +619,7 @@ class _LIBCPP_TEMPLATE_VIS ctype_byname;
616619
617template <>620template <>
618class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<char> : public ctype<char> {621class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<char> : public ctype<char> {
619 locale_t __l_;622 __locale::__locale_t __l_;
620623
621public:624public:
622 explicit ctype_byname(const char*, size_t = 0);625 explicit ctype_byname(const char*, size_t = 0);
...@@ -630,10 +633,10 @@ protected:...@@ -630,10 +633,10 @@ protected:
630 const char_type* do_tolower(char_type* __low, const char_type* __high) const override;633 const char_type* do_tolower(char_type* __low, const char_type* __high) const override;
631};634};
632635
633#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS636#if _LIBCPP_HAS_WIDE_CHARACTERS
634template <>637template <>
635class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<wchar_t> : public ctype<wchar_t> {638class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<wchar_t> : public ctype<wchar_t> {
636 locale_t __l_;639 __locale::__locale_t __l_;
637640
638public:641public:
639 explicit ctype_byname(const char*, size_t = 0);642 explicit ctype_byname(const char*, size_t = 0);
...@@ -655,7 +658,7 @@ protected:...@@ -655,7 +658,7 @@ protected:
655 const char_type*658 const char_type*
656 do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const override;659 do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const override;
657};660};
658#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS661#endif // _LIBCPP_HAS_WIDE_CHARACTERS
659662
660template <class _CharT>663template <class _CharT>
661inline _LIBCPP_HIDE_FROM_ABI bool isspace(_CharT __c, const locale& __loc) {664inline _LIBCPP_HIDE_FROM_ABI bool isspace(_CharT __c, const locale& __loc) {
...@@ -821,10 +824,10 @@ protected:...@@ -821,10 +824,10 @@ protected:
821824
822// template <> class codecvt<wchar_t, char, mbstate_t>825// template <> class codecvt<wchar_t, char, mbstate_t>
823826
824#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS827#if _LIBCPP_HAS_WIDE_CHARACTERS
825template <>828template <>
826class _LIBCPP_EXPORTED_FROM_ABI codecvt<wchar_t, char, mbstate_t> : public locale::facet, public codecvt_base {829class _LIBCPP_EXPORTED_FROM_ABI codecvt<wchar_t, char, mbstate_t> : public locale::facet, public codecvt_base {
827 locale_t __l_;830 __locale::__locale_t __l_;
828831
829public:832public:
830 typedef wchar_t intern_type;833 typedef wchar_t intern_type;
...@@ -900,7 +903,7 @@ protected:...@@ -900,7 +903,7 @@ protected:
900 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;903 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
901 virtual int do_max_length() const _NOEXCEPT;904 virtual int do_max_length() const _NOEXCEPT;
902};905};
903#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS906#endif // _LIBCPP_HAS_WIDE_CHARACTERS
904907
905// template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20908// template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20
906909
...@@ -982,7 +985,7 @@ protected:...@@ -982,7 +985,7 @@ protected:
982 virtual int do_max_length() const _NOEXCEPT;985 virtual int do_max_length() const _NOEXCEPT;
983};986};
984987
985#ifndef _LIBCPP_HAS_NO_CHAR8_T988#if _LIBCPP_HAS_CHAR8_T
986989
987// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20990// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20
988991
...@@ -1145,7 +1148,7 @@ protected:...@@ -1145,7 +1148,7 @@ protected:
1145 virtual int do_max_length() const _NOEXCEPT;1148 virtual int do_max_length() const _NOEXCEPT;
1146};1149};
11471150
1148#ifndef _LIBCPP_HAS_NO_CHAR8_T1151#if _LIBCPP_HAS_CHAR8_T
11491152
1150// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++201153// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20
11511154
...@@ -1248,14 +1251,14 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() {}...@@ -1248,14 +1251,14 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() {}
1248_LIBCPP_SUPPRESS_DEPRECATED_POP1251_LIBCPP_SUPPRESS_DEPRECATED_POP
12491252
1250extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>;1253extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>;
1251#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1254#if _LIBCPP_HAS_WIDE_CHARACTERS
1252extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>;1255extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>;
1253#endif1256#endif
1254extern template class _LIBCPP_DEPRECATED_IN_CXX201257extern template class _LIBCPP_DEPRECATED_IN_CXX20
1255_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++201258_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20
1256extern template class _LIBCPP_DEPRECATED_IN_CXX201259extern template class _LIBCPP_DEPRECATED_IN_CXX20
1257_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++201260_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20
1258#ifndef _LIBCPP_HAS_NO_CHAR8_T1261#if _LIBCPP_HAS_CHAR8_T
1259extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++201262extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20
1260extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++201263extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20
1261#endif1264#endif
...@@ -1438,7 +1441,7 @@ protected:...@@ -1438,7 +1441,7 @@ protected:
1438 string __grouping_;1441 string __grouping_;
1439};1442};
14401443
1441#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1444#if _LIBCPP_HAS_WIDE_CHARACTERS
1442template <>1445template <>
1443class _LIBCPP_EXPORTED_FROM_ABI numpunct<wchar_t> : public locale::facet {1446class _LIBCPP_EXPORTED_FROM_ABI numpunct<wchar_t> : public locale::facet {
1444public:1447public:
...@@ -1467,7 +1470,7 @@ protected:...@@ -1467,7 +1470,7 @@ protected:
1467 char_type __thousands_sep_;1470 char_type __thousands_sep_;
1468 string __grouping_;1471 string __grouping_;
1469};1472};
1470#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS1473#endif // _LIBCPP_HAS_WIDE_CHARACTERS
14711474
1472// template <class charT> class numpunct_byname1475// template <class charT> class numpunct_byname
14731476
...@@ -1490,7 +1493,7 @@ private:...@@ -1490,7 +1493,7 @@ private:
1490 void __init(const char*);1493 void __init(const char*);
1491};1494};
14921495
1493#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1496#if _LIBCPP_HAS_WIDE_CHARACTERS
1494template <>1497template <>
1495class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<wchar_t> : public numpunct<wchar_t> {1498class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<wchar_t> : public numpunct<wchar_t> {
1496public:1499public:
...@@ -1506,7 +1509,7 @@ protected:...@@ -1506,7 +1509,7 @@ protected:
1506private:1509private:
1507 void __init(const char*);1510 void __init(const char*);
1508};1511};
1509#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS1512#endif // _LIBCPP_HAS_WIDE_CHARACTERS
15101513
1511_LIBCPP_END_NAMESPACE_STD1514_LIBCPP_END_NAMESPACE_STD
15121515
lib/libcxx/include/__locale_dir/locale_base_api.h+305-80
...@@ -9,90 +9,315 @@...@@ -9,90 +9,315 @@
9#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H9#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
10#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H10#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
1111
12#if defined(_LIBCPP_MSVCRT_LIKE)12#include <__config>
13# include <__locale_dir/locale_base_api/win32.h>
14#elif defined(_AIX) || defined(__MVS__)
15# include <__locale_dir/locale_base_api/ibm.h>
16#elif defined(__ANDROID__)
17# include <__locale_dir/locale_base_api/android.h>
18#elif defined(__sun__)
19# include <__locale_dir/locale_base_api/solaris.h>
20#elif defined(_NEWLIB_VERSION)
21# include <__locale_dir/locale_base_api/newlib.h>
22#elif defined(__OpenBSD__)
23# include <__locale_dir/locale_base_api/openbsd.h>
24#elif defined(__Fuchsia__)
25# include <__locale_dir/locale_base_api/fuchsia.h>
26#elif defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)
27# include <__locale_dir/locale_base_api/musl.h>
28#elif defined(__APPLE__) || defined(__FreeBSD__)
29# include <xlocale.h>
30#endif
3113
32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
33# pragma GCC system_header15# pragma GCC system_header
34#endif16#endif
3517
36/*18// The platform-specific headers have to provide the following interface.
37The platform-specific headers have to provide the following interface:19//
3820// These functions are equivalent to their C counterparts, except that __locale::__locale_t
39// TODO: rename this to __libcpp_locale_t21// is used instead of the current global locale.
40using locale_t = implementation-defined;22//
4123// Variadic functions may be implemented as templates with a parameter pack instead
42implementation-defined __libcpp_mb_cur_max_l(locale_t);24// of C-style variadic functions.
43wint_t __libcpp_btowc_l(int, locale_t);25//
44int __libcpp_wctob_l(wint_t, locale_t);26// Most of these functions are only required when building the library. Functions that are also
45size_t __libcpp_wcsnrtombs_l(char* dest, const wchar_t** src, size_t wide_char_count, size_t len, mbstate_t, locale_t);27// required when merely using the headers are marked as such below.
46size_t __libcpp_wcrtomb_l(char* str, wchar_t wide_char, mbstate_t*, locale_t);28//
47size_t __libcpp_mbsnrtowcs_l(wchar_t* dest, const char** src, size_t max_out, size_t len, mbstate_t*, locale_t);29// TODO: __localeconv shouldn't take a reference, but the Windows implementation doesn't allow copying __locale_t
48size_t __libcpp_mbrtowc_l(wchar_t* dest, cosnt char* src, size_t count, mbstate_t*, locale_t);30// TODO: Eliminate the need for any of these functions from the headers.
49int __libcpp_mbtowc_l(wchar_t* dest, const char* src, size_t count, locale_t);31//
50size_t __libcpp_mbrlen_l(const char* str, size_t count, mbstate_t*, locale_t);32// Locale management
51lconv* __libcpp_localeconv_l(locale_t);33// -----------------
52size_t __libcpp_mbsrtowcs_l(wchar_t* dest, const char** src, size_t len, mbstate_t*, locale_t);34// namespace __locale {
53int __libcpp_snprintf_l(char* dest, size_t buff_size, locale_t, const char* format, ...);35// using __locale_t = implementation-defined; // required by the headers
54int __libcpp_asprintf_l(char** dest, locale_t, const char* format, ...);36// using __lconv_t = implementation-defined;
55int __libcpp_sscanf_l(const char* dest, locale_t, const char* format, ...);37// __locale_t __newlocale(int, const char*, __locale_t);
5638// void __freelocale(__locale_t);
57// TODO: change these to reserved names39// char* __setlocale(int, const char*);
58float strtof_l(const char* str, char** str_end, locale_t);40// __lconv_t* __localeconv(__locale_t&);
59double strtod_l(const char* str, char** str_end, locale_t);41// }
60long double strtold_l(const char* str, char** str_end, locale_t);42//
61long long strtoll_l(const char* str, char** str_end, locale_t);43// // required by the headers
62unsigned long long strtoull_l(const char* str, char** str_end, locale_t);44// #define _LIBCPP_COLLATE_MASK /* implementation-defined */
6345// #define _LIBCPP_CTYPE_MASK /* implementation-defined */
64locale_t newlocale(int category_mask, const char* locale, locale_t base);46// #define _LIBCPP_MONETARY_MASK /* implementation-defined */
65void freelocale(locale_t);47// #define _LIBCPP_NUMERIC_MASK /* implementation-defined */
6648// #define _LIBCPP_TIME_MASK /* implementation-defined */
67int islower_l(int ch, locale_t);49// #define _LIBCPP_MESSAGES_MASK /* implementation-defined */
68int isupper_l(int ch, locale_t);50// #define _LIBCPP_ALL_MASK /* implementation-defined */
69int isdigit_l(int ch, locale_t);51// #define _LIBCPP_LC_ALL /* implementation-defined */
70int isxdigit_l(int ch, locale_t);52//
71int strcoll_l(const char* lhs, const char* rhs, locale_t);53// Strtonum functions
72size_t strxfrm_l(char* dst, const char* src, size_t n, locale_t);54// ------------------
73int wcscoll_l(const char* lhs, const char* rhs, locale_t);55// namespace __locale {
74size_t wcsxfrm_l(wchar_t* dst, const wchar_t* src, size_t n, locale_t);56// // required by the headers
75int toupper_l(int ch, locale_t);57// float __strtof(const char*, char**, __locale_t);
76int tolower_l(int ch, locale_t);58// double __strtod(const char*, char**, __locale_t);
77int iswspace_l(wint_t ch, locale_t);59// long double __strtold(const char*, char**, __locale_t);
78int iswprint_l(wint_t ch, locale_t);60// long long __strtoll(const char*, char**, __locale_t);
79int iswcntrl_l(wint_t ch, locale_t);61// unsigned long long __strtoull(const char*, char**, __locale_t);
80int iswupper_l(wint_t ch, locale_t);62// }
81int iswlower_l(wint_t ch, locale_t);63//
82int iswalpha_l(wint_t ch, locale_t);64// Character manipulation functions
83int iswblank_l(wint_t ch, locale_t);65// --------------------------------
84int iswdigit_l(wint_t ch, locale_t);66// namespace __locale {
85int iswpunct_l(wint_t ch, locale_t);67// int __islower(int, __locale_t);
86int iswxdigit_l(wint_t ch, locale_t);68// int __isupper(int, __locale_t);
87wint_t towupper_l(wint_t ch, locale_t);69// int __isdigit(int, __locale_t); // required by the headers
88wint_t towlower_l(wint_t ch, locale_t);70// int __isxdigit(int, __locale_t); // required by the headers
89size_t strftime_l(char* str, size_t len, const char* format, const tm*, locale_t);71// int __toupper(int, __locale_t);
9072// int __tolower(int, __locale_t);
9173// int __strcoll(const char*, const char*, __locale_t);
92These functions are equivalent to their C counterparts,74// size_t __strxfrm(char*, const char*, size_t, __locale_t);
93except that locale_t is used instead of the current global locale.75//
9476// int __iswctype(wint_t, wctype_t, __locale_t);
95The variadic functions may be implemented as templates with a parameter pack instead of variadic functions.77// int __iswspace(wint_t, __locale_t);
96*/78// int __iswprint(wint_t, __locale_t);
79// int __iswcntrl(wint_t, __locale_t);
80// int __iswupper(wint_t, __locale_t);
81// int __iswlower(wint_t, __locale_t);
82// int __iswalpha(wint_t, __locale_t);
83// int __iswblank(wint_t, __locale_t);
84// int __iswdigit(wint_t, __locale_t);
85// int __iswpunct(wint_t, __locale_t);
86// int __iswxdigit(wint_t, __locale_t);
87// wint_t __towupper(wint_t, __locale_t);
88// wint_t __towlower(wint_t, __locale_t);
89// int __wcscoll(const wchar_t*, const wchar_t*, __locale_t);
90// size_t __wcsxfrm(wchar_t*, const wchar_t*, size_t, __locale_t);
91//
92// size_t __strftime(char*, size_t, const char*, const tm*, __locale_t);
93// }
94//
95// Other functions
96// ---------------
97// namespace __locale {
98// implementation-defined __mb_len_max(__locale_t);
99// wint_t __btowc(int, __locale_t);
100// int __wctob(wint_t, __locale_t);
101// size_t __wcsnrtombs(char*, const wchar_t**, size_t, size_t, mbstate_t*, __locale_t);
102// size_t __wcrtomb(char*, wchar_t, mbstate_t*, __locale_t);
103// size_t __mbsnrtowcs(wchar_t*, const char**, size_t, size_t, mbstate_t*, __locale_t);
104// size_t __mbrtowc(wchar_t*, const char*, size_t, mbstate_t*, __locale_t);
105// int __mbtowc(wchar_t*, const char*, size_t, __locale_t);
106// size_t __mbrlen(const char*, size_t, mbstate_t*, __locale_t);
107// size_t __mbsrtowcs(wchar_t*, const char**, size_t, mbstate_t*, __locale_t);
108//
109// int __snprintf(char*, size_t, __locale_t, const char*, ...); // required by the headers
110// int __asprintf(char**, __locale_t, const char*, ...); // required by the headers
111// int __sscanf(const char*, __locale_t, const char*, ...); // required by the headers
112// }
113
114#if defined(__APPLE__)
115# include <__locale_dir/support/apple.h>
116#elif defined(__FreeBSD__)
117# include <__locale_dir/support/freebsd.h>
118#elif defined(_LIBCPP_MSVCRT_LIKE)
119# include <__locale_dir/support/windows.h>
120#elif defined(__Fuchsia__)
121# include <__locale_dir/support/fuchsia.h>
122#else
123
124// TODO: This is a temporary definition to bridge between the old way we defined the locale base API
125// (by providing global non-reserved names) and the new API. As we move individual platforms
126// towards the new way of defining the locale base API, this should disappear since each platform
127// will define those directly.
128# if defined(_AIX) || defined(__MVS__)
129# include <__locale_dir/locale_base_api/ibm.h>
130# elif defined(__ANDROID__)
131# include <__locale_dir/locale_base_api/android.h>
132# elif defined(__OpenBSD__)
133# include <__locale_dir/locale_base_api/openbsd.h>
134# elif defined(__wasi__) || _LIBCPP_HAS_MUSL_LIBC
135# include <__locale_dir/locale_base_api/musl.h>
136# endif
137
138# include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h>
139
140# include <__cstddef/size_t.h>
141# include <__utility/forward.h>
142# include <ctype.h>
143# include <string.h>
144# include <time.h>
145# if _LIBCPP_HAS_WIDE_CHARACTERS
146# include <wctype.h>
147# endif
148_LIBCPP_BEGIN_NAMESPACE_STD
149namespace __locale {
150//
151// Locale management
152//
153# define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK
154# define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK
155# define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK
156# define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK
157# define _LIBCPP_TIME_MASK LC_TIME_MASK
158# define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK
159# define _LIBCPP_ALL_MASK LC_ALL_MASK
160# define _LIBCPP_LC_ALL LC_ALL
161
162using __locale_t _LIBCPP_NODEBUG = locale_t;
163
164# if defined(_LIBCPP_BUILDING_LIBRARY)
165using __lconv_t _LIBCPP_NODEBUG = lconv;
166
167inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __name, __locale_t __loc) {
168 return newlocale(__category_mask, __name, __loc);
169}
170
171inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __locale) {
172 return ::setlocale(__category, __locale);
173}
174
175inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { freelocale(__loc); }
176
177inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { return __libcpp_localeconv_l(__loc); }
178# endif // _LIBCPP_BUILDING_LIBRARY
179
180//
181// Strtonum functions
182//
183inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) {
184 return strtof_l(__nptr, __endptr, __loc);
185}
186
187inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) {
188 return strtod_l(__nptr, __endptr, __loc);
189}
190
191inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) {
192 return strtold_l(__nptr, __endptr, __loc);
193}
194
195inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
196 return strtoll_l(__nptr, __endptr, __base, __loc);
197}
198
199inline _LIBCPP_HIDE_FROM_ABI unsigned long long
200__strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
201 return strtoull_l(__nptr, __endptr, __base, __loc);
202}
203
204//
205// Character manipulation functions
206//
207# if defined(_LIBCPP_BUILDING_LIBRARY)
208inline _LIBCPP_HIDE_FROM_ABI int __islower(int __ch, __locale_t __loc) { return islower_l(__ch, __loc); }
209inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __ch, __locale_t __loc) { return isupper_l(__ch, __loc); }
210# endif
211
212inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __ch, __locale_t __loc) { return isdigit_l(__ch, __loc); }
213inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __ch, __locale_t __loc) { return isxdigit_l(__ch, __loc); }
214
215# if defined(_LIBCPP_BUILDING_LIBRARY)
216inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) {
217 return strcoll_l(__s1, __s2, __loc);
218}
219inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, size_t __n, __locale_t __loc) {
220 return strxfrm_l(__dest, __src, __n, __loc);
221}
222inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __ch, __locale_t __loc) { return toupper_l(__ch, __loc); }
223inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __ch, __locale_t __loc) { return tolower_l(__ch, __loc); }
224
225# if _LIBCPP_HAS_WIDE_CHARACTERS
226inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __s1, const wchar_t* __s2, __locale_t __loc) {
227 return wcscoll_l(__s1, __s2, __loc);
228}
229inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) {
230 return wcsxfrm_l(__dest, __src, __n, __loc);
231}
232inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __ch, wctype_t __type, __locale_t __loc) {
233 return iswctype_l(__ch, __type, __loc);
234}
235inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __ch, __locale_t __loc) { return iswspace_l(__ch, __loc); }
236inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __ch, __locale_t __loc) { return iswprint_l(__ch, __loc); }
237inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __ch, __locale_t __loc) { return iswcntrl_l(__ch, __loc); }
238inline _LIBCPP_HIDE_FROM_ABI int __iswupper(wint_t __ch, __locale_t __loc) { return iswupper_l(__ch, __loc); }
239inline _LIBCPP_HIDE_FROM_ABI int __iswlower(wint_t __ch, __locale_t __loc) { return iswlower_l(__ch, __loc); }
240inline _LIBCPP_HIDE_FROM_ABI int __iswalpha(wint_t __ch, __locale_t __loc) { return iswalpha_l(__ch, __loc); }
241inline _LIBCPP_HIDE_FROM_ABI int __iswblank(wint_t __ch, __locale_t __loc) { return iswblank_l(__ch, __loc); }
242inline _LIBCPP_HIDE_FROM_ABI int __iswdigit(wint_t __ch, __locale_t __loc) { return iswdigit_l(__ch, __loc); }
243inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __ch, __locale_t __loc) { return iswpunct_l(__ch, __loc); }
244inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __ch, __locale_t __loc) { return iswxdigit_l(__ch, __loc); }
245inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __ch, __locale_t __loc) { return towupper_l(__ch, __loc); }
246inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __ch, __locale_t __loc) { return towlower_l(__ch, __loc); }
247# endif
248
249inline _LIBCPP_HIDE_FROM_ABI size_t
250__strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __locale_t __loc) {
251 return strftime_l(__s, __max, __format, __tm, __loc);
252}
253
254//
255// Other functions
256//
257inline _LIBCPP_HIDE_FROM_ABI decltype(__libcpp_mb_cur_max_l(__locale_t())) __mb_len_max(__locale_t __loc) {
258 return __libcpp_mb_cur_max_l(__loc);
259}
260# if _LIBCPP_HAS_WIDE_CHARACTERS
261inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __ch, __locale_t __loc) { return __libcpp_btowc_l(__ch, __loc); }
262inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __ch, __locale_t __loc) { return __libcpp_wctob_l(__ch, __loc); }
263inline _LIBCPP_HIDE_FROM_ABI size_t
264__wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t __loc) {
265 return __libcpp_wcsnrtombs_l(__dest, __src, __nwc, __len, __ps, __loc);
266}
267inline _LIBCPP_HIDE_FROM_ABI size_t __wcrtomb(char* __s, wchar_t __ch, mbstate_t* __ps, __locale_t __loc) {
268 return __libcpp_wcrtomb_l(__s, __ch, __ps, __loc);
269}
270inline _LIBCPP_HIDE_FROM_ABI size_t
271__mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t __loc) {
272 return __libcpp_mbsnrtowcs_l(__dest, __src, __nms, __len, __ps, __loc);
273}
274inline _LIBCPP_HIDE_FROM_ABI size_t
275__mbrtowc(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) {
276 return __libcpp_mbrtowc_l(__pwc, __s, __n, __ps, __loc);
277}
278inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t __loc) {
279 return __libcpp_mbtowc_l(__pwc, __pmb, __max, __loc);
280}
281inline _LIBCPP_HIDE_FROM_ABI size_t __mbrlen(const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) {
282 return __libcpp_mbrlen_l(__s, __n, __ps, __loc);
283}
284inline _LIBCPP_HIDE_FROM_ABI size_t
285__mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) {
286 return __libcpp_mbsrtowcs_l(__dest, __src, __len, __ps, __loc);
287}
288# endif // _LIBCPP_HAS_WIDE_CHARACTERS
289# endif // _LIBCPP_BUILDING_LIBRARY
290
291_LIBCPP_DIAGNOSTIC_PUSH
292_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat")
293_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates
294# ifdef _LIBCPP_COMPILER_CLANG_BASED
295# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__)
296# else
297# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */
298# endif
299
300template <class... _Args>
301_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf(
302 char* __s, size_t __n, __locale_t __loc, const char* __format, _Args&&... __args) {
303 return std::__libcpp_snprintf_l(__s, __n, __loc, __format, std::forward<_Args>(__args)...);
304}
305template <class... _Args>
306_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf(
307 char** __s, __locale_t __loc, const char* __format, _Args&&... __args) {
308 return std::__libcpp_asprintf_l(__s, __loc, __format, std::forward<_Args>(__args)...);
309}
310template <class... _Args>
311_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf(
312 const char* __s, __locale_t __loc, const char* __format, _Args&&... __args) {
313 return std::__libcpp_sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...);
314}
315_LIBCPP_DIAGNOSTIC_POP
316# undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
317
318} // namespace __locale
319_LIBCPP_END_NAMESPACE_STD
320
321#endif // Compatibility definition of locale base APIs
97322
98#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H323#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
lib/libcxx/include/__locale_dir/locale_base_api/android.h+4-9
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H10#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_ANDROID_H
11#define _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H11#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_ANDROID_H
1212
13#include <stdlib.h>13#include <stdlib.h>
1414
...@@ -18,9 +18,6 @@ extern "C" {...@@ -18,9 +18,6 @@ extern "C" {
18}18}
1919
20#include <android/api-level.h>20#include <android/api-level.h>
21#if __ANDROID_API__ < 21
22# include <__support/xlocale/__posix_l_fallback.h>
23#endif
2421
25// If we do not have this header, we are in a platform build rather than an NDK22// If we do not have this header, we are in a platform build rather than an NDK
26// build, which will always be at least as new as the ToT NDK, in which case we23// build, which will always be at least as new as the ToT NDK, in which case we
...@@ -30,9 +27,7 @@ extern "C" {...@@ -30,9 +27,7 @@ extern "C" {
30// In NDK versions later than 16, locale-aware functions are provided by27// In NDK versions later than 16, locale-aware functions are provided by
31// legacy_stdlib_inlines.h28// legacy_stdlib_inlines.h
32# if __NDK_MAJOR__ <= 1629# if __NDK_MAJOR__ <= 16
33# if __ANDROID_API__ < 2130# if __ANDROID_API__ < 26
34# include <__support/xlocale/__strtonum_fallback.h>
35# elif __ANDROID_API__ < 26
3631
37inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t) {32inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t) {
38 return ::strtof(__nptr, __endptr);33 return ::strtof(__nptr, __endptr);
...@@ -47,4 +42,4 @@ inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr...@@ -47,4 +42,4 @@ inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr
47# endif // __NDK_MAJOR__ <= 1642# endif // __NDK_MAJOR__ <= 16
48#endif // __has_include(<android/ndk-version.h>)43#endif // __has_include(<android/ndk-version.h>)
4944
50#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H45#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_ANDROID_H
lib/libcxx/include/__locale_dir/locale_base_api/bsd_locale_defaults.h deleted-36
...@@ -1,36 +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// The BSDs have lots of *_l functions. We don't want to define those symbols
10// on other platforms though, for fear of conflicts with user code. So here,
11// we will define the mapping from an internal macro to the real BSD symbol.
12//===----------------------------------------------------------------------===//
13
14#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_BSD_LOCALE_DEFAULTS_H
15#define _LIBCPP___LOCALE_LOCALE_BASE_API_BSD_LOCALE_DEFAULTS_H
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21#define __libcpp_mb_cur_max_l(loc) MB_CUR_MAX_L(loc)
22#define __libcpp_btowc_l(ch, loc) btowc_l(ch, loc)
23#define __libcpp_wctob_l(wch, loc) wctob_l(wch, loc)
24#define __libcpp_wcsnrtombs_l(dst, src, nwc, len, ps, loc) wcsnrtombs_l(dst, src, nwc, len, ps, loc)
25#define __libcpp_wcrtomb_l(src, wc, ps, loc) wcrtomb_l(src, wc, ps, loc)
26#define __libcpp_mbsnrtowcs_l(dst, src, nms, len, ps, loc) mbsnrtowcs_l(dst, src, nms, len, ps, loc)
27#define __libcpp_mbrtowc_l(pwc, s, n, ps, l) mbrtowc_l(pwc, s, n, ps, l)
28#define __libcpp_mbtowc_l(pwc, pmb, max, l) mbtowc_l(pwc, pmb, max, l)
29#define __libcpp_mbrlen_l(s, n, ps, l) mbrlen_l(s, n, ps, l)
30#define __libcpp_localeconv_l(l) localeconv_l(l)
31#define __libcpp_mbsrtowcs_l(dest, src, len, ps, l) mbsrtowcs_l(dest, src, len, ps, l)
32#define __libcpp_snprintf_l(...) snprintf_l(__VA_ARGS__)
33#define __libcpp_asprintf_l(...) asprintf_l(__VA_ARGS__)
34#define __libcpp_sscanf_l(...) sscanf_l(__VA_ARGS__)
35
36#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_BSD_LOCALE_DEFAULTS_H
lib/libcxx/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h+38-24
...@@ -10,15 +10,15 @@...@@ -10,15 +10,15 @@
10// of those functions for non-BSD platforms.10// of those functions for non-BSD platforms.
11//===----------------------------------------------------------------------===//11//===----------------------------------------------------------------------===//
1212
13#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H13#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H
14#define _LIBCPP___LOCALE_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H14#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H
1515
16#include <__locale_dir/locale_base_api/locale_guard.h>16#include <locale.h>
17#include <cstdio>
18#include <stdarg.h>17#include <stdarg.h>
18#include <stdio.h>
19#include <stdlib.h>19#include <stdlib.h>
2020
21#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS21#if _LIBCPP_HAS_WIDE_CHARACTERS
22# include <cwchar>22# include <cwchar>
23#endif23#endif
2424
...@@ -28,65 +28,79 @@...@@ -28,65 +28,79 @@
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
31struct __locale_guard {
32 _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {}
33
34 _LIBCPP_HIDE_FROM_ABI ~__locale_guard() {
35 if (__old_loc_)
36 ::uselocale(__old_loc_);
37 }
38
39 locale_t __old_loc_;
40
41 __locale_guard(__locale_guard const&) = delete;
42 __locale_guard& operator=(__locale_guard const&) = delete;
43};
44
31inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l) {45inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l) {
32 __libcpp_locale_guard __current(__l);46 __locale_guard __current(__l);
33 return MB_CUR_MAX;47 return MB_CUR_MAX;
34}48}
3549
36#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS50#if _LIBCPP_HAS_WIDE_CHARACTERS
37inline _LIBCPP_HIDE_FROM_ABI wint_t __libcpp_btowc_l(int __c, locale_t __l) {51inline _LIBCPP_HIDE_FROM_ABI wint_t __libcpp_btowc_l(int __c, locale_t __l) {
38 __libcpp_locale_guard __current(__l);52 __locale_guard __current(__l);
39 return btowc(__c);53 return btowc(__c);
40}54}
4155
42inline _LIBCPP_HIDE_FROM_ABI int __libcpp_wctob_l(wint_t __c, locale_t __l) {56inline _LIBCPP_HIDE_FROM_ABI int __libcpp_wctob_l(wint_t __c, locale_t __l) {
43 __libcpp_locale_guard __current(__l);57 __locale_guard __current(__l);
44 return wctob(__c);58 return wctob(__c);
45}59}
4660
47inline _LIBCPP_HIDE_FROM_ABI size_t61inline _LIBCPP_HIDE_FROM_ABI size_t
48__libcpp_wcsnrtombs_l(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, locale_t __l) {62__libcpp_wcsnrtombs_l(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, locale_t __l) {
49 __libcpp_locale_guard __current(__l);63 __locale_guard __current(__l);
50 return wcsnrtombs(__dest, __src, __nwc, __len, __ps);64 return wcsnrtombs(__dest, __src, __nwc, __len, __ps);
51}65}
5266
53inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_wcrtomb_l(char* __s, wchar_t __wc, mbstate_t* __ps, locale_t __l) {67inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_wcrtomb_l(char* __s, wchar_t __wc, mbstate_t* __ps, locale_t __l) {
54 __libcpp_locale_guard __current(__l);68 __locale_guard __current(__l);
55 return wcrtomb(__s, __wc, __ps);69 return wcrtomb(__s, __wc, __ps);
56}70}
5771
58inline _LIBCPP_HIDE_FROM_ABI size_t72inline _LIBCPP_HIDE_FROM_ABI size_t
59__libcpp_mbsnrtowcs_l(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, locale_t __l) {73__libcpp_mbsnrtowcs_l(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, locale_t __l) {
60 __libcpp_locale_guard __current(__l);74 __locale_guard __current(__l);
61 return mbsnrtowcs(__dest, __src, __nms, __len, __ps);75 return mbsnrtowcs(__dest, __src, __nms, __len, __ps);
62}76}
6377
64inline _LIBCPP_HIDE_FROM_ABI size_t78inline _LIBCPP_HIDE_FROM_ABI size_t
65__libcpp_mbrtowc_l(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, locale_t __l) {79__libcpp_mbrtowc_l(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, locale_t __l) {
66 __libcpp_locale_guard __current(__l);80 __locale_guard __current(__l);
67 return mbrtowc(__pwc, __s, __n, __ps);81 return mbrtowc(__pwc, __s, __n, __ps);
68}82}
6983
70inline _LIBCPP_HIDE_FROM_ABI int __libcpp_mbtowc_l(wchar_t* __pwc, const char* __pmb, size_t __max, locale_t __l) {84inline _LIBCPP_HIDE_FROM_ABI int __libcpp_mbtowc_l(wchar_t* __pwc, const char* __pmb, size_t __max, locale_t __l) {
71 __libcpp_locale_guard __current(__l);85 __locale_guard __current(__l);
72 return mbtowc(__pwc, __pmb, __max);86 return mbtowc(__pwc, __pmb, __max);
73}87}
7488
75inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_mbrlen_l(const char* __s, size_t __n, mbstate_t* __ps, locale_t __l) {89inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_mbrlen_l(const char* __s, size_t __n, mbstate_t* __ps, locale_t __l) {
76 __libcpp_locale_guard __current(__l);90 __locale_guard __current(__l);
77 return mbrlen(__s, __n, __ps);91 return mbrlen(__s, __n, __ps);
78}92}
79#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS93#endif // _LIBCPP_HAS_WIDE_CHARACTERS
8094
81inline _LIBCPP_HIDE_FROM_ABI lconv* __libcpp_localeconv_l(locale_t __l) {95inline _LIBCPP_HIDE_FROM_ABI lconv* __libcpp_localeconv_l(locale_t& __l) {
82 __libcpp_locale_guard __current(__l);96 __locale_guard __current(__l);
83 return localeconv();97 return localeconv();
84}98}
8599
86#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS100#if _LIBCPP_HAS_WIDE_CHARACTERS
87inline _LIBCPP_HIDE_FROM_ABI size_t101inline _LIBCPP_HIDE_FROM_ABI size_t
88__libcpp_mbsrtowcs_l(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, locale_t __l) {102__libcpp_mbsrtowcs_l(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, locale_t __l) {
89 __libcpp_locale_guard __current(__l);103 __locale_guard __current(__l);
90 return mbsrtowcs(__dest, __src, __len, __ps);104 return mbsrtowcs(__dest, __src, __len, __ps);
91}105}
92#endif106#endif
...@@ -95,7 +109,7 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __libcpp_snprintf_l(...@@ -95,7 +109,7 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __libcpp_snprintf_l(
95 char* __s, size_t __n, locale_t __l, const char* __format, ...) {109 char* __s, size_t __n, locale_t __l, const char* __format, ...) {
96 va_list __va;110 va_list __va;
97 va_start(__va, __format);111 va_start(__va, __format);
98 __libcpp_locale_guard __current(__l);112 __locale_guard __current(__l);
99 int __res = vsnprintf(__s, __n, __format, __va);113 int __res = vsnprintf(__s, __n, __format, __va);
100 va_end(__va);114 va_end(__va);
101 return __res;115 return __res;
...@@ -105,7 +119,7 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __libcpp_asprintf_l(...@@ -105,7 +119,7 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __libcpp_asprintf_l(
105 char** __s, locale_t __l, const char* __format, ...) {119 char** __s, locale_t __l, const char* __format, ...) {
106 va_list __va;120 va_list __va;
107 va_start(__va, __format);121 va_start(__va, __format);
108 __libcpp_locale_guard __current(__l);122 __locale_guard __current(__l);
109 int __res = vasprintf(__s, __format, __va);123 int __res = vasprintf(__s, __format, __va);
110 va_end(__va);124 va_end(__va);
111 return __res;125 return __res;
...@@ -115,7 +129,7 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __libcpp_sscanf_l(...@@ -115,7 +129,7 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __libcpp_sscanf_l(
115 const char* __s, locale_t __l, const char* __format, ...) {129 const char* __s, locale_t __l, const char* __format, ...) {
116 va_list __va;130 va_list __va;
117 va_start(__va, __format);131 va_start(__va, __format);
118 __libcpp_locale_guard __current(__l);132 __locale_guard __current(__l);
119 int __res = vsscanf(__s, __format, __va);133 int __res = vsscanf(__s, __format, __va);
120 va_end(__va);134 va_end(__va);
121 return __res;135 return __res;
...@@ -123,4 +137,4 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __libcpp_sscanf_l(...@@ -123,4 +137,4 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __libcpp_sscanf_l(
123137
124_LIBCPP_END_NAMESPACE_STD138_LIBCPP_END_NAMESPACE_STD
125139
126#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H140#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H
lib/libcxx/include/__locale_dir/locale_base_api/fuchsia.h deleted-18
...@@ -1,18 +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___LOCALE_LOCALE_BASE_API_FUCHSIA_H
11#define _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H
12
13#include <__support/xlocale/__posix_l_fallback.h>
14#include <__support/xlocale/__strtonum_fallback.h>
15#include <cstdlib>
16#include <cwchar>
17
18#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H
lib/libcxx/include/__locale_dir/locale_base_api/ibm.h+5-5
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H10#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_IBM_H
11#define _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H11#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_IBM_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>
...@@ -82,7 +82,7 @@ strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {...@@ -82,7 +82,7 @@ strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
82inline _LIBCPP_HIDE_FROM_ABI82inline _LIBCPP_HIDE_FROM_ABI
83_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) {83_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) {
84 const size_t buff_size = 256;84 const size_t buff_size = 256;
85 if ((*strp = (char*)malloc(buff_size)) == NULL) {85 if ((*strp = (char*)malloc(buff_size)) == nullptr) {
86 return -1;86 return -1;
87 }87 }
8888
...@@ -97,7 +97,7 @@ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char...@@ -97,7 +97,7 @@ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char
97 va_end(ap_copy);97 va_end(ap_copy);
9898
99 if ((size_t)str_size >= buff_size) {99 if ((size_t)str_size >= buff_size) {
100 if ((*strp = (char*)realloc(*strp, str_size + 1)) == NULL) {100 if ((*strp = (char*)realloc(*strp, str_size + 1)) == nullptr) {
101 return -1;101 return -1;
102 }102 }
103 str_size = vsnprintf(*strp, str_size + 1, fmt, ap);103 str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
...@@ -105,4 +105,4 @@ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char...@@ -105,4 +105,4 @@ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char
105 return str_size;105 return str_size;
106}106}
107107
108#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H108#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_IBM_H
lib/libcxx/include/__locale_dir/locale_base_api/locale_guard.h deleted-78
...@@ -1,78 +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___LOCALE_LOCALE_BASE_API_LOCALE_GUARD_H
10#define _LIBCPP___LOCALE_LOCALE_BASE_API_LOCALE_GUARD_H
11
12#include <__config>
13#include <__locale> // for locale_t
14#include <clocale>
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#if !defined(_LIBCPP_LOCALE__L_EXTENSIONS)
23struct __libcpp_locale_guard {
24 _LIBCPP_HIDE_FROM_ABI __libcpp_locale_guard(locale_t& __loc) : __old_loc_(uselocale(__loc)) {}
25
26 _LIBCPP_HIDE_FROM_ABI ~__libcpp_locale_guard() {
27 if (__old_loc_)
28 uselocale(__old_loc_);
29 }
30
31 locale_t __old_loc_;
32
33 __libcpp_locale_guard(__libcpp_locale_guard const&) = delete;
34 __libcpp_locale_guard& operator=(__libcpp_locale_guard const&) = delete;
35};
36#elif defined(_LIBCPP_MSVCRT_LIKE)
37struct __libcpp_locale_guard {
38 __libcpp_locale_guard(locale_t __l) : __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) {
39 // Setting the locale can be expensive even when the locale given is
40 // already the current locale, so do an explicit check to see if the
41 // current locale is already the one we want.
42 const char* __lc = __setlocale(nullptr);
43 // If every category is the same, the locale string will simply be the
44 // locale name, otherwise it will be a semicolon-separated string listing
45 // each category. In the second case, we know at least one category won't
46 // be what we want, so we only have to check the first case.
47 if (std::strcmp(__l.__get_locale(), __lc) != 0) {
48 __locale_all = _strdup(__lc);
49 if (__locale_all == nullptr)
50 __throw_bad_alloc();
51 __setlocale(__l.__get_locale());
52 }
53 }
54 ~__libcpp_locale_guard() {
55 // The CRT documentation doesn't explicitly say, but setlocale() does the
56 // right thing when given a semicolon-separated list of locale settings
57 // for the different categories in the same format as returned by
58 // setlocale(LC_ALL, nullptr).
59 if (__locale_all != nullptr) {
60 __setlocale(__locale_all);
61 free(__locale_all);
62 }
63 _configthreadlocale(__status);
64 }
65 static const char* __setlocale(const char* __locale) {
66 const char* __new_locale = setlocale(LC_ALL, __locale);
67 if (__new_locale == nullptr)
68 __throw_bad_alloc();
69 return __new_locale;
70 }
71 int __status;
72 char* __locale_all = nullptr;
73};
74#endif
75
76_LIBCPP_END_NAMESPACE_STD
77
78#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_LOCALE_GUARD_H
lib/libcxx/include/__locale_dir/locale_base_api/musl.h+3-3
...@@ -14,8 +14,8 @@...@@ -14,8 +14,8 @@
14// in Musl.14// in Musl.
15//===----------------------------------------------------------------------===//15//===----------------------------------------------------------------------===//
1616
17#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H17#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_MUSL_H
18#define _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H18#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_MUSL_H
1919
20#include <cstdlib>20#include <cstdlib>
21#include <cwchar>21#include <cwchar>
...@@ -28,4 +28,4 @@ inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, c...@@ -28,4 +28,4 @@ inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, c
28 return ::strtoull(__nptr, __endptr, __base);28 return ::strtoull(__nptr, __endptr, __base);
29}29}
3030
31#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H31#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_MUSL_H
lib/libcxx/include/__locale_dir/locale_base_api/newlib.h deleted-12
...@@ -1,12 +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___LOCALE_LOCALE_BASE_API_NEWLIB_H
10#define _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H
11
12#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H
lib/libcxx/include/__locale_dir/locale_base_api/openbsd.h+3-3
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H10#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_OPENBSD_H
11#define _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H11#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_OPENBSD_H
1212
13#include <__support/xlocale/__strtonum_fallback.h>13#include <__support/xlocale/__strtonum_fallback.h>
14#include <clocale>14#include <clocale>
...@@ -16,4 +16,4 @@...@@ -16,4 +16,4 @@
16#include <ctype.h>16#include <ctype.h>
17#include <cwctype>17#include <cwctype>
1818
19#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H19#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_OPENBSD_H
lib/libcxx/include/__locale_dir/locale_base_api/win32.h deleted-235
...@@ -1,235 +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___LOCALE_LOCALE_BASE_API_WIN32_H
11#define _LIBCPP___LOCALE_LOCALE_BASE_API_WIN32_H
12
13#include <__config>
14#include <cstddef>
15#include <locale.h> // _locale_t
16#include <stdio.h>
17#include <string>
18
19#define _X_ALL LC_ALL
20#define _X_COLLATE LC_COLLATE
21#define _X_CTYPE LC_CTYPE
22#define _X_MONETARY LC_MONETARY
23#define _X_NUMERIC LC_NUMERIC
24#define _X_TIME LC_TIME
25#define _X_MAX LC_MAX
26#define _X_MESSAGES 6
27#define _NCAT (_X_MESSAGES + 1)
28
29#define _CATMASK(n) ((1 << (n)) >> 1)
30#define _M_COLLATE _CATMASK(_X_COLLATE)
31#define _M_CTYPE _CATMASK(_X_CTYPE)
32#define _M_MONETARY _CATMASK(_X_MONETARY)
33#define _M_NUMERIC _CATMASK(_X_NUMERIC)
34#define _M_TIME _CATMASK(_X_TIME)
35#define _M_MESSAGES _CATMASK(_X_MESSAGES)
36#define _M_ALL (_CATMASK(_NCAT) - 1)
37
38#define LC_COLLATE_MASK _M_COLLATE
39#define LC_CTYPE_MASK _M_CTYPE
40#define LC_MONETARY_MASK _M_MONETARY
41#define LC_NUMERIC_MASK _M_NUMERIC
42#define LC_TIME_MASK _M_TIME
43#define LC_MESSAGES_MASK _M_MESSAGES
44#define LC_ALL_MASK \
45 (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK)
46
47class __lconv_storage {
48public:
49 __lconv_storage(const lconv* __lc_input) {
50 __lc_ = *__lc_input;
51
52 __decimal_point_ = __lc_input->decimal_point;
53 __thousands_sep_ = __lc_input->thousands_sep;
54 __grouping_ = __lc_input->grouping;
55 __int_curr_symbol_ = __lc_input->int_curr_symbol;
56 __currency_symbol_ = __lc_input->currency_symbol;
57 __mon_decimal_point_ = __lc_input->mon_decimal_point;
58 __mon_thousands_sep_ = __lc_input->mon_thousands_sep;
59 __mon_grouping_ = __lc_input->mon_grouping;
60 __positive_sign_ = __lc_input->positive_sign;
61 __negative_sign_ = __lc_input->negative_sign;
62
63 __lc_.decimal_point = const_cast<char*>(__decimal_point_.c_str());
64 __lc_.thousands_sep = const_cast<char*>(__thousands_sep_.c_str());
65 __lc_.grouping = const_cast<char*>(__grouping_.c_str());
66 __lc_.int_curr_symbol = const_cast<char*>(__int_curr_symbol_.c_str());
67 __lc_.currency_symbol = const_cast<char*>(__currency_symbol_.c_str());
68 __lc_.mon_decimal_point = const_cast<char*>(__mon_decimal_point_.c_str());
69 __lc_.mon_thousands_sep = const_cast<char*>(__mon_thousands_sep_.c_str());
70 __lc_.mon_grouping = const_cast<char*>(__mon_grouping_.c_str());
71 __lc_.positive_sign = const_cast<char*>(__positive_sign_.c_str());
72 __lc_.negative_sign = const_cast<char*>(__negative_sign_.c_str());
73 }
74
75 lconv* __get() { return &__lc_; }
76
77private:
78 lconv __lc_;
79 std::string __decimal_point_;
80 std::string __thousands_sep_;
81 std::string __grouping_;
82 std::string __int_curr_symbol_;
83 std::string __currency_symbol_;
84 std::string __mon_decimal_point_;
85 std::string __mon_thousands_sep_;
86 std::string __mon_grouping_;
87 std::string __positive_sign_;
88 std::string __negative_sign_;
89};
90
91class locale_t {
92public:
93 locale_t() : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
94 locale_t(std::nullptr_t) : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
95 locale_t(_locale_t __xlocale, const char* __xlocale_str)
96 : __locale_(__xlocale), __locale_str_(__xlocale_str), __lc_(nullptr) {}
97 locale_t(const locale_t& __l) : __locale_(__l.__locale_), __locale_str_(__l.__locale_str_), __lc_(nullptr) {}
98
99 ~locale_t() { delete __lc_; }
100
101 locale_t& operator=(const locale_t& __l) {
102 __locale_ = __l.__locale_;
103 __locale_str_ = __l.__locale_str_;
104 // __lc_ not copied
105 return *this;
106 }
107
108 friend bool operator==(const locale_t& __left, const locale_t& __right) {
109 return __left.__locale_ == __right.__locale_;
110 }
111
112 friend bool operator==(const locale_t& __left, int __right) { return __left.__locale_ == nullptr && __right == 0; }
113
114 friend bool operator==(const locale_t& __left, long long __right) {
115 return __left.__locale_ == nullptr && __right == 0;
116 }
117
118 friend bool operator==(const locale_t& __left, std::nullptr_t) { return __left.__locale_ == nullptr; }
119
120 friend bool operator==(int __left, const locale_t& __right) { return __left == 0 && nullptr == __right.__locale_; }
121
122 friend bool operator==(std::nullptr_t, const locale_t& __right) { return nullptr == __right.__locale_; }
123
124 friend bool operator!=(const locale_t& __left, const locale_t& __right) { return !(__left == __right); }
125
126 friend bool operator!=(const locale_t& __left, int __right) { return !(__left == __right); }
127
128 friend bool operator!=(const locale_t& __left, long long __right) { return !(__left == __right); }
129
130 friend bool operator!=(const locale_t& __left, std::nullptr_t __right) { return !(__left == __right); }
131
132 friend bool operator!=(int __left, const locale_t& __right) { return !(__left == __right); }
133
134 friend bool operator!=(std::nullptr_t __left, const locale_t& __right) { return !(__left == __right); }
135
136 operator bool() const { return __locale_ != nullptr; }
137
138 const char* __get_locale() const { return __locale_str_; }
139
140 operator _locale_t() const { return __locale_; }
141
142 lconv* __store_lconv(const lconv* __input_lc) {
143 delete __lc_;
144 __lc_ = new __lconv_storage(__input_lc);
145 return __lc_->__get();
146 }
147
148private:
149 _locale_t __locale_;
150 const char* __locale_str_;
151 __lconv_storage* __lc_ = nullptr;
152};
153
154// Locale management functions
155#define freelocale _free_locale
156// FIXME: base currently unused. Needs manual work to construct the new locale
157locale_t newlocale(int __mask, const char* __locale, locale_t __base);
158// uselocale can't be implemented on Windows because Windows allows partial modification
159// of thread-local locale and so _get_current_locale() returns a copy while uselocale does
160// not create any copies.
161// We can still implement raii even without uselocale though.
162
163lconv* localeconv_l(locale_t& __loc);
164size_t mbrlen_l(const char* __restrict __s, size_t __n, mbstate_t* __restrict __ps, locale_t __loc);
165size_t mbsrtowcs_l(
166 wchar_t* __restrict __dst, const char** __restrict __src, size_t __len, mbstate_t* __restrict __ps, locale_t __loc);
167size_t wcrtomb_l(char* __restrict __s, wchar_t __wc, mbstate_t* __restrict __ps, locale_t __loc);
168size_t mbrtowc_l(
169 wchar_t* __restrict __pwc, const char* __restrict __s, size_t __n, mbstate_t* __restrict __ps, locale_t __loc);
170size_t mbsnrtowcs_l(wchar_t* __restrict __dst,
171 const char** __restrict __src,
172 size_t __nms,
173 size_t __len,
174 mbstate_t* __restrict __ps,
175 locale_t __loc);
176size_t wcsnrtombs_l(char* __restrict __dst,
177 const wchar_t** __restrict __src,
178 size_t __nwc,
179 size_t __len,
180 mbstate_t* __restrict __ps,
181 locale_t __loc);
182wint_t btowc_l(int __c, locale_t __loc);
183int wctob_l(wint_t __c, locale_t __loc);
184
185decltype(MB_CUR_MAX) MB_CUR_MAX_L(locale_t __l);
186
187// the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
188#define mbtowc_l _mbtowc_l
189#define strtoll_l _strtoi64_l
190#define strtoull_l _strtoui64_l
191#define strtod_l _strtod_l
192#if defined(_LIBCPP_MSVCRT)
193# define strtof_l _strtof_l
194# define strtold_l _strtold_l
195#else
196_LIBCPP_EXPORTED_FROM_ABI float strtof_l(const char*, char**, locale_t);
197_LIBCPP_EXPORTED_FROM_ABI long double strtold_l(const char*, char**, locale_t);
198#endif
199inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, _locale_t __loc) { return _islower_l((int)__c, __loc); }
200
201inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, _locale_t __loc) { return _isupper_l((int)__c, __loc); }
202
203#define isdigit_l _isdigit_l
204#define isxdigit_l _isxdigit_l
205#define strcoll_l _strcoll_l
206#define strxfrm_l _strxfrm_l
207#define wcscoll_l _wcscoll_l
208#define wcsxfrm_l _wcsxfrm_l
209#define toupper_l _toupper_l
210#define tolower_l _tolower_l
211#define iswspace_l _iswspace_l
212#define iswprint_l _iswprint_l
213#define iswcntrl_l _iswcntrl_l
214#define iswupper_l _iswupper_l
215#define iswlower_l _iswlower_l
216#define iswalpha_l _iswalpha_l
217#define iswdigit_l _iswdigit_l
218#define iswpunct_l _iswpunct_l
219#define iswxdigit_l _iswxdigit_l
220#define towupper_l _towupper_l
221#define towlower_l _towlower_l
222#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
223_LIBCPP_EXPORTED_FROM_ABI size_t strftime_l(char* ret, size_t n, const char* format, const struct tm* tm, locale_t loc);
224#else
225# define strftime_l _strftime_l
226#endif
227#define sscanf_l(__s, __l, __f, ...) _sscanf_l(__s, __f, __l, __VA_ARGS__)
228_LIBCPP_EXPORTED_FROM_ABI int snprintf_l(char* __ret, size_t __n, locale_t __loc, const char* __format, ...);
229_LIBCPP_EXPORTED_FROM_ABI int asprintf_l(char** __ret, locale_t __loc, const char* __format, ...);
230_LIBCPP_EXPORTED_FROM_ABI int vasprintf_l(char** __ret, locale_t __loc, const char* __format, va_list __ap);
231
232// not-so-pressing FIXME: use locale to determine blank characters
233inline int iswblank_l(wint_t __c, locale_t /*loc*/) { return (__c == L' ' || __c == L'\t'); }
234
235#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_WIN32_H
lib/libcxx/include/__locale_dir/pad_and_output.h created+88
...@@ -0,0 +1,88 @@
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___LOCALE_DIR_PAD_AND_OUTPUT_H
10#define _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H
11
12#include <__config>
13
14#if _LIBCPP_HAS_LOCALIZATION
15
16# include <ios>
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 _CharT, class _OutputIterator>
25_LIBCPP_HIDE_FROM_ABI _OutputIterator __pad_and_output(
26 _OutputIterator __s, const _CharT* __ob, const _CharT* __op, const _CharT* __oe, ios_base& __iob, _CharT __fl) {
27 streamsize __sz = __oe - __ob;
28 streamsize __ns = __iob.width();
29 if (__ns > __sz)
30 __ns -= __sz;
31 else
32 __ns = 0;
33 for (; __ob < __op; ++__ob, ++__s)
34 *__s = *__ob;
35 for (; __ns; --__ns, ++__s)
36 *__s = __fl;
37 for (; __ob < __oe; ++__ob, ++__s)
38 *__s = *__ob;
39 __iob.width(0);
40 return __s;
41}
42
43template <class _CharT, class _Traits>
44_LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_CharT, _Traits> __pad_and_output(
45 ostreambuf_iterator<_CharT, _Traits> __s,
46 const _CharT* __ob,
47 const _CharT* __op,
48 const _CharT* __oe,
49 ios_base& __iob,
50 _CharT __fl) {
51 if (__s.__sbuf_ == nullptr)
52 return __s;
53 streamsize __sz = __oe - __ob;
54 streamsize __ns = __iob.width();
55 if (__ns > __sz)
56 __ns -= __sz;
57 else
58 __ns = 0;
59 streamsize __np = __op - __ob;
60 if (__np > 0) {
61 if (__s.__sbuf_->sputn(__ob, __np) != __np) {
62 __s.__sbuf_ = nullptr;
63 return __s;
64 }
65 }
66 if (__ns > 0) {
67 basic_string<_CharT, _Traits> __sp(__ns, __fl);
68 if (__s.__sbuf_->sputn(__sp.data(), __ns) != __ns) {
69 __s.__sbuf_ = nullptr;
70 return __s;
71 }
72 }
73 __np = __oe - __op;
74 if (__np > 0) {
75 if (__s.__sbuf_->sputn(__op, __np) != __np) {
76 __s.__sbuf_ = nullptr;
77 return __s;
78 }
79 }
80 __iob.width(0);
81 return __s;
82}
83
84_LIBCPP_END_NAMESPACE_STD
85
86#endif // _LIBCPP_HAS_LOCALIZATION
87
88#endif // _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H
lib/libcxx/include/__locale_dir/support/apple.h created+20
...@@ -0,0 +1,20 @@
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___LOCALE_DIR_SUPPORT_APPLE_H
10#define _LIBCPP___LOCALE_DIR_SUPPORT_APPLE_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18#include <__locale_dir/support/bsd_like.h>
19
20#endif // _LIBCPP___LOCALE_DIR_SUPPORT_APPLE_H
lib/libcxx/include/__locale_dir/support/bsd_like.h created+234
...@@ -0,0 +1,234 @@
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___LOCALE_DIR_SUPPORT_BSD_LIKE_H
10#define _LIBCPP___LOCALE_DIR_SUPPORT_BSD_LIKE_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__std_mbstate_t.h>
15#include <__utility/forward.h>
16#include <clocale> // std::lconv
17#include <ctype.h>
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21#include <time.h>
22#if _LIBCPP_HAS_WIDE_CHARACTERS
23# include <wchar.h>
24# include <wctype.h>
25#endif
26
27#include <xlocale.h>
28
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header
31#endif
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34namespace __locale {
35
36//
37// Locale management
38//
39#define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK
40#define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK
41#define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK
42#define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK
43#define _LIBCPP_TIME_MASK LC_TIME_MASK
44#define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK
45#define _LIBCPP_ALL_MASK LC_ALL_MASK
46#define _LIBCPP_LC_ALL LC_ALL
47
48using __locale_t = ::locale_t;
49#if defined(_LIBCPP_BUILDING_LIBRARY)
50using __lconv_t = std::lconv;
51
52inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __locale, __locale_t __base) {
53 return ::newlocale(__category_mask, __locale, __base);
54}
55
56inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { ::freelocale(__loc); }
57
58inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __locale) {
59 return ::setlocale(__category, __locale);
60}
61
62inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { return ::localeconv_l(__loc); }
63#endif // _LIBCPP_BUILDING_LIBRARY
64
65//
66// Strtonum functions
67//
68inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) {
69 return ::strtof_l(__nptr, __endptr, __loc);
70}
71
72inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) {
73 return ::strtod_l(__nptr, __endptr, __loc);
74}
75
76inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) {
77 return ::strtold_l(__nptr, __endptr, __loc);
78}
79
80inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
81 return ::strtoll_l(__nptr, __endptr, __base, __loc);
82}
83
84inline _LIBCPP_HIDE_FROM_ABI unsigned long long
85__strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
86 return ::strtoull_l(__nptr, __endptr, __base, __loc);
87}
88
89//
90// Character manipulation functions
91//
92#if defined(_LIBCPP_BUILDING_LIBRARY)
93inline _LIBCPP_HIDE_FROM_ABI int __islower(int __c, __locale_t __loc) { return ::islower_l(__c, __loc); }
94
95inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __c, __locale_t __loc) { return ::isupper_l(__c, __loc); }
96#endif
97
98inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return ::isdigit_l(__c, __loc); }
99
100inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return ::isxdigit_l(__c, __loc); }
101
102#if defined(_LIBCPP_BUILDING_LIBRARY)
103inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return ::toupper_l(__c, __loc); }
104
105inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __c, __locale_t __loc) { return ::tolower_l(__c, __loc); }
106
107inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) {
108 return ::strcoll_l(__s1, __s2, __loc);
109}
110
111inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, size_t __n, __locale_t __loc) {
112 return ::strxfrm_l(__dest, __src, __n, __loc);
113}
114
115# if _LIBCPP_HAS_WIDE_CHARACTERS
116inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) {
117 return ::iswctype_l(__c, __type, __loc);
118}
119
120inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return ::iswspace_l(__c, __loc); }
121
122inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return ::iswprint_l(__c, __loc); }
123
124inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __c, __locale_t __loc) { return ::iswcntrl_l(__c, __loc); }
125
126inline _LIBCPP_HIDE_FROM_ABI int __iswupper(wint_t __c, __locale_t __loc) { return ::iswupper_l(__c, __loc); }
127
128inline _LIBCPP_HIDE_FROM_ABI int __iswlower(wint_t __c, __locale_t __loc) { return ::iswlower_l(__c, __loc); }
129
130inline _LIBCPP_HIDE_FROM_ABI int __iswalpha(wint_t __c, __locale_t __loc) { return ::iswalpha_l(__c, __loc); }
131
132inline _LIBCPP_HIDE_FROM_ABI int __iswblank(wint_t __c, __locale_t __loc) { return ::iswblank_l(__c, __loc); }
133
134inline _LIBCPP_HIDE_FROM_ABI int __iswdigit(wint_t __c, __locale_t __loc) { return ::iswdigit_l(__c, __loc); }
135
136inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __c, __locale_t __loc) { return ::iswpunct_l(__c, __loc); }
137
138inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __c, __locale_t __loc) { return ::iswxdigit_l(__c, __loc); }
139
140inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __c, __locale_t __loc) { return ::towupper_l(__c, __loc); }
141
142inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __c, __locale_t __loc) { return ::towlower_l(__c, __loc); }
143
144inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __ws1, const wchar_t* __ws2, __locale_t __loc) {
145 return ::wcscoll_l(__ws1, __ws2, __loc);
146}
147
148inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) {
149 return ::wcsxfrm_l(__dest, __src, __n, __loc);
150}
151# endif // _LIBCPP_HAS_WIDE_CHARACTERS
152
153inline _LIBCPP_HIDE_FROM_ABI size_t
154__strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t __loc) {
155 return ::strftime_l(__s, __max, __format, __tm, __loc);
156}
157
158//
159// Other functions
160//
161inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __mb_len_max(__locale_t __loc) { return MB_CUR_MAX_L(__loc); }
162
163# if _LIBCPP_HAS_WIDE_CHARACTERS
164inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __c, __locale_t __loc) { return ::btowc_l(__c, __loc); }
165
166inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __c, __locale_t __loc) { return ::wctob_l(__c, __loc); }
167
168inline _LIBCPP_HIDE_FROM_ABI size_t
169__wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t __loc) {
170 return ::wcsnrtombs_l(__dest, __src, __nwc, __len, __ps, __loc); // wcsnrtombs is a POSIX extension
171}
172
173inline _LIBCPP_HIDE_FROM_ABI size_t __wcrtomb(char* __s, wchar_t __wc, mbstate_t* __ps, __locale_t __loc) {
174 return ::wcrtomb_l(__s, __wc, __ps, __loc);
175}
176
177inline _LIBCPP_HIDE_FROM_ABI size_t
178__mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t __loc) {
179 return ::mbsnrtowcs_l(__dest, __src, __nms, __len, __ps, __loc); // mbsnrtowcs is a POSIX extension
180}
181
182inline _LIBCPP_HIDE_FROM_ABI size_t
183__mbrtowc(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) {
184 return ::mbrtowc_l(__pwc, __s, __n, __ps, __loc);
185}
186
187inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t __loc) {
188 return ::mbtowc_l(__pwc, __pmb, __max, __loc);
189}
190
191inline _LIBCPP_HIDE_FROM_ABI size_t __mbrlen(const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) {
192 return ::mbrlen_l(__s, __n, __ps, __loc);
193}
194
195inline _LIBCPP_HIDE_FROM_ABI size_t
196__mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) {
197 return ::mbsrtowcs_l(__dest, __src, __len, __ps, __loc);
198}
199# endif // _LIBCPP_HAS_WIDE_CHARACTERS
200#endif // _LIBCPP_BUILDING_LIBRARY
201
202_LIBCPP_DIAGNOSTIC_PUSH
203_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat")
204_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates
205#ifdef _LIBCPP_COMPILER_CLANG_BASED
206# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__)
207#else
208# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */
209#endif
210
211template <class... _Args>
212_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf(
213 char* __s, size_t __n, __locale_t __loc, const char* __format, _Args&&... __args) {
214 return ::snprintf_l(__s, __n, __loc, __format, std::forward<_Args>(__args)...);
215}
216
217template <class... _Args>
218_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf(
219 char** __s, __locale_t __loc, const char* __format, _Args&&... __args) {
220 return ::asprintf_l(__s, __loc, __format, std::forward<_Args>(__args)...); // non-standard
221}
222
223template <class... _Args>
224_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf(
225 const char* __s, __locale_t __loc, const char* __format, _Args&&... __args) {
226 return ::sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...);
227}
228_LIBCPP_DIAGNOSTIC_POP
229#undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
230
231} // namespace __locale
232_LIBCPP_END_NAMESPACE_STD
233
234#endif // _LIBCPP___LOCALE_DIR_SUPPORT_BSD_LIKE_H
lib/libcxx/include/__locale_dir/support/freebsd.h created+20
...@@ -0,0 +1,20 @@
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___LOCALE_DIR_SUPPORT_FREEBSD_H
10#define _LIBCPP___LOCALE_DIR_SUPPORT_FREEBSD_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18#include <__locale_dir/support/bsd_like.h>
19
20#endif // _LIBCPP___LOCALE_DIR_SUPPORT_FREEBSD_H
lib/libcxx/include/__locale_dir/support/fuchsia.h created+160
...@@ -0,0 +1,160 @@
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___LOCALE_DIR_SUPPORT_FUCHSIA_H
10#define _LIBCPP___LOCALE_DIR_SUPPORT_FUCHSIA_H
11
12#include <__config>
13#include <__utility/forward.h>
14#include <clocale> // uselocale & friends
15#include <cstdio>
16#include <cstdlib>
17#include <cwchar>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24namespace __locale {
25
26struct __locale_guard {
27 _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {}
28
29 _LIBCPP_HIDE_FROM_ABI ~__locale_guard() {
30 if (__old_loc_)
31 ::uselocale(__old_loc_);
32 }
33
34 locale_t __old_loc_;
35
36 __locale_guard(__locale_guard const&) = delete;
37 __locale_guard& operator=(__locale_guard const&) = delete;
38};
39
40//
41// Locale management
42//
43#define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK
44#define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK
45#define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK
46#define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK
47#define _LIBCPP_TIME_MASK LC_TIME_MASK
48#define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK
49#define _LIBCPP_ALL_MASK LC_ALL_MASK
50#define _LIBCPP_LC_ALL LC_ALL
51
52using __locale_t = locale_t;
53
54#if defined(_LIBCPP_BUILDING_LIBRARY)
55using __lconv_t = std::lconv;
56
57inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __name, __locale_t __loc) {
58 return ::newlocale(__category_mask, __name, __loc);
59}
60
61inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { ::freelocale(__loc); }
62
63inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __locale) {
64 return ::setlocale(__category, __locale);
65}
66
67inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) {
68 __locale_guard __current(__loc);
69 return std::localeconv();
70}
71
72//
73// Other functions
74//
75inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __mb_len_max(__locale_t __loc) {
76 __locale_guard __current(__loc);
77 return MB_CUR_MAX;
78}
79# if _LIBCPP_HAS_WIDE_CHARACTERS
80inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __ch, __locale_t __loc) {
81 __locale_guard __current(__loc);
82 return std::btowc(__ch);
83}
84inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __ch, __locale_t __loc) {
85 __locale_guard __current(__loc);
86 return std::wctob(__ch);
87}
88inline _LIBCPP_HIDE_FROM_ABI size_t
89__wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t __loc) {
90 __locale_guard __current(__loc);
91 return ::wcsnrtombs(__dest, __src, __nwc, __len, __ps); // non-standard
92}
93inline _LIBCPP_HIDE_FROM_ABI size_t __wcrtomb(char* __s, wchar_t __ch, mbstate_t* __ps, __locale_t __loc) {
94 __locale_guard __current(__loc);
95 return std::wcrtomb(__s, __ch, __ps);
96}
97inline _LIBCPP_HIDE_FROM_ABI size_t
98__mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t __loc) {
99 __locale_guard __current(__loc);
100 return ::mbsnrtowcs(__dest, __src, __nms, __len, __ps); // non-standard
101}
102inline _LIBCPP_HIDE_FROM_ABI size_t
103__mbrtowc(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) {
104 __locale_guard __current(__loc);
105 return std::mbrtowc(__pwc, __s, __n, __ps);
106}
107inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t __loc) {
108 __locale_guard __current(__loc);
109 return std::mbtowc(__pwc, __pmb, __max);
110}
111inline _LIBCPP_HIDE_FROM_ABI size_t __mbrlen(const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) {
112 __locale_guard __current(__loc);
113 return std::mbrlen(__s, __n, __ps);
114}
115inline _LIBCPP_HIDE_FROM_ABI size_t
116__mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) {
117 __locale_guard __current(__loc);
118 return ::mbsrtowcs(__dest, __src, __len, __ps);
119}
120# endif // _LIBCPP_HAS_WIDE_CHARACTERS
121#endif // _LIBCPP_BUILDING_LIBRARY
122
123_LIBCPP_DIAGNOSTIC_PUSH
124_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat")
125_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates
126#ifdef _LIBCPP_COMPILER_CLANG_BASED
127# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__)
128#else
129# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */
130#endif
131
132template <class... _Args>
133_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf(
134 char* __s, size_t __n, __locale_t __loc, const char* __format, _Args&&... __args) {
135 __locale_guard __current(__loc);
136 return std::snprintf(__s, __n, __format, std::forward<_Args>(__args)...);
137}
138template <class... _Args>
139_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf(
140 char** __s, __locale_t __loc, const char* __format, _Args&&... __args) {
141 __locale_guard __current(__loc);
142 return ::asprintf(__s, __format, std::forward<_Args>(__args)...); // non-standard
143}
144template <class... _Args>
145_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf(
146 const char* __s, __locale_t __loc, const char* __format, _Args&&... __args) {
147 __locale_guard __current(__loc);
148 return std::sscanf(__s, __format, std::forward<_Args>(__args)...);
149}
150
151_LIBCPP_DIAGNOSTIC_POP
152#undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
153
154} // namespace __locale
155_LIBCPP_END_NAMESPACE_STD
156
157#include <__locale_dir/support/no_locale/characters.h>
158#include <__locale_dir/support/no_locale/strtonum.h>
159
160#endif // _LIBCPP___LOCALE_DIR_SUPPORT_FUCHSIA_H
lib/libcxx/include/__locale_dir/support/no_locale/characters.h created+102
...@@ -0,0 +1,102 @@
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___LOCALE_DIR_SUPPORT_NO_LOCALE_CHARACTERS_H
10#define _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_CHARACTERS_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14#include <cctype>
15#include <cstdlib>
16#include <cstring>
17#include <ctime>
18#if _LIBCPP_HAS_WIDE_CHARACTERS
19# include <cwctype>
20#endif
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27namespace __locale {
28
29//
30// Character manipulation functions
31//
32#if defined(_LIBCPP_BUILDING_LIBRARY)
33inline _LIBCPP_HIDE_FROM_ABI int __islower(int __c, __locale_t) { return std::islower(__c); }
34
35inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __c, __locale_t) { return std::isupper(__c); }
36#endif
37
38inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t) { return std::isdigit(__c); }
39
40inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t) { return std::isxdigit(__c); }
41
42#if defined(_LIBCPP_BUILDING_LIBRARY)
43inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t) { return std::toupper(__c); }
44
45inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __c, __locale_t) { return std::tolower(__c); }
46
47inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t) {
48 return std::strcoll(__s1, __s2);
49}
50
51inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, size_t __n, __locale_t) {
52 return std::strxfrm(__dest, __src, __n);
53}
54
55# if _LIBCPP_HAS_WIDE_CHARACTERS
56inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t) {
57 return std::iswctype(__c, __type);
58}
59
60inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t) { return std::iswspace(__c); }
61
62inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t) { return std::iswprint(__c); }
63
64inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __c, __locale_t) { return std::iswcntrl(__c); }
65
66inline _LIBCPP_HIDE_FROM_ABI int __iswupper(wint_t __c, __locale_t) { return std::iswupper(__c); }
67
68inline _LIBCPP_HIDE_FROM_ABI int __iswlower(wint_t __c, __locale_t) { return std::iswlower(__c); }
69
70inline _LIBCPP_HIDE_FROM_ABI int __iswalpha(wint_t __c, __locale_t) { return std::iswalpha(__c); }
71
72inline _LIBCPP_HIDE_FROM_ABI int __iswblank(wint_t __c, __locale_t) { return std::iswblank(__c); }
73
74inline _LIBCPP_HIDE_FROM_ABI int __iswdigit(wint_t __c, __locale_t) { return std::iswdigit(__c); }
75
76inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __c, __locale_t) { return std::iswpunct(__c); }
77
78inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __c, __locale_t) { return std::iswxdigit(__c); }
79
80inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __c, __locale_t) { return std::towupper(__c); }
81
82inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __c, __locale_t) { return std::towlower(__c); }
83
84inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __ws1, const wchar_t* __ws2, __locale_t) {
85 return std::wcscoll(__ws1, __ws2);
86}
87
88inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t) {
89 return std::wcsxfrm(__dest, __src, __n);
90}
91# endif // _LIBCPP_HAS_WIDE_CHARACTERS
92
93inline _LIBCPP_HIDE_FROM_ABI size_t
94__strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t) {
95 return std::strftime(__s, __max, __format, __tm);
96}
97#endif // _LIBCPP_BUILDING_LIBRARY
98
99} // namespace __locale
100_LIBCPP_END_NAMESPACE_STD
101
102#endif // _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_CHARACTERS_H
lib/libcxx/include/__locale_dir/support/no_locale/strtonum.h created+49
...@@ -0,0 +1,49 @@
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___LOCALE_DIR_SUPPORT_NO_LOCALE_STRTONUM_H
10#define _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_STRTONUM_H
11
12#include <__config>
13#include <cstdlib>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20namespace __locale {
21
22//
23// Strtonum functions
24//
25inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t) {
26 return std::strtof(__nptr, __endptr);
27}
28
29inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t) {
30 return std::strtod(__nptr, __endptr);
31}
32
33inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t) {
34 return std::strtold(__nptr, __endptr);
35}
36
37inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t) {
38 return std::strtoll(__nptr, __endptr, __base);
39}
40
41inline _LIBCPP_HIDE_FROM_ABI unsigned long long
42__strtoull(const char* __nptr, char** __endptr, int __base, __locale_t) {
43 return std::strtoull(__nptr, __endptr, __base);
44}
45
46} // namespace __locale
47_LIBCPP_END_NAMESPACE_STD
48
49#endif // _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_STRTONUM_H
lib/libcxx/include/__locale_dir/support/windows.h created+343
...@@ -0,0 +1,343 @@
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___LOCALE_DIR_SUPPORT_WINDOWS_H
10#define _LIBCPP___LOCALE_DIR_SUPPORT_WINDOWS_H
11
12#include <__config>
13#include <__cstddef/nullptr_t.h>
14#include <__utility/forward.h>
15#include <clocale> // std::lconv & friends
16#include <cstddef>
17#include <ctype.h> // ::_isupper_l & friends
18#include <locale.h> // ::_locale_t
19#include <stdio.h> // ::_sscanf_l
20#include <stdlib.h> // ::_strtod_l & friends
21#include <string.h> // ::_strcoll_l
22#include <string>
23#include <time.h> // ::_strftime_l
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30namespace __locale {
31
32using __lconv_t = std::lconv;
33
34class __lconv_storage {
35public:
36 __lconv_storage(const __lconv_t* __lc_input) {
37 __lc_ = *__lc_input;
38
39 __decimal_point_ = __lc_input->decimal_point;
40 __thousands_sep_ = __lc_input->thousands_sep;
41 __grouping_ = __lc_input->grouping;
42 __int_curr_symbol_ = __lc_input->int_curr_symbol;
43 __currency_symbol_ = __lc_input->currency_symbol;
44 __mon_decimal_point_ = __lc_input->mon_decimal_point;
45 __mon_thousands_sep_ = __lc_input->mon_thousands_sep;
46 __mon_grouping_ = __lc_input->mon_grouping;
47 __positive_sign_ = __lc_input->positive_sign;
48 __negative_sign_ = __lc_input->negative_sign;
49
50 __lc_.decimal_point = const_cast<char*>(__decimal_point_.c_str());
51 __lc_.thousands_sep = const_cast<char*>(__thousands_sep_.c_str());
52 __lc_.grouping = const_cast<char*>(__grouping_.c_str());
53 __lc_.int_curr_symbol = const_cast<char*>(__int_curr_symbol_.c_str());
54 __lc_.currency_symbol = const_cast<char*>(__currency_symbol_.c_str());
55 __lc_.mon_decimal_point = const_cast<char*>(__mon_decimal_point_.c_str());
56 __lc_.mon_thousands_sep = const_cast<char*>(__mon_thousands_sep_.c_str());
57 __lc_.mon_grouping = const_cast<char*>(__mon_grouping_.c_str());
58 __lc_.positive_sign = const_cast<char*>(__positive_sign_.c_str());
59 __lc_.negative_sign = const_cast<char*>(__negative_sign_.c_str());
60 }
61
62 __lconv_t* __get() { return &__lc_; }
63
64private:
65 __lconv_t __lc_;
66 std::string __decimal_point_;
67 std::string __thousands_sep_;
68 std::string __grouping_;
69 std::string __int_curr_symbol_;
70 std::string __currency_symbol_;
71 std::string __mon_decimal_point_;
72 std::string __mon_thousands_sep_;
73 std::string __mon_grouping_;
74 std::string __positive_sign_;
75 std::string __negative_sign_;
76};
77
78//
79// Locale management
80//
81#define _CATMASK(n) ((1 << (n)) >> 1)
82#define _LIBCPP_COLLATE_MASK _CATMASK(LC_COLLATE)
83#define _LIBCPP_CTYPE_MASK _CATMASK(LC_CTYPE)
84#define _LIBCPP_MONETARY_MASK _CATMASK(LC_MONETARY)
85#define _LIBCPP_NUMERIC_MASK _CATMASK(LC_NUMERIC)
86#define _LIBCPP_TIME_MASK _CATMASK(LC_TIME)
87#define _LIBCPP_MESSAGES_MASK _CATMASK(6)
88#define _LIBCPP_ALL_MASK \
89 (_LIBCPP_COLLATE_MASK | _LIBCPP_CTYPE_MASK | _LIBCPP_MESSAGES_MASK | _LIBCPP_MONETARY_MASK | _LIBCPP_NUMERIC_MASK | \
90 _LIBCPP_TIME_MASK)
91#define _LIBCPP_LC_ALL LC_ALL
92
93class __locale_t {
94public:
95 __locale_t() : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
96 __locale_t(std::nullptr_t) : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
97 __locale_t(::_locale_t __loc, const char* __loc_str) : __locale_(__loc), __locale_str_(__loc_str), __lc_(nullptr) {}
98 __locale_t(const __locale_t& __loc)
99 : __locale_(__loc.__locale_), __locale_str_(__loc.__locale_str_), __lc_(nullptr) {}
100
101 ~__locale_t() { delete __lc_; }
102
103 __locale_t& operator=(const __locale_t& __loc) {
104 __locale_ = __loc.__locale_;
105 __locale_str_ = __loc.__locale_str_;
106 // __lc_ not copied
107 return *this;
108 }
109
110 friend bool operator==(const __locale_t& __left, const __locale_t& __right) {
111 return __left.__locale_ == __right.__locale_;
112 }
113
114 friend bool operator==(const __locale_t& __left, int __right) { return __left.__locale_ == nullptr && __right == 0; }
115
116 friend bool operator==(const __locale_t& __left, long long __right) {
117 return __left.__locale_ == nullptr && __right == 0;
118 }
119
120 friend bool operator==(const __locale_t& __left, std::nullptr_t) { return __left.__locale_ == nullptr; }
121
122 friend bool operator==(int __left, const __locale_t& __right) { return __left == 0 && nullptr == __right.__locale_; }
123
124 friend bool operator==(std::nullptr_t, const __locale_t& __right) { return nullptr == __right.__locale_; }
125
126 friend bool operator!=(const __locale_t& __left, const __locale_t& __right) { return !(__left == __right); }
127
128 friend bool operator!=(const __locale_t& __left, int __right) { return !(__left == __right); }
129
130 friend bool operator!=(const __locale_t& __left, long long __right) { return !(__left == __right); }
131
132 friend bool operator!=(const __locale_t& __left, std::nullptr_t __right) { return !(__left == __right); }
133
134 friend bool operator!=(int __left, const __locale_t& __right) { return !(__left == __right); }
135
136 friend bool operator!=(std::nullptr_t __left, const __locale_t& __right) { return !(__left == __right); }
137
138 operator bool() const { return __locale_ != nullptr; }
139
140 const char* __get_locale() const { return __locale_str_; }
141
142 operator ::_locale_t() const { return __locale_; }
143
144 __lconv_t* __store_lconv(const __lconv_t* __input_lc) {
145 delete __lc_;
146 __lc_ = new __lconv_storage(__input_lc);
147 return __lc_->__get();
148 }
149
150private:
151 ::_locale_t __locale_;
152 const char* __locale_str_;
153 __lconv_storage* __lc_ = nullptr;
154};
155
156#if defined(_LIBCPP_BUILDING_LIBRARY)
157_LIBCPP_EXPORTED_FROM_ABI __locale_t __newlocale(int __mask, const char* __locale, __locale_t __base);
158inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { ::_free_locale(__loc); }
159inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, const char* __locale) {
160 char* __new_locale = ::setlocale(__category, __locale);
161 if (__new_locale == nullptr)
162 std::__throw_bad_alloc();
163 return __new_locale;
164}
165_LIBCPP_EXPORTED_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc);
166#endif // _LIBCPP_BUILDING_LIBRARY
167
168//
169// Strtonum functions
170//
171
172// the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
173#if defined(_LIBCPP_MSVCRT)
174inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) {
175 return ::_strtof_l(__nptr, __endptr, __loc);
176}
177inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) {
178 return ::_strtold_l(__nptr, __endptr, __loc);
179}
180#else
181_LIBCPP_EXPORTED_FROM_ABI float __strtof(const char*, char**, __locale_t);
182_LIBCPP_EXPORTED_FROM_ABI long double __strtold(const char*, char**, __locale_t);
183#endif
184
185inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) {
186 return ::_strtod_l(__nptr, __endptr, __loc);
187}
188
189inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
190 return ::_strtoi64_l(__nptr, __endptr, __base, __loc);
191}
192inline _LIBCPP_HIDE_FROM_ABI unsigned long long
193__strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
194 return ::_strtoui64_l(__nptr, __endptr, __base, __loc);
195}
196
197//
198// Character manipulation functions
199//
200#if defined(_LIBCPP_BUILDING_LIBRARY)
201inline _LIBCPP_HIDE_FROM_ABI int __islower(int __c, __locale_t __loc) { return _islower_l(__c, __loc); }
202
203inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __c, __locale_t __loc) { return _isupper_l(__c, __loc); }
204#endif
205
206inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return _isdigit_l(__c, __loc); }
207
208inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return _isxdigit_l(__c, __loc); }
209
210#if defined(_LIBCPP_BUILDING_LIBRARY)
211inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return ::_toupper_l(__c, __loc); }
212
213inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __c, __locale_t __loc) { return ::_tolower_l(__c, __loc); }
214
215inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) {
216 return ::_strcoll_l(__s1, __s2, __loc);
217}
218
219inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, size_t __n, __locale_t __loc) {
220 return ::_strxfrm_l(__dest, __src, __n, __loc);
221}
222
223# if _LIBCPP_HAS_WIDE_CHARACTERS
224inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) {
225 return ::_iswctype_l(__c, __type, __loc);
226}
227inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return ::_iswspace_l(__c, __loc); }
228inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return ::_iswprint_l(__c, __loc); }
229inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __c, __locale_t __loc) { return ::_iswcntrl_l(__c, __loc); }
230inline _LIBCPP_HIDE_FROM_ABI int __iswupper(wint_t __c, __locale_t __loc) { return ::_iswupper_l(__c, __loc); }
231inline _LIBCPP_HIDE_FROM_ABI int __iswlower(wint_t __c, __locale_t __loc) { return ::_iswlower_l(__c, __loc); }
232inline _LIBCPP_HIDE_FROM_ABI int __iswalpha(wint_t __c, __locale_t __loc) { return ::_iswalpha_l(__c, __loc); }
233// TODO: use locale to determine blank characters
234inline _LIBCPP_HIDE_FROM_ABI int __iswblank(wint_t __c, __locale_t /*loc*/) { return (__c == L' ' || __c == L'\t'); }
235inline _LIBCPP_HIDE_FROM_ABI int __iswdigit(wint_t __c, __locale_t __loc) { return ::_iswdigit_l(__c, __loc); }
236inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __c, __locale_t __loc) { return ::_iswpunct_l(__c, __loc); }
237inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __c, __locale_t __loc) { return ::_iswxdigit_l(__c, __loc); }
238inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __c, __locale_t __loc) { return ::_towupper_l(__c, __loc); }
239inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __c, __locale_t __loc) { return ::_towlower_l(__c, __loc); }
240
241inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __ws1, const wchar_t* __ws2, __locale_t __loc) {
242 return ::_wcscoll_l(__ws1, __ws2, __loc);
243}
244
245inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) {
246 return ::_wcsxfrm_l(__dest, __src, __n, __loc);
247}
248# endif // _LIBCPP_HAS_WIDE_CHARACTERS
249
250# if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
251_LIBCPP_EXPORTED_FROM_ABI size_t __strftime(char*, size_t, const char*, const struct tm*, __locale_t);
252# else
253inline _LIBCPP_HIDE_FROM_ABI size_t
254__strftime(char* __ret, size_t __n, const char* __format, const struct tm* __tm, __locale_t __loc) {
255 return ::_strftime_l(__ret, __n, __format, __tm, __loc);
256}
257# endif
258
259//
260// Other functions
261//
262_LIBCPP_EXPORTED_FROM_ABI decltype(MB_CUR_MAX) __mb_len_max(__locale_t);
263_LIBCPP_EXPORTED_FROM_ABI wint_t __btowc(int, __locale_t);
264_LIBCPP_EXPORTED_FROM_ABI int __wctob(wint_t, __locale_t);
265_LIBCPP_EXPORTED_FROM_ABI size_t
266__wcsnrtombs(char* __restrict, const wchar_t** __restrict, size_t, size_t, mbstate_t* __restrict, __locale_t);
267_LIBCPP_EXPORTED_FROM_ABI size_t __wcrtomb(char* __restrict, wchar_t, mbstate_t* __restrict, __locale_t);
268_LIBCPP_EXPORTED_FROM_ABI size_t
269__mbsnrtowcs(wchar_t* __restrict, const char** __restrict, size_t, size_t, mbstate_t* __restrict, __locale_t);
270_LIBCPP_EXPORTED_FROM_ABI size_t
271__mbrtowc(wchar_t* __restrict, const char* __restrict, size_t, mbstate_t* __restrict, __locale_t);
272
273inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t __loc) {
274 return ::_mbtowc_l(__pwc, __pmb, __max, __loc);
275}
276
277_LIBCPP_EXPORTED_FROM_ABI size_t __mbrlen(const char* __restrict, size_t, mbstate_t* __restrict, __locale_t);
278
279_LIBCPP_EXPORTED_FROM_ABI size_t
280__mbsrtowcs(wchar_t* __restrict, const char** __restrict, size_t, mbstate_t* __restrict, __locale_t);
281#endif // _LIBCPP_BUILDING_LIBRARY
282
283_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf(
284 char* __ret, size_t __n, __locale_t __loc, const char* __format, ...);
285
286_LIBCPP_EXPORTED_FROM_ABI
287_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf(char** __ret, __locale_t __loc, const char* __format, ...);
288
289_LIBCPP_DIAGNOSTIC_PUSH
290_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat")
291_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates
292#ifdef _LIBCPP_COMPILER_CLANG_BASED
293# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__)
294#else
295# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */
296#endif
297
298template <class... _Args>
299_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf(
300 const char* __dest, __locale_t __loc, const char* __format, _Args&&... __args) {
301 return ::_sscanf_l(__dest, __format, __loc, std::forward<_Args>(__args)...);
302}
303_LIBCPP_DIAGNOSTIC_POP
304#undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
305
306#if defined(_LIBCPP_BUILDING_LIBRARY)
307struct __locale_guard {
308 _LIBCPP_HIDE_FROM_ABI __locale_guard(__locale_t __l) : __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) {
309 // Setting the locale can be expensive even when the locale given is
310 // already the current locale, so do an explicit check to see if the
311 // current locale is already the one we want.
312 const char* __lc = __locale::__setlocale(LC_ALL, nullptr);
313 // If every category is the same, the locale string will simply be the
314 // locale name, otherwise it will be a semicolon-separated string listing
315 // each category. In the second case, we know at least one category won't
316 // be what we want, so we only have to check the first case.
317 if (std::strcmp(__l.__get_locale(), __lc) != 0) {
318 __locale_all = _strdup(__lc);
319 if (__locale_all == nullptr)
320 __throw_bad_alloc();
321 __locale::__setlocale(LC_ALL, __l.__get_locale());
322 }
323 }
324 _LIBCPP_HIDE_FROM_ABI ~__locale_guard() {
325 // The CRT documentation doesn't explicitly say, but setlocale() does the
326 // right thing when given a semicolon-separated list of locale settings
327 // for the different categories in the same format as returned by
328 // setlocale(LC_ALL, nullptr).
329 if (__locale_all != nullptr) {
330 __locale::__setlocale(LC_ALL, __locale_all);
331 free(__locale_all);
332 }
333 _configthreadlocale(__status);
334 }
335 int __status;
336 char* __locale_all = nullptr;
337};
338#endif // _LIBCPP_BUILDING_LIBRARY
339
340} // namespace __locale
341_LIBCPP_END_NAMESPACE_STD
342
343#endif // _LIBCPP___LOCALE_DIR_SUPPORT_WINDOWS_H
lib/libcxx/include/__math/abs.h+4-4
...@@ -23,19 +23,19 @@ namespace __math {...@@ -23,19 +23,19 @@ namespace __math {
2323
24// fabs24// fabs
2525
26_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); }26[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); }
2727
28template <class = int>28template <class = int>
29_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT {29[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT {
30 return __builtin_fabs(__x);30 return __builtin_fabs(__x);
31}31}
3232
33_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {33[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {
34 return __builtin_fabsl(__x);34 return __builtin_fabsl(__x);
35}35}
3636
37template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>37template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
38_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double fabs(_A1 __x) _NOEXCEPT {38[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double fabs(_A1 __x) _NOEXCEPT {
39 return __builtin_fabs((double)__x);39 return __builtin_fabs((double)__x);
40}40}
4141
lib/libcxx/include/__math/copysign.h+3-4
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__type_traits/enable_if.h>13#include <__type_traits/enable_if.h>
14#include <__type_traits/is_arithmetic.h>14#include <__type_traits/is_arithmetic.h>
15#include <__type_traits/promote.h>15#include <__type_traits/promote.h>
16#include <limits>
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
...@@ -25,16 +24,16 @@ namespace __math {...@@ -25,16 +24,16 @@ namespace __math {
2524
26// copysign25// copysign
2726
28_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {27[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
29 return ::__builtin_copysignf(__x, __y);28 return ::__builtin_copysignf(__x, __y);
30}29}
3130
32_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {31[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
33 return ::__builtin_copysignl(__x, __y);32 return ::__builtin_copysignl(__x, __y);
34}33}
3534
36template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>35template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
37_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type copysign(_A1 __x, _A2 __y) _NOEXCEPT {36[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type copysign(_A1 __x, _A2 __y) _NOEXCEPT {
38 return ::__builtin_copysign(__x, __y);37 return ::__builtin_copysign(__x, __y);
39}38}
4039
lib/libcxx/include/__math/hypot.h+2-3
...@@ -9,16 +9,15 @@...@@ -9,16 +9,15 @@
9#ifndef _LIBCPP___MATH_HYPOT_H9#ifndef _LIBCPP___MATH_HYPOT_H
10#define _LIBCPP___MATH_HYPOT_H10#define _LIBCPP___MATH_HYPOT_H
1111
12#include <__algorithm/max.h>
13#include <__config>12#include <__config>
14#include <__math/abs.h>13#include <__math/abs.h>
15#include <__math/exponential_functions.h>14#include <__math/exponential_functions.h>
15#include <__math/min_max.h>
16#include <__math/roots.h>16#include <__math/roots.h>
17#include <__type_traits/enable_if.h>17#include <__type_traits/enable_if.h>
18#include <__type_traits/is_arithmetic.h>18#include <__type_traits/is_arithmetic.h>
19#include <__type_traits/is_same.h>19#include <__type_traits/is_same.h>
20#include <__type_traits/promote.h>20#include <__type_traits/promote.h>
21#include <__utility/pair.h>
22#include <limits>21#include <limits>
2322
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -63,7 +62,7 @@ _LIBCPP_HIDE_FROM_ABI _Real __hypot(_Real __x, _Real __y, _Real __z) {...@@ -63,7 +62,7 @@ _LIBCPP_HIDE_FROM_ABI _Real __hypot(_Real __x, _Real __y, _Real __z) {
63 const _Real __overflow_scale = __math::ldexp(_Real(1), -(__exp + 20));62 const _Real __overflow_scale = __math::ldexp(_Real(1), -(__exp + 20));
6463
65 // Scale arguments depending on their size64 // Scale arguments depending on their size
66 const _Real __max_abs = std::max(__math::fabs(__x), std::max(__math::fabs(__y), __math::fabs(__z)));65 const _Real __max_abs = __math::fmax(__math::fabs(__x), __math::fmax(__math::fabs(__y), __math::fabs(__z)));
67 _Real __scale;66 _Real __scale;
68 if (__max_abs > __overflow_threshold) { // x*x + y*y + z*z might overflow67 if (__max_abs > __overflow_threshold) { // x*x + y*y + z*z might overflow
69 __scale = __overflow_scale;68 __scale = __overflow_scale;
lib/libcxx/include/__math/min_max.h+8-8
...@@ -25,21 +25,21 @@ namespace __math {...@@ -25,21 +25,21 @@ namespace __math {
2525
26// fmax26// fmax
2727
28_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {28[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {
29 return __builtin_fmaxf(__x, __y);29 return __builtin_fmaxf(__x, __y);
30}30}
3131
32template <class = int>32template <class = int>
33_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT {33[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT {
34 return __builtin_fmax(__x, __y);34 return __builtin_fmax(__x, __y);
35}35}
3636
37_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {37[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {
38 return __builtin_fmaxl(__x, __y);38 return __builtin_fmaxl(__x, __y);
39}39}
4040
41template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>41template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
42_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmax(_A1 __x, _A2 __y) _NOEXCEPT {42[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmax(_A1 __x, _A2 __y) _NOEXCEPT {
43 using __result_type = typename __promote<_A1, _A2>::type;43 using __result_type = typename __promote<_A1, _A2>::type;
44 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");44 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
45 return __math::fmax((__result_type)__x, (__result_type)__y);45 return __math::fmax((__result_type)__x, (__result_type)__y);
...@@ -47,21 +47,21 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::typ...@@ -47,21 +47,21 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::typ
4747
48// fmin48// fmin
4949
50_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {50[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {
51 return __builtin_fminf(__x, __y);51 return __builtin_fminf(__x, __y);
52}52}
5353
54template <class = int>54template <class = int>
55_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT {55[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT {
56 return __builtin_fmin(__x, __y);56 return __builtin_fmin(__x, __y);
57}57}
5858
59_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {59[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {
60 return __builtin_fminl(__x, __y);60 return __builtin_fminl(__x, __y);
61}61}
6262
63template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>63template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
64_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmin(_A1 __x, _A2 __y) _NOEXCEPT {64[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmin(_A1 __x, _A2 __y) _NOEXCEPT {
65 using __result_type = typename __promote<_A1, _A2>::type;65 using __result_type = typename __promote<_A1, _A2>::type;
66 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");66 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
67 return __math::fmin((__result_type)__x, (__result_type)__y);67 return __math::fmin((__result_type)__x, (__result_type)__y);
lib/libcxx/include/__math/remainder.h-1
...@@ -14,7 +14,6 @@...@@ -14,7 +14,6 @@
14#include <__type_traits/is_arithmetic.h>14#include <__type_traits/is_arithmetic.h>
15#include <__type_traits/is_same.h>15#include <__type_traits/is_same.h>
16#include <__type_traits/promote.h>16#include <__type_traits/promote.h>
17#include <limits>
1817
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header19# pragma GCC system_header
lib/libcxx/include/__math/roots.h+4-4
...@@ -39,19 +39,19 @@ inline _LIBCPP_HIDE_FROM_ABI double sqrt(_A1 __x) _NOEXCEPT {...@@ -39,19 +39,19 @@ inline _LIBCPP_HIDE_FROM_ABI double sqrt(_A1 __x) _NOEXCEPT {
3939
40// cbrt40// cbrt
4141
42_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT { return __builtin_cbrtf(__x); }42[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT { return __builtin_cbrtf(__x); }
4343
44template <class = int>44template <class = int>
45_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT {45[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT {
46 return __builtin_cbrt(__x);46 return __builtin_cbrt(__x);
47}47}
4848
49_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {49[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {
50 return __builtin_cbrtl(__x);50 return __builtin_cbrtl(__x);
51}51}
5252
53template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>53template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
54_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double cbrt(_A1 __x) _NOEXCEPT {54[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double cbrt(_A1 __x) _NOEXCEPT {
55 return __builtin_cbrt((double)__x);55 return __builtin_cbrt((double)__x);
56}56}
5757
lib/libcxx/include/__math/rounding_functions.h+24-24
...@@ -26,37 +26,37 @@ namespace __math {...@@ -26,37 +26,37 @@ namespace __math {
2626
27// ceil27// ceil
2828
29_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT { return __builtin_ceilf(__x); }29[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT { return __builtin_ceilf(__x); }
3030
31template <class = int>31template <class = int>
32_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT {32[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT {
33 return __builtin_ceil(__x);33 return __builtin_ceil(__x);
34}34}
3535
36_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {36[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {
37 return __builtin_ceill(__x);37 return __builtin_ceill(__x);
38}38}
3939
40template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>40template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
41_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double ceil(_A1 __x) _NOEXCEPT {41[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double ceil(_A1 __x) _NOEXCEPT {
42 return __builtin_ceil((double)__x);42 return __builtin_ceil((double)__x);
43}43}
4444
45// floor45// floor
4646
47_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT { return __builtin_floorf(__x); }47[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT { return __builtin_floorf(__x); }
4848
49template <class = int>49template <class = int>
50_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT {50[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT {
51 return __builtin_floor(__x);51 return __builtin_floor(__x);
52}52}
5353
54_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {54[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {
55 return __builtin_floorl(__x);55 return __builtin_floorl(__x);
56}56}
5757
58template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>58template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
59_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double floor(_A1 __x) _NOEXCEPT {59[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double floor(_A1 __x) _NOEXCEPT {
60 return __builtin_floor((double)__x);60 return __builtin_floor((double)__x);
61}61}
6262
...@@ -126,21 +126,21 @@ inline _LIBCPP_HIDE_FROM_ABI long lround(_A1 __x) _NOEXCEPT {...@@ -126,21 +126,21 @@ inline _LIBCPP_HIDE_FROM_ABI long lround(_A1 __x) _NOEXCEPT {
126126
127// nearbyint127// nearbyint
128128
129_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {129[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {
130 return __builtin_nearbyintf(__x);130 return __builtin_nearbyintf(__x);
131}131}
132132
133template <class = int>133template <class = int>
134_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT {134[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT {
135 return __builtin_nearbyint(__x);135 return __builtin_nearbyint(__x);
136}136}
137137
138_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {138[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {
139 return __builtin_nearbyintl(__x);139 return __builtin_nearbyintl(__x);
140}140}
141141
142template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>142template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
143_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double nearbyint(_A1 __x) _NOEXCEPT {143[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double nearbyint(_A1 __x) _NOEXCEPT {
144 return __builtin_nearbyint((double)__x);144 return __builtin_nearbyint((double)__x);
145}145}
146146
...@@ -186,55 +186,55 @@ inline _LIBCPP_HIDE_FROM_ABI double nexttoward(_A1 __x, long double __y) _NOEXCE...@@ -186,55 +186,55 @@ inline _LIBCPP_HIDE_FROM_ABI double nexttoward(_A1 __x, long double __y) _NOEXCE
186186
187// rint187// rint
188188
189_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT { return __builtin_rintf(__x); }189[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT { return __builtin_rintf(__x); }
190190
191template <class = int>191template <class = int>
192_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT {192[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT {
193 return __builtin_rint(__x);193 return __builtin_rint(__x);
194}194}
195195
196_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT {196[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT {
197 return __builtin_rintl(__x);197 return __builtin_rintl(__x);
198}198}
199199
200template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>200template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
201_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double rint(_A1 __x) _NOEXCEPT {201[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double rint(_A1 __x) _NOEXCEPT {
202 return __builtin_rint((double)__x);202 return __builtin_rint((double)__x);
203}203}
204204
205// round205// round
206206
207_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT { return __builtin_round(__x); }207[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT { return __builtin_round(__x); }
208208
209template <class = int>209template <class = int>
210_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT {210[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT {
211 return __builtin_round(__x);211 return __builtin_round(__x);
212}212}
213213
214_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT {214[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT {
215 return __builtin_roundl(__x);215 return __builtin_roundl(__x);
216}216}
217217
218template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>218template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
219_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double round(_A1 __x) _NOEXCEPT {219[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double round(_A1 __x) _NOEXCEPT {
220 return __builtin_round((double)__x);220 return __builtin_round((double)__x);
221}221}
222222
223// trunc223// trunc
224224
225_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT { return __builtin_trunc(__x); }225[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT { return __builtin_trunc(__x); }
226226
227template <class = int>227template <class = int>
228_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT {228[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT {
229 return __builtin_trunc(__x);229 return __builtin_trunc(__x);
230}230}
231231
232_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT {232[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT {
233 return __builtin_truncl(__x);233 return __builtin_truncl(__x);
234}234}
235235
236template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>236template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
237_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double trunc(_A1 __x) _NOEXCEPT {237[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double trunc(_A1 __x) _NOEXCEPT {
238 return __builtin_trunc((double)__x);238 return __builtin_trunc((double)__x);
239}239}
240240
lib/libcxx/include/__math/traits.h+66-52
...@@ -12,11 +12,9 @@...@@ -12,11 +12,9 @@
12#include <__config>12#include <__config>
13#include <__type_traits/enable_if.h>13#include <__type_traits/enable_if.h>
14#include <__type_traits/is_arithmetic.h>14#include <__type_traits/is_arithmetic.h>
15#include <__type_traits/is_floating_point.h>
16#include <__type_traits/is_integral.h>15#include <__type_traits/is_integral.h>
17#include <__type_traits/is_signed.h>16#include <__type_traits/is_signed.h>
18#include <__type_traits/promote.h>17#include <__type_traits/promote.h>
19#include <limits>
2018
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header20# pragma GCC system_header
...@@ -28,115 +26,131 @@ namespace __math {...@@ -28,115 +26,131 @@ namespace __math {
2826
29// signbit27// signbit
3028
31template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>29// TODO(LLVM 22): Remove conditional once support for Clang 19 is dropped.
32_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {30#if defined(_LIBCPP_COMPILER_GCC) || __has_constexpr_builtin(__builtin_signbit)
31# define _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_CONSTEXPR_SINCE_CXX23
32#else
33# define _LIBCPP_SIGNBIT_CONSTEXPR
34#endif
35
36// The universal C runtime (UCRT) in the WinSDK provides floating point overloads
37// for std::signbit(). By defining our overloads as templates, we can work around
38// this issue as templates are less preferred than non-template functions.
39template <class = void>
40[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(float __x) _NOEXCEPT {
41 return __builtin_signbit(__x);
42}
43
44template <class = void>
45[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(double __x) _NOEXCEPT {
46 return __builtin_signbit(__x);
47}
48
49template <class = void>
50[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(long double __x) _NOEXCEPT {
33 return __builtin_signbit(__x);51 return __builtin_signbit(__x);
34}52}
3553
36template <class _A1, __enable_if_t<is_integral<_A1>::value && is_signed<_A1>::value, int> = 0>54template <class _A1, __enable_if_t<is_integral<_A1>::value && is_signed<_A1>::value, int> = 0>
37_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {55[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
38 return __x < 0;56 return __x < 0;
39}57}
4058
41template <class _A1, __enable_if_t<is_integral<_A1>::value && !is_signed<_A1>::value, int> = 0>59template <class _A1, __enable_if_t<is_integral<_A1>::value && !is_signed<_A1>::value, int> = 0>
42_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {60[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {
43 return false;61 return false;
44}62}
4563
46// isfinite64// isfinite
4765
48template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0>66template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
49_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT {67[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
50 return __builtin_isfinite((typename __promote<_A1>::type)__x);
51}
52
53template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0>
54_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
55 return true;68 return true;
56}69}
5770
58_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(float __x) _NOEXCEPT {71[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(float __x) _NOEXCEPT {
59 return __builtin_isfinite(__x);72 return __builtin_isfinite(__x);
60}73}
6174
62_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(double __x) _NOEXCEPT {75[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(double __x) _NOEXCEPT {
63 return __builtin_isfinite(__x);76 return __builtin_isfinite(__x);
64}77}
6578
66_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(long double __x) _NOEXCEPT {79[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(long double __x) _NOEXCEPT {
67 return __builtin_isfinite(__x);80 return __builtin_isfinite(__x);
68}81}
6982
70// isinf83// isinf
7184
72template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0>85template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
73_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT {86[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1) _NOEXCEPT {
74 return __builtin_isinf((typename __promote<_A1>::type)__x);
75}
76
77template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0>
78_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1) _NOEXCEPT {
79 return false;87 return false;
80}88}
8189
82#ifdef _LIBCPP_PREFERRED_OVERLOAD90[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT {
83_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT {
84 return __builtin_isinf(__x);91 return __builtin_isinf(__x);
85}92}
8693
87_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool94[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
88isinf(double __x) _NOEXCEPT {95#ifdef _LIBCPP_PREFERRED_OVERLOAD
96_LIBCPP_PREFERRED_OVERLOAD
97#endif
98 bool
99 isinf(double __x) _NOEXCEPT {
89 return __builtin_isinf(__x);100 return __builtin_isinf(__x);
90}101}
91102
92_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT {103[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT {
93 return __builtin_isinf(__x);104 return __builtin_isinf(__x);
94}105}
95#endif
96106
97// isnan107// isnan
98108
99template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>
100_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
101 return __builtin_isnan(__x);
102}
103
104template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>109template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
105_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT {110[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT {
106 return false;111 return false;
107}112}
108113
109#ifdef _LIBCPP_PREFERRED_OVERLOAD114[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT {
110_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT {
111 return __builtin_isnan(__x);115 return __builtin_isnan(__x);
112}116}
113117
114_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool118[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
115isnan(double __x) _NOEXCEPT {119#ifdef _LIBCPP_PREFERRED_OVERLOAD
120_LIBCPP_PREFERRED_OVERLOAD
121#endif
122 bool
123 isnan(double __x) _NOEXCEPT {
116 return __builtin_isnan(__x);124 return __builtin_isnan(__x);
117}125}
118126
119_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT {127[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT {
120 return __builtin_isnan(__x);128 return __builtin_isnan(__x);
121}129}
122#endif
123130
124// isnormal131// isnormal
125132
126template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>133template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
127_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {134[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
135 return __x != 0;
136}
137
138[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(float __x) _NOEXCEPT {
128 return __builtin_isnormal(__x);139 return __builtin_isnormal(__x);
129}140}
130141
131template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>142[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(double __x) _NOEXCEPT {
132_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {143 return __builtin_isnormal(__x);
133 return __x != 0;144}
145
146[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(long double __x) _NOEXCEPT {
147 return __builtin_isnormal(__x);
134}148}
135149
136// isgreater150// isgreater
137151
138template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>152template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
139_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {153[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
140 using type = typename __promote<_A1, _A2>::type;154 using type = typename __promote<_A1, _A2>::type;
141 return __builtin_isgreater((type)__x, (type)__y);155 return __builtin_isgreater((type)__x, (type)__y);
142}156}
...@@ -144,7 +158,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y)...@@ -144,7 +158,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y)
144// isgreaterequal158// isgreaterequal
145159
146template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>160template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
147_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {161[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
148 using type = typename __promote<_A1, _A2>::type;162 using type = typename __promote<_A1, _A2>::type;
149 return __builtin_isgreaterequal((type)__x, (type)__y);163 return __builtin_isgreaterequal((type)__x, (type)__y);
150}164}
...@@ -152,7 +166,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2...@@ -152,7 +166,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2
152// isless166// isless
153167
154template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>168template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
155_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {169[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {
156 using type = typename __promote<_A1, _A2>::type;170 using type = typename __promote<_A1, _A2>::type;
157 return __builtin_isless((type)__x, (type)__y);171 return __builtin_isless((type)__x, (type)__y);
158}172}
...@@ -160,7 +174,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NO...@@ -160,7 +174,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NO
160// islessequal174// islessequal
161175
162template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>176template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
163_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {177[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
164 using type = typename __promote<_A1, _A2>::type;178 using type = typename __promote<_A1, _A2>::type;
165 return __builtin_islessequal((type)__x, (type)__y);179 return __builtin_islessequal((type)__x, (type)__y);
166}180}
...@@ -168,7 +182,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y...@@ -168,7 +182,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y
168// islessgreater182// islessgreater
169183
170template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>184template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
171_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {185[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
172 using type = typename __promote<_A1, _A2>::type;186 using type = typename __promote<_A1, _A2>::type;
173 return __builtin_islessgreater((type)__x, (type)__y);187 return __builtin_islessgreater((type)__x, (type)__y);
174}188}
...@@ -176,7 +190,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 _...@@ -176,7 +190,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 _
176// isunordered190// isunordered
177191
178template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>192template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
179_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {193[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
180 using type = typename __promote<_A1, _A2>::type;194 using type = typename __promote<_A1, _A2>::type;
181 return __builtin_isunordered((type)__x, (type)__y);195 return __builtin_isunordered((type)__x, (type)__y);
182}196}
lib/libcxx/include/__mbstate_t.h+2-2
...@@ -35,7 +35,7 @@...@@ -35,7 +35,7 @@
35# define __CORRECT_ISO_CPP_WCHAR_H_PROTO35# define __CORRECT_ISO_CPP_WCHAR_H_PROTO
36#endif36#endif
3737
38#if defined(_LIBCPP_HAS_MUSL_LIBC)38#if _LIBCPP_HAS_MUSL_LIBC
39# define __NEED_mbstate_t39# define __NEED_mbstate_t
40# include <bits/alltypes.h>40# include <bits/alltypes.h>
41# undef __NEED_mbstate_t41# undef __NEED_mbstate_t
...@@ -43,7 +43,7 @@...@@ -43,7 +43,7 @@
43# include <bits/types/mbstate_t.h> // works on most Unixes43# include <bits/types/mbstate_t.h> // works on most Unixes
44#elif __has_include(<sys/_types/_mbstate_t.h>)44#elif __has_include(<sys/_types/_mbstate_t.h>)
45# include <sys/_types/_mbstate_t.h> // works on Darwin45# include <sys/_types/_mbstate_t.h> // works on Darwin
46#elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) && __has_include_next(<wchar.h>)46#elif _LIBCPP_HAS_WIDE_CHARACTERS && __has_include_next(<wchar.h>)
47# include_next <wchar.h> // fall back to the C standard provider of mbstate_t47# include_next <wchar.h> // fall back to the C standard provider of mbstate_t
48#elif __has_include_next(<uchar.h>)48#elif __has_include_next(<uchar.h>)
49# include_next <uchar.h> // <uchar.h> is also required to make mbstate_t visible49# include_next <uchar.h> // <uchar.h> is also required to make mbstate_t visible
lib/libcxx/include/__mdspan/default_accessor.h+1-2
...@@ -18,12 +18,11 @@...@@ -18,12 +18,11 @@
18#define _LIBCPP___MDSPAN_DEFAULT_ACCESSOR_H18#define _LIBCPP___MDSPAN_DEFAULT_ACCESSOR_H
1919
20#include <__config>20#include <__config>
21#include <__cstddef/size_t.h>
21#include <__type_traits/is_abstract.h>22#include <__type_traits/is_abstract.h>
22#include <__type_traits/is_array.h>23#include <__type_traits/is_array.h>
23#include <__type_traits/is_convertible.h>24#include <__type_traits/is_convertible.h>
24#include <__type_traits/remove_const.h>25#include <__type_traits/remove_const.h>
25#include <cinttypes>
26#include <cstddef>
2726
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header28# pragma GCC system_header
lib/libcxx/include/__mdspan/extents.h+10-9
...@@ -19,6 +19,9 @@...@@ -19,6 +19,9 @@
1919
20#include <__assert>20#include <__assert>
21#include <__config>21#include <__config>
22
23#include <__concepts/arithmetic.h>
24#include <__cstddef/byte.h>
22#include <__type_traits/common_type.h>25#include <__type_traits/common_type.h>
23#include <__type_traits/is_convertible.h>26#include <__type_traits/is_convertible.h>
24#include <__type_traits/is_nothrow_constructible.h>27#include <__type_traits/is_nothrow_constructible.h>
...@@ -27,9 +30,7 @@...@@ -27,9 +30,7 @@
27#include <__utility/integer_sequence.h>30#include <__utility/integer_sequence.h>
28#include <__utility/unreachable.h>31#include <__utility/unreachable.h>
29#include <array>32#include <array>
30#include <cinttypes>
31#include <concepts>33#include <concepts>
32#include <cstddef>
33#include <limits>34#include <limits>
34#include <span>35#include <span>
3536
...@@ -128,14 +129,14 @@ private:...@@ -128,14 +129,14 @@ private:
128 // Static values member129 // Static values member
129 static constexpr size_t __size_ = sizeof...(_Values);130 static constexpr size_t __size_ = sizeof...(_Values);
130 static constexpr size_t __size_dynamic_ = ((_Values == _DynTag) + ... + 0);131 static constexpr size_t __size_dynamic_ = ((_Values == _DynTag) + ... + 0);
131 using _StaticValues = __static_array<_TStatic, _Values...>;132 using _StaticValues _LIBCPP_NODEBUG = __static_array<_TStatic, _Values...>;
132 using _DynamicValues = __possibly_empty_array<_TDynamic, __size_dynamic_>;133 using _DynamicValues _LIBCPP_NODEBUG = __possibly_empty_array<_TDynamic, __size_dynamic_>;
133134
134 // Dynamic values member135 // Dynamic values member
135 _LIBCPP_NO_UNIQUE_ADDRESS _DynamicValues __dyn_vals_;136 _LIBCPP_NO_UNIQUE_ADDRESS _DynamicValues __dyn_vals_;
136137
137 // static mapping of indices to the position in the dynamic values array138 // static mapping of indices to the position in the dynamic values array
138 using _DynamicIdxMap = __static_partial_sums<static_cast<size_t>(_Values == _DynTag)...>;139 using _DynamicIdxMap _LIBCPP_NODEBUG = __static_partial_sums<static_cast<size_t>(_Values == _DynTag)...>;
139140
140 template <size_t... _Indices>141 template <size_t... _Indices>
141 _LIBCPP_HIDE_FROM_ABI static constexpr _DynamicValues __zeros(index_sequence<_Indices...>) noexcept {142 _LIBCPP_HIDE_FROM_ABI static constexpr _DynamicValues __zeros(index_sequence<_Indices...>) noexcept {
...@@ -282,8 +283,7 @@ public:...@@ -282,8 +283,7 @@ public:
282 using size_type = make_unsigned_t<index_type>;283 using size_type = make_unsigned_t<index_type>;
283 using rank_type = size_t;284 using rank_type = size_t;
284285
285 static_assert(is_integral<index_type>::value && !is_same<index_type, bool>::value,286 static_assert(__libcpp_integer<index_type>, "extents::index_type must be a signed or unsigned integer type");
286 "extents::index_type must be a signed or unsigned integer type");
287 static_assert(((__mdspan_detail::__is_representable_as<index_type>(_Extents) || (_Extents == dynamic_extent)) && ...),287 static_assert(((__mdspan_detail::__is_representable_as<index_type>(_Extents) || (_Extents == dynamic_extent)) && ...),
288 "extents ctor: arguments must be representable as index_type and nonnegative");288 "extents ctor: arguments must be representable as index_type and nonnegative");
289289
...@@ -292,7 +292,8 @@ private:...@@ -292,7 +292,8 @@ private:
292 static constexpr rank_type __rank_dynamic_ = ((_Extents == dynamic_extent) + ... + 0);292 static constexpr rank_type __rank_dynamic_ = ((_Extents == dynamic_extent) + ... + 0);
293293
294 // internal storage type using __maybe_static_array294 // internal storage type using __maybe_static_array
295 using _Values = __mdspan_detail::__maybe_static_array<_IndexType, size_t, dynamic_extent, _Extents...>;295 using _Values _LIBCPP_NODEBUG =
296 __mdspan_detail::__maybe_static_array<_IndexType, size_t, dynamic_extent, _Extents...>;
296 [[no_unique_address]] _Values __vals_;297 [[no_unique_address]] _Values __vals_;
297298
298public:299public:
...@@ -448,7 +449,7 @@ struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> {...@@ -448,7 +449,7 @@ struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> {
448 using type = extents<_IndexType, _ExtentsPack...>;449 using type = extents<_IndexType, _ExtentsPack...>;
449};450};
450451
451} // end namespace __mdspan_detail452} // namespace __mdspan_detail
452453
453// [mdspan.extents.dextents], alias template454// [mdspan.extents.dextents], alias template
454template <class _IndexType, size_t _Rank>455template <class _IndexType, size_t _Rank>
lib/libcxx/include/__mdspan/layout_left.h+1-3
...@@ -21,14 +21,12 @@...@@ -21,14 +21,12 @@
21#include <__config>21#include <__config>
22#include <__fwd/mdspan.h>22#include <__fwd/mdspan.h>
23#include <__mdspan/extents.h>23#include <__mdspan/extents.h>
24#include <__type_traits/common_type.h>
24#include <__type_traits/is_constructible.h>25#include <__type_traits/is_constructible.h>
25#include <__type_traits/is_convertible.h>26#include <__type_traits/is_convertible.h>
26#include <__type_traits/is_nothrow_constructible.h>27#include <__type_traits/is_nothrow_constructible.h>
27#include <__utility/integer_sequence.h>28#include <__utility/integer_sequence.h>
28#include <array>29#include <array>
29#include <cinttypes>
30#include <cstddef>
31#include <limits>
3230
33#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)31#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
34# pragma GCC system_header32# pragma GCC system_header
lib/libcxx/include/__mdspan/layout_right.h+2-3
...@@ -19,15 +19,14 @@...@@ -19,15 +19,14 @@
1919
20#include <__assert>20#include <__assert>
21#include <__config>21#include <__config>
22#include <__cstddef/size_t.h>
22#include <__fwd/mdspan.h>23#include <__fwd/mdspan.h>
23#include <__mdspan/extents.h>24#include <__mdspan/extents.h>
25#include <__type_traits/common_type.h>
24#include <__type_traits/is_constructible.h>26#include <__type_traits/is_constructible.h>
25#include <__type_traits/is_convertible.h>27#include <__type_traits/is_convertible.h>
26#include <__type_traits/is_nothrow_constructible.h>28#include <__type_traits/is_nothrow_constructible.h>
27#include <__utility/integer_sequence.h>29#include <__utility/integer_sequence.h>
28#include <cinttypes>
29#include <cstddef>
30#include <limits>
3130
32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)31#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
33# pragma GCC system_header32# pragma GCC system_header
lib/libcxx/include/__mdspan/layout_stride.h+5-2
...@@ -18,19 +18,22 @@...@@ -18,19 +18,22 @@
18#define _LIBCPP___MDSPAN_LAYOUT_STRIDE_H18#define _LIBCPP___MDSPAN_LAYOUT_STRIDE_H
1919
20#include <__assert>20#include <__assert>
21#include <__concepts/same_as.h>
21#include <__config>22#include <__config>
22#include <__fwd/mdspan.h>23#include <__fwd/mdspan.h>
23#include <__mdspan/extents.h>24#include <__mdspan/extents.h>
25#include <__type_traits/common_type.h>
24#include <__type_traits/is_constructible.h>26#include <__type_traits/is_constructible.h>
25#include <__type_traits/is_convertible.h>27#include <__type_traits/is_convertible.h>
28#include <__type_traits/is_integral.h>
26#include <__type_traits/is_nothrow_constructible.h>29#include <__type_traits/is_nothrow_constructible.h>
30#include <__type_traits/is_same.h>
27#include <__utility/as_const.h>31#include <__utility/as_const.h>
28#include <__utility/integer_sequence.h>32#include <__utility/integer_sequence.h>
29#include <__utility/swap.h>33#include <__utility/swap.h>
30#include <array>34#include <array>
31#include <cinttypes>
32#include <cstddef>
33#include <limits>35#include <limits>
36#include <span>
3437
35#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
36# pragma GCC system_header39# pragma GCC system_header
lib/libcxx/include/__mdspan/mdspan.h-3
...@@ -37,9 +37,6 @@...@@ -37,9 +37,6 @@
37#include <__type_traits/remove_reference.h>37#include <__type_traits/remove_reference.h>
38#include <__utility/integer_sequence.h>38#include <__utility/integer_sequence.h>
39#include <array>39#include <array>
40#include <cinttypes>
41#include <cstddef>
42#include <limits>
43#include <span>40#include <span>
4441
45#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)42#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__memory/addressof.h+3-5
...@@ -23,17 +23,15 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* a...@@ -23,17 +23,15 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* a
23 return __builtin_addressof(__x);23 return __builtin_addressof(__x);
24}24}
2525
26#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)26#if _LIBCPP_HAS_OBJC_ARC
27// Objective-C++ Automatic Reference Counting uses qualified pointers27// Objective-C++ Automatic Reference Counting uses qualified pointers
28// that require special addressof() signatures. When28// that require special addressof() signatures.
29// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
30// itself is providing these definitions. Otherwise, we provide them.
31template <class _Tp>29template <class _Tp>
32inline _LIBCPP_HIDE_FROM_ABI __strong _Tp* addressof(__strong _Tp& __x) _NOEXCEPT {30inline _LIBCPP_HIDE_FROM_ABI __strong _Tp* addressof(__strong _Tp& __x) _NOEXCEPT {
33 return &__x;31 return &__x;
34}32}
3533
36# ifdef _LIBCPP_HAS_OBJC_ARC_WEAK34# if _LIBCPP_HAS_OBJC_ARC_WEAK
37template <class _Tp>35template <class _Tp>
38inline _LIBCPP_HIDE_FROM_ABI __weak _Tp* addressof(__weak _Tp& __x) _NOEXCEPT {36inline _LIBCPP_HIDE_FROM_ABI __weak _Tp* addressof(__weak _Tp& __x) _NOEXCEPT {
39 return &__x;37 return &__x;
lib/libcxx/include/__memory/align.h+1-1
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#define _LIBCPP___MEMORY_ALIGN_H10#define _LIBCPP___MEMORY_ALIGN_H
1111
12#include <__config>12#include <__config>
13#include <cstddef>13#include <__cstddef/size_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
lib/libcxx/include/__memory/aligned_alloc.h+3-4
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___MEMORY_ALIGNED_ALLOC_H10#define _LIBCPP___MEMORY_ALIGNED_ALLOC_H
1111
12#include <__config>12#include <__config>
13#include <cstddef>
14#include <cstdlib>13#include <cstdlib>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -19,7 +18,7 @@...@@ -19,7 +18,7 @@
1918
20_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2120
22#ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION21#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
2322
24// Low-level helpers to call the aligned allocation and deallocation functions23// Low-level helpers to call the aligned allocation and deallocation functions
25// on the target platform. This is used to implement libc++'s own memory24// on the target platform. This is used to implement libc++'s own memory
...@@ -30,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -30,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
30inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {29inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
31# if defined(_LIBCPP_MSVCRT_LIKE)30# if defined(_LIBCPP_MSVCRT_LIKE)
32 return ::_aligned_malloc(__size, __alignment);31 return ::_aligned_malloc(__size, __alignment);
33# elif _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_C11_ALIGNED_ALLOC)32# elif _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_C11_ALIGNED_ALLOC
34 // aligned_alloc() requires that __size is a multiple of __alignment,33 // aligned_alloc() requires that __size is a multiple of __alignment,
35 // but for C++ [new.delete.general], only states "if the value of an34 // but for C++ [new.delete.general], only states "if the value of an
36 // alignment argument passed to any of these functions is not a valid35 // alignment argument passed to any of these functions is not a valid
...@@ -57,7 +56,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_aligned_free(void* __ptr) {...@@ -57,7 +56,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_aligned_free(void* __ptr) {
57# endif56# endif
58}57}
5958
60#endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION59#endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
6160
62_LIBCPP_END_NAMESPACE_STD61_LIBCPP_END_NAMESPACE_STD
6362
lib/libcxx/include/__memory/allocate_at_least.h+2-2
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H10#define _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__memory/allocator_traits.h>14#include <__memory/allocator_traits.h>
14#include <cstddef>
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
...@@ -35,7 +35,7 @@ struct __allocation_result {...@@ -35,7 +35,7 @@ struct __allocation_result {
35};35};
3636
37template <class _Alloc>37template <class _Alloc>
38_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI38[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI
39_LIBCPP_CONSTEXPR __allocation_result<typename allocator_traits<_Alloc>::pointer>39_LIBCPP_CONSTEXPR __allocation_result<typename allocator_traits<_Alloc>::pointer>
40__allocate_at_least(_Alloc& __alloc, size_t __n) {40__allocate_at_least(_Alloc& __alloc, size_t __n) {
41 return {__alloc.allocate(__n), __n};41 return {__alloc.allocate(__n), __n};
lib/libcxx/include/__memory/allocation_guard.h+2-3
...@@ -14,7 +14,6 @@...@@ -14,7 +14,6 @@
14#include <__memory/addressof.h>14#include <__memory/addressof.h>
15#include <__memory/allocator_traits.h>15#include <__memory/allocator_traits.h>
16#include <__utility/move.h>16#include <__utility/move.h>
17#include <cstddef>
1817
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header19# pragma GCC system_header
...@@ -46,8 +45,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -46,8 +45,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
46// custom allocator.45// custom allocator.
47template <class _Alloc>46template <class _Alloc>
48struct __allocation_guard {47struct __allocation_guard {
49 using _Pointer = typename allocator_traits<_Alloc>::pointer;48 using _Pointer _LIBCPP_NODEBUG = typename allocator_traits<_Alloc>::pointer;
50 using _Size = typename allocator_traits<_Alloc>::size_type;49 using _Size _LIBCPP_NODEBUG = typename allocator_traits<_Alloc>::size_type;
5150
52 template <class _AllocT> // we perform the allocator conversion inside the constructor51 template <class _AllocT> // we perform the allocator conversion inside the constructor
53 _LIBCPP_HIDE_FROM_ABI explicit __allocation_guard(_AllocT __alloc, _Size __n)52 _LIBCPP_HIDE_FROM_ABI explicit __allocation_guard(_AllocT __alloc, _Size __n)
lib/libcxx/include/__memory/allocator.h+11-102
...@@ -11,17 +11,19 @@...@@ -11,17 +11,19 @@
11#define _LIBCPP___MEMORY_ALLOCATOR_H11#define _LIBCPP___MEMORY_ALLOCATOR_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
15#include <__cstddef/size_t.h>
14#include <__memory/addressof.h>16#include <__memory/addressof.h>
15#include <__memory/allocate_at_least.h>17#include <__memory/allocate_at_least.h>
16#include <__memory/allocator_traits.h>18#include <__memory/allocator_traits.h>
19#include <__new/allocate.h>
20#include <__new/exceptions.h>
17#include <__type_traits/is_const.h>21#include <__type_traits/is_const.h>
18#include <__type_traits/is_constant_evaluated.h>22#include <__type_traits/is_constant_evaluated.h>
19#include <__type_traits/is_same.h>23#include <__type_traits/is_same.h>
20#include <__type_traits/is_void.h>24#include <__type_traits/is_void.h>
21#include <__type_traits/is_volatile.h>25#include <__type_traits/is_volatile.h>
22#include <__utility/forward.h>26#include <__utility/forward.h>
23#include <cstddef>
24#include <new>
2527
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header29# pragma GCC system_header
...@@ -47,23 +49,7 @@ public:...@@ -47,23 +49,7 @@ public:
47 typedef allocator<_Up> other;49 typedef allocator<_Up> other;
48 };50 };
49};51};
5052#endif // _LIBCPP_STD_VER <= 17
51// TODO(LLVM 20): Remove the escape hatch
52# ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST
53template <>
54class _LIBCPP_TEMPLATE_VIS allocator<const void> {
55public:
56 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer;
57 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;
58 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void value_type;
59
60 template <class _Up>
61 struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
62 typedef allocator<_Up> other;
63 };
64};
65# endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST
66#endif // _LIBCPP_STD_VER <= 17
6753
68// This class provides a non-trivial default constructor to the class that derives from it54// This class provides a non-trivial default constructor to the class that derives from it
69// if the condition is satisfied.55// if the condition is satisfied.
...@@ -109,18 +95,20 @@ public:...@@ -109,18 +95,20 @@ public:
109 template <class _Up>95 template <class _Up>
110 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {}96 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {}
11197
112 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) {98 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) {
99 static_assert(sizeof(_Tp) >= 0, "cannot allocate memory for an incomplete type");
113 if (__n > allocator_traits<allocator>::max_size(*this))100 if (__n > allocator_traits<allocator>::max_size(*this))
114 __throw_bad_array_new_length();101 __throw_bad_array_new_length();
115 if (__libcpp_is_constant_evaluated()) {102 if (__libcpp_is_constant_evaluated()) {
116 return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));103 return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
117 } else {104 } else {
118 return static_cast<_Tp*>(std::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));105 return std::__libcpp_allocate<_Tp>(__element_count(__n));
119 }106 }
120 }107 }
121108
122#if _LIBCPP_STD_VER >= 23109#if _LIBCPP_STD_VER >= 23
123 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<_Tp*> allocate_at_least(size_t __n) {110 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<_Tp*> allocate_at_least(size_t __n) {
111 static_assert(sizeof(_Tp) >= 0, "cannot allocate memory for an incomplete type");
124 return {allocate(__n), __n};112 return {allocate(__n), __n};
125 }113 }
126#endif114#endif
...@@ -129,7 +117,7 @@ public:...@@ -129,7 +117,7 @@ public:
129 if (__libcpp_is_constant_evaluated()) {117 if (__libcpp_is_constant_evaluated()) {
130 ::operator delete(__p);118 ::operator delete(__p);
131 } else {119 } else {
132 std::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));120 std::__libcpp_deallocate<_Tp>(__p, __element_count(__n));
133 }121 }
134 }122 }
135123
...@@ -152,7 +140,7 @@ public:...@@ -152,7 +140,7 @@ public:
152 return std::addressof(__x);140 return std::addressof(__x);
153 }141 }
154142
155 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 _Tp* allocate(size_t __n, const void*) {143 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 _Tp* allocate(size_t __n, const void*) {
156 return allocate(__n);144 return allocate(__n);
157 }145 }
158146
...@@ -169,85 +157,6 @@ public:...@@ -169,85 +157,6 @@ public:
169#endif157#endif
170};158};
171159
172// TODO(LLVM 20): Remove the escape hatch
173#ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST
174template <class _Tp>
175class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>
176 : private __non_trivial_if<!is_void<_Tp>::value, allocator<const _Tp> > {
177 static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types");
178
179public:
180 typedef size_t size_type;
181 typedef ptrdiff_t difference_type;
182 typedef const _Tp value_type;
183 typedef true_type propagate_on_container_move_assignment;
184# if _LIBCPP_STD_VER <= 23 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS)
185 _LIBCPP_DEPRECATED_IN_CXX23 typedef true_type is_always_equal;
186# endif
187
188 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator() _NOEXCEPT = default;
189
190 template <class _Up>
191 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {}
192
193 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const _Tp* allocate(size_t __n) {
194 if (__n > allocator_traits<allocator>::max_size(*this))
195 __throw_bad_array_new_length();
196 if (__libcpp_is_constant_evaluated()) {
197 return static_cast<const _Tp*>(::operator new(__n * sizeof(_Tp)));
198 } else {
199 return static_cast<const _Tp*>(std::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
200 }
201 }
202
203# if _LIBCPP_STD_VER >= 23
204 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<const _Tp*> allocate_at_least(size_t __n) {
205 return {allocate(__n), __n};
206 }
207# endif
208
209 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void deallocate(const _Tp* __p, size_t __n) {
210 if (__libcpp_is_constant_evaluated()) {
211 ::operator delete(const_cast<_Tp*>(__p));
212 } else {
213 std::__libcpp_deallocate((void*)const_cast<_Tp*>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
214 }
215 }
216
217 // C++20 Removed members
218# if _LIBCPP_STD_VER <= 17
219 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer;
220 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
221 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference;
222 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
223
224 template <class _Up>
225 struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
226 typedef allocator<_Up> other;
227 };
228
229 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI const_pointer address(const_reference __x) const _NOEXCEPT {
230 return std::addressof(__x);
231 }
232
233 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 const _Tp* allocate(size_t __n, const void*) {
234 return allocate(__n);
235 }
236
237 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
238 return size_type(~0) / sizeof(_Tp);
239 }
240
241 template <class _Up, class... _Args>
242 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void construct(_Up* __p, _Args&&... __args) {
243 ::new ((void*)__p) _Up(std::forward<_Args>(__args)...);
244 }
245
246 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void destroy(pointer __p) { __p->~_Tp(); }
247# endif
248};
249#endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST
250
251template <class _Tp, class _Up>160template <class _Tp, class _Up>
252inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool161inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
253operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {162operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {
lib/libcxx/include/__memory/allocator_arg_t.h+7-7
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP___FUNCTIONAL_ALLOCATOR_ARG_T_H10#ifndef _LIBCPP___MEMORY_ALLOCATOR_ARG_T_H
11#define _LIBCPP___FUNCTIONAL_ALLOCATOR_ARG_T_H11#define _LIBCPP___MEMORY_ALLOCATOR_ARG_T_H
1212
13#include <__config>13#include <__config>
14#include <__memory/uses_allocator.h>14#include <__memory/uses_allocator.h>
...@@ -39,10 +39,10 @@ constexpr allocator_arg_t allocator_arg = allocator_arg_t();...@@ -39,10 +39,10 @@ constexpr allocator_arg_t allocator_arg = allocator_arg_t();
3939
40template <class _Tp, class _Alloc, class... _Args>40template <class _Tp, class _Alloc, class... _Args>
41struct __uses_alloc_ctor_imp {41struct __uses_alloc_ctor_imp {
42 typedef _LIBCPP_NODEBUG __remove_cvref_t<_Alloc> _RawAlloc;42 using _RawAlloc _LIBCPP_NODEBUG = __remove_cvref_t<_Alloc>;
43 static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;43 static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
44 static const bool __ic = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;44 static const bool __ic = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
45 static const int value = __ua ? 2 - __ic : 0;45 static const int value = __ua ? 2 - __ic : 0;
46};46};
4747
48template <class _Tp, class _Alloc, class... _Args>48template <class _Tp, class _Alloc, class... _Args>
...@@ -72,4 +72,4 @@ __user_alloc_construct_impl(integral_constant<int, 2>, _Tp* __storage, const _Al...@@ -72,4 +72,4 @@ __user_alloc_construct_impl(integral_constant<int, 2>, _Tp* __storage, const _Al
7272
73_LIBCPP_END_NAMESPACE_STD73_LIBCPP_END_NAMESPACE_STD
7474
75#endif // _LIBCPP___FUNCTIONAL_ALLOCATOR_ARG_T_H75#endif // _LIBCPP___MEMORY_ALLOCATOR_ARG_T_H
lib/libcxx/include/__memory/allocator_destructor.h+3-3
...@@ -20,11 +20,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -20,11 +20,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Alloc>21template <class _Alloc>
22class __allocator_destructor {22class __allocator_destructor {
23 typedef _LIBCPP_NODEBUG allocator_traits<_Alloc> __alloc_traits;23 using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<_Alloc>;
2424
25public:25public:
26 typedef _LIBCPP_NODEBUG typename __alloc_traits::pointer pointer;26 using pointer _LIBCPP_NODEBUG = typename __alloc_traits::pointer;
27 typedef _LIBCPP_NODEBUG typename __alloc_traits::size_type size_type;27 using size_type _LIBCPP_NODEBUG = typename __alloc_traits::size_type;
2828
29private:29private:
30 _Alloc& __alloc_;30 _Alloc& __alloc_;
lib/libcxx/include/__memory/allocator_traits.h+53-63
...@@ -11,8 +11,11 @@...@@ -11,8 +11,11 @@
11#define _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H11#define _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/size_t.h>
15#include <__fwd/memory.h>
14#include <__memory/construct_at.h>16#include <__memory/construct_at.h>
15#include <__memory/pointer_traits.h>17#include <__memory/pointer_traits.h>
18#include <__type_traits/detected_or.h>
16#include <__type_traits/enable_if.h>19#include <__type_traits/enable_if.h>
17#include <__type_traits/is_constructible.h>20#include <__type_traits/is_constructible.h>
18#include <__type_traits/is_empty.h>21#include <__type_traits/is_empty.h>
...@@ -22,7 +25,6 @@...@@ -22,7 +25,6 @@
22#include <__type_traits/void_t.h>25#include <__type_traits/void_t.h>
23#include <__utility/declval.h>26#include <__utility/declval.h>
24#include <__utility/forward.h>27#include <__utility/forward.h>
25#include <cstddef>
26#include <limits>28#include <limits>
2729
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -41,17 +43,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -41,17 +43,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
41 struct NAME<_Tp, __void_t<typename _Tp::PROPERTY > > : true_type {}43 struct NAME<_Tp, __void_t<typename _Tp::PROPERTY > > : true_type {}
4244
43// __pointer45// __pointer
44template <class _Tp,46template <class _Tp>
45 class _Alloc,47using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer;
46 class _RawAlloc = __libcpp_remove_reference_t<_Alloc>,48
47 bool = __has_pointer<_RawAlloc>::value>49template <class _Tp, class _Alloc>
48struct __pointer {50using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp*, __pointer_member, __libcpp_remove_reference_t<_Alloc> >;
49 using type _LIBCPP_NODEBUG = typename _RawAlloc::pointer;
50};
51template <class _Tp, class _Alloc, class _RawAlloc>
52struct __pointer<_Tp, _Alloc, _RawAlloc, false> {
53 using type _LIBCPP_NODEBUG = _Tp*;
54};
5551
56// __const_pointer52// __const_pointer
57_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer);53_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer);
...@@ -62,7 +58,7 @@ struct __const_pointer {...@@ -62,7 +58,7 @@ struct __const_pointer {
62template <class _Tp, class _Ptr, class _Alloc>58template <class _Tp, class _Ptr, class _Alloc>
63struct __const_pointer<_Tp, _Ptr, _Alloc, false> {59struct __const_pointer<_Tp, _Ptr, _Alloc, false> {
64#ifdef _LIBCPP_CXX03_LANG60#ifdef _LIBCPP_CXX03_LANG
65 using type = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other;61 using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other;
66#else62#else
67 using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>;63 using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>;
68#endif64#endif
...@@ -99,13 +95,11 @@ struct __const_void_pointer<_Ptr, _Alloc, false> {...@@ -99,13 +95,11 @@ struct __const_void_pointer<_Ptr, _Alloc, false> {
99};95};
10096
101// __size_type97// __size_type
102_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_size_type, size_type);98template <class _Tp>
103template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value>99using __size_type_member _LIBCPP_NODEBUG = typename _Tp::size_type;
104struct __size_type : make_unsigned<_DiffType> {};100
105template <class _Alloc, class _DiffType>101template <class _Alloc, class _DiffType>
106struct __size_type<_Alloc, _DiffType, true> {102using __size_type _LIBCPP_NODEBUG = __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>;
107 using type _LIBCPP_NODEBUG = typename _Alloc::size_type;
108};
109103
110// __alloc_traits_difference_type104// __alloc_traits_difference_type
111_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type);105_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type);
...@@ -119,40 +113,38 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true> {...@@ -119,40 +113,38 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true> {
119};113};
120114
121// __propagate_on_container_copy_assignment115// __propagate_on_container_copy_assignment
122_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_copy_assignment, propagate_on_container_copy_assignment);116template <class _Tp>
123template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value>117using __propagate_on_container_copy_assignment_member _LIBCPP_NODEBUG =
124struct __propagate_on_container_copy_assignment : false_type {};118 typename _Tp::propagate_on_container_copy_assignment;
119
125template <class _Alloc>120template <class _Alloc>
126struct __propagate_on_container_copy_assignment<_Alloc, true> {121using __propagate_on_container_copy_assignment _LIBCPP_NODEBUG =
127 using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_copy_assignment;122 __detected_or_t<false_type, __propagate_on_container_copy_assignment_member, _Alloc>;
128};
129123
130// __propagate_on_container_move_assignment124// __propagate_on_container_move_assignment
131_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_move_assignment, propagate_on_container_move_assignment);125template <class _Tp>
132template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value>126using __propagate_on_container_move_assignment_member _LIBCPP_NODEBUG =
133struct __propagate_on_container_move_assignment : false_type {};127 typename _Tp::propagate_on_container_move_assignment;
128
134template <class _Alloc>129template <class _Alloc>
135struct __propagate_on_container_move_assignment<_Alloc, true> {130using __propagate_on_container_move_assignment _LIBCPP_NODEBUG =
136 using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_move_assignment;131 __detected_or_t<false_type, __propagate_on_container_move_assignment_member, _Alloc>;
137};
138132
139// __propagate_on_container_swap133// __propagate_on_container_swap
140_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_swap, propagate_on_container_swap);134template <class _Tp>
141template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value>135using __propagate_on_container_swap_member _LIBCPP_NODEBUG = typename _Tp::propagate_on_container_swap;
142struct __propagate_on_container_swap : false_type {};136
143template <class _Alloc>137template <class _Alloc>
144struct __propagate_on_container_swap<_Alloc, true> {138using __propagate_on_container_swap _LIBCPP_NODEBUG =
145 using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_swap;139 __detected_or_t<false_type, __propagate_on_container_swap_member, _Alloc>;
146};
147140
148// __is_always_equal141// __is_always_equal
149_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_is_always_equal, is_always_equal);142template <class _Tp>
150template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value>143using __is_always_equal_member _LIBCPP_NODEBUG = typename _Tp::is_always_equal;
151struct __is_always_equal : is_empty<_Alloc> {};144
152template <class _Alloc>145template <class _Alloc>
153struct __is_always_equal<_Alloc, true> {146using __is_always_equal _LIBCPP_NODEBUG =
154 using type _LIBCPP_NODEBUG = typename _Alloc::is_always_equal;147 __detected_or_t<typename is_empty<_Alloc>::type, __is_always_equal_member, _Alloc>;
155};
156148
157// __allocator_traits_rebind149// __allocator_traits_rebind
158_LIBCPP_SUPPRESS_DEPRECATED_PUSH150_LIBCPP_SUPPRESS_DEPRECATED_PUSH
...@@ -177,7 +169,7 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> {...@@ -177,7 +169,7 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> {
177_LIBCPP_SUPPRESS_DEPRECATED_POP169_LIBCPP_SUPPRESS_DEPRECATED_POP
178170
179template <class _Alloc, class _Tp>171template <class _Alloc, class _Tp>
180using __allocator_traits_rebind_t = typename __allocator_traits_rebind<_Alloc, _Tp>::type;172using __allocator_traits_rebind_t _LIBCPP_NODEBUG = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
181173
182_LIBCPP_SUPPRESS_DEPRECATED_PUSH174_LIBCPP_SUPPRESS_DEPRECATED_PUSH
183175
...@@ -244,20 +236,18 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);...@@ -244,20 +236,18 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);
244236
245template <class _Alloc>237template <class _Alloc>
246struct _LIBCPP_TEMPLATE_VIS allocator_traits {238struct _LIBCPP_TEMPLATE_VIS allocator_traits {
247 using allocator_type = _Alloc;239 using allocator_type = _Alloc;
248 using value_type = typename allocator_type::value_type;240 using value_type = typename allocator_type::value_type;
249 using pointer = typename __pointer<value_type, allocator_type>::type;241 using pointer = __pointer<value_type, allocator_type>;
250 using const_pointer = typename __const_pointer<value_type, pointer, allocator_type>::type;242 using const_pointer = typename __const_pointer<value_type, pointer, allocator_type>::type;
251 using void_pointer = typename __void_pointer<pointer, allocator_type>::type;243 using void_pointer = typename __void_pointer<pointer, allocator_type>::type;
252 using const_void_pointer = typename __const_void_pointer<pointer, allocator_type>::type;244 using const_void_pointer = typename __const_void_pointer<pointer, allocator_type>::type;
253 using difference_type = typename __alloc_traits_difference_type<allocator_type, pointer>::type;245 using difference_type = typename __alloc_traits_difference_type<allocator_type, pointer>::type;
254 using size_type = typename __size_type<allocator_type, difference_type>::type;246 using size_type = __size_type<allocator_type, difference_type>;
255 using propagate_on_container_copy_assignment =247 using propagate_on_container_copy_assignment = __propagate_on_container_copy_assignment<allocator_type>;
256 typename __propagate_on_container_copy_assignment<allocator_type>::type;248 using propagate_on_container_move_assignment = __propagate_on_container_move_assignment<allocator_type>;
257 using propagate_on_container_move_assignment =249 using propagate_on_container_swap = __propagate_on_container_swap<allocator_type>;
258 typename __propagate_on_container_move_assignment<allocator_type>::type;250 using is_always_equal = __is_always_equal<allocator_type>;
259 using propagate_on_container_swap = typename __propagate_on_container_swap<allocator_type>::type;
260 using is_always_equal = typename __is_always_equal<allocator_type>::type;
261251
262#ifndef _LIBCPP_CXX03_LANG252#ifndef _LIBCPP_CXX03_LANG
263 template <class _Tp>253 template <class _Tp>
...@@ -275,13 +265,13 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {...@@ -275,13 +265,13 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
275 };265 };
276#endif // _LIBCPP_CXX03_LANG266#endif // _LIBCPP_CXX03_LANG
277267
278 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer268 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
279 allocate(allocator_type& __a, size_type __n) {269 allocate(allocator_type& __a, size_type __n) {
280 return __a.allocate(__n);270 return __a.allocate(__n);
281 }271 }
282272
283 template <class _Ap = _Alloc, __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0>273 template <class _Ap = _Alloc, __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0>
284 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer274 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
285 allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) {275 allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) {
286 _LIBCPP_SUPPRESS_DEPRECATED_PUSH276 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
287 return __a.allocate(__n, __hint);277 return __a.allocate(__n, __hint);
...@@ -290,7 +280,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {...@@ -290,7 +280,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
290 template <class _Ap = _Alloc,280 template <class _Ap = _Alloc,
291 class = void,281 class = void,
292 __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0>282 __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0>
293 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer283 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
294 allocate(allocator_type& __a, size_type __n, const_void_pointer) {284 allocate(allocator_type& __a, size_type __n, const_void_pointer) {
295 return __a.allocate(__n);285 return __a.allocate(__n);
296 }286 }
...@@ -369,12 +359,12 @@ template <class _Traits, class _Tp>...@@ -369,12 +359,12 @@ template <class _Traits, class _Tp>
369using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>;359using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>;
370#else360#else
371template <class _Traits, class _Tp>361template <class _Traits, class _Tp>
372using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>::other;362using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>::other;
373#endif363#endif
374364
375template <class _Alloc>365template <class _Alloc>
376struct __check_valid_allocator : true_type {366struct __check_valid_allocator : true_type {
377 using _Traits = std::allocator_traits<_Alloc>;367 using _Traits _LIBCPP_NODEBUG = std::allocator_traits<_Alloc>;
378 static_assert(is_same<_Alloc, __rebind_alloc<_Traits, typename _Traits::value_type> >::value,368 static_assert(is_same<_Alloc, __rebind_alloc<_Traits, typename _Traits::value_type> >::value,
379 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "369 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
380 "original allocator");370 "original allocator");
lib/libcxx/include/__memory/array_cookie.h created+55
...@@ -0,0 +1,55 @@
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_ARRAY_COOKIE_H
11#define _LIBCPP___MEMORY_ARRAY_COOKIE_H
12
13#include <__config>
14#include <__configuration/abi.h>
15#include <__cstddef/size_t.h>
16#include <__type_traits/integral_constant.h>
17#include <__type_traits/is_trivially_destructible.h>
18#include <__type_traits/negation.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// Trait representing whether a type requires an array cookie at the start of its allocation when
27// allocated as `new T[n]` and deallocated as `delete[] array`.
28//
29// Under the Itanium C++ ABI [1], we know that an array cookie is available unless `T` is trivially
30// destructible and the call to `operator delete[]` is not a sized operator delete. Under ABIs other
31// than the Itanium ABI, we assume there are no array cookies.
32//
33// [1]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#array-cookies
34#ifdef _LIBCPP_ABI_ITANIUM
35// TODO: Use a builtin instead
36// TODO: We should factor in the choice of the usual deallocation function in this determination.
37template <class _Tp>
38struct __has_array_cookie : _Not<is_trivially_destructible<_Tp> > {};
39#else
40template <class _Tp>
41struct __has_array_cookie : false_type {};
42#endif
43
44template <class _Tp>
45// Avoid failures when -fsanitize-address-poison-custom-array-cookie is enabled
46_LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") size_t __get_array_cookie(_Tp const* __ptr) {
47 static_assert(
48 __has_array_cookie<_Tp>::value, "Trying to access the array cookie of a type that is not guaranteed to have one");
49 size_t const* __cookie = reinterpret_cast<size_t const*>(__ptr) - 1; // TODO: Use a builtin instead
50 return *__cookie;
51}
52
53_LIBCPP_END_NAMESPACE_STD
54
55#endif // _LIBCPP___MEMORY_ARRAY_COOKIE_H
lib/libcxx/include/__memory/assume_aligned.h+2-2
...@@ -12,8 +12,8 @@...@@ -12,8 +12,8 @@
1212
13#include <__assert>13#include <__assert>
14#include <__config>14#include <__config>
15#include <__cstddef/size_t.h>
15#include <__type_traits/is_constant_evaluated.h>16#include <__type_traits/is_constant_evaluated.h>
16#include <cstddef>
17#include <cstdint>17#include <cstdint>
1818
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -23,7 +23,7 @@...@@ -23,7 +23,7 @@
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25template <size_t _Np, class _Tp>25template <size_t _Np, class _Tp>
26_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __assume_aligned(_Tp* __ptr) {26[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __assume_aligned(_Tp* __ptr) {
27 static_assert(_Np != 0 && (_Np & (_Np - 1)) == 0, "std::assume_aligned<N>(p) requires N to be a power of two");27 static_assert(_Np != 0 && (_Np & (_Np - 1)) == 0, "std::assume_aligned<N>(p) requires N to be a power of two");
2828
29 if (__libcpp_is_constant_evaluated()) {29 if (__libcpp_is_constant_evaluated()) {
lib/libcxx/include/__memory/builtin_new_allocator.h deleted-67
...@@ -1,67 +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___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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __builtin_new_deleter(size_t __size, size_t __align)
32 : __size_(__size), __align_(__align) {}
33
34 _LIBCPP_HIDE_FROM_ABI void operator()(void* __p) const _NOEXCEPT {
35 std::__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 _LIBCPP_HIDE_FROM_ABI static __holder_t __allocate_bytes(size_t __s, size_t __align) {
46 return __holder_t(std::__libcpp_allocate(__s, __align), __builtin_new_deleter(__s, __align));
47 }
48
49 _LIBCPP_HIDE_FROM_ABI static void __deallocate_bytes(void* __p, size_t __s, size_t __align) _NOEXCEPT {
50 std::__libcpp_deallocate(__p, __s, __align);
51 }
52
53 template <class _Tp>
54 _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI static __holder_t __allocate_type(size_t __n) {
55 return __allocate_bytes(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
56 }
57
58 template <class _Tp>
59 _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI static void
60 __deallocate_type(void* __p, size_t __n) _NOEXCEPT {
61 __deallocate_bytes(__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
62 }
63};
64
65_LIBCPP_END_NAMESPACE_STD
66
67#endif // _LIBCPP___MEMORY_BUILTIN_NEW_ALLOCATOR_H
lib/libcxx/include/__memory/compressed_pair.h+72-138
...@@ -11,161 +11,95 @@...@@ -11,161 +11,95 @@
11#define _LIBCPP___MEMORY_COMPRESSED_PAIR_H11#define _LIBCPP___MEMORY_COMPRESSED_PAIR_H
1212
13#include <__config>13#include <__config>
14#include <__fwd/tuple.h>14#include <__cstddef/size_t.h>
15#include <__tuple/tuple_indices.h>15#include <__type_traits/datasizeof.h>
16#include <__type_traits/decay.h>
17#include <__type_traits/dependent_type.h>
18#include <__type_traits/enable_if.h>
19#include <__type_traits/is_constructible.h>
20#include <__type_traits/is_empty.h>16#include <__type_traits/is_empty.h>
21#include <__type_traits/is_final.h>17#include <__type_traits/is_final.h>
22#include <__type_traits/is_same.h>18#include <__type_traits/is_reference.h>
23#include <__type_traits/is_swappable.h>
24#include <__utility/forward.h>
25#include <__utility/move.h>
26#include <__utility/piecewise_construct.h>
27#include <cstddef>
2819
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header21# pragma GCC system_header
31#endif22#endif
3223
33_LIBCPP_PUSH_MACROS
34#include <__undef_macros>
35
36_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
3725
38// Tag used to default initialize one or both of the pair's elements.26// ================================================================================================================== //
39struct __default_init_tag {};27// The utilites here are for staying ABI compatible with the legacy `__compressed_pair`. They should not be used //
40struct __value_init_tag {};28// for new data structures. Use `_LIBCPP_NO_UNIQUE_ADDRESS` for new data structures instead (but make sure you //
4129// understand how it works). //
42template <class _Tp, int _Idx, bool _CanBeEmptyBase = is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value>30// ================================================================================================================== //
43struct __compressed_pair_elem {
44 using _ParamT = _Tp;
45 using reference = _Tp&;
46 using const_reference = const _Tp&;
47
48 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {}
49 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_() {}
50
51 template <class _Up, __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value, int> = 0>
52 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u)
53 : __value_(std::forward<_Up>(__u)) {}
5431
55#ifndef _LIBCPP_CXX03_LANG32// The first member is aligned to the alignment of the second member to force padding in front of the compressed pair
56 template <class... _Args, size_t... _Indices>33// in case there are members before it.
57 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit __compressed_pair_elem(34//
58 piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)35// For example:
59 : __value_(std::forward<_Args>(std::get<_Indices>(__args))...) {}36// (assuming x86-64 linux)
60#endif37// class SomeClass {
6138// uint32_t member1;
62 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference __get() _NOEXCEPT { return __value_; }39// _LIBCPP_COMPRESSED_PAIR(uint32_t, member2, uint64_t, member3);
63 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; }40// }
6441//
65private:42// The layout with __compressed_pair is:
66 _Tp __value_;43// member1 - offset: 0, size: 4
67};44// padding - offset: 4, size: 4
45// member2 - offset: 8, size: 4
46// padding - offset: 12, size: 4
47// member3 - offset: 16, size: 8
48//
49// If the [[gnu::aligned]] wasn't there, the layout would instead be:
50// member1 - offset: 0, size: 4
51// member2 - offset: 4, size: 4
52// member3 - offset: 8, size: 8
53//
54// Furthermore, that alignment must be the same as what was used in the old __compressed_pair layout, so we must
55// handle reference types specially since alignof(T&) == alignof(T).
56// See https://github.com/llvm/llvm-project/issues/118559.
6857
69template <class _Tp, int _Idx>58#ifndef _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
70struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
71 using _ParamT = _Tp;
72 using reference = _Tp&;
73 using const_reference = const _Tp&;
74 using __value_type = _Tp;
75
76 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem() = default;
77 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {}
78 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_type() {}
79
80 template <class _Up, __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value, int> = 0>
81 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u)
82 : __value_type(std::forward<_Up>(__u)) {}
83
84#ifndef _LIBCPP_CXX03_LANG
85 template <class... _Args, size_t... _Indices>
86 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
87 __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)
88 : __value_type(std::forward<_Args>(std::get<_Indices>(__args))...) {}
89#endif
9059
91 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference __get() _NOEXCEPT { return *this; }60template <class _Tp>
92 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; }61inline const size_t __compressed_pair_alignment = _LIBCPP_ALIGNOF(_Tp);
93};
9462
95template <class _T1, class _T2>63template <class _Tp>
96class __compressed_pair : private __compressed_pair_elem<_T1, 0>, private __compressed_pair_elem<_T2, 1> {64inline const size_t __compressed_pair_alignment<_Tp&> = _LIBCPP_ALIGNOF(void*);
97public:
98 // NOTE: This static assert should never fire because __compressed_pair
99 // is *almost never* used in a scenario where it's possible for T1 == T2.
100 // (The exception is std::function where it is possible that the function
101 // object and the allocator have the same type).
102 static_assert(
103 (!is_same<_T1, _T2>::value),
104 "__compressed_pair cannot be instantiated when T1 and T2 are the same type; "
105 "The current implementation is NOT ABI-compatible with the previous implementation for this configuration");
106
107 using _Base1 _LIBCPP_NODEBUG = __compressed_pair_elem<_T1, 0>;
108 using _Base2 _LIBCPP_NODEBUG = __compressed_pair_elem<_T2, 1>;
109
110 template <bool _Dummy = true,
111 __enable_if_t< __dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
112 __dependent_type<is_default_constructible<_T2>, _Dummy>::value,
113 int> = 0>
114 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair()
115 : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {}
116
117 template <class _U1, class _U2>
118 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair(_U1&& __t1, _U2&& __t2)
119 : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {}
120
121#ifndef _LIBCPP_CXX03_LANG
122 template <class... _Args1, class... _Args2>
123 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit __compressed_pair(
124 piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
125 : _Base1(__pc, std::move(__first_args), typename __make_tuple_indices<sizeof...(_Args1)>::type()),
126 _Base2(__pc, std::move(__second_args), typename __make_tuple_indices<sizeof...(_Args2)>::type()) {}
127#endif
12865
129 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename _Base1::reference first() _NOEXCEPT {66template <class _ToPad,
130 return static_cast<_Base1&>(*this).__get();67 bool _Empty = ((is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) ||
131 }68 is_reference<_ToPad>::value || sizeof(_ToPad) == __datasizeof_v<_ToPad>)>
13269class __compressed_pair_padding {
133 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename _Base1::const_reference first() const _NOEXCEPT {70 char __padding_[sizeof(_ToPad) - __datasizeof_v<_ToPad>] = {};
134 return static_cast<_Base1 const&>(*this).__get();
135 }
136
137 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename _Base2::reference second() _NOEXCEPT {
138 return static_cast<_Base2&>(*this).__get();
139 }
140
141 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename _Base2::const_reference second() const _NOEXCEPT {
142 return static_cast<_Base2 const&>(*this).__get();
143 }
144
145 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static _Base1* __get_first_base(__compressed_pair* __pair) _NOEXCEPT {
146 return static_cast<_Base1*>(__pair);
147 }
148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static _Base2* __get_second_base(__compressed_pair* __pair) _NOEXCEPT {
149 return static_cast<_Base2*>(__pair);
150 }
151
152 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(__compressed_pair& __x)
153 _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) {
154 using std::swap;
155 swap(first(), __x.first());
156 swap(second(), __x.second());
157 }
158};71};
15972
160template <class _T1, class _T2>73template <class _ToPad>
161inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void74class __compressed_pair_padding<_ToPad, true> {};
162swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)75
163 _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) {76# define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \
164 __x.swap(__y);77 _LIBCPP_NO_UNIQUE_ADDRESS __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>))) T1 Initializer1; \
165}78 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \
79 _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
80 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _)
81
82# define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \
83 _LIBCPP_NO_UNIQUE_ADDRESS \
84 __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>), \
85 __aligned__(::std::__compressed_pair_alignment<T3>))) T1 Initializer1; \
86 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \
87 _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
88 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \
89 _LIBCPP_NO_UNIQUE_ADDRESS T3 Initializer3; \
90 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T3> _LIBCPP_CONCAT3(__padding3_, __LINE__, _)
91
92#else
93# define _LIBCPP_COMPRESSED_PAIR(T1, Name1, T2, Name2) \
94 _LIBCPP_NO_UNIQUE_ADDRESS T1 Name1; \
95 _LIBCPP_NO_UNIQUE_ADDRESS T2 Name2
96
97# define _LIBCPP_COMPRESSED_TRIPLE(T1, Name1, T2, Name2, T3, Name3) \
98 _LIBCPP_NO_UNIQUE_ADDRESS T1 Name1; \
99 _LIBCPP_NO_UNIQUE_ADDRESS T2 Name2; \
100 _LIBCPP_NO_UNIQUE_ADDRESS T3 Name3
101#endif // _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
166102
167_LIBCPP_END_NAMESPACE_STD103_LIBCPP_END_NAMESPACE_STD
168104
169_LIBCPP_POP_MACROS
170
171#endif // _LIBCPP___MEMORY_COMPRESSED_PAIR_H105#endif // _LIBCPP___MEMORY_COMPRESSED_PAIR_H
lib/libcxx/include/__memory/construct_at.h+3-4
...@@ -14,13 +14,12 @@...@@ -14,13 +14,12 @@
14#include <__config>14#include <__config>
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 <__new/placement_new_delete.h>
18#include <__type_traits/enable_if.h>18#include <__type_traits/enable_if.h>
19#include <__type_traits/is_array.h>19#include <__type_traits/is_array.h>
20#include <__utility/declval.h>20#include <__utility/declval.h>
21#include <__utility/forward.h>21#include <__utility/forward.h>
22#include <__utility/move.h>22#include <__utility/move.h>
23#include <new>
2423
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header25# pragma GCC system_header
...@@ -38,7 +37,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -38,7 +37,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
38template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>37template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
39_LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) {38_LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) {
40 _LIBCPP_ASSERT_NON_NULL(__location != nullptr, "null pointer given to construct_at");39 _LIBCPP_ASSERT_NON_NULL(__location != nullptr, "null pointer given to construct_at");
41 return ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);40 return ::new (static_cast<void*>(__location)) _Tp(std::forward<_Args>(__args)...);
42}41}
4342
44#endif43#endif
...@@ -49,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __l...@@ -49,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __l
49 return std::construct_at(__location, std::forward<_Args>(__args)...);48 return std::construct_at(__location, std::forward<_Args>(__args)...);
50#else49#else
51 return _LIBCPP_ASSERT_NON_NULL(__location != nullptr, "null pointer given to construct_at"),50 return _LIBCPP_ASSERT_NON_NULL(__location != nullptr, "null pointer given to construct_at"),
52 ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);51 ::new (static_cast<void*>(__location)) _Tp(std::forward<_Args>(__args)...);
53#endif52#endif
54}53}
5554
lib/libcxx/include/__memory/destruct_n.h+11-11
...@@ -10,9 +10,9 @@...@@ -10,9 +10,9 @@
10#define _LIBCPP___MEMORY_DESTRUCT_N_H10#define _LIBCPP___MEMORY_DESTRUCT_N_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_trivially_destructible.h>15#include <__type_traits/is_trivially_destructible.h>
15#include <cstddef>
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
...@@ -25,35 +25,35 @@ private:...@@ -25,35 +25,35 @@ private:
25 size_t __size_;25 size_t __size_;
2626
27 template <class _Tp>27 template <class _Tp>
28 _LIBCPP_HIDE_FROM_ABI void __process(_Tp* __p, false_type) _NOEXCEPT {28 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __process(_Tp* __p, false_type) _NOEXCEPT {
29 for (size_t __i = 0; __i < __size_; ++__i, ++__p)29 for (size_t __i = 0; __i < __size_; ++__i, ++__p)
30 __p->~_Tp();30 __p->~_Tp();
31 }31 }
3232
33 template <class _Tp>33 template <class _Tp>
34 _LIBCPP_HIDE_FROM_ABI void __process(_Tp*, true_type) _NOEXCEPT {}34 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __process(_Tp*, true_type) _NOEXCEPT {}
3535
36 _LIBCPP_HIDE_FROM_ABI void __incr(false_type) _NOEXCEPT { ++__size_; }36 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __incr(false_type) _NOEXCEPT { ++__size_; }
37 _LIBCPP_HIDE_FROM_ABI void __incr(true_type) _NOEXCEPT {}37 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __incr(true_type) _NOEXCEPT {}
3838
39 _LIBCPP_HIDE_FROM_ABI void __set(size_t __s, false_type) _NOEXCEPT { __size_ = __s; }39 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __set(size_t __s, false_type) _NOEXCEPT { __size_ = __s; }
40 _LIBCPP_HIDE_FROM_ABI void __set(size_t, true_type) _NOEXCEPT {}40 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __set(size_t, true_type) _NOEXCEPT {}
4141
42public:42public:
43 _LIBCPP_HIDE_FROM_ABI explicit __destruct_n(size_t __s) _NOEXCEPT : __size_(__s) {}43 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __destruct_n(size_t __s) _NOEXCEPT : __size_(__s) {}
4444
45 template <class _Tp>45 template <class _Tp>
46 _LIBCPP_HIDE_FROM_ABI void __incr() _NOEXCEPT {46 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __incr() _NOEXCEPT {
47 __incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());47 __incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());
48 }48 }
4949
50 template <class _Tp>50 template <class _Tp>
51 _LIBCPP_HIDE_FROM_ABI void __set(size_t __s, _Tp*) _NOEXCEPT {51 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __set(size_t __s, _Tp*) _NOEXCEPT {
52 __set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());52 __set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());
53 }53 }
5454
55 template <class _Tp>55 template <class _Tp>
56 _LIBCPP_HIDE_FROM_ABI void operator()(_Tp* __p) _NOEXCEPT {56 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void operator()(_Tp* __p) _NOEXCEPT {
57 __process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());57 __process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());
58 }58 }
59};59};
lib/libcxx/include/__memory/inout_ptr.h+1
...@@ -15,6 +15,7 @@...@@ -15,6 +15,7 @@
15#include <__memory/pointer_traits.h>15#include <__memory/pointer_traits.h>
16#include <__memory/shared_ptr.h>16#include <__memory/shared_ptr.h>
17#include <__memory/unique_ptr.h>17#include <__memory/unique_ptr.h>
18#include <__type_traits/is_pointer.h>
18#include <__type_traits/is_same.h>19#include <__type_traits/is_same.h>
19#include <__type_traits/is_specialization.h>20#include <__type_traits/is_specialization.h>
20#include <__type_traits/is_void.h>21#include <__type_traits/is_void.h>
lib/libcxx/include/__memory/noexcept_move_assign_container.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___MEMORY_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H
10#define _LIBCPP___MEMORY_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_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
25 : public integral_constant<bool,
26 _Traits::propagate_on_container_move_assignment::value
27#if _LIBCPP_STD_VER >= 17
28 || _Traits::is_always_equal::value
29#else
30 && is_nothrow_move_assignable<_Alloc>::value
31#endif
32 > {
33};
34
35_LIBCPP_END_NAMESPACE_STD
36
37#endif // _LIBCPP___MEMORY_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H
lib/libcxx/include/__memory/out_ptr.h+1
...@@ -15,6 +15,7 @@...@@ -15,6 +15,7 @@
15#include <__memory/pointer_traits.h>15#include <__memory/pointer_traits.h>
16#include <__memory/shared_ptr.h>16#include <__memory/shared_ptr.h>
17#include <__memory/unique_ptr.h>17#include <__memory/unique_ptr.h>
18#include <__type_traits/is_pointer.h>
18#include <__type_traits/is_specialization.h>19#include <__type_traits/is_specialization.h>
19#include <__type_traits/is_void.h>20#include <__type_traits/is_void.h>
20#include <__utility/forward.h>21#include <__utility/forward.h>
lib/libcxx/include/__memory/pointer_traits.h+16-14
...@@ -11,17 +11,19 @@...@@ -11,17 +11,19 @@
11#define _LIBCPP___MEMORY_POINTER_TRAITS_H11#define _LIBCPP___MEMORY_POINTER_TRAITS_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
14#include <__memory/addressof.h>15#include <__memory/addressof.h>
15#include <__type_traits/conditional.h>16#include <__type_traits/conditional.h>
16#include <__type_traits/conjunction.h>17#include <__type_traits/conjunction.h>
17#include <__type_traits/decay.h>18#include <__type_traits/decay.h>
19#include <__type_traits/enable_if.h>
20#include <__type_traits/integral_constant.h>
18#include <__type_traits/is_class.h>21#include <__type_traits/is_class.h>
19#include <__type_traits/is_function.h>22#include <__type_traits/is_function.h>
20#include <__type_traits/is_void.h>23#include <__type_traits/is_void.h>
21#include <__type_traits/void_t.h>24#include <__type_traits/void_t.h>
22#include <__utility/declval.h>25#include <__utility/declval.h>
23#include <__utility/forward.h>26#include <__utility/forward.h>
24#include <cstddef>
2527
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header29# pragma GCC system_header
...@@ -48,17 +50,17 @@ struct __pointer_traits_element_type {};...@@ -48,17 +50,17 @@ struct __pointer_traits_element_type {};
4850
49template <class _Ptr>51template <class _Ptr>
50struct __pointer_traits_element_type<_Ptr, true> {52struct __pointer_traits_element_type<_Ptr, true> {
51 typedef _LIBCPP_NODEBUG typename _Ptr::element_type type;53 using type _LIBCPP_NODEBUG = typename _Ptr::element_type;
52};54};
5355
54template <template <class, class...> class _Sp, class _Tp, class... _Args>56template <template <class, class...> class _Sp, class _Tp, class... _Args>
55struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> {57struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> {
56 typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::element_type type;58 using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::element_type;
57};59};
5860
59template <template <class, class...> class _Sp, class _Tp, class... _Args>61template <template <class, class...> class _Sp, class _Tp, class... _Args>
60struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> {62struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> {
61 typedef _LIBCPP_NODEBUG _Tp type;63 using type _LIBCPP_NODEBUG = _Tp;
62};64};
6365
64template <class _Tp, class = void>66template <class _Tp, class = void>
...@@ -69,12 +71,12 @@ struct __has_difference_type<_Tp, __void_t<typename _Tp::difference_type> > : tr...@@ -69,12 +71,12 @@ struct __has_difference_type<_Tp, __void_t<typename _Tp::difference_type> > : tr
6971
70template <class _Ptr, bool = __has_difference_type<_Ptr>::value>72template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
71struct __pointer_traits_difference_type {73struct __pointer_traits_difference_type {
72 typedef _LIBCPP_NODEBUG ptrdiff_t type;74 using type _LIBCPP_NODEBUG = ptrdiff_t;
73};75};
7476
75template <class _Ptr>77template <class _Ptr>
76struct __pointer_traits_difference_type<_Ptr, true> {78struct __pointer_traits_difference_type<_Ptr, true> {
77 typedef _LIBCPP_NODEBUG typename _Ptr::difference_type type;79 using type _LIBCPP_NODEBUG = typename _Ptr::difference_type;
78};80};
7981
80template <class _Tp, class _Up>82template <class _Tp, class _Up>
...@@ -94,18 +96,18 @@ public:...@@ -94,18 +96,18 @@ public:
94template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>96template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
95struct __pointer_traits_rebind {97struct __pointer_traits_rebind {
96#ifndef _LIBCPP_CXX03_LANG98#ifndef _LIBCPP_CXX03_LANG
97 typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up> type;99 using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>;
98#else100#else
99 typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up>::other type;101 using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other;
100#endif102#endif
101};103};
102104
103template <template <class, class...> class _Sp, class _Tp, class... _Args, class _Up>105template <template <class, class...> class _Sp, class _Tp, class... _Args, class _Up>
104struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> {106struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> {
105#ifndef _LIBCPP_CXX03_LANG107#ifndef _LIBCPP_CXX03_LANG
106 typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up> type;108 using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::template rebind<_Up>;
107#else109#else
108 typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;110 using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::template rebind<_Up>::other;
109#endif111#endif
110};112};
111113
...@@ -174,10 +176,10 @@ public:...@@ -174,10 +176,10 @@ public:
174176
175#ifndef _LIBCPP_CXX03_LANG177#ifndef _LIBCPP_CXX03_LANG
176template <class _From, class _To>178template <class _From, class _To>
177using __rebind_pointer_t = typename pointer_traits<_From>::template rebind<_To>;179using __rebind_pointer_t _LIBCPP_NODEBUG = typename pointer_traits<_From>::template rebind<_To>;
178#else180#else
179template <class _From, class _To>181template <class _From, class _To>
180using __rebind_pointer_t = typename pointer_traits<_From>::template rebind<_To>::other;182using __rebind_pointer_t _LIBCPP_NODEBUG = typename pointer_traits<_From>::template rebind<_To>::other;
181#endif183#endif
182184
183// to_address185// to_address
...@@ -274,7 +276,7 @@ struct __pointer_of<_Tp> {...@@ -274,7 +276,7 @@ struct __pointer_of<_Tp> {
274};276};
275277
276template <typename _Tp>278template <typename _Tp>
277using __pointer_of_t = typename __pointer_of<_Tp>::type;279using __pointer_of_t _LIBCPP_NODEBUG = typename __pointer_of<_Tp>::type;
278280
279template <class _Tp, class _Up>281template <class _Tp, class _Up>
280struct __pointer_of_or {282struct __pointer_of_or {
...@@ -288,7 +290,7 @@ struct __pointer_of_or<_Tp, _Up> {...@@ -288,7 +290,7 @@ struct __pointer_of_or<_Tp, _Up> {
288};290};
289291
290template <typename _Tp, typename _Up>292template <typename _Tp, typename _Up>
291using __pointer_of_or_t = typename __pointer_of_or<_Tp, _Up>::type;293using __pointer_of_or_t _LIBCPP_NODEBUG = typename __pointer_of_or<_Tp, _Up>::type;
292294
293template <class _Smart>295template <class _Smart>
294concept __resettable_smart_pointer = requires(_Smart __s) { __s.reset(); };296concept __resettable_smart_pointer = requires(_Smart __s) { __s.reset(); };
lib/libcxx/include/__memory/ranges_construct_at.h+8-25
...@@ -22,7 +22,6 @@...@@ -22,7 +22,6 @@
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>
2625
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header27# pragma GCC system_header
...@@ -38,43 +37,33 @@ namespace ranges {...@@ -38,43 +37,33 @@ namespace ranges {
3837
39// construct_at38// construct_at
4039
41namespace __construct_at {40struct __construct_at {
42
43struct __fn {
44 template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>41 template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
45 _LIBCPP_HIDE_FROM_ABI constexpr _Tp* operator()(_Tp* __location, _Args&&... __args) const {42 _LIBCPP_HIDE_FROM_ABI constexpr _Tp* operator()(_Tp* __location, _Args&&... __args) const {
46 return std::construct_at(__location, std::forward<_Args>(__args)...);43 return std::construct_at(__location, std::forward<_Args>(__args)...);
47 }44 }
48};45};
4946
50} // namespace __construct_at
51
52inline namespace __cpo {47inline namespace __cpo {
53inline constexpr auto construct_at = __construct_at::__fn{};48inline constexpr auto construct_at = __construct_at{};
54} // namespace __cpo49} // namespace __cpo
5550
56// destroy_at51// destroy_at
5752
58namespace __destroy_at {53struct __destroy_at {
59
60struct __fn {
61 template <destructible _Tp>54 template <destructible _Tp>
62 _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Tp* __location) const noexcept {55 _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Tp* __location) const noexcept {
63 std::destroy_at(__location);56 std::destroy_at(__location);
64 }57 }
65};58};
6659
67} // namespace __destroy_at
68
69inline namespace __cpo {60inline namespace __cpo {
70inline constexpr auto destroy_at = __destroy_at::__fn{};61inline constexpr auto destroy_at = __destroy_at{};
71} // namespace __cpo62} // namespace __cpo
7263
73// destroy64// destroy
7465
75namespace __destroy {66struct __destroy {
76
77struct __fn {
78 template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel>67 template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel>
79 requires destructible<iter_value_t<_InputIterator>>68 requires destructible<iter_value_t<_InputIterator>>
80 _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept {69 _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept {
...@@ -88,17 +77,13 @@ struct __fn {...@@ -88,17 +77,13 @@ struct __fn {
88 }77 }
89};78};
9079
91} // namespace __destroy
92
93inline namespace __cpo {80inline namespace __cpo {
94inline constexpr auto destroy = __destroy::__fn{};81inline constexpr auto destroy = __destroy{};
95} // namespace __cpo82} // namespace __cpo
9683
97// destroy_n84// destroy_n
9885
99namespace __destroy_n {86struct __destroy_n {
100
101struct __fn {
102 template <__nothrow_input_iterator _InputIterator>87 template <__nothrow_input_iterator _InputIterator>
103 requires destructible<iter_value_t<_InputIterator>>88 requires destructible<iter_value_t<_InputIterator>>
104 _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator89 _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator
...@@ -107,10 +92,8 @@ struct __fn {...@@ -107,10 +92,8 @@ struct __fn {
107 }92 }
108};93};
10994
110} // namespace __destroy_n
111
112inline namespace __cpo {95inline namespace __cpo {
113inline constexpr auto destroy_n = __destroy_n::__fn{};96inline constexpr auto destroy_n = __destroy_n{};
114} // namespace __cpo97} // namespace __cpo
11598
116} // namespace ranges99} // namespace ranges
lib/libcxx/include/__memory/ranges_uninitialized_algorithms.h+20-61
...@@ -25,7 +25,6 @@...@@ -25,7 +25,6 @@
25#include <__ranges/dangling.h>25#include <__ranges/dangling.h>
26#include <__type_traits/remove_reference.h>26#include <__type_traits/remove_reference.h>
27#include <__utility/move.h>27#include <__utility/move.h>
28#include <new>
2928
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header30# pragma GCC system_header
...@@ -42,9 +41,7 @@ namespace ranges {...@@ -42,9 +41,7 @@ namespace ranges {
4241
43// uninitialized_default_construct42// uninitialized_default_construct
4443
45namespace __uninitialized_default_construct {44struct __uninitialized_default_construct {
46
47struct __fn {
48 template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel>45 template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel>
49 requires default_initializable<iter_value_t<_ForwardIterator>>46 requires default_initializable<iter_value_t<_ForwardIterator>>
50 _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const {47 _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const {
...@@ -59,17 +56,13 @@ struct __fn {...@@ -59,17 +56,13 @@ struct __fn {
59 }56 }
60};57};
6158
62} // namespace __uninitialized_default_construct
63
64inline namespace __cpo {59inline namespace __cpo {
65inline constexpr auto uninitialized_default_construct = __uninitialized_default_construct::__fn{};60inline constexpr auto uninitialized_default_construct = __uninitialized_default_construct{};
66} // namespace __cpo61} // namespace __cpo
6762
68// uninitialized_default_construct_n63// uninitialized_default_construct_n
6964
70namespace __uninitialized_default_construct_n {65struct __uninitialized_default_construct_n {
71
72struct __fn {
73 template <__nothrow_forward_iterator _ForwardIterator>66 template <__nothrow_forward_iterator _ForwardIterator>
74 requires default_initializable<iter_value_t<_ForwardIterator>>67 requires default_initializable<iter_value_t<_ForwardIterator>>
75 _LIBCPP_HIDE_FROM_ABI _ForwardIterator68 _LIBCPP_HIDE_FROM_ABI _ForwardIterator
...@@ -79,17 +72,13 @@ struct __fn {...@@ -79,17 +72,13 @@ struct __fn {
79 }72 }
80};73};
8174
82} // namespace __uninitialized_default_construct_n
83
84inline namespace __cpo {75inline namespace __cpo {
85inline constexpr auto uninitialized_default_construct_n = __uninitialized_default_construct_n::__fn{};76inline constexpr auto uninitialized_default_construct_n = __uninitialized_default_construct_n{};
86} // namespace __cpo77} // namespace __cpo
8778
88// uninitialized_value_construct79// uninitialized_value_construct
8980
90namespace __uninitialized_value_construct {81struct __uninitialized_value_construct {
91
92struct __fn {
93 template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel>82 template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel>
94 requires default_initializable<iter_value_t<_ForwardIterator>>83 requires default_initializable<iter_value_t<_ForwardIterator>>
95 _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const {84 _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const {
...@@ -104,17 +93,13 @@ struct __fn {...@@ -104,17 +93,13 @@ struct __fn {
104 }93 }
105};94};
10695
107} // namespace __uninitialized_value_construct
108
109inline namespace __cpo {96inline namespace __cpo {
110inline constexpr auto uninitialized_value_construct = __uninitialized_value_construct::__fn{};97inline constexpr auto uninitialized_value_construct = __uninitialized_value_construct{};
111} // namespace __cpo98} // namespace __cpo
11299
113// uninitialized_value_construct_n100// uninitialized_value_construct_n
114101
115namespace __uninitialized_value_construct_n {102struct __uninitialized_value_construct_n {
116
117struct __fn {
118 template <__nothrow_forward_iterator _ForwardIterator>103 template <__nothrow_forward_iterator _ForwardIterator>
119 requires default_initializable<iter_value_t<_ForwardIterator>>104 requires default_initializable<iter_value_t<_ForwardIterator>>
120 _LIBCPP_HIDE_FROM_ABI _ForwardIterator105 _LIBCPP_HIDE_FROM_ABI _ForwardIterator
...@@ -124,17 +109,13 @@ struct __fn {...@@ -124,17 +109,13 @@ struct __fn {
124 }109 }
125};110};
126111
127} // namespace __uninitialized_value_construct_n
128
129inline namespace __cpo {112inline namespace __cpo {
130inline constexpr auto uninitialized_value_construct_n = __uninitialized_value_construct_n::__fn{};113inline constexpr auto uninitialized_value_construct_n = __uninitialized_value_construct_n{};
131} // namespace __cpo114} // namespace __cpo
132115
133// uninitialized_fill116// uninitialized_fill
134117
135namespace __uninitialized_fill {118struct __uninitialized_fill {
136
137struct __fn {
138 template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel, class _Tp>119 template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel, class _Tp>
139 requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&>120 requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&>
140 _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) const {121 _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) const {
...@@ -149,17 +130,13 @@ struct __fn {...@@ -149,17 +130,13 @@ struct __fn {
149 }130 }
150};131};
151132
152} // namespace __uninitialized_fill
153
154inline namespace __cpo {133inline namespace __cpo {
155inline constexpr auto uninitialized_fill = __uninitialized_fill::__fn{};134inline constexpr auto uninitialized_fill = __uninitialized_fill{};
156} // namespace __cpo135} // namespace __cpo
157136
158// uninitialized_fill_n137// uninitialized_fill_n
159138
160namespace __uninitialized_fill_n {139struct __uninitialized_fill_n {
161
162struct __fn {
163 template <__nothrow_forward_iterator _ForwardIterator, class _Tp>140 template <__nothrow_forward_iterator _ForwardIterator, class _Tp>
164 requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&>141 requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&>
165 _LIBCPP_HIDE_FROM_ABI _ForwardIterator142 _LIBCPP_HIDE_FROM_ABI _ForwardIterator
...@@ -169,10 +146,8 @@ struct __fn {...@@ -169,10 +146,8 @@ struct __fn {
169 }146 }
170};147};
171148
172} // namespace __uninitialized_fill_n
173
174inline namespace __cpo {149inline namespace __cpo {
175inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n::__fn{};150inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n{};
176} // namespace __cpo151} // namespace __cpo
177152
178// uninitialized_copy153// uninitialized_copy
...@@ -180,9 +155,7 @@ inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n::__fn{};...@@ -180,9 +155,7 @@ inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n::__fn{};
180template <class _InputIterator, class _OutputIterator>155template <class _InputIterator, class _OutputIterator>
181using uninitialized_copy_result = in_out_result<_InputIterator, _OutputIterator>;156using uninitialized_copy_result = in_out_result<_InputIterator, _OutputIterator>;
182157
183namespace __uninitialized_copy {158struct __uninitialized_copy {
184
185struct __fn {
186 template <input_iterator _InputIterator,159 template <input_iterator _InputIterator,
187 sentinel_for<_InputIterator> _Sentinel1,160 sentinel_for<_InputIterator> _Sentinel1,
188 __nothrow_forward_iterator _OutputIterator,161 __nothrow_forward_iterator _OutputIterator,
...@@ -207,10 +180,8 @@ struct __fn {...@@ -207,10 +180,8 @@ struct __fn {
207 }180 }
208};181};
209182
210} // namespace __uninitialized_copy
211
212inline namespace __cpo {183inline namespace __cpo {
213inline constexpr auto uninitialized_copy = __uninitialized_copy::__fn{};184inline constexpr auto uninitialized_copy = __uninitialized_copy{};
214} // namespace __cpo185} // namespace __cpo
215186
216// uninitialized_copy_n187// uninitialized_copy_n
...@@ -218,9 +189,7 @@ inline constexpr auto uninitialized_copy = __uninitialized_copy::__fn{};...@@ -218,9 +189,7 @@ inline constexpr auto uninitialized_copy = __uninitialized_copy::__fn{};
218template <class _InputIterator, class _OutputIterator>189template <class _InputIterator, class _OutputIterator>
219using uninitialized_copy_n_result = in_out_result<_InputIterator, _OutputIterator>;190using uninitialized_copy_n_result = in_out_result<_InputIterator, _OutputIterator>;
220191
221namespace __uninitialized_copy_n {192struct __uninitialized_copy_n {
222
223struct __fn {
224 template <input_iterator _InputIterator,193 template <input_iterator _InputIterator,
225 __nothrow_forward_iterator _OutputIterator,194 __nothrow_forward_iterator _OutputIterator,
226 __nothrow_sentinel_for<_OutputIterator> _Sentinel>195 __nothrow_sentinel_for<_OutputIterator> _Sentinel>
...@@ -238,10 +207,8 @@ struct __fn {...@@ -238,10 +207,8 @@ struct __fn {
238 }207 }
239};208};
240209
241} // namespace __uninitialized_copy_n
242
243inline namespace __cpo {210inline namespace __cpo {
244inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n::__fn{};211inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n{};
245} // namespace __cpo212} // namespace __cpo
246213
247// uninitialized_move214// uninitialized_move
...@@ -249,9 +216,7 @@ inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n::__fn{};...@@ -249,9 +216,7 @@ inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n::__fn{};
249template <class _InputIterator, class _OutputIterator>216template <class _InputIterator, class _OutputIterator>
250using uninitialized_move_result = in_out_result<_InputIterator, _OutputIterator>;217using uninitialized_move_result = in_out_result<_InputIterator, _OutputIterator>;
251218
252namespace __uninitialized_move {219struct __uninitialized_move {
253
254struct __fn {
255 template <input_iterator _InputIterator,220 template <input_iterator _InputIterator,
256 sentinel_for<_InputIterator> _Sentinel1,221 sentinel_for<_InputIterator> _Sentinel1,
257 __nothrow_forward_iterator _OutputIterator,222 __nothrow_forward_iterator _OutputIterator,
...@@ -276,10 +241,8 @@ struct __fn {...@@ -276,10 +241,8 @@ struct __fn {
276 }241 }
277};242};
278243
279} // namespace __uninitialized_move
280
281inline namespace __cpo {244inline namespace __cpo {
282inline constexpr auto uninitialized_move = __uninitialized_move::__fn{};245inline constexpr auto uninitialized_move = __uninitialized_move{};
283} // namespace __cpo246} // namespace __cpo
284247
285// uninitialized_move_n248// uninitialized_move_n
...@@ -287,9 +250,7 @@ inline constexpr auto uninitialized_move = __uninitialized_move::__fn{};...@@ -287,9 +250,7 @@ inline constexpr auto uninitialized_move = __uninitialized_move::__fn{};
287template <class _InputIterator, class _OutputIterator>250template <class _InputIterator, class _OutputIterator>
288using uninitialized_move_n_result = in_out_result<_InputIterator, _OutputIterator>;251using uninitialized_move_n_result = in_out_result<_InputIterator, _OutputIterator>;
289252
290namespace __uninitialized_move_n {253struct __uninitialized_move_n {
291
292struct __fn {
293 template <input_iterator _InputIterator,254 template <input_iterator _InputIterator,
294 __nothrow_forward_iterator _OutputIterator,255 __nothrow_forward_iterator _OutputIterator,
295 __nothrow_sentinel_for<_OutputIterator> _Sentinel>256 __nothrow_sentinel_for<_OutputIterator> _Sentinel>
...@@ -308,10 +269,8 @@ struct __fn {...@@ -308,10 +269,8 @@ struct __fn {
308 }269 }
309};270};
310271
311} // namespace __uninitialized_move_n
312
313inline namespace __cpo {272inline namespace __cpo {
314inline constexpr auto uninitialized_move_n = __uninitialized_move_n::__fn{};273inline constexpr auto uninitialized_move_n = __uninitialized_move_n{};
315} // namespace __cpo274} // namespace __cpo
316275
317} // namespace ranges276} // namespace ranges
lib/libcxx/include/__memory/raw_storage_iterator.h+1-2
...@@ -11,12 +11,11 @@...@@ -11,12 +11,11 @@
11#define _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H11#define _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
14#include <__iterator/iterator.h>15#include <__iterator/iterator.h>
15#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
16#include <__memory/addressof.h>17#include <__memory/addressof.h>
17#include <__utility/move.h>18#include <__utility/move.h>
18#include <cstddef>
19#include <new>
2019
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header21# pragma GCC system_header
lib/libcxx/include/__memory/shared_count.h created+136
...@@ -0,0 +1,136 @@
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_SHARED_COUNT_H
10#define _LIBCPP___MEMORY_SHARED_COUNT_H
11
12#include <__config>
13#include <typeinfo>
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// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
22// should be sufficient for thread safety.
23// See https://llvm.org/PR22803
24#if (defined(__clang__) && __has_builtin(__atomic_add_fetch) && defined(__ATOMIC_RELAXED) && \
25 defined(__ATOMIC_ACQ_REL)) || \
26 defined(_LIBCPP_COMPILER_GCC)
27# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT 1
28#else
29# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT 0
30#endif
31
32template <class _ValueType>
33inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_relaxed_load(_ValueType const* __value) {
34#if _LIBCPP_HAS_THREADS && defined(__ATOMIC_RELAXED) && \
35 (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC))
36 return __atomic_load_n(__value, __ATOMIC_RELAXED);
37#else
38 return *__value;
39#endif
40}
41
42template <class _ValueType>
43inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_acquire_load(_ValueType const* __value) {
44#if _LIBCPP_HAS_THREADS && defined(__ATOMIC_ACQUIRE) && \
45 (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC))
46 return __atomic_load_n(__value, __ATOMIC_ACQUIRE);
47#else
48 return *__value;
49#endif
50}
51
52template <class _Tp>
53inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT {
54#if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS
55 return __atomic_add_fetch(&__t, 1, __ATOMIC_RELAXED);
56#else
57 return __t += 1;
58#endif
59}
60
61template <class _Tp>
62inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT {
63#if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS
64 return __atomic_add_fetch(&__t, -1, __ATOMIC_ACQ_REL);
65#else
66 return __t -= 1;
67#endif
68}
69
70class _LIBCPP_EXPORTED_FROM_ABI __shared_count {
71 __shared_count(const __shared_count&);
72 __shared_count& operator=(const __shared_count&);
73
74protected:
75 long __shared_owners_;
76 virtual ~__shared_count();
77
78private:
79 virtual void __on_zero_shared() _NOEXCEPT = 0;
80
81public:
82 _LIBCPP_HIDE_FROM_ABI explicit __shared_count(long __refs = 0) _NOEXCEPT : __shared_owners_(__refs) {}
83
84#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
85 void __add_shared() noexcept;
86 bool __release_shared() noexcept;
87#else
88 _LIBCPP_HIDE_FROM_ABI void __add_shared() _NOEXCEPT { __libcpp_atomic_refcount_increment(__shared_owners_); }
89 _LIBCPP_HIDE_FROM_ABI bool __release_shared() _NOEXCEPT {
90 if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1) {
91 __on_zero_shared();
92 return true;
93 }
94 return false;
95 }
96#endif
97 _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { return __libcpp_relaxed_load(&__shared_owners_) + 1; }
98};
99
100class _LIBCPP_EXPORTED_FROM_ABI __shared_weak_count : private __shared_count {
101 long __shared_weak_owners_;
102
103public:
104 _LIBCPP_HIDE_FROM_ABI explicit __shared_weak_count(long __refs = 0) _NOEXCEPT
105 : __shared_count(__refs),
106 __shared_weak_owners_(__refs) {}
107
108protected:
109 ~__shared_weak_count() override;
110
111public:
112#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
113 void __add_shared() noexcept;
114 void __add_weak() noexcept;
115 void __release_shared() noexcept;
116#else
117 _LIBCPP_HIDE_FROM_ABI void __add_shared() _NOEXCEPT { __shared_count::__add_shared(); }
118 _LIBCPP_HIDE_FROM_ABI void __add_weak() _NOEXCEPT { __libcpp_atomic_refcount_increment(__shared_weak_owners_); }
119 _LIBCPP_HIDE_FROM_ABI void __release_shared() _NOEXCEPT {
120 if (__shared_count::__release_shared())
121 __release_weak();
122 }
123#endif
124 void __release_weak() _NOEXCEPT;
125 _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { return __shared_count::use_count(); }
126 __shared_weak_count* lock() _NOEXCEPT;
127
128 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
129
130private:
131 virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
132};
133
134_LIBCPP_END_NAMESPACE_STD
135
136#endif // _LIBCPP___MEMORY_SHARED_COUNT_H
lib/libcxx/include/__memory/shared_ptr.h+67-177
...@@ -13,6 +13,8 @@...@@ -13,6 +13,8 @@
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 <__cstddef/nullptr_t.h>
17#include <__cstddef/ptrdiff_t.h>
16#include <__exception/exception.h>18#include <__exception/exception.h>
17#include <__functional/binary_function.h>19#include <__functional/binary_function.h>
18#include <__functional/operations.h>20#include <__functional/operations.h>
...@@ -28,20 +30,26 @@...@@ -28,20 +30,26 @@
28#include <__memory/compressed_pair.h>30#include <__memory/compressed_pair.h>
29#include <__memory/construct_at.h>31#include <__memory/construct_at.h>
30#include <__memory/pointer_traits.h>32#include <__memory/pointer_traits.h>
33#include <__memory/shared_count.h>
31#include <__memory/uninitialized_algorithms.h>34#include <__memory/uninitialized_algorithms.h>
32#include <__memory/unique_ptr.h>35#include <__memory/unique_ptr.h>
33#include <__type_traits/add_lvalue_reference.h>36#include <__type_traits/add_lvalue_reference.h>
34#include <__type_traits/conditional.h>37#include <__type_traits/conditional.h>
35#include <__type_traits/conjunction.h>38#include <__type_traits/conjunction.h>
36#include <__type_traits/disjunction.h>39#include <__type_traits/disjunction.h>
40#include <__type_traits/enable_if.h>
41#include <__type_traits/integral_constant.h>
37#include <__type_traits/is_array.h>42#include <__type_traits/is_array.h>
38#include <__type_traits/is_bounded_array.h>43#include <__type_traits/is_bounded_array.h>
39#include <__type_traits/is_constructible.h>44#include <__type_traits/is_constructible.h>
40#include <__type_traits/is_convertible.h>45#include <__type_traits/is_convertible.h>
46#include <__type_traits/is_function.h>
41#include <__type_traits/is_reference.h>47#include <__type_traits/is_reference.h>
48#include <__type_traits/is_same.h>
42#include <__type_traits/is_unbounded_array.h>49#include <__type_traits/is_unbounded_array.h>
43#include <__type_traits/nat.h>50#include <__type_traits/nat.h>
44#include <__type_traits/negation.h>51#include <__type_traits/negation.h>
52#include <__type_traits/remove_cv.h>
45#include <__type_traits/remove_extent.h>53#include <__type_traits/remove_extent.h>
46#include <__type_traits/remove_reference.h>54#include <__type_traits/remove_reference.h>
47#include <__utility/declval.h>55#include <__utility/declval.h>
...@@ -49,10 +57,8 @@...@@ -49,10 +57,8 @@
49#include <__utility/move.h>57#include <__utility/move.h>
50#include <__utility/swap.h>58#include <__utility/swap.h>
51#include <__verbose_abort>59#include <__verbose_abort>
52#include <cstddef>
53#include <new>
54#include <typeinfo>60#include <typeinfo>
55#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)61#if _LIBCPP_HAS_ATOMIC_HEADER
56# include <__atomic/memory_order.h>62# include <__atomic/memory_order.h>
57#endif63#endif
5864
...@@ -65,53 +71,6 @@ _LIBCPP_PUSH_MACROS...@@ -65,53 +71,6 @@ _LIBCPP_PUSH_MACROS
6571
66_LIBCPP_BEGIN_NAMESPACE_STD72_LIBCPP_BEGIN_NAMESPACE_STD
6773
68// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
69// should be sufficient for thread safety.
70// See https://llvm.org/PR22803
71#if defined(__clang__) && __has_builtin(__atomic_add_fetch) && defined(__ATOMIC_RELAXED) && defined(__ATOMIC_ACQ_REL)
72# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT
73#elif defined(_LIBCPP_COMPILER_GCC)
74# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT
75#endif
76
77template <class _ValueType>
78inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_relaxed_load(_ValueType const* __value) {
79#if !defined(_LIBCPP_HAS_NO_THREADS) && defined(__ATOMIC_RELAXED) && \
80 (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC))
81 return __atomic_load_n(__value, __ATOMIC_RELAXED);
82#else
83 return *__value;
84#endif
85}
86
87template <class _ValueType>
88inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_acquire_load(_ValueType const* __value) {
89#if !defined(_LIBCPP_HAS_NO_THREADS) && defined(__ATOMIC_ACQUIRE) && \
90 (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC))
91 return __atomic_load_n(__value, __ATOMIC_ACQUIRE);
92#else
93 return *__value;
94#endif
95}
96
97template <class _Tp>
98inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT {
99#if defined(_LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT) && !defined(_LIBCPP_HAS_NO_THREADS)
100 return __atomic_add_fetch(&__t, 1, __ATOMIC_RELAXED);
101#else
102 return __t += 1;
103#endif
104}
105
106template <class _Tp>
107inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT {
108#if defined(_LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT) && !defined(_LIBCPP_HAS_NO_THREADS)
109 return __atomic_add_fetch(&__t, -1, __ATOMIC_ACQ_REL);
110#else
111 return __t -= 1;
112#endif
113}
114
115class _LIBCPP_EXPORTED_FROM_ABI bad_weak_ptr : public std::exception {74class _LIBCPP_EXPORTED_FROM_ABI bad_weak_ptr : public std::exception {
116public:75public:
117 _LIBCPP_HIDE_FROM_ABI bad_weak_ptr() _NOEXCEPT = default;76 _LIBCPP_HIDE_FROM_ABI bad_weak_ptr() _NOEXCEPT = default;
...@@ -121,8 +80,8 @@ public:...@@ -121,8 +80,8 @@ public:
121 const char* what() const _NOEXCEPT override;80 const char* what() const _NOEXCEPT override;
122};81};
12382
124_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_weak_ptr() {83[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_weak_ptr() {
125#ifndef _LIBCPP_HAS_NO_EXCEPTIONS84#if _LIBCPP_HAS_EXCEPTIONS
126 throw bad_weak_ptr();85 throw bad_weak_ptr();
127#else86#else
128 _LIBCPP_VERBOSE_ABORT("bad_weak_ptr was thrown in -fno-exceptions mode");87 _LIBCPP_VERBOSE_ABORT("bad_weak_ptr was thrown in -fno-exceptions mode");
...@@ -132,79 +91,15 @@ _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_weak_ptr() {...@@ -132,79 +91,15 @@ _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_weak_ptr() {
132template <class _Tp>91template <class _Tp>
133class _LIBCPP_TEMPLATE_VIS weak_ptr;92class _LIBCPP_TEMPLATE_VIS weak_ptr;
13493
135class _LIBCPP_EXPORTED_FROM_ABI __shared_count {
136 __shared_count(const __shared_count&);
137 __shared_count& operator=(const __shared_count&);
138
139protected:
140 long __shared_owners_;
141 virtual ~__shared_count();
142
143private:
144 virtual void __on_zero_shared() _NOEXCEPT = 0;
145
146public:
147 _LIBCPP_HIDE_FROM_ABI explicit __shared_count(long __refs = 0) _NOEXCEPT : __shared_owners_(__refs) {}
148
149#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
150 void __add_shared() noexcept;
151 bool __release_shared() noexcept;
152#else
153 _LIBCPP_HIDE_FROM_ABI void __add_shared() _NOEXCEPT { __libcpp_atomic_refcount_increment(__shared_owners_); }
154 _LIBCPP_HIDE_FROM_ABI bool __release_shared() _NOEXCEPT {
155 if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1) {
156 __on_zero_shared();
157 return true;
158 }
159 return false;
160 }
161#endif
162 _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { return __libcpp_relaxed_load(&__shared_owners_) + 1; }
163};
164
165class _LIBCPP_EXPORTED_FROM_ABI __shared_weak_count : private __shared_count {
166 long __shared_weak_owners_;
167
168public:
169 _LIBCPP_HIDE_FROM_ABI explicit __shared_weak_count(long __refs = 0) _NOEXCEPT
170 : __shared_count(__refs),
171 __shared_weak_owners_(__refs) {}
172
173protected:
174 ~__shared_weak_count() override;
175
176public:
177#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
178 void __add_shared() noexcept;
179 void __add_weak() noexcept;
180 void __release_shared() noexcept;
181#else
182 _LIBCPP_HIDE_FROM_ABI void __add_shared() _NOEXCEPT { __shared_count::__add_shared(); }
183 _LIBCPP_HIDE_FROM_ABI void __add_weak() _NOEXCEPT { __libcpp_atomic_refcount_increment(__shared_weak_owners_); }
184 _LIBCPP_HIDE_FROM_ABI void __release_shared() _NOEXCEPT {
185 if (__shared_count::__release_shared())
186 __release_weak();
187 }
188#endif
189 void __release_weak() _NOEXCEPT;
190 _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { return __shared_count::use_count(); }
191 __shared_weak_count* lock() _NOEXCEPT;
192
193 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
194
195private:
196 virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
197};
198
199template <class _Tp, class _Dp, class _Alloc>94template <class _Tp, class _Dp, class _Alloc>
200class __shared_ptr_pointer : public __shared_weak_count {95class __shared_ptr_pointer : public __shared_weak_count {
201 __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_;96 _LIBCPP_COMPRESSED_TRIPLE(_Tp, __ptr_, _Dp, __deleter_, _Alloc, __alloc_);
20297
203public:98public:
204 _LIBCPP_HIDE_FROM_ABI __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a)99 _LIBCPP_HIDE_FROM_ABI __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a)
205 : __data_(__compressed_pair<_Tp, _Dp>(__p, std::move(__d)), std::move(__a)) {}100 : __ptr_(__p), __deleter_(std::move(__d)), __alloc_(std::move(__a)) {}
206101
207#ifndef _LIBCPP_HAS_NO_RTTI102#if _LIBCPP_HAS_RTTI
208 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const void* __get_deleter(const type_info&) const _NOEXCEPT override;103 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const void* __get_deleter(const type_info&) const _NOEXCEPT override;
209#endif104#endif
210105
...@@ -213,19 +108,19 @@ private:...@@ -213,19 +108,19 @@ private:
213 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override;108 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override;
214};109};
215110
216#ifndef _LIBCPP_HAS_NO_RTTI111#if _LIBCPP_HAS_RTTI
217112
218template <class _Tp, class _Dp, class _Alloc>113template <class _Tp, class _Dp, class _Alloc>
219const void* __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT {114const void* __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT {
220 return __t == typeid(_Dp) ? std::addressof(__data_.first().second()) : nullptr;115 return __t == typeid(_Dp) ? std::addressof(__deleter_) : nullptr;
221}116}
222117
223#endif // _LIBCPP_HAS_NO_RTTI118#endif // _LIBCPP_HAS_RTTI
224119
225template <class _Tp, class _Dp, class _Alloc>120template <class _Tp, class _Dp, class _Alloc>
226void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT {121void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT {
227 __data_.first().second()(__data_.first().first());122 __deleter_(__ptr_);
228 __data_.first().second().~_Dp();123 __deleter_.~_Dp();
229}124}
230125
231template <class _Tp, class _Dp, class _Alloc>126template <class _Tp, class _Dp, class _Alloc>
...@@ -234,8 +129,8 @@ void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT {...@@ -234,8 +129,8 @@ void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT {
234 typedef allocator_traits<_Al> _ATraits;129 typedef allocator_traits<_Al> _ATraits;
235 typedef pointer_traits<typename _ATraits::pointer> _PTraits;130 typedef pointer_traits<typename _ATraits::pointer> _PTraits;
236131
237 _Al __a(__data_.second());132 _Al __a(__alloc_);
238 __data_.second().~_Alloc();133 __alloc_.~_Alloc();
239 __a.deallocate(_PTraits::pointer_to(*this), 1);134 __a.deallocate(_PTraits::pointer_to(*this), 1);
240}135}
241136
...@@ -246,33 +141,35 @@ struct __for_overwrite_tag {};...@@ -246,33 +141,35 @@ struct __for_overwrite_tag {};
246141
247template <class _Tp, class _Alloc>142template <class _Tp, class _Alloc>
248struct __shared_ptr_emplace : __shared_weak_count {143struct __shared_ptr_emplace : __shared_weak_count {
144 using __value_type _LIBCPP_NODEBUG = __remove_cv_t<_Tp>;
145
249 template <class... _Args,146 template <class... _Args,
250 class _Allocator = _Alloc,147 class _Allocator = _Alloc,
251 __enable_if_t<is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0>148 __enable_if_t<is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0>
252 _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace(_Alloc __a, _Args&&...) : __storage_(std::move(__a)) {149 _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace(_Alloc __a, _Args&&...) : __storage_(std::move(__a)) {
253 static_assert(150 static_assert(
254 sizeof...(_Args) == 0, "No argument should be provided to the control block when using _for_overwrite");151 sizeof...(_Args) == 0, "No argument should be provided to the control block when using _for_overwrite");
255 ::new ((void*)__get_elem()) _Tp;152 ::new (static_cast<void*>(__get_elem())) __value_type;
256 }153 }
257154
258 template <class... _Args,155 template <class... _Args,
259 class _Allocator = _Alloc,156 class _Allocator = _Alloc,
260 __enable_if_t<!is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0>157 __enable_if_t<!is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0>
261 _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace(_Alloc __a, _Args&&... __args) : __storage_(std::move(__a)) {158 _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace(_Alloc __a, _Args&&... __args) : __storage_(std::move(__a)) {
262 using _TpAlloc = typename __allocator_traits_rebind<_Alloc, __remove_cv_t<_Tp> >::type;159 using _TpAlloc = typename __allocator_traits_rebind<_Alloc, __value_type>::type;
263 _TpAlloc __tmp(*__get_alloc());160 _TpAlloc __tmp(*__get_alloc());
264 allocator_traits<_TpAlloc>::construct(__tmp, __get_elem(), std::forward<_Args>(__args)...);161 allocator_traits<_TpAlloc>::construct(__tmp, __get_elem(), std::forward<_Args>(__args)...);
265 }162 }
266163
267 _LIBCPP_HIDE_FROM_ABI _Alloc* __get_alloc() _NOEXCEPT { return __storage_.__get_alloc(); }164 _LIBCPP_HIDE_FROM_ABI _Alloc* __get_alloc() _NOEXCEPT { return __storage_.__get_alloc(); }
268165
269 _LIBCPP_HIDE_FROM_ABI _Tp* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); }166 _LIBCPP_HIDE_FROM_ABI __value_type* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); }
270167
271private:168private:
272 template <class _Allocator = _Alloc,169 template <class _Allocator = _Alloc,
273 __enable_if_t<is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0>170 __enable_if_t<is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0>
274 _LIBCPP_HIDE_FROM_ABI void __on_zero_shared_impl() _NOEXCEPT {171 _LIBCPP_HIDE_FROM_ABI void __on_zero_shared_impl() _NOEXCEPT {
275 __get_elem()->~_Tp();172 __get_elem()->~__value_type();
276 }173 }
277174
278 template <class _Allocator = _Alloc,175 template <class _Allocator = _Alloc,
...@@ -293,36 +190,28 @@ private:...@@ -293,36 +190,28 @@ private:
293 allocator_traits<_ControlBlockAlloc>::deallocate(__tmp, pointer_traits<_ControlBlockPointer>::pointer_to(*this), 1);190 allocator_traits<_ControlBlockAlloc>::deallocate(__tmp, pointer_traits<_ControlBlockPointer>::pointer_to(*this), 1);
294 }191 }
295192
193 // TODO: It should be possible to refactor this to remove `_Storage` entirely.
296 // This class implements the control block for non-array shared pointers created194 // This class implements the control block for non-array shared pointers created
297 // through `std::allocate_shared` and `std::make_shared`.195 // through `std::allocate_shared` and `std::make_shared`.
298 //196 struct _Storage {
299 // In previous versions of the library, we used a compressed pair to store197 struct _Data {
300 // both the _Alloc and the _Tp. This implies using EBO, which is incompatible198 _LIBCPP_COMPRESSED_PAIR(_Alloc, __alloc_, __value_type, __elem_);
301 // with Allocator construction for _Tp. To allow implementing P0674 in C++20,199 };
302 // we now use a properly aligned char buffer while making sure that we maintain200
303 // the same layout that we had when we used a compressed pair.201 _ALIGNAS_TYPE(_Data) char __buffer_[sizeof(_Data)];
304 using _CompressedPair = __compressed_pair<_Alloc, _Tp>;
305 struct _ALIGNAS_TYPE(_CompressedPair) _Storage {
306 char __blob_[sizeof(_CompressedPair)];
307202
308 _LIBCPP_HIDE_FROM_ABI explicit _Storage(_Alloc&& __a) { ::new ((void*)__get_alloc()) _Alloc(std::move(__a)); }203 _LIBCPP_HIDE_FROM_ABI explicit _Storage(_Alloc&& __a) { ::new ((void*)__get_alloc()) _Alloc(std::move(__a)); }
309 _LIBCPP_HIDE_FROM_ABI ~_Storage() { __get_alloc()->~_Alloc(); }204 _LIBCPP_HIDE_FROM_ABI ~_Storage() { __get_alloc()->~_Alloc(); }
205
310 _LIBCPP_HIDE_FROM_ABI _Alloc* __get_alloc() _NOEXCEPT {206 _LIBCPP_HIDE_FROM_ABI _Alloc* __get_alloc() _NOEXCEPT {
311 _CompressedPair* __as_pair = reinterpret_cast<_CompressedPair*>(__blob_);207 return std::addressof(reinterpret_cast<_Data*>(__buffer_)->__alloc_);
312 typename _CompressedPair::_Base1* __first = _CompressedPair::__get_first_base(__as_pair);
313 _Alloc* __alloc = reinterpret_cast<_Alloc*>(__first);
314 return __alloc;
315 }208 }
316 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp* __get_elem() _NOEXCEPT {209
317 _CompressedPair* __as_pair = reinterpret_cast<_CompressedPair*>(__blob_);210 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI __value_type* __get_elem() _NOEXCEPT {
318 typename _CompressedPair::_Base2* __second = _CompressedPair::__get_second_base(__as_pair);211 return std::addressof(reinterpret_cast<_Data*>(__buffer_)->__elem_);
319 _Tp* __elem = reinterpret_cast<_Tp*>(__second);
320 return __elem;
321 }212 }
322 };213 };
323214
324 static_assert(_LIBCPP_ALIGNOF(_Storage) == _LIBCPP_ALIGNOF(_CompressedPair), "");
325 static_assert(sizeof(_Storage) == sizeof(_CompressedPair), "");
326 _Storage __storage_;215 _Storage __storage_;
327};216};
328217
...@@ -404,7 +293,8 @@ struct __shared_ptr_deleter_ctor_reqs {...@@ -404,7 +293,8 @@ struct __shared_ptr_deleter_ctor_reqs {
404};293};
405294
406template <class _Dp>295template <class _Dp>
407using __shared_ptr_nullptr_deleter_ctor_reqs = _And<is_move_constructible<_Dp>, __well_formed_deleter<_Dp, nullptr_t> >;296using __shared_ptr_nullptr_deleter_ctor_reqs _LIBCPP_NODEBUG =
297 _And<is_move_constructible<_Dp>, __well_formed_deleter<_Dp, nullptr_t> >;
408298
409#if defined(_LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI)299#if defined(_LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI)
410# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI __attribute__((__trivial_abi__))300# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI __attribute__((__trivial_abi__))
...@@ -426,7 +316,7 @@ public:...@@ -426,7 +316,7 @@ public:
426316
427 // A shared_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require317 // A shared_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require
428 // any bookkeeping, so it's always trivially relocatable.318 // any bookkeeping, so it's always trivially relocatable.
429 using __trivially_relocatable = shared_ptr;319 using __trivially_relocatable _LIBCPP_NODEBUG = shared_ptr;
430320
431private:321private:
432 element_type* __ptr_;322 element_type* __ptr_;
...@@ -459,9 +349,9 @@ public:...@@ -459,9 +349,9 @@ public:
459349
460 template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0>350 template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0>
461 _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d) : __ptr_(__p) {351 _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d) : __ptr_(__p) {
462#ifndef _LIBCPP_HAS_NO_EXCEPTIONS352#if _LIBCPP_HAS_EXCEPTIONS
463 try {353 try {
464#endif // _LIBCPP_HAS_NO_EXCEPTIONS354#endif // _LIBCPP_HAS_EXCEPTIONS
465 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;355 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
466 typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT> _CntrlBlk;356 typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT> _CntrlBlk;
467#ifndef _LIBCPP_CXX03_LANG357#ifndef _LIBCPP_CXX03_LANG
...@@ -470,12 +360,12 @@ public:...@@ -470,12 +360,12 @@ public:
470 __cntrl_ = new _CntrlBlk(__p, __d, _AllocT());360 __cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
471#endif // not _LIBCPP_CXX03_LANG361#endif // not _LIBCPP_CXX03_LANG
472 __enable_weak_this(__p, __p);362 __enable_weak_this(__p, __p);
473#ifndef _LIBCPP_HAS_NO_EXCEPTIONS363#if _LIBCPP_HAS_EXCEPTIONS
474 } catch (...) {364 } catch (...) {
475 __d(__p);365 __d(__p);
476 throw;366 throw;
477 }367 }
478#endif // _LIBCPP_HAS_NO_EXCEPTIONS368#endif // _LIBCPP_HAS_EXCEPTIONS
479 }369 }
480370
481 template <class _Yp,371 template <class _Yp,
...@@ -483,9 +373,9 @@ public:...@@ -483,9 +373,9 @@ public:
483 class _Alloc,373 class _Alloc,
484 __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0>374 __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0>
485 _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) : __ptr_(__p) {375 _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) : __ptr_(__p) {
486#ifndef _LIBCPP_HAS_NO_EXCEPTIONS376#if _LIBCPP_HAS_EXCEPTIONS
487 try {377 try {
488#endif // _LIBCPP_HAS_NO_EXCEPTIONS378#endif // _LIBCPP_HAS_EXCEPTIONS
489 typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk;379 typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk;
490 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;380 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
491 typedef __allocator_destructor<_A2> _D2;381 typedef __allocator_destructor<_A2> _D2;
...@@ -499,12 +389,12 @@ public:...@@ -499,12 +389,12 @@ public:
499#endif // not _LIBCPP_CXX03_LANG389#endif // not _LIBCPP_CXX03_LANG
500 __cntrl_ = std::addressof(*__hold2.release());390 __cntrl_ = std::addressof(*__hold2.release());
501 __enable_weak_this(__p, __p);391 __enable_weak_this(__p, __p);
502#ifndef _LIBCPP_HAS_NO_EXCEPTIONS392#if _LIBCPP_HAS_EXCEPTIONS
503 } catch (...) {393 } catch (...) {
504 __d(__p);394 __d(__p);
505 throw;395 throw;
506 }396 }
507#endif // _LIBCPP_HAS_NO_EXCEPTIONS397#endif // _LIBCPP_HAS_EXCEPTIONS
508 }398 }
509399
510 template <class _Dp>400 template <class _Dp>
...@@ -513,9 +403,9 @@ public:...@@ -513,9 +403,9 @@ public:
513 _Dp __d,403 _Dp __d,
514 __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag())404 __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag())
515 : __ptr_(nullptr) {405 : __ptr_(nullptr) {
516#ifndef _LIBCPP_HAS_NO_EXCEPTIONS406#if _LIBCPP_HAS_EXCEPTIONS
517 try {407 try {
518#endif // _LIBCPP_HAS_NO_EXCEPTIONS408#endif // _LIBCPP_HAS_EXCEPTIONS
519 typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT;409 typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT;
520 typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT> _CntrlBlk;410 typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT> _CntrlBlk;
521#ifndef _LIBCPP_CXX03_LANG411#ifndef _LIBCPP_CXX03_LANG
...@@ -523,12 +413,12 @@ public:...@@ -523,12 +413,12 @@ public:
523#else413#else
524 __cntrl_ = new _CntrlBlk(__p, __d, _AllocT());414 __cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
525#endif // not _LIBCPP_CXX03_LANG415#endif // not _LIBCPP_CXX03_LANG
526#ifndef _LIBCPP_HAS_NO_EXCEPTIONS416#if _LIBCPP_HAS_EXCEPTIONS
527 } catch (...) {417 } catch (...) {
528 __d(__p);418 __d(__p);
529 throw;419 throw;
530 }420 }
531#endif // _LIBCPP_HAS_NO_EXCEPTIONS421#endif // _LIBCPP_HAS_EXCEPTIONS
532 }422 }
533423
534 template <class _Dp, class _Alloc>424 template <class _Dp, class _Alloc>
...@@ -538,9 +428,9 @@ public:...@@ -538,9 +428,9 @@ public:
538 _Alloc __a,428 _Alloc __a,
539 __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag())429 __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag())
540 : __ptr_(nullptr) {430 : __ptr_(nullptr) {
541#ifndef _LIBCPP_HAS_NO_EXCEPTIONS431#if _LIBCPP_HAS_EXCEPTIONS
542 try {432 try {
543#endif // _LIBCPP_HAS_NO_EXCEPTIONS433#endif // _LIBCPP_HAS_EXCEPTIONS
544 typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk;434 typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk;
545 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;435 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
546 typedef __allocator_destructor<_A2> _D2;436 typedef __allocator_destructor<_A2> _D2;
...@@ -553,12 +443,12 @@ public:...@@ -553,12 +443,12 @@ public:
553 _CntrlBlk(__p, __d, __a);443 _CntrlBlk(__p, __d, __a);
554#endif // not _LIBCPP_CXX03_LANG444#endif // not _LIBCPP_CXX03_LANG
555 __cntrl_ = std::addressof(*__hold2.release());445 __cntrl_ = std::addressof(*__hold2.release());
556#ifndef _LIBCPP_HAS_NO_EXCEPTIONS446#if _LIBCPP_HAS_EXCEPTIONS
557 } catch (...) {447 } catch (...) {
558 __d(__p);448 __d(__p);
559 throw;449 throw;
560 }450 }
561#endif // _LIBCPP_HAS_NO_EXCEPTIONS451#endif // _LIBCPP_HAS_EXCEPTIONS
562 }452 }
563453
564 template <class _Yp>454 template <class _Yp>
...@@ -771,12 +661,12 @@ public:...@@ -771,12 +661,12 @@ public:
771 }661 }
772#endif662#endif
773663
774#ifndef _LIBCPP_HAS_NO_RTTI664#if _LIBCPP_HAS_RTTI
775 template <class _Dp>665 template <class _Dp>
776 _LIBCPP_HIDE_FROM_ABI _Dp* __get_deleter() const _NOEXCEPT {666 _LIBCPP_HIDE_FROM_ABI _Dp* __get_deleter() const _NOEXCEPT {
777 return static_cast<_Dp*>(__cntrl_ ? const_cast<void*>(__cntrl_->__get_deleter(typeid(_Dp))) : nullptr);667 return static_cast<_Dp*>(__cntrl_ ? const_cast<void*>(__cntrl_->__get_deleter(typeid(_Dp))) : nullptr);
778 }668 }
779#endif // _LIBCPP_HAS_NO_RTTI669#endif // _LIBCPP_HAS_RTTI
780670
781 template <class _Yp, class _CntrlBlk>671 template <class _Yp, class _CntrlBlk>
782 _LIBCPP_HIDE_FROM_ABI static shared_ptr<_Tp> __create_with_control_block(_Yp* __p, _CntrlBlk* __cntrl) _NOEXCEPT {672 _LIBCPP_HIDE_FROM_ABI static shared_ptr<_Tp> __create_with_control_block(_Yp* __p, _CntrlBlk* __cntrl) _NOEXCEPT {
...@@ -959,7 +849,7 @@ private:...@@ -959,7 +849,7 @@ private:
959template <class _Array, class _Alloc, class... _Arg>849template <class _Array, class _Alloc, class... _Arg>
960_LIBCPP_HIDE_FROM_ABI shared_ptr<_Array>850_LIBCPP_HIDE_FROM_ABI shared_ptr<_Array>
961__allocate_shared_unbounded_array(const _Alloc& __a, size_t __n, _Arg&&... __arg) {851__allocate_shared_unbounded_array(const _Alloc& __a, size_t __n, _Arg&&... __arg) {
962 static_assert(__libcpp_is_unbounded_array<_Array>::value);852 static_assert(__is_unbounded_array_v<_Array>);
963 // We compute the number of bytes necessary to hold the control block and the853 // We compute the number of bytes necessary to hold the control block and the
964 // array elements. Then, we allocate an array of properly-aligned dummy structs854 // array elements. Then, we allocate an array of properly-aligned dummy structs
965 // large enough to hold the control block and array. This allows shifting the855 // large enough to hold the control block and array. This allows shifting the
...@@ -1036,7 +926,7 @@ private:...@@ -1036,7 +926,7 @@ private:
1036926
1037template <class _Array, class _Alloc, class... _Arg>927template <class _Array, class _Alloc, class... _Arg>
1038_LIBCPP_HIDE_FROM_ABI shared_ptr<_Array> __allocate_shared_bounded_array(const _Alloc& __a, _Arg&&... __arg) {928_LIBCPP_HIDE_FROM_ABI shared_ptr<_Array> __allocate_shared_bounded_array(const _Alloc& __a, _Arg&&... __arg) {
1039 static_assert(__libcpp_is_bounded_array<_Array>::value);929 static_assert(__is_bounded_array_v<_Array>);
1040 using _ControlBlock = __bounded_array_control_block<_Array, _Alloc>;930 using _ControlBlock = __bounded_array_control_block<_Array, _Alloc>;
1041 using _ControlBlockAlloc = __allocator_traits_rebind_t<_Alloc, _ControlBlock>;931 using _ControlBlockAlloc = __allocator_traits_rebind_t<_Alloc, _ControlBlock>;
1042932
...@@ -1301,14 +1191,14 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(shared_ptr<_Up>&&...@@ -1301,14 +1191,14 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(shared_ptr<_Up>&&
1301}1191}
1302#endif1192#endif
13031193
1304#ifndef _LIBCPP_HAS_NO_RTTI1194#if _LIBCPP_HAS_RTTI
13051195
1306template <class _Dp, class _Tp>1196template <class _Dp, class _Tp>
1307inline _LIBCPP_HIDE_FROM_ABI _Dp* get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT {1197inline _LIBCPP_HIDE_FROM_ABI _Dp* get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT {
1308 return __p.template __get_deleter<_Dp>();1198 return __p.template __get_deleter<_Dp>();
1309}1199}
13101200
1311#endif // _LIBCPP_HAS_NO_RTTI1201#endif // _LIBCPP_HAS_RTTI
13121202
1313template <class _Tp>1203template <class _Tp>
1314class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr {1204class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr {
...@@ -1321,7 +1211,7 @@ public:...@@ -1321,7 +1211,7 @@ public:
13211211
1322 // A weak_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require1212 // A weak_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require
1323 // any bookkeeping, so it's always trivially relocatable.1213 // any bookkeeping, so it's always trivially relocatable.
1324 using __trivially_relocatable = weak_ptr;1214 using __trivially_relocatable _LIBCPP_NODEBUG = weak_ptr;
13251215
1326private:1216private:
1327 element_type* __ptr_;1217 element_type* __ptr_;
...@@ -1583,7 +1473,7 @@ template <class _CharT, class _Traits, class _Yp>...@@ -1583,7 +1473,7 @@ template <class _CharT, class _Traits, class _Yp>
1583inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&1473inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
1584operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);1474operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
15851475
1586#if !defined(_LIBCPP_HAS_NO_THREADS)1476#if _LIBCPP_HAS_THREADS
15871477
1588class _LIBCPP_EXPORTED_FROM_ABI __sp_mut {1478class _LIBCPP_EXPORTED_FROM_ABI __sp_mut {
1589 void* __lx_;1479 void* __lx_;
...@@ -1685,7 +1575,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_weak_explicit(...@@ -1685,7 +1575,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_weak_explicit(
1685 return std::atomic_compare_exchange_weak(__p, __v, __w);1575 return std::atomic_compare_exchange_weak(__p, __v, __w);
1686}1576}
16871577
1688#endif // !defined(_LIBCPP_HAS_NO_THREADS)1578#endif // _LIBCPP_HAS_THREADS
16891579
1690_LIBCPP_END_NAMESPACE_STD1580_LIBCPP_END_NAMESPACE_STD
16911581
lib/libcxx/include/__memory/temporary_buffer.h+13-43
...@@ -11,65 +11,35 @@...@@ -11,65 +11,35 @@
11#define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H11#define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
15#include <__memory/unique_temporary_buffer.h>
14#include <__utility/pair.h>16#include <__utility/pair.h>
15#include <cstddef>
16#include <new>
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#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER)
23
22_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2325
24template <class _Tp>26template <class _Tp>
25_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptrdiff_t>27[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptrdiff_t>
26get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT {28get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT {
27 pair<_Tp*, ptrdiff_t> __r(0, 0);29 __unique_temporary_buffer<_Tp> __unique_buf = std::__allocate_unique_temporary_buffer<_Tp>(__n);
28 const ptrdiff_t __m =30 pair<_Tp*, ptrdiff_t> __result(__unique_buf.get(), __unique_buf.get_deleter().__count_);
29 (~ptrdiff_t(0) ^ ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) / sizeof(_Tp);31 __unique_buf.release();
30 if (__n > __m)32 return __result;
31 __n = __m;
32 while (__n > 0) {
33#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
34 if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) {
35 align_val_t __al = align_val_t(_LIBCPP_ALIGNOF(_Tp));
36 __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), __al, nothrow));
37 } else {
38 __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow));
39 }
40#else
41 if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) {
42 // Since aligned operator new is unavailable, return an empty
43 // buffer rather than one with invalid alignment.
44 return __r;
45 }
46
47 __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow));
48#endif
49
50 if (__r.first) {
51 __r.second = __n;
52 break;
53 }
54 __n /= 2;
55 }
56 return __r;
57}33}
5834
59template <class _Tp>35template <class _Tp>
60inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 void return_temporary_buffer(_Tp* __p) _NOEXCEPT {36inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 void return_temporary_buffer(_Tp* __p) _NOEXCEPT {
61 std::__libcpp_deallocate_unsized((void*)__p, _LIBCPP_ALIGNOF(_Tp));37 __unique_temporary_buffer<_Tp> __unique_buf(__p);
38 (void)__unique_buf;
62}39}
6340
64struct __return_temporary_buffer {
65 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
66 template <class _Tp>
67 _LIBCPP_HIDE_FROM_ABI void operator()(_Tp* __p) const {
68 std::return_temporary_buffer(__p);
69 }
70 _LIBCPP_SUPPRESS_DEPRECATED_POP
71};
72
73_LIBCPP_END_NAMESPACE_STD41_LIBCPP_END_NAMESPACE_STD
7442
43#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER)
44
75#endif // _LIBCPP___MEMORY_TEMPORARY_BUFFER_H45#endif // _LIBCPP___MEMORY_TEMPORARY_BUFFER_H
lib/libcxx/include/__memory/uninitialized_algorithms.h+61-59
...@@ -15,16 +15,18 @@...@@ -15,16 +15,18 @@
15#include <__algorithm/unwrap_iter.h>15#include <__algorithm/unwrap_iter.h>
16#include <__algorithm/unwrap_range.h>16#include <__algorithm/unwrap_range.h>
17#include <__config>17#include <__config>
18#include <__cstddef/size_t.h>
18#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
19#include <__iterator/reverse_iterator.h>20#include <__iterator/reverse_iterator.h>
20#include <__memory/addressof.h>21#include <__memory/addressof.h>
21#include <__memory/allocator_traits.h>22#include <__memory/allocator_traits.h>
22#include <__memory/construct_at.h>23#include <__memory/construct_at.h>
23#include <__memory/pointer_traits.h>24#include <__memory/pointer_traits.h>
24#include <__memory/voidify.h>25#include <__type_traits/enable_if.h>
25#include <__type_traits/extent.h>26#include <__type_traits/extent.h>
26#include <__type_traits/is_array.h>27#include <__type_traits/is_array.h>
27#include <__type_traits/is_constant_evaluated.h>28#include <__type_traits/is_constant_evaluated.h>
29#include <__type_traits/is_same.h>
28#include <__type_traits/is_trivially_assignable.h>30#include <__type_traits/is_trivially_assignable.h>
29#include <__type_traits/is_trivially_constructible.h>31#include <__type_traits/is_trivially_constructible.h>
30#include <__type_traits/is_trivially_relocatable.h>32#include <__type_traits/is_trivially_relocatable.h>
...@@ -35,7 +37,6 @@...@@ -35,7 +37,6 @@
35#include <__utility/exception_guard.h>37#include <__utility/exception_guard.h>
36#include <__utility/move.h>38#include <__utility/move.h>
37#include <__utility/pair.h>39#include <__utility/pair.h>
38#include <new>
3940
40#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)41#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
41# pragma GCC system_header42# pragma GCC system_header
...@@ -59,12 +60,12 @@ template <class _ValueType, class _InputIterator, class _Sentinel1, class _Forwa...@@ -59,12 +60,12 @@ template <class _ValueType, class _InputIterator, class _Sentinel1, class _Forwa
59inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_copy(60inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_copy(
60 _InputIterator __ifirst, _Sentinel1 __ilast, _ForwardIterator __ofirst, _EndPredicate __stop_copying) {61 _InputIterator __ifirst, _Sentinel1 __ilast, _ForwardIterator __ofirst, _EndPredicate __stop_copying) {
61 _ForwardIterator __idx = __ofirst;62 _ForwardIterator __idx = __ofirst;
62#ifndef _LIBCPP_HAS_NO_EXCEPTIONS63#if _LIBCPP_HAS_EXCEPTIONS
63 try {64 try {
64#endif65#endif
65 for (; __ifirst != __ilast && !__stop_copying(__idx); ++__ifirst, (void)++__idx)66 for (; __ifirst != __ilast && !__stop_copying(__idx); ++__ifirst, (void)++__idx)
66 ::new (std::__voidify(*__idx)) _ValueType(*__ifirst);67 ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(*__ifirst);
67#ifndef _LIBCPP_HAS_NO_EXCEPTIONS68#if _LIBCPP_HAS_EXCEPTIONS
68 } catch (...) {69 } catch (...) {
69 std::__destroy(__ofirst, __idx);70 std::__destroy(__ofirst, __idx);
70 throw;71 throw;
...@@ -89,12 +90,12 @@ template <class _ValueType, class _InputIterator, class _Size, class _ForwardIte...@@ -89,12 +90,12 @@ template <class _ValueType, class _InputIterator, class _Size, class _ForwardIte
89inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator>90inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator>
90__uninitialized_copy_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_copying) {91__uninitialized_copy_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_copying) {
91 _ForwardIterator __idx = __ofirst;92 _ForwardIterator __idx = __ofirst;
92#ifndef _LIBCPP_HAS_NO_EXCEPTIONS93#if _LIBCPP_HAS_EXCEPTIONS
93 try {94 try {
94#endif95#endif
95 for (; __n > 0 && !__stop_copying(__idx); ++__ifirst, (void)++__idx, (void)--__n)96 for (; __n > 0 && !__stop_copying(__idx); ++__ifirst, (void)++__idx, (void)--__n)
96 ::new (std::__voidify(*__idx)) _ValueType(*__ifirst);97 ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(*__ifirst);
97#ifndef _LIBCPP_HAS_NO_EXCEPTIONS98#if _LIBCPP_HAS_EXCEPTIONS
98 } catch (...) {99 } catch (...) {
99 std::__destroy(__ofirst, __idx);100 std::__destroy(__ofirst, __idx);
100 throw;101 throw;
...@@ -119,12 +120,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel, class _Tp>...@@ -119,12 +120,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel, class _Tp>
119inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator120inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
120__uninitialized_fill(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) {121__uninitialized_fill(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) {
121 _ForwardIterator __idx = __first;122 _ForwardIterator __idx = __first;
122#ifndef _LIBCPP_HAS_NO_EXCEPTIONS123#if _LIBCPP_HAS_EXCEPTIONS
123 try {124 try {
124#endif125#endif
125 for (; __idx != __last; ++__idx)126 for (; __idx != __last; ++__idx)
126 ::new (std::__voidify(*__idx)) _ValueType(__x);127 ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__x);
127#ifndef _LIBCPP_HAS_NO_EXCEPTIONS128#if _LIBCPP_HAS_EXCEPTIONS
128 } catch (...) {129 } catch (...) {
129 std::__destroy(__first, __idx);130 std::__destroy(__first, __idx);
130 throw;131 throw;
...@@ -147,12 +148,12 @@ template <class _ValueType, class _ForwardIterator, class _Size, class _Tp>...@@ -147,12 +148,12 @@ template <class _ValueType, class _ForwardIterator, class _Size, class _Tp>
147inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator148inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
148__uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) {149__uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) {
149 _ForwardIterator __idx = __first;150 _ForwardIterator __idx = __first;
150#ifndef _LIBCPP_HAS_NO_EXCEPTIONS151#if _LIBCPP_HAS_EXCEPTIONS
151 try {152 try {
152#endif153#endif
153 for (; __n > 0; ++__idx, (void)--__n)154 for (; __n > 0; ++__idx, (void)--__n)
154 ::new (std::__voidify(*__idx)) _ValueType(__x);155 ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__x);
155#ifndef _LIBCPP_HAS_NO_EXCEPTIONS156#if _LIBCPP_HAS_EXCEPTIONS
156 } catch (...) {157 } catch (...) {
157 std::__destroy(__first, __idx);158 std::__destroy(__first, __idx);
158 throw;159 throw;
...@@ -177,12 +178,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel>...@@ -177,12 +178,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel>
177inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator178inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
178__uninitialized_default_construct(_ForwardIterator __first, _Sentinel __last) {179__uninitialized_default_construct(_ForwardIterator __first, _Sentinel __last) {
179 auto __idx = __first;180 auto __idx = __first;
180# ifndef _LIBCPP_HAS_NO_EXCEPTIONS181# if _LIBCPP_HAS_EXCEPTIONS
181 try {182 try {
182# endif183# endif
183 for (; __idx != __last; ++__idx)184 for (; __idx != __last; ++__idx)
184 ::new (std::__voidify(*__idx)) _ValueType;185 ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType;
185# ifndef _LIBCPP_HAS_NO_EXCEPTIONS186# if _LIBCPP_HAS_EXCEPTIONS
186 } catch (...) {187 } catch (...) {
187 std::__destroy(__first, __idx);188 std::__destroy(__first, __idx);
188 throw;189 throw;
...@@ -203,12 +204,12 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_default_construct(_ForwardIterat...@@ -203,12 +204,12 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_default_construct(_ForwardIterat
203template <class _ValueType, class _ForwardIterator, class _Size>204template <class _ValueType, class _ForwardIterator, class _Size>
204inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {205inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {
205 auto __idx = __first;206 auto __idx = __first;
206# ifndef _LIBCPP_HAS_NO_EXCEPTIONS207# if _LIBCPP_HAS_EXCEPTIONS
207 try {208 try {
208# endif209# endif
209 for (; __n > 0; ++__idx, (void)--__n)210 for (; __n > 0; ++__idx, (void)--__n)
210 ::new (std::__voidify(*__idx)) _ValueType;211 ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType;
211# ifndef _LIBCPP_HAS_NO_EXCEPTIONS212# if _LIBCPP_HAS_EXCEPTIONS
212 } catch (...) {213 } catch (...) {
213 std::__destroy(__first, __idx);214 std::__destroy(__first, __idx);
214 throw;215 throw;
...@@ -230,12 +231,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel>...@@ -230,12 +231,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel>
230inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator231inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
231__uninitialized_value_construct(_ForwardIterator __first, _Sentinel __last) {232__uninitialized_value_construct(_ForwardIterator __first, _Sentinel __last) {
232 auto __idx = __first;233 auto __idx = __first;
233# ifndef _LIBCPP_HAS_NO_EXCEPTIONS234# if _LIBCPP_HAS_EXCEPTIONS
234 try {235 try {
235# endif236# endif
236 for (; __idx != __last; ++__idx)237 for (; __idx != __last; ++__idx)
237 ::new (std::__voidify(*__idx)) _ValueType();238 ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType();
238# ifndef _LIBCPP_HAS_NO_EXCEPTIONS239# if _LIBCPP_HAS_EXCEPTIONS
239 } catch (...) {240 } catch (...) {
240 std::__destroy(__first, __idx);241 std::__destroy(__first, __idx);
241 throw;242 throw;
...@@ -256,12 +257,12 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_value_construct(_ForwardIterator...@@ -256,12 +257,12 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_value_construct(_ForwardIterator
256template <class _ValueType, class _ForwardIterator, class _Size>257template <class _ValueType, class _ForwardIterator, class _Size>
257inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {258inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
258 auto __idx = __first;259 auto __idx = __first;
259# ifndef _LIBCPP_HAS_NO_EXCEPTIONS260# if _LIBCPP_HAS_EXCEPTIONS
260 try {261 try {
261# endif262# endif
262 for (; __n > 0; ++__idx, (void)--__n)263 for (; __n > 0; ++__idx, (void)--__n)
263 ::new (std::__voidify(*__idx)) _ValueType();264 ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType();
264# ifndef _LIBCPP_HAS_NO_EXCEPTIONS265# if _LIBCPP_HAS_EXCEPTIONS
265 } catch (...) {266 } catch (...) {
266 std::__destroy(__first, __idx);267 std::__destroy(__first, __idx);
267 throw;268 throw;
...@@ -292,13 +293,13 @@ inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitiali...@@ -292,13 +293,13 @@ inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitiali
292 _EndPredicate __stop_moving,293 _EndPredicate __stop_moving,
293 _IterMove __iter_move) {294 _IterMove __iter_move) {
294 auto __idx = __ofirst;295 auto __idx = __ofirst;
295# ifndef _LIBCPP_HAS_NO_EXCEPTIONS296# if _LIBCPP_HAS_EXCEPTIONS
296 try {297 try {
297# endif298# endif
298 for (; __ifirst != __ilast && !__stop_moving(__idx); ++__idx, (void)++__ifirst) {299 for (; __ifirst != __ilast && !__stop_moving(__idx); ++__idx, (void)++__ifirst) {
299 ::new (std::__voidify(*__idx)) _ValueType(__iter_move(__ifirst));300 ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__iter_move(__ifirst));
300 }301 }
301# ifndef _LIBCPP_HAS_NO_EXCEPTIONS302# if _LIBCPP_HAS_EXCEPTIONS
302 } catch (...) {303 } catch (...) {
303 std::__destroy(__ofirst, __idx);304 std::__destroy(__ofirst, __idx);
304 throw;305 throw;
...@@ -330,12 +331,12 @@ template <class _ValueType,...@@ -330,12 +331,12 @@ template <class _ValueType,
330inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_move_n(331inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_move_n(
331 _InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_moving, _IterMove __iter_move) {332 _InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_moving, _IterMove __iter_move) {
332 auto __idx = __ofirst;333 auto __idx = __ofirst;
333# ifndef _LIBCPP_HAS_NO_EXCEPTIONS334# if _LIBCPP_HAS_EXCEPTIONS
334 try {335 try {
335# endif336# endif
336 for (; __n > 0 && !__stop_moving(__idx); ++__idx, (void)++__ifirst, --__n)337 for (; __n > 0 && !__stop_moving(__idx); ++__idx, (void)++__ifirst, --__n)
337 ::new (std::__voidify(*__idx)) _ValueType(__iter_move(__ifirst));338 ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__iter_move(__ifirst));
338# ifndef _LIBCPP_HAS_NO_EXCEPTIONS339# if _LIBCPP_HAS_EXCEPTIONS
339 } catch (...) {340 } catch (...) {
340 std::__destroy(__ofirst, __idx);341 std::__destroy(__ofirst, __idx);
341 throw;342 throw;
...@@ -375,7 +376,7 @@ __allocator_destroy_multidimensional(_Alloc& __alloc, _BidirIter __first, _Bidir...@@ -375,7 +376,7 @@ __allocator_destroy_multidimensional(_Alloc& __alloc, _BidirIter __first, _Bidir
375 return;376 return;
376377
377 if constexpr (is_array_v<_ValueType>) {378 if constexpr (is_array_v<_ValueType>) {
378 static_assert(!__libcpp_is_unbounded_array<_ValueType>::value,379 static_assert(!__is_unbounded_array_v<_ValueType>,
379 "arrays of unbounded arrays don't exist, but if they did we would mess up here");380 "arrays of unbounded arrays don't exist, but if they did we would mess up here");
380381
381 using _Element = remove_extent_t<_ValueType>;382 using _Element = remove_extent_t<_ValueType>;
...@@ -562,17 +563,13 @@ struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_ty...@@ -562,17 +563,13 @@ struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_ty
562563
563template <class _Alloc,564template <class _Alloc,
564 class _In,565 class _In,
565 class _RawTypeIn = __remove_const_t<_In>,
566 class _Out,566 class _Out,
567 __enable_if_t<567 __enable_if_t<is_trivially_copy_constructible<_In>::value && is_trivially_copy_assignable<_In>::value &&
568 // using _RawTypeIn because of the allocator<T const> extension568 is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value &&
569 is_trivially_copy_constructible<_RawTypeIn>::value && is_trivially_copy_assignable<_RawTypeIn>::value &&569 __allocator_has_trivial_copy_construct<_Alloc, _In>::value,
570 is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value &&570 int> = 0>
571 __allocator_has_trivial_copy_construct<_Alloc, _RawTypeIn>::value,
572 int> = 0>
573_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out*571_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out*
574__uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* __first2) {572__uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* __first2) {
575 // TODO: Remove the const_cast once we drop support for std::allocator<T const>
576 if (__libcpp_is_constant_evaluated()) {573 if (__libcpp_is_constant_evaluated()) {
577 while (__first1 != __last1) {574 while (__first1 != __last1) {
578 std::__construct_at(std::__to_address(__first2), *__first1);575 std::__construct_at(std::__to_address(__first2), *__first1);
...@@ -581,16 +578,16 @@ __uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out*...@@ -581,16 +578,16 @@ __uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out*
581 }578 }
582 return __first2;579 return __first2;
583 } else {580 } else {
584 return std::copy(__first1, __last1, const_cast<_RawTypeIn*>(__first2));581 return std::copy(__first1, __last1, __first2);
585 }582 }
586}583}
587584
588template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>585template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>
589_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2586_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2
590__uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {587__uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
591 auto __unwrapped_range = std::__unwrap_range(__first1, __last1);588 auto __unwrapped_range = std::__unwrap_range(std::move(__first1), std::move(__last1));
592 auto __result = std::__uninitialized_allocator_copy_impl(589 auto __result = std::__uninitialized_allocator_copy_impl(
593 __alloc, __unwrapped_range.first, __unwrapped_range.second, std::__unwrap_iter(__first2));590 __alloc, std::move(__unwrapped_range.first), std::move(__unwrapped_range.second), std::__unwrap_iter(__first2));
594 return std::__rewrap_iter(__first2, __result);591 return std::__rewrap_iter(__first2, __result);
595}592}
596593
...@@ -615,26 +612,28 @@ struct __allocator_has_trivial_destroy<allocator<_Tp>, _Up> : true_type {};...@@ -615,26 +612,28 @@ struct __allocator_has_trivial_destroy<allocator<_Tp>, _Up> : true_type {};
615// [__first, __last) doesn't contain any objects612// [__first, __last) doesn't contain any objects
616//613//
617// The strong exception guarantee is provided if any of the following are true:614// The strong exception guarantee is provided if any of the following are true:
618// - is_nothrow_move_constructible<_Tp>615// - is_nothrow_move_constructible<_ValueType>
619// - is_copy_constructible<_Tp>616// - is_copy_constructible<_ValueType>
620// - __libcpp_is_trivially_relocatable<_Tp>617// - __libcpp_is_trivially_relocatable<_ValueType>
621template <class _Alloc, class _Tp>618template <class _Alloc, class _ContiguousIterator>
622_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void619_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __uninitialized_allocator_relocate(
623__uninitialized_allocator_relocate(_Alloc& __alloc, _Tp* __first, _Tp* __last, _Tp* __result) {620 _Alloc& __alloc, _ContiguousIterator __first, _ContiguousIterator __last, _ContiguousIterator __result) {
621 static_assert(__libcpp_is_contiguous_iterator<_ContiguousIterator>::value, "");
622 using _ValueType = typename iterator_traits<_ContiguousIterator>::value_type;
624 static_assert(__is_cpp17_move_insertable<_Alloc>::value,623 static_assert(__is_cpp17_move_insertable<_Alloc>::value,
625 "The specified type does not meet the requirements of Cpp17MoveInsertable");624 "The specified type does not meet the requirements of Cpp17MoveInsertable");
626 if (__libcpp_is_constant_evaluated() || !__libcpp_is_trivially_relocatable<_Tp>::value ||625 if (__libcpp_is_constant_evaluated() || !__libcpp_is_trivially_relocatable<_ValueType>::value ||
627 !__allocator_has_trivial_move_construct<_Alloc, _Tp>::value ||626 !__allocator_has_trivial_move_construct<_Alloc, _ValueType>::value ||
628 !__allocator_has_trivial_destroy<_Alloc, _Tp>::value) {627 !__allocator_has_trivial_destroy<_Alloc, _ValueType>::value) {
629 auto __destruct_first = __result;628 auto __destruct_first = __result;
630 auto __guard =629 auto __guard = std::__make_exception_guard(
631 std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Tp*>(__alloc, __destruct_first, __result));630 _AllocatorDestroyRangeReverse<_Alloc, _ContiguousIterator>(__alloc, __destruct_first, __result));
632 auto __iter = __first;631 auto __iter = __first;
633 while (__iter != __last) {632 while (__iter != __last) {
634#ifndef _LIBCPP_HAS_NO_EXCEPTIONS633#if _LIBCPP_HAS_EXCEPTIONS
635 allocator_traits<_Alloc>::construct(__alloc, __result, std::move_if_noexcept(*__iter));634 allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__result), std::move_if_noexcept(*__iter));
636#else635#else
637 allocator_traits<_Alloc>::construct(__alloc, __result, std::move(*__iter));636 allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__result), std::move(*__iter));
638#endif637#endif
639 ++__iter;638 ++__iter;
640 ++__result;639 ++__result;
...@@ -642,7 +641,10 @@ __uninitialized_allocator_relocate(_Alloc& __alloc, _Tp* __first, _Tp* __last, _...@@ -642,7 +641,10 @@ __uninitialized_allocator_relocate(_Alloc& __alloc, _Tp* __first, _Tp* __last, _
642 __guard.__complete();641 __guard.__complete();
643 std::__allocator_destroy(__alloc, __first, __last);642 std::__allocator_destroy(__alloc, __first, __last);
644 } else {643 } else {
645 __builtin_memcpy(const_cast<__remove_const_t<_Tp>*>(__result), __first, sizeof(_Tp) * (__last - __first));644 // Casting to void* to suppress clang complaining that this is technically UB.
645 __builtin_memcpy(static_cast<void*>(std::__to_address(__result)),
646 std::__to_address(__first),
647 sizeof(_ValueType) * (__last - __first));
646 }648 }
647}649}
648650
lib/libcxx/include/__memory/unique_ptr.h+243-113
...@@ -10,22 +10,30 @@...@@ -10,22 +10,30 @@
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 <__assert>
13#include <__compare/compare_three_way.h>14#include <__compare/compare_three_way.h>
14#include <__compare/compare_three_way_result.h>15#include <__compare/compare_three_way_result.h>
15#include <__compare/three_way_comparable.h>16#include <__compare/three_way_comparable.h>
16#include <__config>17#include <__config>
18#include <__cstddef/nullptr_t.h>
19#include <__cstddef/size_t.h>
17#include <__functional/hash.h>20#include <__functional/hash.h>
18#include <__functional/operations.h>21#include <__functional/operations.h>
19#include <__memory/allocator_traits.h> // __pointer22#include <__memory/allocator_traits.h> // __pointer
23#include <__memory/array_cookie.h>
20#include <__memory/auto_ptr.h>24#include <__memory/auto_ptr.h>
21#include <__memory/compressed_pair.h>25#include <__memory/compressed_pair.h>
26#include <__memory/pointer_traits.h>
22#include <__type_traits/add_lvalue_reference.h>27#include <__type_traits/add_lvalue_reference.h>
23#include <__type_traits/common_type.h>28#include <__type_traits/common_type.h>
24#include <__type_traits/conditional.h>29#include <__type_traits/conditional.h>
25#include <__type_traits/dependent_type.h>30#include <__type_traits/dependent_type.h>
31#include <__type_traits/enable_if.h>
26#include <__type_traits/integral_constant.h>32#include <__type_traits/integral_constant.h>
27#include <__type_traits/is_array.h>33#include <__type_traits/is_array.h>
28#include <__type_traits/is_assignable.h>34#include <__type_traits/is_assignable.h>
35#include <__type_traits/is_bounded_array.h>
36#include <__type_traits/is_constant_evaluated.h>
29#include <__type_traits/is_constructible.h>37#include <__type_traits/is_constructible.h>
30#include <__type_traits/is_convertible.h>38#include <__type_traits/is_convertible.h>
31#include <__type_traits/is_function.h>39#include <__type_traits/is_function.h>
...@@ -34,14 +42,15 @@...@@ -34,14 +42,15 @@
34#include <__type_traits/is_same.h>42#include <__type_traits/is_same.h>
35#include <__type_traits/is_swappable.h>43#include <__type_traits/is_swappable.h>
36#include <__type_traits/is_trivially_relocatable.h>44#include <__type_traits/is_trivially_relocatable.h>
45#include <__type_traits/is_unbounded_array.h>
37#include <__type_traits/is_void.h>46#include <__type_traits/is_void.h>
38#include <__type_traits/remove_extent.h>47#include <__type_traits/remove_extent.h>
39#include <__type_traits/remove_pointer.h>
40#include <__type_traits/type_identity.h>48#include <__type_traits/type_identity.h>
41#include <__utility/declval.h>49#include <__utility/declval.h>
42#include <__utility/forward.h>50#include <__utility/forward.h>
43#include <__utility/move.h>51#include <__utility/move.h>
44#include <cstddef>52#include <__utility/private_constructor_tag.h>
53#include <cstdint>
4554
46#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)55#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
47# pragma GCC system_header56# pragma GCC system_header
...@@ -52,17 +61,6 @@ _LIBCPP_PUSH_MACROS...@@ -52,17 +61,6 @@ _LIBCPP_PUSH_MACROS
5261
53_LIBCPP_BEGIN_NAMESPACE_STD62_LIBCPP_BEGIN_NAMESPACE_STD
5463
55#ifndef _LIBCPP_CXX03_LANG
56
57template <class _Ptr>
58struct __is_noexcept_deref_or_void {
59 static constexpr bool value = noexcept(*std::declval<_Ptr>());
60};
61
62template <>
63struct __is_noexcept_deref_or_void<void*> : true_type {};
64#endif
65
66template <class _Tp>64template <class _Tp>
67struct _LIBCPP_TEMPLATE_VIS default_delete {65struct _LIBCPP_TEMPLATE_VIS default_delete {
68 static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types");66 static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types");
...@@ -106,6 +104,12 @@ public:...@@ -106,6 +104,12 @@ public:
106 }104 }
107};105};
108106
107template <class _Deleter>
108struct __is_default_deleter : false_type {};
109
110template <class _Tp>
111struct __is_default_deleter<default_delete<_Tp> > : true_type {};
112
109template <class _Deleter>113template <class _Deleter>
110struct __unique_ptr_deleter_sfinae {114struct __unique_ptr_deleter_sfinae {
111 static_assert(!is_reference<_Deleter>::value, "incorrect specialization");115 static_assert(!is_reference<_Deleter>::value, "incorrect specialization");
...@@ -139,7 +143,7 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {...@@ -139,7 +143,7 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
139public:143public:
140 typedef _Tp element_type;144 typedef _Tp element_type;
141 typedef _Dp deleter_type;145 typedef _Dp deleter_type;
142 typedef _LIBCPP_NODEBUG typename __pointer<_Tp, deleter_type>::type pointer;146 using pointer _LIBCPP_NODEBUG = __pointer<_Tp, deleter_type>;
143147
144 static_assert(!is_rvalue_reference<deleter_type>::value, "the specified deleter type cannot be an rvalue reference");148 static_assert(!is_rvalue_reference<deleter_type>::value, "the specified deleter type cannot be an rvalue reference");
145149
...@@ -149,15 +153,15 @@ public:...@@ -149,15 +153,15 @@ public:
149 //153 //
150 // This unique_ptr implementation only contains a pointer to the unique object and a deleter, so there are no154 // This unique_ptr implementation only contains a pointer to the unique object and a deleter, so there are no
151 // references to itself. This means that the entire structure is trivially relocatable if its members are.155 // references to itself. This means that the entire structure is trivially relocatable if its members are.
152 using __trivially_relocatable = __conditional_t<156 using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<
153 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,157 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,
154 unique_ptr,158 unique_ptr,
155 void>;159 void>;
156160
157private:161private:
158 __compressed_pair<pointer, deleter_type> __ptr_;162 _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_);
159163
160 typedef _LIBCPP_NODEBUG __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;164 using _DeleterSFINAE _LIBCPP_NODEBUG = __unique_ptr_deleter_sfinae<_Dp>;
161165
162 template <bool _Dummy>166 template <bool _Dummy>
163 using _LValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;167 using _LValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
...@@ -185,27 +189,29 @@ private:...@@ -185,27 +189,29 @@ private:
185 (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value) >;189 (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value) >;
186190
187 template <class _UDel>191 template <class _UDel>
188 using _EnableIfDeleterAssignable = __enable_if_t< is_assignable<_Dp&, _UDel&&>::value >;192 using _EnableIfDeleterAssignable _LIBCPP_NODEBUG = __enable_if_t< is_assignable<_Dp&, _UDel&&>::value >;
189193
190public:194public:
191 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >195 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
192 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}196 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(), __deleter_() {}
193197
194 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >198 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
195 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT199 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(), __deleter_() {}
196 : __ptr_(__value_init_tag(), __value_init_tag()) {}
197200
198 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >201 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
199 _LIBCPP_HIDE_FROM_ABI202 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT
200 _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __value_init_tag()) {}203 : __ptr_(__p),
204 __deleter_() {}
201205
202 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >206 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
203 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT207 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT
204 : __ptr_(__p, __d) {}208 : __ptr_(__p),
209 __deleter_(__d) {}
205210
206 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >211 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
207 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT212 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
208 : __ptr_(__p, std::move(__d)) {213 : __ptr_(__p),
214 __deleter_(std::move(__d)) {
209 static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");215 static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
210 }216 }
211217
...@@ -213,24 +219,26 @@ public:...@@ -213,24 +219,26 @@ public:
213 _LIBCPP_HIDE_FROM_ABI unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;219 _LIBCPP_HIDE_FROM_ABI unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;
214220
215 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT221 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT
216 : __ptr_(__u.release(), std::forward<deleter_type>(__u.get_deleter())) {}222 : __ptr_(__u.release()),
223 __deleter_(std::forward<deleter_type>(__u.get_deleter())) {}
217224
218 template <class _Up,225 template <class _Up,
219 class _Ep,226 class _Ep,
220 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,227 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
221 class = _EnableIfDeleterConvertible<_Ep> >228 class = _EnableIfDeleterConvertible<_Ep> >
222 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT229 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
223 : __ptr_(__u.release(), std::forward<_Ep>(__u.get_deleter())) {}230 : __ptr_(__u.release()),
231 __deleter_(std::forward<_Ep>(__u.get_deleter())) {}
224232
225#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)233#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
226 template <class _Up,234 template <class _Up,
227 __enable_if_t<is_convertible<_Up*, _Tp*>::value && is_same<_Dp, default_delete<_Tp> >::value, int> = 0>235 __enable_if_t<is_convertible<_Up*, _Tp*>::value && is_same<_Dp, default_delete<_Tp> >::value, int> = 0>
228 _LIBCPP_HIDE_FROM_ABI unique_ptr(auto_ptr<_Up>&& __p) _NOEXCEPT : __ptr_(__p.release(), __value_init_tag()) {}236 _LIBCPP_HIDE_FROM_ABI unique_ptr(auto_ptr<_Up>&& __p) _NOEXCEPT : __ptr_(__p.release()), __deleter_() {}
229#endif237#endif
230238
231 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {239 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
232 reset(__u.release());240 reset(__u.release());
233 __ptr_.second() = std::forward<deleter_type>(__u.get_deleter());241 __deleter_ = std::forward<deleter_type>(__u.get_deleter());
234 return *this;242 return *this;
235 }243 }
236244
...@@ -240,7 +248,7 @@ public:...@@ -240,7 +248,7 @@ public:
240 class = _EnableIfDeleterAssignable<_Ep> >248 class = _EnableIfDeleterAssignable<_Ep> >
241 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {249 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
242 reset(__u.release());250 reset(__u.release());
243 __ptr_.second() = std::forward<_Ep>(__u.get_deleter());251 __deleter_ = std::forward<_Ep>(__u.get_deleter());
244 return *this;252 return *this;
245 }253 }
246254
...@@ -266,33 +274,135 @@ public:...@@ -266,33 +274,135 @@ public:
266 }274 }
267275
268 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const276 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const
269 _NOEXCEPT_(__is_noexcept_deref_or_void<pointer>::value) {277 _NOEXCEPT_(_NOEXCEPT_(*std::declval<pointer>())) {
270 return *__ptr_.first();278 return *__ptr_;
271 }279 }
272 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_.first(); }280 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_; }
273 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); }281 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_; }
274 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __ptr_.second(); }282 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __deleter_; }
275 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {283 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {
276 return __ptr_.second();284 return __deleter_;
277 }285 }
278 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT {286 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT {
279 return __ptr_.first() != nullptr;287 return __ptr_ != nullptr;
280 }288 }
281289
282 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT {290 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT {
283 pointer __t = __ptr_.first();291 pointer __t = __ptr_;
284 __ptr_.first() = pointer();292 __ptr_ = pointer();
285 return __t;293 return __t;
286 }294 }
287295
288 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(pointer __p = pointer()) _NOEXCEPT {296 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(pointer __p = pointer()) _NOEXCEPT {
289 pointer __tmp = __ptr_.first();297 pointer __tmp = __ptr_;
290 __ptr_.first() = __p;298 __ptr_ = __p;
291 if (__tmp)299 if (__tmp)
292 __ptr_.second()(__tmp);300 __deleter_(__tmp);
293 }301 }
294302
295 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { __ptr_.swap(__u.__ptr_); }303 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT {
304 using std::swap;
305 swap(__ptr_, __u.__ptr_);
306 swap(__deleter_, __u.__deleter_);
307 }
308};
309
310// Bounds checking in unique_ptr<T[]>
311// ==================================
312//
313// We provide some helper classes that allow bounds checking when accessing a unique_ptr<T[]>.
314// There are a few cases where bounds checking can be implemented:
315//
316// 1. When an array cookie (see [1]) exists at the beginning of the array allocation, we are
317// able to reuse that cookie to extract the size of the array and perform bounds checking.
318// An array cookie is a size inserted at the beginning of the allocation by the compiler.
319// That size is inserted implicitly when doing `new T[n]` in some cases (as of writing this
320// exactly when the array elements are not trivially destructible), and its main purpose is
321// to allow the runtime to destroy the `n` array elements when doing `delete[] array`.
322// When we are able to use array cookies, we reuse information already available in the
323// current runtime, so bounds checking does not require changing libc++'s ABI.
324//
325// However, note that we cannot assume the presence of an array cookie when a custom deleter
326// is used, because the unique_ptr could have been created from an allocation that wasn't
327// obtained via `new T[n]` (since it may not be deleted with `delete[] arr`).
328//
329// 2. When the "bounded unique_ptr" ABI configuration (controlled by `_LIBCPP_ABI_BOUNDED_UNIQUE_PTR`)
330// is enabled, we store the size of the allocation (when it is known) so we can check it when
331// indexing into the `unique_ptr`. That changes the layout of `std::unique_ptr<T[]>`, which is
332// an ABI break from the default configuration.
333//
334// Note that even under this ABI configuration, we can't always know the size of the unique_ptr.
335// Indeed, the size of the allocation can only be known when the unique_ptr is created via
336// make_unique or a similar API. For example, it can't be known when constructed from an arbitrary
337// pointer, in which case we are not able to check the bounds on access:
338//
339// unique_ptr<T[], MyDeleter> ptr(new T[3]);
340//
341// When we don't know the size of the allocation via the API used to create the unique_ptr, we
342// try to fall back to using an array cookie when available.
343//
344// Finally, note that when this ABI configuration is enabled, we have no choice but to always
345// make space for the size to be stored in the unique_ptr. Indeed, while we might want to avoid
346// storing the size when an array cookie is available, knowing whether an array cookie is available
347// requires the type stored in the unique_ptr to be complete, while unique_ptr can normally
348// accommodate incomplete types.
349//
350// (1) Implementation where we rely on the array cookie to know the size of the allocation, if
351// an array cookie exists.
352struct __unique_ptr_array_bounds_stateless {
353 __unique_ptr_array_bounds_stateless() = default;
354 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __unique_ptr_array_bounds_stateless(size_t) {}
355
356 template <class _Deleter,
357 class _Tp,
358 __enable_if_t<__is_default_deleter<_Deleter>::value && __has_array_cookie<_Tp>::value, int> = 0>
359 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const {
360 // In constant expressions, we can't check the array cookie so we just pretend that the index
361 // is in-bounds. The compiler catches invalid accesses anyway.
362 if (__libcpp_is_constant_evaluated())
363 return true;
364 size_t __cookie = std::__get_array_cookie(__ptr);
365 return __index < __cookie;
366 }
367
368 template <class _Deleter,
369 class _Tp,
370 __enable_if_t<!__is_default_deleter<_Deleter>::value || !__has_array_cookie<_Tp>::value, int> = 0>
371 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t) const {
372 return true; // If we don't have an array cookie, we assume the access is in-bounds
373 }
374};
375
376// (2) Implementation where we store the size in the class whenever we have it.
377//
378// Semantically, we'd need to store the size as an optional<size_t>. However, since that
379// is really heavy weight, we instead store a size_t and use SIZE_MAX as a magic value
380// meaning that we don't know the size.
381struct __unique_ptr_array_bounds_stored {
382 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __unique_ptr_array_bounds_stored() : __size_(SIZE_MAX) {}
383 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __unique_ptr_array_bounds_stored(size_t __size) : __size_(__size) {}
384
385 // Use the array cookie if there's one
386 template <class _Deleter,
387 class _Tp,
388 __enable_if_t<__is_default_deleter<_Deleter>::value && __has_array_cookie<_Tp>::value, int> = 0>
389 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const {
390 if (__libcpp_is_constant_evaluated())
391 return true;
392 size_t __cookie = std::__get_array_cookie(__ptr);
393 return __index < __cookie;
394 }
395
396 // Otherwise, fall back on the stored size (if any)
397 template <class _Deleter,
398 class _Tp,
399 __enable_if_t<!__is_default_deleter<_Deleter>::value || !__has_array_cookie<_Tp>::value, int> = 0>
400 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t __index) const {
401 return __index < __size_;
402 }
403
404private:
405 size_t __size_;
296};406};
297407
298template <class _Tp, class _Dp>408template <class _Tp, class _Dp>
...@@ -300,21 +410,31 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp>...@@ -300,21 +410,31 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp>
300public:410public:
301 typedef _Tp element_type;411 typedef _Tp element_type;
302 typedef _Dp deleter_type;412 typedef _Dp deleter_type;
303 typedef typename __pointer<_Tp, deleter_type>::type pointer;413 using pointer = __pointer<_Tp, deleter_type>;
304414
305 // A unique_ptr contains the following members which may be trivially relocatable:415 // A unique_ptr contains the following members which may be trivially relocatable:
306 // - pointer : this may be trivially relocatable, so it's checked416 // - pointer: this may be trivially relocatable, so it's checked
307 // - deleter_type: this may be trivially relocatable, so it's checked417 // - deleter_type: this may be trivially relocatable, so it's checked
418 // - (optionally) size: this is trivially relocatable
308 //419 //
309 // This unique_ptr implementation only contains a pointer to the unique object and a deleter, so there are no420 // This unique_ptr implementation only contains a pointer to the unique object and a deleter, so there are no
310 // references to itself. This means that the entire structure is trivially relocatable if its members are.421 // references to itself. This means that the entire structure is trivially relocatable if its members are.
311 using __trivially_relocatable = __conditional_t<422 using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<
312 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,423 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,
313 unique_ptr,424 unique_ptr,
314 void>;425 void>;
315426
316private:427private:
317 __compressed_pair<pointer, deleter_type> __ptr_;428 template <class _Up, class _OtherDeleter>
429 friend class unique_ptr;
430
431 _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_);
432#ifdef _LIBCPP_ABI_BOUNDED_UNIQUE_PTR
433 using _BoundsChecker _LIBCPP_NODEBUG = __unique_ptr_array_bounds_stored;
434#else
435 using _BoundsChecker _LIBCPP_NODEBUG = __unique_ptr_array_bounds_stateless;
436#endif
437 _LIBCPP_NO_UNIQUE_ADDRESS _BoundsChecker __checker_;
318438
319 template <class _From>439 template <class _From>
320 struct _CheckArrayPointerConversion : is_same<_From, pointer> {};440 struct _CheckArrayPointerConversion : is_same<_From, pointer> {};
...@@ -363,42 +483,54 @@ private:...@@ -363,42 +483,54 @@ private:
363483
364public:484public:
365 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >485 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
366 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}486 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(), __deleter_() {}
367487
368 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >488 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
369 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT489 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(), __deleter_() {}
370 : __ptr_(__value_init_tag(), __value_init_tag()) {}
371490
372 template <class _Pp,491 template <class _Pp,
373 bool _Dummy = true,492 bool _Dummy = true,
374 class = _EnableIfDeleterDefaultConstructible<_Dummy>,493 class = _EnableIfDeleterDefaultConstructible<_Dummy>,
375 class = _EnableIfPointerConvertible<_Pp> >494 class = _EnableIfPointerConvertible<_Pp> >
376 _LIBCPP_HIDE_FROM_ABI495 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __ptr) _NOEXCEPT
377 _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __p) _NOEXCEPT : __ptr_(__p, __value_init_tag()) {}496 : __ptr_(__ptr),
497 __deleter_() {}
498
499 // Private constructor used by make_unique & friends to pass the size that was allocated
500 template <class _Tag, class _Ptr, __enable_if_t<is_same<_Tag, __private_constructor_tag>::value, int> = 0>
501 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Tag, _Ptr __ptr, size_t __size) _NOEXCEPT
502 : __ptr_(__ptr),
503 __checker_(__size) {}
378504
379 template <class _Pp,505 template <class _Pp,
380 bool _Dummy = true,506 bool _Dummy = true,
381 class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,507 class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,
382 class = _EnableIfPointerConvertible<_Pp> >508 class = _EnableIfPointerConvertible<_Pp> >
383 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __p, _LValRefType<_Dummy> __d) _NOEXCEPT509 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __ptr, _LValRefType<_Dummy> __deleter) _NOEXCEPT
384 : __ptr_(__p, __d) {}510 : __ptr_(__ptr),
511 __deleter_(__deleter) {}
385512
386 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >513 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
387 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _LValRefType<_Dummy> __d) _NOEXCEPT514 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _LValRefType<_Dummy> __deleter) _NOEXCEPT
388 : __ptr_(nullptr, __d) {}515 : __ptr_(nullptr),
516 __deleter_(__deleter) {}
389517
390 template <class _Pp,518 template <class _Pp,
391 bool _Dummy = true,519 bool _Dummy = true,
392 class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >,520 class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >,
393 class = _EnableIfPointerConvertible<_Pp> >521 class = _EnableIfPointerConvertible<_Pp> >
394 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT522 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
395 : __ptr_(__p, std::move(__d)) {523 unique_ptr(_Pp __ptr, _GoodRValRefType<_Dummy> __deleter) _NOEXCEPT
524 : __ptr_(__ptr),
525 __deleter_(std::move(__deleter)) {
396 static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");526 static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
397 }527 }
398528
399 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >529 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
400 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __d) _NOEXCEPT530 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
401 : __ptr_(nullptr, std::move(__d)) {531 unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __deleter) _NOEXCEPT
532 : __ptr_(nullptr),
533 __deleter_(std::move(__deleter)) {
402 static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");534 static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
403 }535 }
404536
...@@ -406,14 +538,17 @@ public:...@@ -406,14 +538,17 @@ public:
406 bool _Dummy = true,538 bool _Dummy = true,
407 class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> >,539 class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> >,
408 class = _EnableIfPointerConvertible<_Pp> >540 class = _EnableIfPointerConvertible<_Pp> >
409 _LIBCPP_HIDE_FROM_ABI unique_ptr(_Pp __p, _BadRValRefType<_Dummy> __d) = delete;541 _LIBCPP_HIDE_FROM_ABI unique_ptr(_Pp __ptr, _BadRValRefType<_Dummy> __deleter) = delete;
410542
411 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT543 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT
412 : __ptr_(__u.release(), std::forward<deleter_type>(__u.get_deleter())) {}544 : __ptr_(__u.release()),
545 __deleter_(std::forward<deleter_type>(__u.get_deleter())),
546 __checker_(std::move(__u.__checker_)) {}
413547
414 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {548 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
415 reset(__u.release());549 reset(__u.release());
416 __ptr_.second() = std::forward<deleter_type>(__u.get_deleter());550 __deleter_ = std::forward<deleter_type>(__u.get_deleter());
551 __checker_ = std::move(__u.__checker_);
417 return *this;552 return *this;
418 }553 }
419554
...@@ -422,7 +557,9 @@ public:...@@ -422,7 +557,9 @@ public:
422 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,557 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
423 class = _EnableIfDeleterConvertible<_Ep> >558 class = _EnableIfDeleterConvertible<_Ep> >
424 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT559 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
425 : __ptr_(__u.release(), std::forward<_Ep>(__u.get_deleter())) {}560 : __ptr_(__u.release()),
561 __deleter_(std::forward<_Ep>(__u.get_deleter())),
562 __checker_(std::move(__u.__checker_)) {}
426563
427 template <class _Up,564 template <class _Up,
428 class _Ep,565 class _Ep,
...@@ -430,7 +567,8 @@ public:...@@ -430,7 +567,8 @@ public:
430 class = _EnableIfDeleterAssignable<_Ep> >567 class = _EnableIfDeleterAssignable<_Ep> >
431 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {568 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
432 reset(__u.release());569 reset(__u.release());
433 __ptr_.second() = std::forward<_Ep>(__u.get_deleter());570 __deleter_ = std::forward<_Ep>(__u.get_deleter());
571 __checker_ = std::move(__u.__checker_);
434 return *this;572 return *this;
435 }573 }
436574
...@@ -448,41 +586,52 @@ public:...@@ -448,41 +586,52 @@ public:
448 }586 }
449587
450 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator[](size_t __i) const {588 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator[](size_t __i) const {
451 return __ptr_.first()[__i];589 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__checker_.__in_bounds<deleter_type>(std::__to_address(__ptr_), __i),
590 "unique_ptr<T[]>::operator[](index): index out of range");
591 return __ptr_[__i];
452 }592 }
453 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); }593 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_; }
454594
455 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __ptr_.second(); }595 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __deleter_; }
456596
457 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {597 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {
458 return __ptr_.second();598 return __deleter_;
459 }599 }
460 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT {600 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT {
461 return __ptr_.first() != nullptr;601 return __ptr_ != nullptr;
462 }602 }
463603
464 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT {604 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT {
465 pointer __t = __ptr_.first();605 pointer __t = __ptr_;
466 __ptr_.first() = pointer();606 __ptr_ = pointer();
607 // The deleter and the optional bounds-checker are left unchanged. The bounds-checker
608 // will be reinitialized appropriately when/if the unique_ptr gets assigned-to or reset.
467 return __t;609 return __t;
468 }610 }
469611
470 template <class _Pp, __enable_if_t<_CheckArrayPointerConversion<_Pp>::value, int> = 0>612 template <class _Pp, __enable_if_t<_CheckArrayPointerConversion<_Pp>::value, int> = 0>
471 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(_Pp __p) _NOEXCEPT {613 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(_Pp __ptr) _NOEXCEPT {
472 pointer __tmp = __ptr_.first();614 pointer __tmp = __ptr_;
473 __ptr_.first() = __p;615 __ptr_ = __ptr;
616 __checker_ = _BoundsChecker();
474 if (__tmp)617 if (__tmp)
475 __ptr_.second()(__tmp);618 __deleter_(__tmp);
476 }619 }
477620
478 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(nullptr_t = nullptr) _NOEXCEPT {621 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(nullptr_t = nullptr) _NOEXCEPT {
479 pointer __tmp = __ptr_.first();622 pointer __tmp = __ptr_;
480 __ptr_.first() = nullptr;623 __ptr_ = nullptr;
624 __checker_ = _BoundsChecker();
481 if (__tmp)625 if (__tmp)
482 __ptr_.second()(__tmp);626 __deleter_(__tmp);
483 }627 }
484628
485 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { __ptr_.swap(__u.__ptr_); }629 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT {
630 using std::swap;
631 swap(__ptr_, __u.__ptr_);
632 swap(__deleter_, __u.__deleter_);
633 swap(__checker_, __u.__checker_);
634 }
486};635};
487636
488template <class _Tp, class _Dp, __enable_if_t<__is_swappable_v<_Dp>, int> = 0>637template <class _Tp, class _Dp, __enable_if_t<__is_swappable_v<_Dp>, int> = 0>
...@@ -613,55 +762,36 @@ operator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {...@@ -613,55 +762,36 @@ operator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
613762
614#if _LIBCPP_STD_VER >= 14763#if _LIBCPP_STD_VER >= 14
615764
616template <class _Tp>765template <class _Tp, class... _Args, enable_if_t<!is_array<_Tp>::value, int> = 0>
617struct __unique_if {766inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique(_Args&&... __args) {
618 typedef unique_ptr<_Tp> __unique_single;
619};
620
621template <class _Tp>
622struct __unique_if<_Tp[]> {
623 typedef unique_ptr<_Tp[]> __unique_array_unknown_bound;
624};
625
626template <class _Tp, size_t _Np>
627struct __unique_if<_Tp[_Np]> {
628 typedef void __unique_array_known_bound;
629};
630
631template <class _Tp, class... _Args>
632inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_single
633make_unique(_Args&&... __args) {
634 return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...));767 return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...));
635}768}
636769
637template <class _Tp>770template <class _Tp, enable_if_t<__is_unbounded_array_v<_Tp>, int> = 0>
638inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_array_unknown_bound771inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique(size_t __n) {
639make_unique(size_t __n) {
640 typedef __remove_extent_t<_Tp> _Up;772 typedef __remove_extent_t<_Tp> _Up;
641 return unique_ptr<_Tp>(new _Up[__n]());773 return unique_ptr<_Tp>(__private_constructor_tag(), new _Up[__n](), __n);
642}774}
643775
644template <class _Tp, class... _Args>776template <class _Tp, class... _Args, enable_if_t<__is_bounded_array_v<_Tp>, int> = 0>
645typename __unique_if<_Tp>::__unique_array_known_bound make_unique(_Args&&...) = delete;777void make_unique(_Args&&...) = delete;
646778
647#endif // _LIBCPP_STD_VER >= 14779#endif // _LIBCPP_STD_VER >= 14
648780
649#if _LIBCPP_STD_VER >= 20781#if _LIBCPP_STD_VER >= 20
650782
651template <class _Tp>783template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0>
652_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_single784_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique_for_overwrite() {
653make_unique_for_overwrite() {
654 return unique_ptr<_Tp>(new _Tp);785 return unique_ptr<_Tp>(new _Tp);
655}786}
656787
657template <class _Tp>788template <class _Tp, enable_if_t<is_unbounded_array_v<_Tp>, int> = 0>
658_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_array_unknown_bound789_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique_for_overwrite(size_t __n) {
659make_unique_for_overwrite(size_t __n) {790 return unique_ptr<_Tp>(__private_constructor_tag(), new __remove_extent_t<_Tp>[__n], __n);
660 return unique_ptr<_Tp>(new __remove_extent_t<_Tp>[__n]);
661}791}
662792
663template <class _Tp, class... _Args>793template <class _Tp, class... _Args, enable_if_t<is_bounded_array_v<_Tp>, int> = 0>
664typename __unique_if<_Tp>::__unique_array_known_bound make_unique_for_overwrite(_Args&&...) = delete;794void make_unique_for_overwrite(_Args&&...) = delete;
665795
666#endif // _LIBCPP_STD_VER >= 20796#endif // _LIBCPP_STD_VER >= 20
667797
lib/libcxx/include/__memory/unique_temporary_buffer.h created+93
...@@ -0,0 +1,93 @@
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_UNIQUE_TEMPORARY_BUFFER_H
11#define _LIBCPP___MEMORY_UNIQUE_TEMPORARY_BUFFER_H
12
13#include <__assert>
14#include <__config>
15
16#include <__cstddef/ptrdiff_t.h>
17#include <__memory/allocator.h>
18#include <__memory/unique_ptr.h>
19#include <__new/allocate.h>
20#include <__new/global_new_delete.h>
21#include <__type_traits/is_constant_evaluated.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29template <class _Tp>
30struct __temporary_buffer_deleter {
31 ptrdiff_t __count_; // ignored in non-constant evaluation
32
33 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __temporary_buffer_deleter() _NOEXCEPT : __count_(0) {}
34 _LIBCPP_HIDE_FROM_ABI
35 _LIBCPP_CONSTEXPR explicit __temporary_buffer_deleter(ptrdiff_t __count) _NOEXCEPT : __count_(__count) {}
36
37 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator()(_Tp* __ptr) _NOEXCEPT {
38 if (__libcpp_is_constant_evaluated()) {
39 allocator<_Tp>().deallocate(__ptr, __count_);
40 return;
41 }
42
43 std::__libcpp_deallocate_unsized<_Tp>(__ptr);
44 }
45};
46
47template <class _Tp>
48using __unique_temporary_buffer _LIBCPP_NODEBUG = unique_ptr<_Tp, __temporary_buffer_deleter<_Tp> >;
49
50template <class _Tp>
51inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_CONSTEXPR_SINCE_CXX23 __unique_temporary_buffer<_Tp>
52__allocate_unique_temporary_buffer(ptrdiff_t __count) {
53 using __deleter_type = __temporary_buffer_deleter<_Tp>;
54 using __unique_buffer_type = __unique_temporary_buffer<_Tp>;
55
56 if (__libcpp_is_constant_evaluated()) {
57 return __unique_buffer_type(allocator<_Tp>().allocate(__count), __deleter_type(__count));
58 }
59
60 _Tp* __ptr = nullptr;
61 const ptrdiff_t __max_count =
62 (~ptrdiff_t(0) ^ ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) / sizeof(_Tp);
63 if (__count > __max_count)
64 __count = __max_count;
65 while (__count > 0) {
66#if _LIBCPP_HAS_ALIGNED_ALLOCATION
67 if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) {
68 align_val_t __al = align_val_t(_LIBCPP_ALIGNOF(_Tp));
69 __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), __al, nothrow));
70 } else {
71 __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), nothrow));
72 }
73#else
74 if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) {
75 // Since aligned operator new is unavailable, constructs an empty buffer rather than one with invalid alignment.
76 return __unique_buffer_type();
77 }
78
79 __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), nothrow));
80#endif
81
82 if (__ptr) {
83 break;
84 }
85 __count /= 2;
86 }
87
88 return __unique_buffer_type(__ptr, __deleter_type(__count));
89}
90
91_LIBCPP_END_NAMESPACE_STD
92
93#endif // _LIBCPP___MEMORY_UNIQUE_TEMPORARY_BUFFER_H
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/integral_constant.h>
14#include <__type_traits/is_convertible.h>15#include <__type_traits/is_convertible.h>
15#include <cstddef>
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+122-129
...@@ -40,104 +40,8 @@ inline constexpr bool __is_std_pair<pair<_Type1, _Type2>> = true;...@@ -40,104 +40,8 @@ inline constexpr bool __is_std_pair<pair<_Type1, _Type2>> = true;
40template <class _Tp>40template <class _Tp>
41inline constexpr bool __is_cv_std_pair = __is_std_pair<remove_cv_t<_Tp>>;41inline constexpr bool __is_cv_std_pair = __is_std_pair<remove_cv_t<_Tp>>;
4242
43template <class _Type, class _Alloc, class... _Args, __enable_if_t<!__is_cv_std_pair<_Type>, int> = 0>43template <class _Tp, class = void>
44_LIBCPP_HIDE_FROM_ABI constexpr auto44struct __uses_allocator_construction_args;
45__uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept {
46 if constexpr (!uses_allocator_v<remove_cv_t<_Type>, _Alloc> && is_constructible_v<_Type, _Args...>) {
47 return std::forward_as_tuple(std::forward<_Args>(__args)...);
48 } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> &&
49 is_constructible_v<_Type, allocator_arg_t, const _Alloc&, _Args...>) {
50 return tuple<allocator_arg_t, const _Alloc&, _Args&&...>(allocator_arg, __alloc, std::forward<_Args>(__args)...);
51 } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> &&
52 is_constructible_v<_Type, _Args..., const _Alloc&>) {
53 return std::forward_as_tuple(std::forward<_Args>(__args)..., __alloc);
54 } else {
55 static_assert(
56 sizeof(_Type) + 1 == 0, "If uses_allocator_v<Type> is true, the type has to be allocator-constructible");
57 }
58}
59
60template <class _Pair, class _Alloc, class _Tuple1, class _Tuple2, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
61_LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(
62 const _Alloc& __alloc, piecewise_construct_t, _Tuple1&& __x, _Tuple2&& __y) noexcept {
63 return std::make_tuple(
64 piecewise_construct,
65 std::apply(
66 [&__alloc](auto&&... __args1) {
67 return std::__uses_allocator_construction_args<typename _Pair::first_type>(
68 __alloc, std::forward<decltype(__args1)>(__args1)...);
69 },
70 std::forward<_Tuple1>(__x)),
71 std::apply(
72 [&__alloc](auto&&... __args2) {
73 return std::__uses_allocator_construction_args<typename _Pair::second_type>(
74 __alloc, std::forward<decltype(__args2)>(__args2)...);
75 },
76 std::forward<_Tuple2>(__y)));
77}
78
79template <class _Pair, class _Alloc, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
80_LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc) noexcept {
81 return std::__uses_allocator_construction_args<_Pair>(__alloc, piecewise_construct, tuple<>{}, tuple<>{});
82}
83
84template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
85_LIBCPP_HIDE_FROM_ABI constexpr auto
86__uses_allocator_construction_args(const _Alloc& __alloc, _Up&& __u, _Vp&& __v) noexcept {
87 return std::__uses_allocator_construction_args<_Pair>(
88 __alloc,
89 piecewise_construct,
90 std::forward_as_tuple(std::forward<_Up>(__u)),
91 std::forward_as_tuple(std::forward<_Vp>(__v)));
92}
93
94# if _LIBCPP_STD_VER >= 23
95template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
96_LIBCPP_HIDE_FROM_ABI constexpr auto
97__uses_allocator_construction_args(const _Alloc& __alloc, 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# endif
102
103template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
104_LIBCPP_HIDE_FROM_ABI constexpr auto
105__uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>& __pair) noexcept {
106 return std::__uses_allocator_construction_args<_Pair>(
107 __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second));
108}
109
110template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
111_LIBCPP_HIDE_FROM_ABI constexpr auto
112__uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>&& __pair) noexcept {
113 return std::__uses_allocator_construction_args<_Pair>(
114 __alloc,
115 piecewise_construct,
116 std::forward_as_tuple(std::get<0>(std::move(__pair))),
117 std::forward_as_tuple(std::get<1>(std::move(__pair))));
118}
119
120# if _LIBCPP_STD_VER >= 23
121template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
122_LIBCPP_HIDE_FROM_ABI constexpr auto
123__uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&& __pair) noexcept {
124 return std::__uses_allocator_construction_args<_Pair>(
125 __alloc,
126 piecewise_construct,
127 std::forward_as_tuple(std::get<0>(std::move(__pair))),
128 std::forward_as_tuple(std::get<1>(std::move(__pair))));
129}
130
131template <class _Pair, class _Alloc, __pair_like_no_subrange _PairLike, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
132_LIBCPP_HIDE_FROM_ABI constexpr auto
133__uses_allocator_construction_args(const _Alloc& __alloc, _PairLike&& __p) noexcept {
134 return std::__uses_allocator_construction_args<_Pair>(
135 __alloc,
136 piecewise_construct,
137 std::forward_as_tuple(std::get<0>(std::forward<_PairLike>(__p))),
138 std::forward_as_tuple(std::get<1>(std::forward<_PairLike>(__p))));
139}
140# endif
14145
142namespace __uses_allocator_detail {46namespace __uses_allocator_detail {
14347
...@@ -165,46 +69,135 @@ inline constexpr bool __uses_allocator_constraints = __is_cv_std_pair<_Tp> && !_...@@ -165,46 +69,135 @@ inline constexpr bool __uses_allocator_constraints = __is_cv_std_pair<_Tp> && !_
16569
166} // namespace __uses_allocator_detail70} // namespace __uses_allocator_detail
16771
168template < class _Pair,
169 class _Alloc,
170 class _Type,
171 __enable_if_t<__uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int> = 0>
172_LIBCPP_HIDE_FROM_ABI constexpr auto
173__uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept;
174
175template <class _Type, class _Alloc, class... _Args>72template <class _Type, class _Alloc, class... _Args>
176_LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args);73_LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args);
17774
178template < class _Pair,75template <class _Pair>
179 class _Alloc,76struct __uses_allocator_construction_args<_Pair, __enable_if_t<__is_cv_std_pair<_Pair>>> {
180 class _Type,77 template <class _Alloc, class _Tuple1, class _Tuple2>
181 __enable_if_t< __uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int>>78 static _LIBCPP_HIDE_FROM_ABI constexpr auto
182_LIBCPP_HIDE_FROM_ABI constexpr auto79 __apply(const _Alloc& __alloc, piecewise_construct_t, _Tuple1&& __x, _Tuple2&& __y) noexcept {
183__uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept {80 return std::make_tuple(
184 struct __pair_constructor {81 piecewise_construct,
185 using _PairMutable = remove_cv_t<_Pair>;82 std::apply(
83 [&__alloc](auto&&... __args1) {
84 return __uses_allocator_construction_args<typename _Pair::first_type>::__apply(
85 __alloc, std::forward<decltype(__args1)>(__args1)...);
86 },
87 std::forward<_Tuple1>(__x)),
88 std::apply(
89 [&__alloc](auto&&... __args2) {
90 return __uses_allocator_construction_args<typename _Pair::second_type>::__apply(
91 __alloc, std::forward<decltype(__args2)>(__args2)...);
92 },
93 std::forward<_Tuple2>(__y)));
94 }
18695
187 _LIBCPP_HIDDEN constexpr auto __do_construct(const _PairMutable& __pair) const {96 template <class _Alloc>
188 return std::__make_obj_using_allocator<_PairMutable>(__alloc_, __pair);97 static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc) noexcept {
189 }98 return __uses_allocator_construction_args<_Pair>::__apply(__alloc, piecewise_construct, tuple<>{}, tuple<>{});
99 }
190100
191 _LIBCPP_HIDDEN constexpr auto __do_construct(_PairMutable&& __pair) const {101 template <class _Alloc, class _Up, class _Vp>
192 return std::__make_obj_using_allocator<_PairMutable>(__alloc_, std::move(__pair));102 static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, _Up&& __u, _Vp&& __v) noexcept {
193 }103 return __uses_allocator_construction_args<_Pair>::__apply(
104 __alloc,
105 piecewise_construct,
106 std::forward_as_tuple(std::forward<_Up>(__u)),
107 std::forward_as_tuple(std::forward<_Vp>(__v)));
108 }
194109
195 const _Alloc& __alloc_;110# if _LIBCPP_STD_VER >= 23
196 _Type& __value_;111 template <class _Alloc, class _Up, class _Vp>
112 static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, pair<_Up, _Vp>& __pair) noexcept {
113 return __uses_allocator_construction_args<_Pair>::__apply(
114 __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second));
115 }
116# endif
197117
198 _LIBCPP_HIDDEN constexpr operator _PairMutable() const { return __do_construct(std::forward<_Type>(__value_)); }118 template <class _Alloc, class _Up, class _Vp>
199 };119 static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, const pair<_Up, _Vp>& __pair) noexcept {
120 return __uses_allocator_construction_args<_Pair>::__apply(
121 __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second));
122 }
200123
201 return std::make_tuple(__pair_constructor{__alloc, __value});124 template <class _Alloc, class _Up, class _Vp>
202}125 static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, pair<_Up, _Vp>&& __pair) noexcept {
126 return __uses_allocator_construction_args<_Pair>::__apply(
127 __alloc,
128 piecewise_construct,
129 std::forward_as_tuple(std::get<0>(std::move(__pair))),
130 std::forward_as_tuple(std::get<1>(std::move(__pair))));
131 }
132
133# if _LIBCPP_STD_VER >= 23
134 template <class _Alloc, class _Up, class _Vp>
135 static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, const pair<_Up, _Vp>&& __pair) noexcept {
136 return __uses_allocator_construction_args<_Pair>::__apply(
137 __alloc,
138 piecewise_construct,
139 std::forward_as_tuple(std::get<0>(std::move(__pair))),
140 std::forward_as_tuple(std::get<1>(std::move(__pair))));
141 }
142
143 template < class _Alloc, __pair_like_no_subrange _PairLike>
144 static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, _PairLike&& __p) noexcept {
145 return __uses_allocator_construction_args<_Pair>::__apply(
146 __alloc,
147 piecewise_construct,
148 std::forward_as_tuple(std::get<0>(std::forward<_PairLike>(__p))),
149 std::forward_as_tuple(std::get<1>(std::forward<_PairLike>(__p))));
150 }
151# endif
152
153 template <class _Alloc,
154 class _Type,
155 __enable_if_t<__uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int> = 0>
156 static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, _Type&& __value) noexcept {
157 struct __pair_constructor {
158 using _PairMutable = remove_cv_t<_Pair>;
159
160 _LIBCPP_HIDDEN constexpr auto __do_construct(const _PairMutable& __pair) const {
161 return std::__make_obj_using_allocator<_PairMutable>(__alloc_, __pair);
162 }
163
164 _LIBCPP_HIDDEN constexpr auto __do_construct(_PairMutable&& __pair) const {
165 return std::__make_obj_using_allocator<_PairMutable>(__alloc_, std::move(__pair));
166 }
167
168 const _Alloc& __alloc_;
169 _Type& __value_;
170
171 _LIBCPP_HIDDEN constexpr operator _PairMutable() const { return __do_construct(std::forward<_Type>(__value_)); }
172 };
173
174 return std::make_tuple(__pair_constructor{__alloc, __value});
175 }
176};
177
178template <class _Type>
179struct __uses_allocator_construction_args<_Type, __enable_if_t<!__is_cv_std_pair<_Type>>> {
180 template <class _Alloc, class... _Args>
181 static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, _Args&&... __args) noexcept {
182 if constexpr (!uses_allocator_v<remove_cv_t<_Type>, _Alloc> && is_constructible_v<_Type, _Args...>) {
183 return std::forward_as_tuple(std::forward<_Args>(__args)...);
184 } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> &&
185 is_constructible_v<_Type, allocator_arg_t, const _Alloc&, _Args...>) {
186 return tuple<allocator_arg_t, const _Alloc&, _Args&&...>(allocator_arg, __alloc, std::forward<_Args>(__args)...);
187 } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> &&
188 is_constructible_v<_Type, _Args..., const _Alloc&>) {
189 return std::forward_as_tuple(std::forward<_Args>(__args)..., __alloc);
190 } else {
191 static_assert(
192 sizeof(_Type) + 1 == 0, "If uses_allocator_v<Type> is true, the type has to be allocator-constructible");
193 }
194 }
195};
203196
204template <class _Type, class _Alloc, class... _Args>197template <class _Type, class _Alloc, class... _Args>
205_LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args) {198_LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args) {
206 return std::make_from_tuple<_Type>(199 return std::make_from_tuple<_Type>(
207 std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...));200 __uses_allocator_construction_args<_Type>::__apply(__alloc, std::forward<_Args>(__args)...));
208}201}
209202
210template <class _Type, class _Alloc, class... _Args>203template <class _Type, class _Alloc, class... _Args>
...@@ -212,7 +205,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Type*...@@ -212,7 +205,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Type*
212__uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _Args&&... __args) {205__uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _Args&&... __args) {
213 return std::apply(206 return std::apply(
214 [&__ptr](auto&&... __xs) { return std::__construct_at(__ptr, std::forward<decltype(__xs)>(__xs)...); },207 [&__ptr](auto&&... __xs) { return std::__construct_at(__ptr, std::forward<decltype(__xs)>(__xs)...); },
215 std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...));208 __uses_allocator_construction_args<_Type>::__apply(__alloc, std::forward<_Args>(__args)...));
216}209}
217210
218#endif // _LIBCPP_STD_VER >= 17211#endif // _LIBCPP_STD_VER >= 17
...@@ -221,8 +214,8 @@ __uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _...@@ -221,8 +214,8 @@ __uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _
221214
222template <class _Type, class _Alloc, class... _Args>215template <class _Type, class _Alloc, class... _Args>
223_LIBCPP_HIDE_FROM_ABI constexpr auto uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept216_LIBCPP_HIDE_FROM_ABI constexpr auto uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept
224 -> decltype(std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...)) {217 -> decltype(__uses_allocator_construction_args<_Type>::__apply(__alloc, std::forward<_Args>(__args)...)) {
225 return /*--*/ std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...);218 return /*--*/ __uses_allocator_construction_args<_Type>::__apply(__alloc, std::forward<_Args>(__args)...);
226}219}
227220
228template <class _Type, class _Alloc, class... _Args>221template <class _Type, class _Alloc, class... _Args>
lib/libcxx/include/__memory/voidify.h deleted-30
...@@ -1,30 +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___MEMORY_VOIDIFY_H
11#define _LIBCPP___MEMORY_VOIDIFY_H
12
13#include <__config>
14#include <__memory/addressof.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 <typename _Tp>
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.
25 return const_cast<void*>(static_cast<const volatile void*>(std::addressof(__from)));
26}
27
28_LIBCPP_END_NAMESPACE_STD
29
30#endif // _LIBCPP___MEMORY_VOIDIFY_H
lib/libcxx/include/__memory_resource/memory_resource.h+2-1
...@@ -10,8 +10,9 @@...@@ -10,8 +10,9 @@
10#define _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H10#define _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/max_align_t.h>
14#include <__cstddef/size_t.h>
13#include <__fwd/memory_resource.h>15#include <__fwd/memory_resource.h>
14#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
lib/libcxx/include/__memory_resource/monotonic_buffer_resource.h+2-5
...@@ -10,9 +10,9 @@...@@ -10,9 +10,9 @@
10#define _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H10#define _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__memory/addressof.h>14#include <__memory/addressof.h>
14#include <__memory_resource/memory_resource.h>15#include <__memory_resource/memory_resource.h>
15#include <cstddef>
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
...@@ -27,8 +27,7 @@ namespace pmr {...@@ -27,8 +27,7 @@ namespace pmr {
27// [mem.res.monotonic.buffer]27// [mem.res.monotonic.buffer]
2828
29class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI monotonic_buffer_resource : public memory_resource {29class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI monotonic_buffer_resource : public memory_resource {
30 static const size_t __default_buffer_capacity = 1024;30 static constexpr size_t __default_buffer_capacity = 1024;
31 static const size_t __default_buffer_alignment = 16;
3231
33 struct __chunk_footer {32 struct __chunk_footer {
34 __chunk_footer* __next_;33 __chunk_footer* __next_;
...@@ -38,7 +37,6 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI monotonic_buffer_resour...@@ -38,7 +37,6 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI monotonic_buffer_resour
38 _LIBCPP_HIDE_FROM_ABI size_t __allocation_size() {37 _LIBCPP_HIDE_FROM_ABI size_t __allocation_size() {
39 return (reinterpret_cast<char*>(this) - __start_) + sizeof(*this);38 return (reinterpret_cast<char*>(this) - __start_) + sizeof(*this);
40 }39 }
41 void* __try_allocate_from_chunk(size_t, size_t);
42 };40 };
4341
44 struct __initial_descriptor {42 struct __initial_descriptor {
...@@ -48,7 +46,6 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI monotonic_buffer_resour...@@ -48,7 +46,6 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI monotonic_buffer_resour
48 char* __end_;46 char* __end_;
49 size_t __size_;47 size_t __size_;
50 };48 };
51 void* __try_allocate_from_chunk(size_t, size_t);
52 };49 };
5350
54public:51public:
lib/libcxx/include/__memory_resource/polymorphic_allocator.h+17-2
...@@ -11,12 +11,14 @@...@@ -11,12 +11,14 @@
1111
12#include <__assert>12#include <__assert>
13#include <__config>13#include <__config>
14#include <__cstddef/byte.h>
15#include <__cstddef/max_align_t.h>
14#include <__fwd/pair.h>16#include <__fwd/pair.h>
15#include <__memory_resource/memory_resource.h>17#include <__memory_resource/memory_resource.h>
18#include <__new/exceptions.h>
19#include <__new/placement_new_delete.h>
16#include <__utility/exception_guard.h>20#include <__utility/exception_guard.h>
17#include <cstddef>
18#include <limits>21#include <limits>
19#include <new>
20#include <tuple>22#include <tuple>
2123
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -174,6 +176,19 @@ public:...@@ -174,6 +176,19 @@ public:
174176
175 _LIBCPP_HIDE_FROM_ABI memory_resource* resource() const noexcept { return __res_; }177 _LIBCPP_HIDE_FROM_ABI memory_resource* resource() const noexcept { return __res_; }
176178
179 _LIBCPP_HIDE_FROM_ABI friend bool
180 operator==(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept {
181 return *__lhs.resource() == *__rhs.resource();
182 }
183
184# if _LIBCPP_STD_VER <= 17
185 // This overload is not specified, it was added due to LWG3683.
186 _LIBCPP_HIDE_FROM_ABI friend bool
187 operator!=(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept {
188 return *__lhs.resource() != *__rhs.resource();
189 }
190# endif
191
177private:192private:
178 template <class... _Args, size_t... _Is>193 template <class... _Args, size_t... _Is>
179 _LIBCPP_HIDE_FROM_ABI tuple<_Args&&...>194 _LIBCPP_HIDE_FROM_ABI tuple<_Args&&...>
lib/libcxx/include/__memory_resource/pool_options.h+1-1
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#define _LIBCPP___MEMORY_RESOURCE_POOL_OPTIONS_H10#define _LIBCPP___MEMORY_RESOURCE_POOL_OPTIONS_H
1111
12#include <__config>12#include <__config>
13#include <cstddef>13#include <__cstddef/size_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
lib/libcxx/include/__memory_resource/synchronized_pool_resource.h+7-6
...@@ -10,11 +10,12 @@...@@ -10,11 +10,12 @@
10#define _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H10#define _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__memory_resource/memory_resource.h>14#include <__memory_resource/memory_resource.h>
14#include <__memory_resource/pool_options.h>15#include <__memory_resource/pool_options.h>
15#include <__memory_resource/unsynchronized_pool_resource.h>16#include <__memory_resource/unsynchronized_pool_resource.h>
16#include <cstddef>17#include <__mutex/mutex.h>
17#include <mutex>18#include <__mutex/unique_lock.h>
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
...@@ -49,7 +50,7 @@ public:...@@ -49,7 +50,7 @@ public:
49 synchronized_pool_resource& operator=(const synchronized_pool_resource&) = delete;50 synchronized_pool_resource& operator=(const synchronized_pool_resource&) = delete;
5051
51 _LIBCPP_HIDE_FROM_ABI void release() {52 _LIBCPP_HIDE_FROM_ABI void release() {
52# if !defined(_LIBCPP_HAS_NO_THREADS)53# if _LIBCPP_HAS_THREADS
53 unique_lock<mutex> __lk(__mut_);54 unique_lock<mutex> __lk(__mut_);
54# endif55# endif
55 __unsync_.release();56 __unsync_.release();
...@@ -61,14 +62,14 @@ public:...@@ -61,14 +62,14 @@ public:
6162
62protected:63protected:
63 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void* do_allocate(size_t __bytes, size_t __align) override {64 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void* do_allocate(size_t __bytes, size_t __align) override {
64# if !defined(_LIBCPP_HAS_NO_THREADS)65# if _LIBCPP_HAS_THREADS
65 unique_lock<mutex> __lk(__mut_);66 unique_lock<mutex> __lk(__mut_);
66# endif67# endif
67 return __unsync_.allocate(__bytes, __align);68 return __unsync_.allocate(__bytes, __align);
68 }69 }
6970
70 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void do_deallocate(void* __p, size_t __bytes, size_t __align) override {71 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void do_deallocate(void* __p, size_t __bytes, size_t __align) override {
71# if !defined(_LIBCPP_HAS_NO_THREADS)72# if _LIBCPP_HAS_THREADS
72 unique_lock<mutex> __lk(__mut_);73 unique_lock<mutex> __lk(__mut_);
73# endif74# endif
74 return __unsync_.deallocate(__p, __bytes, __align);75 return __unsync_.deallocate(__p, __bytes, __align);
...@@ -77,7 +78,7 @@ protected:...@@ -77,7 +78,7 @@ protected:
77 bool do_is_equal(const memory_resource& __other) const noexcept override; // key function78 bool do_is_equal(const memory_resource& __other) const noexcept override; // key function
7879
79private:80private:
80# if !defined(_LIBCPP_HAS_NO_THREADS)81# if _LIBCPP_HAS_THREADS
81 mutex __mut_;82 mutex __mut_;
82# endif83# endif
83 unsynchronized_pool_resource __unsync_;84 unsynchronized_pool_resource __unsync_;
lib/libcxx/include/__memory_resource/unsynchronized_pool_resource.h+1-1
...@@ -10,9 +10,9 @@...@@ -10,9 +10,9 @@
10#define _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H10#define _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__memory_resource/memory_resource.h>14#include <__memory_resource/memory_resource.h>
14#include <__memory_resource/pool_options.h>15#include <__memory_resource/pool_options.h>
15#include <cstddef>
16#include <cstdint>16#include <cstdint>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__mutex/lock_guard.h+2-2
...@@ -27,13 +27,13 @@ private:...@@ -27,13 +27,13 @@ private:
27 mutex_type& __m_;27 mutex_type& __m_;
2828
29public:29public:
30 _LIBCPP_NODISCARD30 [[__nodiscard__]]
31 _LIBCPP_HIDE_FROM_ABI explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))31 _LIBCPP_HIDE_FROM_ABI explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
32 : __m_(__m) {32 : __m_(__m) {
33 __m_.lock();33 __m_.lock();
34 }34 }
3535
36 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t)36 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t)
37 _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))37 _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
38 : __m_(__m) {}38 : __m_(__m) {}
39 _LIBCPP_HIDE_FROM_ABI ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); }39 _LIBCPP_HIDE_FROM_ABI ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); }
lib/libcxx/include/__mutex/mutex.h+3-3
...@@ -17,7 +17,7 @@...@@ -17,7 +17,7 @@
17# pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20#ifndef _LIBCPP_HAS_NO_THREADS20#if _LIBCPP_HAS_THREADS
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
...@@ -30,7 +30,7 @@ public:...@@ -30,7 +30,7 @@ public:
30 mutex(const mutex&) = delete;30 mutex(const mutex&) = delete;
31 mutex& operator=(const mutex&) = delete;31 mutex& operator=(const mutex&) = delete;
3232
33# if defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION)33# if _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
34 _LIBCPP_HIDE_FROM_ABI ~mutex() = default;34 _LIBCPP_HIDE_FROM_ABI ~mutex() = default;
35# else35# else
36 ~mutex() _NOEXCEPT;36 ~mutex() _NOEXCEPT;
...@@ -48,6 +48,6 @@ static_assert(is_nothrow_default_constructible<mutex>::value, "the default const...@@ -48,6 +48,6 @@ static_assert(is_nothrow_default_constructible<mutex>::value, "the default const
4848
49_LIBCPP_END_NAMESPACE_STD49_LIBCPP_END_NAMESPACE_STD
5050
51#endif // _LIBCPP_HAS_NO_THREADS51#endif // _LIBCPP_HAS_THREADS
5252
53#endif // _LIBCPP___MUTEX_MUTEX_H53#endif // _LIBCPP___MUTEX_MUTEX_H
lib/libcxx/include/__mutex/once_flag.h+1-1
...@@ -11,7 +11,7 @@...@@ -11,7 +11,7 @@
1111
12#include <__config>12#include <__config>
13#include <__functional/invoke.h>13#include <__functional/invoke.h>
14#include <__memory/shared_ptr.h> // __libcpp_acquire_load14#include <__memory/shared_count.h> // __libcpp_acquire_load
15#include <__tuple/tuple_indices.h>15#include <__tuple/tuple_indices.h>
16#include <__tuple/tuple_size.h>16#include <__tuple/tuple_size.h>
17#include <__utility/forward.h>17#include <__utility/forward.h>
lib/libcxx/include/__mutex/unique_lock.h+19-23
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__config>14#include <__config>
15#include <__memory/addressof.h>15#include <__memory/addressof.h>
16#include <__mutex/tag_types.h>16#include <__mutex/tag_types.h>
17#include <__system_error/system_error.h>17#include <__system_error/throw_system_error.h>
18#include <__utility/swap.h>18#include <__utility/swap.h>
19#include <cerrno>19#include <cerrno>
2020
...@@ -22,8 +22,6 @@...@@ -22,8 +22,6 @@
22# pragma GCC system_header22# pragma GCC system_header
23#endif23#endif
2424
25#ifndef _LIBCPP_HAS_NO_THREADS
26
27_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2826
29template <class _Mutex>27template <class _Mutex>
...@@ -36,28 +34,28 @@ private:...@@ -36,28 +34,28 @@ private:
36 bool __owns_;34 bool __owns_;
3735
38public:36public:
39 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {}37 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {}
40 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI explicit unique_lock(mutex_type& __m)38 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI explicit unique_lock(mutex_type& __m)
41 : __m_(std::addressof(__m)), __owns_(true) {39 : __m_(std::addressof(__m)), __owns_(true) {
42 __m_->lock();40 __m_->lock();
43 }41 }
4442
45 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT43 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
46 : __m_(std::addressof(__m)),44 : __m_(std::addressof(__m)),
47 __owns_(false) {}45 __owns_(false) {}
4846
49 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, try_to_lock_t)47 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, try_to_lock_t)
50 : __m_(std::addressof(__m)), __owns_(__m.try_lock()) {}48 : __m_(std::addressof(__m)), __owns_(__m.try_lock()) {}
5149
52 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, adopt_lock_t)50 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, adopt_lock_t)
53 : __m_(std::addressof(__m)), __owns_(true) {}51 : __m_(std::addressof(__m)), __owns_(true) {}
5452
55 template <class _Clock, class _Duration>53 template <class _Clock, class _Duration>
56 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t)54 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t)
57 : __m_(std::addressof(__m)), __owns_(__m.try_lock_until(__t)) {}55 : __m_(std::addressof(__m)), __owns_(__m.try_lock_until(__t)) {}
5856
59 template <class _Rep, class _Period>57 template <class _Rep, class _Period>
60 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d)58 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d)
61 : __m_(std::addressof(__m)), __owns_(__m.try_lock_for(__d)) {}59 : __m_(std::addressof(__m)), __owns_(__m.try_lock_for(__d)) {}
6260
63 _LIBCPP_HIDE_FROM_ABI ~unique_lock() {61 _LIBCPP_HIDE_FROM_ABI ~unique_lock() {
...@@ -68,7 +66,7 @@ public:...@@ -68,7 +66,7 @@ public:
68 unique_lock(unique_lock const&) = delete;66 unique_lock(unique_lock const&) = delete;
69 unique_lock& operator=(unique_lock const&) = delete;67 unique_lock& operator=(unique_lock const&) = delete;
7068
71 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(unique_lock&& __u) _NOEXCEPT69 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(unique_lock&& __u) _NOEXCEPT
72 : __m_(__u.__m_),70 : __m_(__u.__m_),
73 __owns_(__u.__owns_) {71 __owns_(__u.__owns_) {
74 __u.__m_ = nullptr;72 __u.__m_ = nullptr;
...@@ -86,16 +84,16 @@ public:...@@ -86,16 +84,16 @@ public:
86 return *this;84 return *this;
87 }85 }
8886
89 void lock();87 _LIBCPP_HIDE_FROM_ABI void lock();
90 bool try_lock();88 _LIBCPP_HIDE_FROM_ABI bool try_lock();
9189
92 template <class _Rep, class _Period>90 template <class _Rep, class _Period>
93 bool try_lock_for(const chrono::duration<_Rep, _Period>& __d);91 _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d);
9492
95 template <class _Clock, class _Duration>93 template <class _Clock, class _Duration>
96 bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);94 _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
9795
98 void unlock();96 _LIBCPP_HIDE_FROM_ABI void unlock();
9997
100 _LIBCPP_HIDE_FROM_ABI void swap(unique_lock& __u) _NOEXCEPT {98 _LIBCPP_HIDE_FROM_ABI void swap(unique_lock& __u) _NOEXCEPT {
101 std::swap(__m_, __u.__m_);99 std::swap(__m_, __u.__m_);
...@@ -116,7 +114,7 @@ public:...@@ -116,7 +114,7 @@ public:
116_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock);114_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock);
117115
118template <class _Mutex>116template <class _Mutex>
119void unique_lock<_Mutex>::lock() {117_LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::lock() {
120 if (__m_ == nullptr)118 if (__m_ == nullptr)
121 __throw_system_error(EPERM, "unique_lock::lock: references null mutex");119 __throw_system_error(EPERM, "unique_lock::lock: references null mutex");
122 if (__owns_)120 if (__owns_)
...@@ -126,7 +124,7 @@ void unique_lock<_Mutex>::lock() {...@@ -126,7 +124,7 @@ void unique_lock<_Mutex>::lock() {
126}124}
127125
128template <class _Mutex>126template <class _Mutex>
129bool unique_lock<_Mutex>::try_lock() {127_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock() {
130 if (__m_ == nullptr)128 if (__m_ == nullptr)
131 __throw_system_error(EPERM, "unique_lock::try_lock: references null mutex");129 __throw_system_error(EPERM, "unique_lock::try_lock: references null mutex");
132 if (__owns_)130 if (__owns_)
...@@ -137,7 +135,7 @@ bool unique_lock<_Mutex>::try_lock() {...@@ -137,7 +135,7 @@ bool unique_lock<_Mutex>::try_lock() {
137135
138template <class _Mutex>136template <class _Mutex>
139template <class _Rep, class _Period>137template <class _Rep, class _Period>
140bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) {138_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) {
141 if (__m_ == nullptr)139 if (__m_ == nullptr)
142 __throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex");140 __throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex");
143 if (__owns_)141 if (__owns_)
...@@ -148,7 +146,7 @@ bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __...@@ -148,7 +146,7 @@ bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __
148146
149template <class _Mutex>147template <class _Mutex>
150template <class _Clock, class _Duration>148template <class _Clock, class _Duration>
151bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {149_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {
152 if (__m_ == nullptr)150 if (__m_ == nullptr)
153 __throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex");151 __throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex");
154 if (__owns_)152 if (__owns_)
...@@ -158,7 +156,7 @@ bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Durat...@@ -158,7 +156,7 @@ bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Durat
158}156}
159157
160template <class _Mutex>158template <class _Mutex>
161void unique_lock<_Mutex>::unlock() {159_LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::unlock() {
162 if (!__owns_)160 if (!__owns_)
163 __throw_system_error(EPERM, "unique_lock::unlock: not locked");161 __throw_system_error(EPERM, "unique_lock::unlock: not locked");
164 __m_->unlock();162 __m_->unlock();
...@@ -172,6 +170,4 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(unique_lock<_Mutex>& __x, unique_lock<_Mu...@@ -172,6 +170,4 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(unique_lock<_Mutex>& __x, unique_lock<_Mu
172170
173_LIBCPP_END_NAMESPACE_STD171_LIBCPP_END_NAMESPACE_STD
174172
175#endif // _LIBCPP_HAS_NO_THREADS
176
177#endif // _LIBCPP___MUTEX_UNIQUE_LOCK_H173#endif // _LIBCPP___MUTEX_UNIQUE_LOCK_H
lib/libcxx/include/__new/align_val_t.h created+30
...@@ -0,0 +1,30 @@
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___NEW_ALIGN_VAL_T_H
10#define _LIBCPP___NEW_ALIGN_VAL_T_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19// purposefully not using versioning namespace
20namespace std {
21#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME)
22# ifndef _LIBCPP_CXX03_LANG
23enum class align_val_t : size_t {};
24# else
25enum align_val_t { __zero = 0, __max = (size_t)-1 };
26# endif
27#endif
28} // namespace std
29
30#endif // _LIBCPP___NEW_ALIGN_VAL_T_H
lib/libcxx/include/__new/allocate.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___NEW_ALLOCATE_H
10#define _LIBCPP___NEW_ALLOCATE_H
11
12#include <__config>
13#include <__cstddef/max_align_t.h>
14#include <__cstddef/size_t.h>
15#include <__new/align_val_t.h>
16#include <__new/global_new_delete.h> // for _LIBCPP_HAS_SIZED_DEALLOCATION
17#include <__type_traits/type_identity.h>
18#include <__utility/element_count.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_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI bool __is_overaligned_for_new(size_t __align) _NOEXCEPT {
27#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
28 return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
29#else
30 return __align > _LIBCPP_ALIGNOF(max_align_t);
31#endif
32}
33
34template <class... _Args>
35_LIBCPP_HIDE_FROM_ABI void* __libcpp_operator_new(_Args... __args) {
36#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
37 return __builtin_operator_new(__args...);
38#else
39 return ::operator new(__args...);
40#endif
41}
42
43template <class... _Args>
44_LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) _NOEXCEPT {
45#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
46 __builtin_operator_delete(__args...);
47#else
48 ::operator delete(__args...);
49#endif
50}
51
52template <class _Tp>
53inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp*
54__libcpp_allocate(__element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) {
55 size_t __size = static_cast<size_t>(__n) * sizeof(_Tp);
56#if _LIBCPP_HAS_ALIGNED_ALLOCATION
57 if (__is_overaligned_for_new(__align)) {
58 const align_val_t __align_val = static_cast<align_val_t>(__align);
59 return static_cast<_Tp*>(std::__libcpp_operator_new(__size, __align_val));
60 }
61#endif
62
63 (void)__align;
64 return static_cast<_Tp*>(std::__libcpp_operator_new(__size));
65}
66
67#if _LIBCPP_HAS_SIZED_DEALLOCATION
68# define _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(...) __VA_ARGS__
69#else
70# define _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(...) /* nothing */
71#endif
72
73template <class _Tp>
74inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(
75 __type_identity_t<_Tp>* __ptr, __element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {
76 size_t __size = static_cast<size_t>(__n) * sizeof(_Tp);
77 (void)__size;
78#if !_LIBCPP_HAS_ALIGNED_ALLOCATION
79 (void)__align;
80 return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size));
81#else
82 if (__is_overaligned_for_new(__align)) {
83 const align_val_t __align_val = static_cast<align_val_t>(__align);
84 return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size), __align_val);
85 } else {
86 return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size));
87 }
88#endif
89}
90
91#undef _LIBCPP_ONLY_IF_SIZED_DEALLOCATION
92
93template <class _Tp>
94inline _LIBCPP_HIDE_FROM_ABI void
95__libcpp_deallocate_unsized(__type_identity_t<_Tp>* __ptr, size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {
96#if !_LIBCPP_HAS_ALIGNED_ALLOCATION
97 (void)__align;
98 return std::__libcpp_operator_delete(__ptr);
99#else
100 if (__is_overaligned_for_new(__align)) {
101 const align_val_t __align_val = static_cast<align_val_t>(__align);
102 return std::__libcpp_operator_delete(__ptr, __align_val);
103 } else {
104 return std::__libcpp_operator_delete(__ptr);
105 }
106#endif
107}
108_LIBCPP_END_NAMESPACE_STD
109
110#endif // _LIBCPP___NEW_ALLOCATE_H
lib/libcxx/include/__new/destroying_delete_t.h created+30
...@@ -0,0 +1,30 @@
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___NEW_DESTROYING_DELETE_T_H
10#define _LIBCPP___NEW_DESTROYING_DELETE_T_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// purposefully not using versioning namespace
20namespace std {
21// Enable the declaration even if the compiler doesn't support the language
22// feature.
23struct destroying_delete_t {
24 explicit destroying_delete_t() = default;
25};
26inline constexpr destroying_delete_t destroying_delete{};
27} // namespace std
28#endif
29
30#endif // _LIBCPP___NEW_DESTROYING_DELETE_T_H
lib/libcxx/include/__new/exceptions.h created+74
...@@ -0,0 +1,74 @@
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___NEW_EXCEPTIONS_H
10#define _LIBCPP___NEW_EXCEPTIONS_H
11
12#include <__config>
13#include <__exception/exception.h>
14#include <__verbose_abort>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20// purposefully not using versioning namespace
21namespace std {
22#if !defined(_LIBCPP_ABI_VCRUNTIME)
23
24class _LIBCPP_EXPORTED_FROM_ABI bad_alloc : public exception {
25public:
26 bad_alloc() _NOEXCEPT;
27 _LIBCPP_HIDE_FROM_ABI bad_alloc(const bad_alloc&) _NOEXCEPT = default;
28 _LIBCPP_HIDE_FROM_ABI bad_alloc& operator=(const bad_alloc&) _NOEXCEPT = default;
29 ~bad_alloc() _NOEXCEPT override;
30 const char* what() const _NOEXCEPT override;
31};
32
33class _LIBCPP_EXPORTED_FROM_ABI bad_array_new_length : public bad_alloc {
34public:
35 bad_array_new_length() _NOEXCEPT;
36 _LIBCPP_HIDE_FROM_ABI bad_array_new_length(const bad_array_new_length&) _NOEXCEPT = default;
37 _LIBCPP_HIDE_FROM_ABI bad_array_new_length& operator=(const bad_array_new_length&) _NOEXCEPT = default;
38 ~bad_array_new_length() _NOEXCEPT override;
39 const char* what() const _NOEXCEPT override;
40};
41
42#elif defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 // !_LIBCPP_ABI_VCRUNTIME
43
44// When _HAS_EXCEPTIONS == 0, these complete definitions are needed,
45// since they would normally be provided in vcruntime_exception.h
46class bad_alloc : public exception {
47public:
48 bad_alloc() noexcept : exception("bad allocation") {}
49
50private:
51 friend class bad_array_new_length;
52
53 bad_alloc(char const* const __message) noexcept : exception(__message) {}
54};
55
56class bad_array_new_length : public bad_alloc {
57public:
58 bad_array_new_length() noexcept : bad_alloc("bad array new length") {}
59};
60
61#endif // defined(_LIBCPP_ABI_VCRUNTIME) && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0
62
63[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_bad_alloc(); // not in C++ spec
64
65[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_array_new_length() {
66#if _LIBCPP_HAS_EXCEPTIONS
67 throw bad_array_new_length();
68#else
69 _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode");
70#endif
71}
72} // namespace std
73
74#endif // _LIBCPP___NEW_EXCEPTIONS_H
lib/libcxx/include/__new/global_new_delete.h created+77
...@@ -0,0 +1,77 @@
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___NEW_GLOBAL_NEW_DELETE_H
10#define _LIBCPP___NEW_GLOBAL_NEW_DELETE_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__new/align_val_t.h>
15#include <__new/exceptions.h>
16#include <__new/nothrow_t.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22#if defined(_LIBCPP_CXX03_LANG)
23# define _THROW_BAD_ALLOC throw(std::bad_alloc)
24#else
25# define _THROW_BAD_ALLOC
26#endif
27
28#if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L
29# define _LIBCPP_HAS_SIZED_DEALLOCATION 1
30#else
31# define _LIBCPP_HAS_SIZED_DEALLOCATION 0
32#endif
33
34#if defined(_LIBCPP_ABI_VCRUNTIME)
35# include <new.h>
36#else
37[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;
38[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT
39 _LIBCPP_NOALIAS;
40_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT;
41_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
42# if _LIBCPP_HAS_SIZED_DEALLOCATION
43_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
44# endif
45
46[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC;
47[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT
48 _LIBCPP_NOALIAS;
49_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT;
50_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
51# if _LIBCPP_HAS_SIZED_DEALLOCATION
52_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
53# endif
54
55# if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
56[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
57[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void*
58operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
59_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
60_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
61# if _LIBCPP_HAS_SIZED_DEALLOCATION
62_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
63# endif
64
65[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void*
66operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
67[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void*
68operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
69_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
70_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
71# if _LIBCPP_HAS_SIZED_DEALLOCATION
72_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
73# endif
74# endif
75#endif
76
77#endif // _LIBCPP___NEW_GLOBAL_NEW_DELETE_H
lib/libcxx/include/__new/interference_size.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___NEW_INTERFERENCE_SIZE_H
10#define _LIBCPP___NEW_INTERFERENCE_SIZE_H
11
12#include <__config>
13#include <__cstddef/size_t.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#if _LIBCPP_STD_VER >= 17
22
23# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
24
25inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE;
26inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE;
27
28# endif // defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
29
30#endif // _LIBCPP_STD_VER >= 17
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___NEW_INTERFERENCE_SIZE_H
lib/libcxx/include/__new/launder.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___NEW_LAUNDER_H
10#define _LIBCPP___NEW_LAUNDER_H
11
12#include <__config>
13#include <__type_traits/is_function.h>
14#include <__type_traits/is_void.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21template <class _Tp>
22[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT {
23 static_assert(!(is_function<_Tp>::value), "can't launder functions");
24 static_assert(!is_void<_Tp>::value, "can't launder cv-void");
25 return __builtin_launder(__p);
26}
27
28#if _LIBCPP_STD_VER >= 17
29template <class _Tp>
30[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept {
31 return std::__launder(__p);
32}
33#endif
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___NEW_LAUNDER_H
lib/libcxx/include/__new/new_handler.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___NEW_NEW_HANDLER_H
10#define _LIBCPP___NEW_NEW_HANDLER_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 defined(_LIBCPP_ABI_VCRUNTIME)
19# include <new.h>
20#else
21// purposefully not using versioning namespace
22namespace std {
23typedef void (*new_handler)();
24_LIBCPP_EXPORTED_FROM_ABI new_handler set_new_handler(new_handler) _NOEXCEPT;
25_LIBCPP_EXPORTED_FROM_ABI new_handler get_new_handler() _NOEXCEPT;
26} // namespace std
27#endif // _LIBCPP_ABI_VCRUNTIME
28
29#endif // _LIBCPP___NEW_NEW_HANDLER_H
lib/libcxx/include/__new/nothrow_t.h created+30
...@@ -0,0 +1,30 @@
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___NEW_NOTHROW_T_H
10#define _LIBCPP___NEW_NOTHROW_T_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 defined(_LIBCPP_ABI_VCRUNTIME)
19# include <new.h>
20#else
21// purposefully not using versioning namespace
22namespace std {
23struct _LIBCPP_EXPORTED_FROM_ABI nothrow_t {
24 explicit nothrow_t() = default;
25};
26extern _LIBCPP_EXPORTED_FROM_ABI const nothrow_t nothrow;
27} // namespace std
28#endif // _LIBCPP_ABI_VCRUNTIME
29
30#endif // _LIBCPP___NEW_NOTHROW_T_H
lib/libcxx/include/__new/placement_new_delete.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___NEW_PLACEMENT_NEW_DELETE_H
10#define _LIBCPP___NEW_PLACEMENT_NEW_DELETE_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19#if defined(_LIBCPP_ABI_VCRUNTIME)
20# include <new.h>
21#else
22[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void*
23operator new(std::size_t, void* __p) _NOEXCEPT {
24 return __p;
25}
26[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void*
27operator new[](std::size_t, void* __p) _NOEXCEPT {
28 return __p;
29}
30inline _LIBCPP_HIDE_FROM_ABI void operator delete(void*, void*) _NOEXCEPT {}
31inline _LIBCPP_HIDE_FROM_ABI void operator delete[](void*, void*) _NOEXCEPT {}
32#endif
33
34#endif // _LIBCPP___NEW_PLACEMENT_NEW_DELETE_H
lib/libcxx/include/__node_handle+2-2
...@@ -188,10 +188,10 @@ struct __map_node_handle_specifics {...@@ -188,10 +188,10 @@ struct __map_node_handle_specifics {
188};188};
189189
190template <class _NodeType, class _Alloc>190template <class _NodeType, class _Alloc>
191using __set_node_handle = __basic_node_handle< _NodeType, _Alloc, __set_node_handle_specifics>;191using __set_node_handle _LIBCPP_NODEBUG = __basic_node_handle< _NodeType, _Alloc, __set_node_handle_specifics>;
192192
193template <class _NodeType, class _Alloc>193template <class _NodeType, class _Alloc>
194using __map_node_handle = __basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>;194using __map_node_handle _LIBCPP_NODEBUG = __basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>;
195195
196template <class _Iterator, class _NodeType>196template <class _Iterator, class _NodeType>
197struct _LIBCPP_TEMPLATE_VIS __insert_return_type {197struct _LIBCPP_TEMPLATE_VIS __insert_return_type {
lib/libcxx/include/__numeric/gcd_lcm.h+10-13
...@@ -55,7 +55,8 @@ template <class _Tp>...@@ -55,7 +55,8 @@ template <class _Tp>
55constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) {55constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) {
56 static_assert(!is_signed<_Tp>::value, "");56 static_assert(!is_signed<_Tp>::value, "");
5757
58 // From: https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor58 // Using Binary GCD algorithm https://en.wikipedia.org/wiki/Binary_GCD_algorithm, based on an implementation
59 // from https://lemire.me/blog/2024/04/13/greatest-common-divisor-the-extended-euclidean-algorithm-and-speed/
59 //60 //
60 // If power of two divides both numbers, we can push it out.61 // If power of two divides both numbers, we can push it out.
61 // - gcd( 2^x * a, 2^x * b) = 2^x * gcd(a, b)62 // - gcd( 2^x * a, 2^x * b) = 2^x * gcd(a, b)
...@@ -76,21 +77,17 @@ constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) {...@@ -76,21 +77,17 @@ constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) {
76 if (__a == 0)77 if (__a == 0)
77 return __b;78 return __b;
7879
79 int __az = std::__countr_zero(__a);80 _Tp __c = __a | __b;
80 int __bz = std::__countr_zero(__b);81 int __shift = std::__countr_zero(__c);
81 int __shift = std::min(__az, __bz);82 __a >>= std::__countr_zero(__a);
82 __a >>= __az;
83 __b >>= __bz;
84 do {83 do {
85 _Tp __diff = __a - __b;84 _Tp __t = __b >> std::__countr_zero(__b);
86 if (__a > __b) {85 if (__a > __t) {
87 __a = __b;86 __b = __a - __t;
88 __b = __diff;87 __a = __t;
89 } else {88 } else {
90 __b = __b - __a;89 __b = __t - __a;
91 }90 }
92 if (__diff != 0)
93 __b >>= std::__countr_zero(__diff);
94 } while (__b != 0);91 } while (__b != 0);
95 return __a << __shift;92 return __a << __shift;
96}93}
lib/libcxx/include/__numeric/midpoint.h+1-1
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
11#define _LIBCPP___NUMERIC_MIDPOINT_H11#define _LIBCPP___NUMERIC_MIDPOINT_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
14#include <__type_traits/enable_if.h>15#include <__type_traits/enable_if.h>
15#include <__type_traits/is_floating_point.h>16#include <__type_traits/is_floating_point.h>
16#include <__type_traits/is_integral.h>17#include <__type_traits/is_integral.h>
...@@ -21,7 +22,6 @@...@@ -21,7 +22,6 @@
21#include <__type_traits/is_void.h>22#include <__type_traits/is_void.h>
22#include <__type_traits/make_unsigned.h>23#include <__type_traits/make_unsigned.h>
23#include <__type_traits/remove_pointer.h>24#include <__type_traits/remove_pointer.h>
24#include <cstddef>
25#include <limits>25#include <limits>
2626
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__numeric/pstl.h+2-2
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_PUSH_MACROS18_LIBCPP_PUSH_MACROS
19#include <__undef_macros>19#include <__undef_macros>
2020
21#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 1721#if _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
2222
23# include <__functional/identity.h>23# include <__functional/identity.h>
24# include <__functional/operations.h>24# include <__functional/operations.h>
...@@ -167,7 +167,7 @@ _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(...@@ -167,7 +167,7 @@ _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(
167167
168_LIBCPP_END_NAMESPACE_STD168_LIBCPP_END_NAMESPACE_STD
169169
170#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17170#endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
171171
172_LIBCPP_POP_MACROS172_LIBCPP_POP_MACROS
173173
lib/libcxx/include/__ostream/basic_ostream.h+133-315
...@@ -10,29 +10,32 @@...@@ -10,29 +10,32 @@
10#define _LIBCPP___OSTREAM_BASIC_OSTREAM_H10#define _LIBCPP___OSTREAM_BASIC_OSTREAM_H
1111
12#include <__config>12#include <__config>
13#include <__exception/operations.h>13
14#include <__memory/shared_ptr.h>14#if _LIBCPP_HAS_LOCALIZATION
15#include <__memory/unique_ptr.h>15
16#include <__system_error/error_code.h>16# include <__exception/operations.h>
17#include <__type_traits/conjunction.h>17# include <__fwd/memory.h>
18#include <__type_traits/enable_if.h>18# include <__memory/unique_ptr.h>
19#include <__type_traits/is_base_of.h>19# include <__new/exceptions.h>
20#include <__type_traits/void_t.h>20# include <__ostream/put_character_sequence.h>
21#include <__utility/declval.h>21# include <__system_error/error_code.h>
22#include <bitset>22# include <__type_traits/conjunction.h>
23#include <cstddef>23# include <__type_traits/enable_if.h>
24#include <ios>24# include <__type_traits/is_base_of.h>
25#include <locale>25# include <__type_traits/void_t.h>
26#include <new> // for __throw_bad_alloc26# include <__utility/declval.h>
27#include <streambuf>27# include <bitset>
28#include <string_view>28# include <ios>
2929# include <locale>
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30# include <streambuf>
31# pragma GCC system_header31# include <string_view>
32#endif32
33# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
34# pragma GCC system_header
35# endif
3336
34_LIBCPP_PUSH_MACROS37_LIBCPP_PUSH_MACROS
35#include <__undef_macros>38# include <__undef_macros>
3639
37_LIBCPP_BEGIN_NAMESPACE_STD40_LIBCPP_BEGIN_NAMESPACE_STD
3841
...@@ -85,6 +88,55 @@ public:...@@ -85,6 +88,55 @@ public:
85 return *this;88 return *this;
86 }89 }
8790
91 template <class _Tp>
92 _LIBCPP_HIDE_FROM_ABI basic_ostream& __put_num(_Tp __value) {
93# if _LIBCPP_HAS_EXCEPTIONS
94 try {
95# endif // _LIBCPP_HAS_EXCEPTIONS
96 sentry __s(*this);
97 if (__s) {
98 using _Fp = num_put<char_type, ostreambuf_iterator<char_type, traits_type> >;
99 const _Fp& __facet = std::use_facet<_Fp>(this->getloc());
100 if (__facet.put(*this, *this, this->fill(), __value).failed())
101 this->setstate(ios_base::badbit | ios_base::failbit);
102 }
103# if _LIBCPP_HAS_EXCEPTIONS
104 } catch (...) {
105 this->__set_badbit_and_consider_rethrow();
106 }
107# endif // _LIBCPP_HAS_EXCEPTIONS
108 return *this;
109 }
110
111 template <class _Tp>
112 _LIBCPP_HIDE_FROM_ABI basic_ostream& __put_num_integer_promote(_Tp __value) {
113# if _LIBCPP_HAS_EXCEPTIONS
114 try {
115# endif // _LIBCPP_HAS_EXCEPTIONS
116 sentry __s(*this);
117 if (__s) {
118 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
119
120 using _Fp = num_put<char_type, ostreambuf_iterator<char_type, traits_type> >;
121 const _Fp& __facet = std::use_facet<_Fp>(this->getloc());
122 if (__facet
123 .put(*this,
124 *this,
125 this->fill(),
126 __flags == ios_base::oct || __flags == ios_base::hex
127 ? static_cast<__copy_unsigned_t<_Tp, long> >(std::__to_unsigned_like(__value))
128 : static_cast<__copy_unsigned_t<_Tp, long> >(__value))
129 .failed())
130 this->setstate(ios_base::badbit | ios_base::failbit);
131 }
132# if _LIBCPP_HAS_EXCEPTIONS
133 } catch (...) {
134 this->__set_badbit_and_consider_rethrow();
135 }
136# endif // _LIBCPP_HAS_EXCEPTIONS
137 return *this;
138 }
139
88 basic_ostream& operator<<(bool __n);140 basic_ostream& operator<<(bool __n);
89 basic_ostream& operator<<(short __n);141 basic_ostream& operator<<(short __n);
90 basic_ostream& operator<<(unsigned short __n);142 basic_ostream& operator<<(unsigned short __n);
...@@ -99,19 +151,19 @@ public:...@@ -99,19 +151,19 @@ public:
99 basic_ostream& operator<<(long double __f);151 basic_ostream& operator<<(long double __f);
100 basic_ostream& operator<<(const void* __p);152 basic_ostream& operator<<(const void* __p);
101153
102#if _LIBCPP_STD_VER >= 23154# if _LIBCPP_STD_VER >= 23
103 _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(const volatile void* __p) {155 _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(const volatile void* __p) {
104 return operator<<(const_cast<const void*>(__p));156 return operator<<(const_cast<const void*>(__p));
105 }157 }
106#endif158# endif
107159
108 basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);160 basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
109161
110#if _LIBCPP_STD_VER >= 17162# if _LIBCPP_STD_VER >= 17
111 // LWG 2221 - nullptr. This is not backported to older standards modes.163 // LWG 2221 - nullptr. This is not backported to older standards modes.
112 // See https://reviews.llvm.org/D127033 for more info on the rationale.164 // See https://reviews.llvm.org/D127033 for more info on the rationale.
113 _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(nullptr_t) { return *this << "nullptr"; }165 _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(nullptr_t) { return *this << "nullptr"; }
114#endif166# endif
115167
116 // 27.7.2.7 Unformatted output:168 // 27.7.2.7 Unformatted output:
117 basic_ostream& put(char_type __c);169 basic_ostream& put(char_type __c);
...@@ -152,16 +204,16 @@ basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& _...@@ -152,16 +204,16 @@ basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& _
152204
153template <class _CharT, class _Traits>205template <class _CharT, class _Traits>
154basic_ostream<_CharT, _Traits>::sentry::~sentry() {206basic_ostream<_CharT, _Traits>::sentry::~sentry() {
155 if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && !uncaught_exception()) {207 if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && uncaught_exceptions() == 0) {
156#ifndef _LIBCPP_HAS_NO_EXCEPTIONS208# if _LIBCPP_HAS_EXCEPTIONS
157 try {209 try {
158#endif // _LIBCPP_HAS_NO_EXCEPTIONS210# endif // _LIBCPP_HAS_EXCEPTIONS
159 if (__os_.rdbuf()->pubsync() == -1)211 if (__os_.rdbuf()->pubsync() == -1)
160 __os_.setstate(ios_base::badbit);212 __os_.setstate(ios_base::badbit);
161#ifndef _LIBCPP_HAS_NO_EXCEPTIONS213# if _LIBCPP_HAS_EXCEPTIONS
162 } catch (...) {214 } catch (...) {
163 }215 }
164#endif // _LIBCPP_HAS_NO_EXCEPTIONS216# endif // _LIBCPP_HAS_EXCEPTIONS
165 }217 }
166}218}
167219
...@@ -182,15 +234,15 @@ basic_ostream<_CharT, _Traits>::~basic_ostream() {}...@@ -182,15 +234,15 @@ basic_ostream<_CharT, _Traits>::~basic_ostream() {}
182template <class _CharT, class _Traits>234template <class _CharT, class _Traits>
183basic_ostream<_CharT, _Traits>&235basic_ostream<_CharT, _Traits>&
184basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb) {236basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb) {
185#ifndef _LIBCPP_HAS_NO_EXCEPTIONS237# if _LIBCPP_HAS_EXCEPTIONS
186 try {238 try {
187#endif // _LIBCPP_HAS_NO_EXCEPTIONS239# endif // _LIBCPP_HAS_EXCEPTIONS
188 sentry __s(*this);240 sentry __s(*this);
189 if (__s) {241 if (__s) {
190 if (__sb) {242 if (__sb) {
191#ifndef _LIBCPP_HAS_NO_EXCEPTIONS243# if _LIBCPP_HAS_EXCEPTIONS
192 try {244 try {
193#endif // _LIBCPP_HAS_NO_EXCEPTIONS245# endif // _LIBCPP_HAS_EXCEPTIONS
194 typedef istreambuf_iterator<_CharT, _Traits> _Ip;246 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
195 typedef ostreambuf_iterator<_CharT, _Traits> _Op;247 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
196 _Ip __i(__sb);248 _Ip __i(__sb);
...@@ -204,321 +256,85 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_typ...@@ -204,321 +256,85 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_typ
204 }256 }
205 if (__c == 0)257 if (__c == 0)
206 this->setstate(ios_base::failbit);258 this->setstate(ios_base::failbit);
207#ifndef _LIBCPP_HAS_NO_EXCEPTIONS259# if _LIBCPP_HAS_EXCEPTIONS
208 } catch (...) {260 } catch (...) {
209 this->__set_failbit_and_consider_rethrow();261 this->__set_failbit_and_consider_rethrow();
210 }262 }
211#endif // _LIBCPP_HAS_NO_EXCEPTIONS263# endif // _LIBCPP_HAS_EXCEPTIONS
212 } else264 } else
213 this->setstate(ios_base::badbit);265 this->setstate(ios_base::badbit);
214 }266 }
215#ifndef _LIBCPP_HAS_NO_EXCEPTIONS267# if _LIBCPP_HAS_EXCEPTIONS
216 } catch (...) {268 } catch (...) {
217 this->__set_badbit_and_consider_rethrow();269 this->__set_badbit_and_consider_rethrow();
218 }270 }
219#endif // _LIBCPP_HAS_NO_EXCEPTIONS271# endif // _LIBCPP_HAS_EXCEPTIONS
220 return *this;272 return *this;
221}273}
222274
223template <class _CharT, class _Traits>275template <class _CharT, class _Traits>
224basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool __n) {276basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool __n) {
225#ifndef _LIBCPP_HAS_NO_EXCEPTIONS277 return __put_num(__n);
226 try {
227#endif // _LIBCPP_HAS_NO_EXCEPTIONS
228 sentry __s(*this);
229 if (__s) {
230 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
231 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
232 if (__f.put(*this, *this, this->fill(), __n).failed())
233 this->setstate(ios_base::badbit | ios_base::failbit);
234 }
235#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
236 } catch (...) {
237 this->__set_badbit_and_consider_rethrow();
238 }
239#endif // _LIBCPP_HAS_NO_EXCEPTIONS
240 return *this;
241}278}
242279
243template <class _CharT, class _Traits>280template <class _CharT, class _Traits>
244basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short __n) {281basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short __n) {
245#ifndef _LIBCPP_HAS_NO_EXCEPTIONS282 return __put_num_integer_promote(__n);
246 try {
247#endif // _LIBCPP_HAS_NO_EXCEPTIONS
248 sentry __s(*this);
249 if (__s) {
250 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
251 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
252 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
253 if (__f.put(*this,
254 *this,
255 this->fill(),
256 __flags == ios_base::oct || __flags == ios_base::hex
257 ? static_cast<long>(static_cast<unsigned short>(__n))
258 : static_cast<long>(__n))
259 .failed())
260 this->setstate(ios_base::badbit | ios_base::failbit);
261 }
262#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
263 } catch (...) {
264 this->__set_badbit_and_consider_rethrow();
265 }
266#endif // _LIBCPP_HAS_NO_EXCEPTIONS
267 return *this;
268}283}
269284
270template <class _CharT, class _Traits>285template <class _CharT, class _Traits>
271basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n) {286basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n) {
272#ifndef _LIBCPP_HAS_NO_EXCEPTIONS287 return __put_num_integer_promote(__n);
273 try {
274#endif // _LIBCPP_HAS_NO_EXCEPTIONS
275 sentry __s(*this);
276 if (__s) {
277 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
278 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
279 if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
280 this->setstate(ios_base::badbit | ios_base::failbit);
281 }
282#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
283 } catch (...) {
284 this->__set_badbit_and_consider_rethrow();
285 }
286#endif // _LIBCPP_HAS_NO_EXCEPTIONS
287 return *this;
288}288}
289289
290template <class _CharT, class _Traits>290template <class _CharT, class _Traits>
291basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int __n) {291basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int __n) {
292#ifndef _LIBCPP_HAS_NO_EXCEPTIONS292 return __put_num_integer_promote(__n);
293 try {
294#endif // _LIBCPP_HAS_NO_EXCEPTIONS
295 sentry __s(*this);
296 if (__s) {
297 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
298 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
299 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
300 if (__f.put(*this,
301 *this,
302 this->fill(),
303 __flags == ios_base::oct || __flags == ios_base::hex
304 ? static_cast<long>(static_cast<unsigned int>(__n))
305 : static_cast<long>(__n))
306 .failed())
307 this->setstate(ios_base::badbit | ios_base::failbit);
308 }
309#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
310 } catch (...) {
311 this->__set_badbit_and_consider_rethrow();
312 }
313#endif // _LIBCPP_HAS_NO_EXCEPTIONS
314 return *this;
315}293}
316294
317template <class _CharT, class _Traits>295template <class _CharT, class _Traits>
318basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n) {296basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n) {
319#ifndef _LIBCPP_HAS_NO_EXCEPTIONS297 return __put_num_integer_promote(__n);
320 try {
321#endif // _LIBCPP_HAS_NO_EXCEPTIONS
322 sentry __s(*this);
323 if (__s) {
324 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
325 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
326 if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
327 this->setstate(ios_base::badbit | ios_base::failbit);
328 }
329#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
330 } catch (...) {
331 this->__set_badbit_and_consider_rethrow();
332 }
333#endif // _LIBCPP_HAS_NO_EXCEPTIONS
334 return *this;
335}298}
336299
337template <class _CharT, class _Traits>300template <class _CharT, class _Traits>
338basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) {301basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) {
339#ifndef _LIBCPP_HAS_NO_EXCEPTIONS302 return __put_num(__n);
340 try {
341#endif // _LIBCPP_HAS_NO_EXCEPTIONS
342 sentry __s(*this);
343 if (__s) {
344 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
345 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
346 if (__f.put(*this, *this, this->fill(), __n).failed())
347 this->setstate(ios_base::badbit | ios_base::failbit);
348 }
349#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
350 } catch (...) {
351 this->__set_badbit_and_consider_rethrow();
352 }
353#endif // _LIBCPP_HAS_NO_EXCEPTIONS
354 return *this;
355}303}
356304
357template <class _CharT, class _Traits>305template <class _CharT, class _Traits>
358basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n) {306basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n) {
359#ifndef _LIBCPP_HAS_NO_EXCEPTIONS307 return __put_num(__n);
360 try {
361#endif // _LIBCPP_HAS_NO_EXCEPTIONS
362 sentry __s(*this);
363 if (__s) {
364 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
365 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
366 if (__f.put(*this, *this, this->fill(), __n).failed())
367 this->setstate(ios_base::badbit | ios_base::failbit);
368 }
369#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
370 } catch (...) {
371 this->__set_badbit_and_consider_rethrow();
372 }
373#endif // _LIBCPP_HAS_NO_EXCEPTIONS
374 return *this;
375}308}
376309
377template <class _CharT, class _Traits>310template <class _CharT, class _Traits>
378basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long long __n) {311basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long long __n) {
379#ifndef _LIBCPP_HAS_NO_EXCEPTIONS312 return __put_num(__n);
380 try {
381#endif // _LIBCPP_HAS_NO_EXCEPTIONS
382 sentry __s(*this);
383 if (__s) {
384 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
385 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
386 if (__f.put(*this, *this, this->fill(), __n).failed())
387 this->setstate(ios_base::badbit | ios_base::failbit);
388 }
389#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
390 } catch (...) {
391 this->__set_badbit_and_consider_rethrow();
392 }
393#endif // _LIBCPP_HAS_NO_EXCEPTIONS
394 return *this;
395}313}
396314
397template <class _CharT, class _Traits>315template <class _CharT, class _Traits>
398basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n) {316basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n) {
399#ifndef _LIBCPP_HAS_NO_EXCEPTIONS317 return __put_num(__n);
400 try {
401#endif // _LIBCPP_HAS_NO_EXCEPTIONS
402 sentry __s(*this);
403 if (__s) {
404 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
405 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
406 if (__f.put(*this, *this, this->fill(), __n).failed())
407 this->setstate(ios_base::badbit | ios_base::failbit);
408 }
409#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
410 } catch (...) {
411 this->__set_badbit_and_consider_rethrow();
412 }
413#endif // _LIBCPP_HAS_NO_EXCEPTIONS
414 return *this;
415}318}
416319
417template <class _CharT, class _Traits>320template <class _CharT, class _Traits>
418basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float __n) {321basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float __n) {
419#ifndef _LIBCPP_HAS_NO_EXCEPTIONS322 return *this << static_cast<double>(__n);
420 try {
421#endif // _LIBCPP_HAS_NO_EXCEPTIONS
422 sentry __s(*this);
423 if (__s) {
424 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
425 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
426 if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed())
427 this->setstate(ios_base::badbit | ios_base::failbit);
428 }
429#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
430 } catch (...) {
431 this->__set_badbit_and_consider_rethrow();
432 }
433#endif // _LIBCPP_HAS_NO_EXCEPTIONS
434 return *this;
435}323}
436324
437template <class _CharT, class _Traits>325template <class _CharT, class _Traits>
438basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(double __n) {326basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(double __n) {
439#ifndef _LIBCPP_HAS_NO_EXCEPTIONS327 return __put_num(__n);
440 try {
441#endif // _LIBCPP_HAS_NO_EXCEPTIONS
442 sentry __s(*this);
443 if (__s) {
444 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
445 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
446 if (__f.put(*this, *this, this->fill(), __n).failed())
447 this->setstate(ios_base::badbit | ios_base::failbit);
448 }
449#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
450 } catch (...) {
451 this->__set_badbit_and_consider_rethrow();
452 }
453#endif // _LIBCPP_HAS_NO_EXCEPTIONS
454 return *this;
455}328}
456329
457template <class _CharT, class _Traits>330template <class _CharT, class _Traits>
458basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long double __n) {331basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long double __n) {
459#ifndef _LIBCPP_HAS_NO_EXCEPTIONS332 return __put_num(__n);
460 try {
461#endif // _LIBCPP_HAS_NO_EXCEPTIONS
462 sentry __s(*this);
463 if (__s) {
464 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
465 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
466 if (__f.put(*this, *this, this->fill(), __n).failed())
467 this->setstate(ios_base::badbit | ios_base::failbit);
468 }
469#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
470 } catch (...) {
471 this->__set_badbit_and_consider_rethrow();
472 }
473#endif // _LIBCPP_HAS_NO_EXCEPTIONS
474 return *this;
475}333}
476334
477template <class _CharT, class _Traits>335template <class _CharT, class _Traits>
478basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const void* __n) {336basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const void* __n) {
479#ifndef _LIBCPP_HAS_NO_EXCEPTIONS337 return __put_num(__n);
480 try {
481#endif // _LIBCPP_HAS_NO_EXCEPTIONS
482 sentry __s(*this);
483 if (__s) {
484 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
485 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
486 if (__f.put(*this, *this, this->fill(), __n).failed())
487 this->setstate(ios_base::badbit | ios_base::failbit);
488 }
489#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
490 } catch (...) {
491 this->__set_badbit_and_consider_rethrow();
492 }
493#endif // _LIBCPP_HAS_NO_EXCEPTIONS
494 return *this;
495}
496
497template <class _CharT, class _Traits>
498_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
499__put_character_sequence(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str, size_t __len) {
500#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
501 try {
502#endif // _LIBCPP_HAS_NO_EXCEPTIONS
503 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
504 if (__s) {
505 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
506 if (std::__pad_and_output(
507 _Ip(__os),
508 __str,
509 (__os.flags() & ios_base::adjustfield) == ios_base::left ? __str + __len : __str,
510 __str + __len,
511 __os,
512 __os.fill())
513 .failed())
514 __os.setstate(ios_base::badbit | ios_base::failbit);
515 }
516#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
517 } catch (...) {
518 __os.__set_badbit_and_consider_rethrow();
519 }
520#endif // _LIBCPP_HAS_NO_EXCEPTIONS
521 return __os;
522}338}
523339
524template <class _CharT, class _Traits>340template <class _CharT, class _Traits>
...@@ -528,9 +344,9 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_...@@ -528,9 +344,9 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_
528344
529template <class _CharT, class _Traits>345template <class _CharT, class _Traits>
530_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) {346_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) {
531#ifndef _LIBCPP_HAS_NO_EXCEPTIONS347# if _LIBCPP_HAS_EXCEPTIONS
532 try {348 try {
533#endif // _LIBCPP_HAS_NO_EXCEPTIONS349# endif // _LIBCPP_HAS_EXCEPTIONS
534 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);350 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
535 if (__s) {351 if (__s) {
536 _CharT __c = __os.widen(__cn);352 _CharT __c = __os.widen(__cn);
...@@ -545,11 +361,11 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_...@@ -545,11 +361,11 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_
545 .failed())361 .failed())
546 __os.setstate(ios_base::badbit | ios_base::failbit);362 __os.setstate(ios_base::badbit | ios_base::failbit);
547 }363 }
548#ifndef _LIBCPP_HAS_NO_EXCEPTIONS364# if _LIBCPP_HAS_EXCEPTIONS
549 } catch (...) {365 } catch (...) {
550 __os.__set_badbit_and_consider_rethrow();366 __os.__set_badbit_and_consider_rethrow();
551 }367 }
552#endif // _LIBCPP_HAS_NO_EXCEPTIONS368# endif // _LIBCPP_HAS_EXCEPTIONS
553 return __os;369 return __os;
554}370}
555371
...@@ -577,9 +393,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) {...@@ -577,9 +393,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) {
577template <class _CharT, class _Traits>393template <class _CharT, class _Traits>
578_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&394_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
579operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) {395operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) {
580#ifndef _LIBCPP_HAS_NO_EXCEPTIONS396# if _LIBCPP_HAS_EXCEPTIONS
581 try {397 try {
582#endif // _LIBCPP_HAS_NO_EXCEPTIONS398# endif // _LIBCPP_HAS_EXCEPTIONS
583 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);399 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
584 if (__s) {400 if (__s) {
585 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;401 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
...@@ -606,11 +422,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) {...@@ -606,11 +422,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) {
606 .failed())422 .failed())
607 __os.setstate(ios_base::badbit | ios_base::failbit);423 __os.setstate(ios_base::badbit | ios_base::failbit);
608 }424 }
609#ifndef _LIBCPP_HAS_NO_EXCEPTIONS425# if _LIBCPP_HAS_EXCEPTIONS
610 } catch (...) {426 } catch (...) {
611 __os.__set_badbit_and_consider_rethrow();427 __os.__set_badbit_and_consider_rethrow();
612 }428 }
613#endif // _LIBCPP_HAS_NO_EXCEPTIONS429# endif // _LIBCPP_HAS_EXCEPTIONS
614 return __os;430 return __os;
615}431}
616432
...@@ -635,9 +451,9 @@ operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str) {...@@ -635,9 +451,9 @@ operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str) {
635451
636template <class _CharT, class _Traits>452template <class _CharT, class _Traits>
637basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __c) {453basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __c) {
638#ifndef _LIBCPP_HAS_NO_EXCEPTIONS454# if _LIBCPP_HAS_EXCEPTIONS
639 try {455 try {
640#endif // _LIBCPP_HAS_NO_EXCEPTIONS456# endif // _LIBCPP_HAS_EXCEPTIONS
641 sentry __s(*this);457 sentry __s(*this);
642 if (__s) {458 if (__s) {
643 typedef ostreambuf_iterator<_CharT, _Traits> _Op;459 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
...@@ -646,37 +462,37 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __...@@ -646,37 +462,37 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __
646 if (__o.failed())462 if (__o.failed())
647 this->setstate(ios_base::badbit);463 this->setstate(ios_base::badbit);
648 }464 }
649#ifndef _LIBCPP_HAS_NO_EXCEPTIONS465# if _LIBCPP_HAS_EXCEPTIONS
650 } catch (...) {466 } catch (...) {
651 this->__set_badbit_and_consider_rethrow();467 this->__set_badbit_and_consider_rethrow();
652 }468 }
653#endif // _LIBCPP_HAS_NO_EXCEPTIONS469# endif // _LIBCPP_HAS_EXCEPTIONS
654 return *this;470 return *this;
655}471}
656472
657template <class _CharT, class _Traits>473template <class _CharT, class _Traits>
658basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) {474basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) {
659#ifndef _LIBCPP_HAS_NO_EXCEPTIONS475# if _LIBCPP_HAS_EXCEPTIONS
660 try {476 try {
661#endif // _LIBCPP_HAS_NO_EXCEPTIONS477# endif // _LIBCPP_HAS_EXCEPTIONS
662 sentry __sen(*this);478 sentry __sen(*this);
663 if (__sen && __n) {479 if (__sen && __n) {
664 if (this->rdbuf()->sputn(__s, __n) != __n)480 if (this->rdbuf()->sputn(__s, __n) != __n)
665 this->setstate(ios_base::badbit);481 this->setstate(ios_base::badbit);
666 }482 }
667#ifndef _LIBCPP_HAS_NO_EXCEPTIONS483# if _LIBCPP_HAS_EXCEPTIONS
668 } catch (...) {484 } catch (...) {
669 this->__set_badbit_and_consider_rethrow();485 this->__set_badbit_and_consider_rethrow();
670 }486 }
671#endif // _LIBCPP_HAS_NO_EXCEPTIONS487# endif // _LIBCPP_HAS_EXCEPTIONS
672 return *this;488 return *this;
673}489}
674490
675template <class _CharT, class _Traits>491template <class _CharT, class _Traits>
676basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() {492basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() {
677#ifndef _LIBCPP_HAS_NO_EXCEPTIONS493# if _LIBCPP_HAS_EXCEPTIONS
678 try {494 try {
679#endif // _LIBCPP_HAS_NO_EXCEPTIONS495# endif // _LIBCPP_HAS_EXCEPTIONS
680 if (this->rdbuf()) {496 if (this->rdbuf()) {
681 sentry __s(*this);497 sentry __s(*this);
682 if (__s) {498 if (__s) {
...@@ -684,11 +500,11 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() {...@@ -684,11 +500,11 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() {
684 this->setstate(ios_base::badbit);500 this->setstate(ios_base::badbit);
685 }501 }
686 }502 }
687#ifndef _LIBCPP_HAS_NO_EXCEPTIONS503# if _LIBCPP_HAS_EXCEPTIONS
688 } catch (...) {504 } catch (...) {
689 this->__set_badbit_and_consider_rethrow();505 this->__set_badbit_and_consider_rethrow();
690 }506 }
691#endif // _LIBCPP_HAS_NO_EXCEPTIONS507# endif // _LIBCPP_HAS_EXCEPTIONS
692 return *this;508 return *this;
693}509}
694510
...@@ -797,9 +613,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) {...@@ -797,9 +613,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) {
797 std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));613 std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
798}614}
799615
800#if _LIBCPP_STD_VER >= 20616# if _LIBCPP_STD_VER >= 20
801617
802# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS618# if _LIBCPP_HAS_WIDE_CHARACTERS
803template <class _Traits>619template <class _Traits>
804basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete;620basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete;
805621
...@@ -818,9 +634,9 @@ basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, co...@@ -818,9 +634,9 @@ basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, co
818template <class _Traits>634template <class _Traits>
819basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete;635basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete;
820636
821# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS637# endif // _LIBCPP_HAS_WIDE_CHARACTERS
822638
823# ifndef _LIBCPP_HAS_NO_CHAR8_T639# if _LIBCPP_HAS_CHAR8_T
824template <class _Traits>640template <class _Traits>
825basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete;641basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete;
826642
...@@ -832,7 +648,7 @@ basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const ch...@@ -832,7 +648,7 @@ basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const ch
832648
833template <class _Traits>649template <class _Traits>
834basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete;650basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete;
835# endif651# endif
836652
837template <class _Traits>653template <class _Traits>
838basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;654basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;
...@@ -846,15 +662,17 @@ basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const ch...@@ -846,15 +662,17 @@ basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const ch
846template <class _Traits>662template <class _Traits>
847basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete;663basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete;
848664
849#endif // _LIBCPP_STD_VER >= 20665# endif // _LIBCPP_STD_VER >= 20
850666
851extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>;667extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>;
852#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS668# if _LIBCPP_HAS_WIDE_CHARACTERS
853extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;669extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;
854#endif670# endif
855671
856_LIBCPP_END_NAMESPACE_STD672_LIBCPP_END_NAMESPACE_STD
857673
858_LIBCPP_POP_MACROS674_LIBCPP_POP_MACROS
859675
676#endif // _LIBCPP_HAS_LOCALIZATION
677
860#endif // _LIBCPP___OSTREAM_BASIC_OSTREAM_H678#endif // _LIBCPP___OSTREAM_BASIC_OSTREAM_H
lib/libcxx/include/__ostream/print.h+42-37
...@@ -10,21 +10,24 @@...@@ -10,21 +10,24 @@
10#define _LIBCPP___OSTREAM_PRINT_H10#define _LIBCPP___OSTREAM_PRINT_H
1111
12#include <__config>12#include <__config>
13#include <__fwd/ostream.h>13
14#include <__iterator/ostreambuf_iterator.h>14#if _LIBCPP_HAS_LOCALIZATION
15#include <__ostream/basic_ostream.h>15
16#include <format>16# include <__fwd/ostream.h>
17#include <ios>17# include <__iterator/ostreambuf_iterator.h>
18#include <locale>18# include <__ostream/basic_ostream.h>
19#include <print>19# include <format>
2020# include <ios>
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21# include <locale>
22# pragma GCC system_header22# include <print>
23#endif23
24# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26# endif
2427
25_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2629
27#if _LIBCPP_STD_VER >= 2330# if _LIBCPP_STD_VER >= 23
2831
29template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).32template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
30_LIBCPP_HIDE_FROM_ABI inline void33_LIBCPP_HIDE_FROM_ABI inline void
...@@ -49,9 +52,9 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _...@@ -49,9 +52,9 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _
49 const char* __str = __o.data();52 const char* __str = __o.data();
50 size_t __len = __o.size();53 size_t __len = __o.size();
5154
52# ifndef _LIBCPP_HAS_NO_EXCEPTIONS55# if _LIBCPP_HAS_EXCEPTIONS
53 try {56 try {
54# endif // _LIBCPP_HAS_NO_EXCEPTIONS57# endif // _LIBCPP_HAS_EXCEPTIONS
55 typedef ostreambuf_iterator<char> _Ip;58 typedef ostreambuf_iterator<char> _Ip;
56 if (std::__pad_and_output(59 if (std::__pad_and_output(
57 _Ip(__os),60 _Ip(__os),
...@@ -63,11 +66,11 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _...@@ -63,11 +66,11 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _
63 .failed())66 .failed())
64 __os.setstate(ios_base::badbit | ios_base::failbit);67 __os.setstate(ios_base::badbit | ios_base::failbit);
6568
66# ifndef _LIBCPP_HAS_NO_EXCEPTIONS69# if _LIBCPP_HAS_EXCEPTIONS
67 } catch (...) {70 } catch (...) {
68 __os.__set_badbit_and_consider_rethrow();71 __os.__set_badbit_and_consider_rethrow();
69 }72 }
70# endif // _LIBCPP_HAS_NO_EXCEPTIONS73# endif // _LIBCPP_HAS_EXCEPTIONS
71 }74 }
72}75}
7376
...@@ -91,12 +94,12 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(ostream& __os, string_view _...@@ -91,12 +94,12 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(ostream& __os, string_view _
91// is determined in the same way as the print(FILE*, ...) overloads.94// is determined in the same way as the print(FILE*, ...) overloads.
92_LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os);95_LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os);
9396
94# ifndef _LIBCPP_HAS_NO_UNICODE97# if _LIBCPP_HAS_UNICODE
95template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).98template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
96_LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) {99_LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) {
97# if _LIBCPP_AVAILABILITY_HAS_PRINT == 0100# if _LIBCPP_AVAILABILITY_HAS_PRINT == 0
98 return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);101 return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);
99# else102# else
100 FILE* __file = std::__get_ostream_file(__os);103 FILE* __file = std::__get_ostream_file(__os);
101 if (!__file || !__print::__is_terminal(__file))104 if (!__file || !__print::__is_terminal(__file))
102 return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);105 return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);
...@@ -112,49 +115,49 @@ _LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, fo...@@ -112,49 +115,49 @@ _LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, fo
112 // This is the path for the native API, start with flushing.115 // This is the path for the native API, start with flushing.
113 __os.flush();116 __os.flush();
114117
115# ifndef _LIBCPP_HAS_NO_EXCEPTIONS118# if _LIBCPP_HAS_EXCEPTIONS
116 try {119 try {
117# endif // _LIBCPP_HAS_NO_EXCEPTIONS120# endif // _LIBCPP_HAS_EXCEPTIONS
118 ostream::sentry __s(__os);121 ostream::sentry __s(__os);
119 if (__s) {122 if (__s) {
120# ifndef _LIBCPP_WIN32API123# ifndef _LIBCPP_WIN32API
121 __print::__vprint_unicode_posix(__file, __fmt, __args, __write_nl, true);124 __print::__vprint_unicode_posix(__file, __fmt, __args, __write_nl, true);
122# elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)125# elif _LIBCPP_HAS_WIDE_CHARACTERS
123 __print::__vprint_unicode_windows(__file, __fmt, __args, __write_nl, true);126 __print::__vprint_unicode_windows(__file, __fmt, __args, __write_nl, true);
124# else127# else
125# error "Windows builds with wchar_t disabled are not supported."128# error "Windows builds with wchar_t disabled are not supported."
126# endif129# endif
127 }130 }
128131
129# ifndef _LIBCPP_HAS_NO_EXCEPTIONS132# if _LIBCPP_HAS_EXCEPTIONS
130 } catch (...) {133 } catch (...) {
131 __os.__set_badbit_and_consider_rethrow();134 __os.__set_badbit_and_consider_rethrow();
132 }135 }
133# endif // _LIBCPP_HAS_NO_EXCEPTIONS136# endif // _LIBCPP_HAS_EXCEPTIONS
134# endif // _LIBCPP_AVAILABILITY_HAS_PRINT137# endif // _LIBCPP_AVAILABILITY_HAS_PRINT
135}138}
136139
137template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).140template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
138_LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(ostream& __os, string_view __fmt, format_args __args) {141_LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(ostream& __os, string_view __fmt, format_args __args) {
139 std::__vprint_unicode(__os, __fmt, __args, false);142 std::__vprint_unicode(__os, __fmt, __args, false);
140}143}
141# endif // _LIBCPP_HAS_NO_UNICODE144# endif // _LIBCPP_HAS_UNICODE
142145
143template <class... _Args>146template <class... _Args>
144_LIBCPP_HIDE_FROM_ABI void print(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {147_LIBCPP_HIDE_FROM_ABI void print(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {
145# ifndef _LIBCPP_HAS_NO_UNICODE148# if _LIBCPP_HAS_UNICODE
146 if constexpr (__print::__use_unicode_execution_charset)149 if constexpr (__print::__use_unicode_execution_charset)
147 std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), false);150 std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), false);
148 else151 else
149 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false);152 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false);
150# else // _LIBCPP_HAS_NO_UNICODE153# else // _LIBCPP_HAS_UNICODE
151 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false);154 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false);
152# endif // _LIBCPP_HAS_NO_UNICODE155# endif // _LIBCPP_HAS_UNICODE
153}156}
154157
155template <class... _Args>158template <class... _Args>
156_LIBCPP_HIDE_FROM_ABI void println(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {159_LIBCPP_HIDE_FROM_ABI void println(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {
157# ifndef _LIBCPP_HAS_NO_UNICODE160# if _LIBCPP_HAS_UNICODE
158 // Note the wording in the Standard is inefficient. The output of161 // Note the wording in the Standard is inefficient. The output of
159 // std::format is a std::string which is then copied. This solution162 // std::format is a std::string which is then copied. This solution
160 // just appends a newline at the end of the output.163 // just appends a newline at the end of the output.
...@@ -162,9 +165,9 @@ _LIBCPP_HIDE_FROM_ABI void println(ostream& __os, format_string<_Args...> __fmt,...@@ -162,9 +165,9 @@ _LIBCPP_HIDE_FROM_ABI void println(ostream& __os, format_string<_Args...> __fmt,
162 std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), true);165 std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), true);
163 else166 else
164 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true);167 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true);
165# else // _LIBCPP_HAS_NO_UNICODE168# else // _LIBCPP_HAS_UNICODE
166 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true);169 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true);
167# endif // _LIBCPP_HAS_NO_UNICODE170# endif // _LIBCPP_HAS_UNICODE
168}171}
169172
170template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).173template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
...@@ -172,8 +175,10 @@ _LIBCPP_HIDE_FROM_ABI inline void println(ostream& __os) {...@@ -172,8 +175,10 @@ _LIBCPP_HIDE_FROM_ABI inline void println(ostream& __os) {
172 std::print(__os, "\n");175 std::print(__os, "\n");
173}176}
174177
175#endif // _LIBCPP_STD_VER >= 23178# endif // _LIBCPP_STD_VER >= 23
176179
177_LIBCPP_END_NAMESPACE_STD180_LIBCPP_END_NAMESPACE_STD
178181
182#endif // _LIBCPP_HAS_LOCALIZATION
183
179#endif // _LIBCPP___OSTREAM_PRINT_H184#endif // _LIBCPP___OSTREAM_PRINT_H
lib/libcxx/include/__ostream/put_character_sequence.h created+59
...@@ -0,0 +1,59 @@
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___OSTREAM_PUT_CHARACTER_SEQUENCE_H
10#define _LIBCPP___OSTREAM_PUT_CHARACTER_SEQUENCE_H
11
12#include <__config>
13
14#if _LIBCPP_HAS_LOCALIZATION
15
16# include <__cstddef/size_t.h>
17# include <__fwd/ostream.h>
18# include <__iterator/ostreambuf_iterator.h>
19# include <__locale_dir/pad_and_output.h>
20# include <ios>
21
22# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24# endif
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28template <class _CharT, class _Traits>
29_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
30__put_character_sequence(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str, size_t __len) {
31# if _LIBCPP_HAS_EXCEPTIONS
32 try {
33# endif // _LIBCPP_HAS_EXCEPTIONS
34 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
35 if (__s) {
36 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
37 if (std::__pad_and_output(
38 _Ip(__os),
39 __str,
40 (__os.flags() & ios_base::adjustfield) == ios_base::left ? __str + __len : __str,
41 __str + __len,
42 __os,
43 __os.fill())
44 .failed())
45 __os.setstate(ios_base::badbit | ios_base::failbit);
46 }
47# if _LIBCPP_HAS_EXCEPTIONS
48 } catch (...) {
49 __os.__set_badbit_and_consider_rethrow();
50 }
51# endif // _LIBCPP_HAS_EXCEPTIONS
52 return __os;
53}
54
55_LIBCPP_END_NAMESPACE_STD
56
57#endif // _LIBCPP_HAS_LOCALIZATION
58
59#endif // _LIBCPP___OSTREAM_PUT_CHARACTER_SEQUENCE_H
lib/libcxx/include/__pstl/backend.h+14-10
...@@ -19,16 +19,20 @@...@@ -19,16 +19,20 @@
19_LIBCPP_PUSH_MACROS19_LIBCPP_PUSH_MACROS
20#include <__undef_macros>20#include <__undef_macros>
2121
22#if defined(_LIBCPP_PSTL_BACKEND_SERIAL)22#if _LIBCPP_STD_VER >= 17
23# include <__pstl/backends/default.h>23
24# include <__pstl/backends/serial.h>24# if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
25#elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)25# include <__pstl/backends/default.h>
26# include <__pstl/backends/default.h>26# include <__pstl/backends/serial.h>
27# include <__pstl/backends/std_thread.h>27# elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)
28#elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)28# include <__pstl/backends/default.h>
29# include <__pstl/backends/default.h>29# include <__pstl/backends/std_thread.h>
30# include <__pstl/backends/libdispatch.h>30# elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)
31#endif31# include <__pstl/backends/default.h>
32# include <__pstl/backends/libdispatch.h>
33# endif
34
35#endif // _LIBCPP_STD_VER >= 17
3236
33_LIBCPP_POP_MACROS37_LIBCPP_POP_MACROS
3438
lib/libcxx/include/__pstl/backend_fwd.h+15-9
...@@ -39,6 +39,8 @@ _LIBCPP_PUSH_MACROS...@@ -39,6 +39,8 @@ _LIBCPP_PUSH_MACROS
39// the user.39// the user.
40//40//
4141
42#if _LIBCPP_STD_VER >= 17
43
42_LIBCPP_BEGIN_NAMESPACE_STD44_LIBCPP_BEGIN_NAMESPACE_STD
43namespace __pstl {45namespace __pstl {
4446
...@@ -50,18 +52,20 @@ struct __libdispatch_backend_tag;...@@ -50,18 +52,20 @@ struct __libdispatch_backend_tag;
50struct __serial_backend_tag;52struct __serial_backend_tag;
51struct __std_thread_backend_tag;53struct __std_thread_backend_tag;
5254
53#if defined(_LIBCPP_PSTL_BACKEND_SERIAL)55# if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
54using __current_configuration = __backend_configuration<__serial_backend_tag, __default_backend_tag>;56using __current_configuration _LIBCPP_NODEBUG = __backend_configuration<__serial_backend_tag, __default_backend_tag>;
55#elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)57# elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)
56using __current_configuration = __backend_configuration<__std_thread_backend_tag, __default_backend_tag>;58using __current_configuration _LIBCPP_NODEBUG =
57#elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)59 __backend_configuration<__std_thread_backend_tag, __default_backend_tag>;
58using __current_configuration = __backend_configuration<__libdispatch_backend_tag, __default_backend_tag>;60# elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)
59#else61using __current_configuration _LIBCPP_NODEBUG =
62 __backend_configuration<__libdispatch_backend_tag, __default_backend_tag>;
63# else
6064
61// ...New vendors can add parallel backends here...65// ...New vendors can add parallel backends here...
6266
63# error "Invalid PSTL backend configuration"67# error "Invalid PSTL backend configuration"
64#endif68# endif
6569
66template <class _Backend, class _ExecutionPolicy>70template <class _Backend, class _ExecutionPolicy>
67struct __find_if;71struct __find_if;
...@@ -296,6 +300,8 @@ struct __reduce;...@@ -296,6 +300,8 @@ struct __reduce;
296} // namespace __pstl300} // namespace __pstl
297_LIBCPP_END_NAMESPACE_STD301_LIBCPP_END_NAMESPACE_STD
298302
303#endif // _LIBCPP_STD_VER >= 17
304
299_LIBCPP_POP_MACROS305_LIBCPP_POP_MACROS
300306
301#endif // _LIBCPP___PSTL_BACKEND_FWD_H307#endif // _LIBCPP___PSTL_BACKEND_FWD_H
lib/libcxx/include/__pstl/backends/default.h+5-1
...@@ -33,6 +33,8 @@...@@ -33,6 +33,8 @@
33_LIBCPP_PUSH_MACROS33_LIBCPP_PUSH_MACROS
34#include <__undef_macros>34#include <__undef_macros>
3535
36#if _LIBCPP_STD_VER >= 17
37
36_LIBCPP_BEGIN_NAMESPACE_STD38_LIBCPP_BEGIN_NAMESPACE_STD
37namespace __pstl {39namespace __pstl {
3840
...@@ -163,7 +165,7 @@ struct __is_partitioned<__default_backend_tag, _ExecutionPolicy> {...@@ -163,7 +165,7 @@ struct __is_partitioned<__default_backend_tag, _ExecutionPolicy> {
163 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>165 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
164 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept {166 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept {
165 using _FindIfNot = __dispatch<__find_if_not, __current_configuration, _ExecutionPolicy>;167 using _FindIfNot = __dispatch<__find_if_not, __current_configuration, _ExecutionPolicy>;
166 auto __maybe_first = _FindIfNot()(__policy, std::move(__first), std::move(__last), __pred);168 auto __maybe_first = _FindIfNot()(__policy, std::move(__first), __last, __pred);
167 if (__maybe_first == nullopt)169 if (__maybe_first == nullopt)
168 return nullopt;170 return nullopt;
169171
...@@ -498,6 +500,8 @@ struct __rotate_copy<__default_backend_tag, _ExecutionPolicy> {...@@ -498,6 +500,8 @@ struct __rotate_copy<__default_backend_tag, _ExecutionPolicy> {
498} // namespace __pstl500} // namespace __pstl
499_LIBCPP_END_NAMESPACE_STD501_LIBCPP_END_NAMESPACE_STD
500502
503#endif // _LIBCPP_STD_VER >= 17
504
501_LIBCPP_POP_MACROS505_LIBCPP_POP_MACROS
502506
503#endif // _LIBCPP___PSTL_BACKENDS_DEFAULT_H507#endif // _LIBCPP___PSTL_BACKENDS_DEFAULT_H
lib/libcxx/include/__pstl/backends/libdispatch.h+10-6
...@@ -16,12 +16,14 @@...@@ -16,12 +16,14 @@
16#include <__algorithm/upper_bound.h>16#include <__algorithm/upper_bound.h>
17#include <__atomic/atomic.h>17#include <__atomic/atomic.h>
18#include <__config>18#include <__config>
19#include <__cstddef/ptrdiff_t.h>
19#include <__exception/terminate.h>20#include <__exception/terminate.h>
20#include <__iterator/iterator_traits.h>21#include <__iterator/iterator_traits.h>
21#include <__iterator/move_iterator.h>22#include <__iterator/move_iterator.h>
22#include <__memory/allocator.h>23#include <__memory/allocator.h>
23#include <__memory/construct_at.h>24#include <__memory/construct_at.h>
24#include <__memory/unique_ptr.h>25#include <__memory/unique_ptr.h>
26#include <__new/exceptions.h>
25#include <__numeric/reduce.h>27#include <__numeric/reduce.h>
26#include <__pstl/backend_fwd.h>28#include <__pstl/backend_fwd.h>
27#include <__pstl/cpu_algos/any_of.h>29#include <__pstl/cpu_algos/any_of.h>
...@@ -37,13 +39,13 @@...@@ -37,13 +39,13 @@
37#include <__utility/exception_guard.h>39#include <__utility/exception_guard.h>
38#include <__utility/move.h>40#include <__utility/move.h>
39#include <__utility/pair.h>41#include <__utility/pair.h>
40#include <cstddef>
41#include <new>
42#include <optional>42#include <optional>
4343
44_LIBCPP_PUSH_MACROS44_LIBCPP_PUSH_MACROS
45#include <__undef_macros>45#include <__undef_macros>
4646
47#if _LIBCPP_STD_VER >= 17
48
47_LIBCPP_BEGIN_NAMESPACE_STD49_LIBCPP_BEGIN_NAMESPACE_STD
48namespace __pstl {50namespace __pstl {
4951
...@@ -140,15 +142,15 @@ struct __cpu_traits<__libdispatch_backend_tag> {...@@ -140,15 +142,15 @@ struct __cpu_traits<__libdispatch_backend_tag> {
140142
141 unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges(143 unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges(
142 [&]() -> __merge_range_t* {144 [&]() -> __merge_range_t* {
143#ifndef _LIBCPP_HAS_NO_EXCEPTIONS145# if _LIBCPP_HAS_EXCEPTIONS
144 try {146 try {
145#endif147# endif
146 return std::allocator<__merge_range_t>().allocate(__n_ranges);148 return std::allocator<__merge_range_t>().allocate(__n_ranges);
147#ifndef _LIBCPP_HAS_NO_EXCEPTIONS149# if _LIBCPP_HAS_EXCEPTIONS
148 } catch (const std::bad_alloc&) {150 } catch (const std::bad_alloc&) {
149 return nullptr;151 return nullptr;
150 }152 }
151#endif153# endif
152 }(),154 }(),
153 __destroy);155 __destroy);
154156
...@@ -392,6 +394,8 @@ struct __fill<__libdispatch_backend_tag, _ExecutionPolicy>...@@ -392,6 +394,8 @@ struct __fill<__libdispatch_backend_tag, _ExecutionPolicy>
392} // namespace __pstl394} // namespace __pstl
393_LIBCPP_END_NAMESPACE_STD395_LIBCPP_END_NAMESPACE_STD
394396
397#endif // _LIBCPP_STD_VER >= 17
398
395_LIBCPP_POP_MACROS399_LIBCPP_POP_MACROS
396400
397#endif // _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H401#endif // _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H
lib/libcxx/include/__pstl/backends/serial.h+4
...@@ -30,6 +30,8 @@...@@ -30,6 +30,8 @@
30_LIBCPP_PUSH_MACROS30_LIBCPP_PUSH_MACROS
31#include <__undef_macros>31#include <__undef_macros>
3232
33#if _LIBCPP_STD_VER >= 17
34
33_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
34namespace __pstl {36namespace __pstl {
3537
...@@ -176,6 +178,8 @@ struct __transform_reduce_binary<__serial_backend_tag, _ExecutionPolicy> {...@@ -176,6 +178,8 @@ struct __transform_reduce_binary<__serial_backend_tag, _ExecutionPolicy> {
176} // namespace __pstl178} // namespace __pstl
177_LIBCPP_END_NAMESPACE_STD179_LIBCPP_END_NAMESPACE_STD
178180
181#endif // _LIBCPP_STD_VER >= 17
182
179_LIBCPP_POP_MACROS183_LIBCPP_POP_MACROS
180184
181#endif // _LIBCPP___PSTL_BACKENDS_SERIAL_H185#endif // _LIBCPP___PSTL_BACKENDS_SERIAL_H
lib/libcxx/include/__pstl/backends/std_thread.h+4-1
...@@ -22,7 +22,6 @@...@@ -22,7 +22,6 @@
22#include <__pstl/cpu_algos/transform_reduce.h>22#include <__pstl/cpu_algos/transform_reduce.h>
23#include <__utility/empty.h>23#include <__utility/empty.h>
24#include <__utility/move.h>24#include <__utility/move.h>
25#include <cstddef>
26#include <optional>25#include <optional>
2726
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -32,6 +31,8 @@...@@ -32,6 +31,8 @@
32_LIBCPP_PUSH_MACROS31_LIBCPP_PUSH_MACROS
33#include <__undef_macros>32#include <__undef_macros>
3433
34#if _LIBCPP_STD_VER >= 17
35
35_LIBCPP_BEGIN_NAMESPACE_STD36_LIBCPP_BEGIN_NAMESPACE_STD
36namespace __pstl {37namespace __pstl {
3738
...@@ -131,6 +132,8 @@ struct __fill<__std_thread_backend_tag, _ExecutionPolicy>...@@ -131,6 +132,8 @@ struct __fill<__std_thread_backend_tag, _ExecutionPolicy>
131} // namespace __pstl132} // namespace __pstl
132_LIBCPP_END_NAMESPACE_STD133_LIBCPP_END_NAMESPACE_STD
133134
135#endif // _LIBCPP_STD_VER >= 17
136
134_LIBCPP_POP_MACROS137_LIBCPP_POP_MACROS
135138
136#endif // _LIBCPP___PSTL_BACKENDS_STD_THREAD_H139#endif // _LIBCPP___PSTL_BACKENDS_STD_THREAD_H
lib/libcxx/include/__pstl/cpu_algos/any_of.h+4
...@@ -26,6 +26,8 @@...@@ -26,6 +26,8 @@
26_LIBCPP_PUSH_MACROS26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>27#include <__undef_macros>
2828
29#if _LIBCPP_STD_VER >= 17
30
29_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
30namespace __pstl {32namespace __pstl {
3133
...@@ -94,6 +96,8 @@ struct __cpu_parallel_any_of {...@@ -94,6 +96,8 @@ struct __cpu_parallel_any_of {
94} // namespace __pstl96} // namespace __pstl
95_LIBCPP_END_NAMESPACE_STD97_LIBCPP_END_NAMESPACE_STD
9698
99#endif // _LIBCPP_STD_VER >= 17
100
97_LIBCPP_POP_MACROS101_LIBCPP_POP_MACROS
98102
99#endif // _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H103#endif // _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H
lib/libcxx/include/__pstl/cpu_algos/cpu_traits.h+4-1
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H10#define _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H
1111
12#include <__config>12#include <__config>
13#include <cstddef>
1413
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header15# pragma GCC system_header
...@@ -19,6 +18,8 @@...@@ -19,6 +18,8 @@
19_LIBCPP_PUSH_MACROS18_LIBCPP_PUSH_MACROS
20#include <__undef_macros>19#include <__undef_macros>
2120
21#if _LIBCPP_STD_VER >= 17
22
22_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
23namespace __pstl {24namespace __pstl {
2425
...@@ -81,6 +82,8 @@ struct __cpu_traits;...@@ -81,6 +82,8 @@ struct __cpu_traits;
81} // namespace __pstl82} // namespace __pstl
82_LIBCPP_END_NAMESPACE_STD83_LIBCPP_END_NAMESPACE_STD
8384
85#endif // _LIBCPP_STD_VER >= 17
86
84_LIBCPP_POP_MACROS87_LIBCPP_POP_MACROS
8588
86#endif // _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H89#endif // _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H
lib/libcxx/include/__pstl/cpu_algos/fill.h+4
...@@ -23,6 +23,8 @@...@@ -23,6 +23,8 @@
23# pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26#if _LIBCPP_STD_VER >= 17
27
26_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
27namespace __pstl {29namespace __pstl {
2830
...@@ -63,4 +65,6 @@ struct __cpu_parallel_fill {...@@ -63,4 +65,6 @@ struct __cpu_parallel_fill {
63} // namespace __pstl65} // namespace __pstl
64_LIBCPP_END_NAMESPACE_STD66_LIBCPP_END_NAMESPACE_STD
6567
68#endif // _LIBCPP_STD_VER >= 17
69
66#endif // _LIBCPP___PSTL_CPU_ALGOS_FILL_H70#endif // _LIBCPP___PSTL_CPU_ALGOS_FILL_H
lib/libcxx/include/__pstl/cpu_algos/find_if.h+4-1
...@@ -21,7 +21,6 @@...@@ -21,7 +21,6 @@
21#include <__type_traits/is_execution_policy.h>21#include <__type_traits/is_execution_policy.h>
22#include <__utility/move.h>22#include <__utility/move.h>
23#include <__utility/pair.h>23#include <__utility/pair.h>
24#include <cstddef>
25#include <optional>24#include <optional>
2625
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -31,6 +30,8 @@...@@ -31,6 +30,8 @@
31_LIBCPP_PUSH_MACROS30_LIBCPP_PUSH_MACROS
32#include <__undef_macros>31#include <__undef_macros>
3332
33#if _LIBCPP_STD_VER >= 17
34
34_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
35namespace __pstl {36namespace __pstl {
3637
...@@ -132,6 +133,8 @@ struct __cpu_parallel_find_if {...@@ -132,6 +133,8 @@ struct __cpu_parallel_find_if {
132} // namespace __pstl133} // namespace __pstl
133_LIBCPP_END_NAMESPACE_STD134_LIBCPP_END_NAMESPACE_STD
134135
136#endif // _LIBCPP_STD_VER >= 17
137
135_LIBCPP_POP_MACROS138_LIBCPP_POP_MACROS
136139
137#endif // _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H140#endif // _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H
lib/libcxx/include/__pstl/cpu_algos/for_each.h+4
...@@ -23,6 +23,8 @@...@@ -23,6 +23,8 @@
23# pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26#if _LIBCPP_STD_VER >= 17
27
26_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
27namespace __pstl {29namespace __pstl {
2830
...@@ -63,4 +65,6 @@ struct __cpu_parallel_for_each {...@@ -63,4 +65,6 @@ struct __cpu_parallel_for_each {
63} // namespace __pstl65} // namespace __pstl
64_LIBCPP_END_NAMESPACE_STD66_LIBCPP_END_NAMESPACE_STD
6567
68#endif // _LIBCPP_STD_VER >= 17
69
66#endif // _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H70#endif // _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H
lib/libcxx/include/__pstl/cpu_algos/merge.h+4
...@@ -26,6 +26,8 @@...@@ -26,6 +26,8 @@
26_LIBCPP_PUSH_MACROS26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>27#include <__undef_macros>
2828
29#if _LIBCPP_STD_VER >= 17
30
29_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
30namespace __pstl {32namespace __pstl {
3133
...@@ -80,6 +82,8 @@ struct __cpu_parallel_merge {...@@ -80,6 +82,8 @@ struct __cpu_parallel_merge {
80} // namespace __pstl82} // namespace __pstl
81_LIBCPP_END_NAMESPACE_STD83_LIBCPP_END_NAMESPACE_STD
8284
85#endif // _LIBCPP_STD_VER >= 17
86
83_LIBCPP_POP_MACROS87_LIBCPP_POP_MACROS
8488
85#endif // _LIBCPP___PSTL_CPU_ALGOS_MERGE_H89#endif // _LIBCPP___PSTL_CPU_ALGOS_MERGE_H
lib/libcxx/include/__pstl/cpu_algos/stable_sort.h+4
...@@ -21,6 +21,8 @@...@@ -21,6 +21,8 @@
21# pragma GCC system_header21# pragma GCC system_header
22#endif22#endif
2323
24#if _LIBCPP_STD_VER >= 17
25
24_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
25namespace __pstl {27namespace __pstl {
2628
...@@ -44,4 +46,6 @@ struct __cpu_parallel_stable_sort {...@@ -44,4 +46,6 @@ struct __cpu_parallel_stable_sort {
44} // namespace __pstl46} // namespace __pstl
45_LIBCPP_END_NAMESPACE_STD47_LIBCPP_END_NAMESPACE_STD
4648
49#endif // _LIBCPP_STD_VER >= 17
50
47#endif // _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H51#endif // _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H
lib/libcxx/include/__pstl/cpu_algos/transform.h+4
...@@ -27,6 +27,8 @@...@@ -27,6 +27,8 @@
27_LIBCPP_PUSH_MACROS27_LIBCPP_PUSH_MACROS
28#include <__undef_macros>28#include <__undef_macros>
2929
30#if _LIBCPP_STD_VER >= 17
31
30_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
31namespace __pstl {33namespace __pstl {
3234
...@@ -148,6 +150,8 @@ struct __cpu_parallel_transform_binary {...@@ -148,6 +150,8 @@ struct __cpu_parallel_transform_binary {
148} // namespace __pstl150} // namespace __pstl
149_LIBCPP_END_NAMESPACE_STD151_LIBCPP_END_NAMESPACE_STD
150152
153#endif // _LIBCPP_STD_VER >= 17
154
151_LIBCPP_POP_MACROS155_LIBCPP_POP_MACROS
152156
153#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H157#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H
lib/libcxx/include/__pstl/cpu_algos/transform_reduce.h+4-2
...@@ -20,8 +20,6 @@...@@ -20,8 +20,6 @@
20#include <__type_traits/is_arithmetic.h>20#include <__type_traits/is_arithmetic.h>
21#include <__type_traits/is_execution_policy.h>21#include <__type_traits/is_execution_policy.h>
22#include <__utility/move.h>22#include <__utility/move.h>
23#include <cstddef>
24#include <new>
25#include <optional>23#include <optional>
2624
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -31,6 +29,8 @@...@@ -31,6 +29,8 @@
31_LIBCPP_PUSH_MACROS29_LIBCPP_PUSH_MACROS
32#include <__undef_macros>30#include <__undef_macros>
3331
32#if _LIBCPP_STD_VER >= 17
33
34_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
35namespace __pstl {35namespace __pstl {
3636
...@@ -211,6 +211,8 @@ struct __cpu_parallel_transform_reduce {...@@ -211,6 +211,8 @@ struct __cpu_parallel_transform_reduce {
211} // namespace __pstl211} // namespace __pstl
212_LIBCPP_END_NAMESPACE_STD212_LIBCPP_END_NAMESPACE_STD
213213
214#endif // _LIBCPP_STD_VER >= 17
215
214_LIBCPP_POP_MACROS216_LIBCPP_POP_MACROS
215217
216#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H218#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H
lib/libcxx/include/__pstl/dispatch.h+6-1
...@@ -23,6 +23,8 @@...@@ -23,6 +23,8 @@
23_LIBCPP_PUSH_MACROS23_LIBCPP_PUSH_MACROS
24#include <__undef_macros>24#include <__undef_macros>
2525
26#if _LIBCPP_STD_VER >= 17
27
26_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
27namespace __pstl {29namespace __pstl {
2830
...@@ -56,11 +58,14 @@ struct __find_first_implemented<_Algorithm, __backend_configuration<_B1, _Bn...>...@@ -56,11 +58,14 @@ struct __find_first_implemented<_Algorithm, __backend_configuration<_B1, _Bn...>
56 __find_first_implemented<_Algorithm, __backend_configuration<_Bn...>, _ExecutionPolicy> > {};58 __find_first_implemented<_Algorithm, __backend_configuration<_Bn...>, _ExecutionPolicy> > {};
5759
58template <template <class, class> class _Algorithm, class _BackendConfiguration, class _ExecutionPolicy>60template <template <class, class> class _Algorithm, class _BackendConfiguration, class _ExecutionPolicy>
59using __dispatch = typename __find_first_implemented<_Algorithm, _BackendConfiguration, _ExecutionPolicy>::type;61using __dispatch _LIBCPP_NODEBUG =
62 typename __find_first_implemented<_Algorithm, _BackendConfiguration, _ExecutionPolicy>::type;
6063
61} // namespace __pstl64} // namespace __pstl
62_LIBCPP_END_NAMESPACE_STD65_LIBCPP_END_NAMESPACE_STD
6366
67#endif // _LIBCPP_STD_VER >= 17
68
64_LIBCPP_POP_MACROS69_LIBCPP_POP_MACROS
6570
66#endif // _LIBCPP___PSTL_DISPATCH_H71#endif // _LIBCPP___PSTL_DISPATCH_H
lib/libcxx/include/__pstl/handle_exception.h+5-1
...@@ -10,9 +10,9 @@...@@ -10,9 +10,9 @@
10#define _LIBCPP___PSTL_HANDLE_EXCEPTION_H10#define _LIBCPP___PSTL_HANDLE_EXCEPTION_H
1111
12#include <__config>12#include <__config>
13#include <__new/exceptions.h>
13#include <__utility/forward.h>14#include <__utility/forward.h>
14#include <__utility/move.h>15#include <__utility/move.h>
15#include <new> // __throw_bad_alloc
16#include <optional>16#include <optional>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -22,6 +22,8 @@...@@ -22,6 +22,8 @@
22_LIBCPP_PUSH_MACROS22_LIBCPP_PUSH_MACROS
23#include <__undef_macros>23#include <__undef_macros>
2424
25#if _LIBCPP_STD_VER >= 17
26
25_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
26namespace __pstl {28namespace __pstl {
2729
...@@ -52,6 +54,8 @@ _LIBCPP_HIDE_FROM_ABI auto __handle_exception(_Args&&... __args) {...@@ -52,6 +54,8 @@ _LIBCPP_HIDE_FROM_ABI auto __handle_exception(_Args&&... __args) {
52} // namespace __pstl54} // namespace __pstl
53_LIBCPP_END_NAMESPACE_STD55_LIBCPP_END_NAMESPACE_STD
5456
57#endif // _LIBCPP_STD_VER >= 17
58
55_LIBCPP_POP_MACROS59_LIBCPP_POP_MACROS
5660
57#endif // _LIBCPP___PSTL_HANDLE_EXCEPTION_H61#endif // _LIBCPP___PSTL_HANDLE_EXCEPTION_H
lib/libcxx/include/__random/binomial_distribution.h+3-2
...@@ -97,12 +97,13 @@ public:...@@ -97,12 +97,13 @@ public:
97 }97 }
98};98};
9999
100#ifndef _LIBCPP_MSVCRT_LIKE100// The LLVM C library provides this with conflicting `noexcept` attributes.
101#if !defined(_LIBCPP_MSVCRT_LIKE) && !defined(__LLVM_LIBC__)
101extern "C" double lgamma_r(double, int*);102extern "C" double lgamma_r(double, int*);
102#endif103#endif
103104
104inline _LIBCPP_HIDE_FROM_ABI double __libcpp_lgamma(double __d) {105inline _LIBCPP_HIDE_FROM_ABI double __libcpp_lgamma(double __d) {
105#if defined(_LIBCPP_MSVCRT_LIKE)106#if defined(_LIBCPP_MSVCRT_LIKE) || defined(__LLVM_LIBC__)
106 return lgamma(__d);107 return lgamma(__d);
107#else108#else
108 int __sign;109 int __sign;
lib/libcxx/include/__random/discard_block_engine.h+3-9
...@@ -10,11 +10,11 @@...@@ -10,11 +10,11 @@
10#define _LIBCPP___RANDOM_DISCARD_BLOCK_ENGINE_H10#define _LIBCPP___RANDOM_DISCARD_BLOCK_ENGINE_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__random/is_seed_sequence.h>14#include <__random/is_seed_sequence.h>
14#include <__type_traits/enable_if.h>15#include <__type_traits/enable_if.h>
15#include <__type_traits/is_convertible.h>16#include <__type_traits/is_convertible.h>
16#include <__utility/move.h>17#include <__utility/move.h>
17#include <cstddef>
18#include <iosfwd>18#include <iosfwd>
19#include <limits>19#include <limits>
2020
...@@ -43,8 +43,8 @@ public:...@@ -43,8 +43,8 @@ public:
43 typedef typename _Engine::result_type result_type;43 typedef typename _Engine::result_type result_type;
4444
45 // engine characteristics45 // engine characteristics
46 static _LIBCPP_CONSTEXPR const size_t block_size = __p;46 static inline _LIBCPP_CONSTEXPR const size_t block_size = __p;
47 static _LIBCPP_CONSTEXPR const size_t used_block = __r;47 static inline _LIBCPP_CONSTEXPR const size_t used_block = __r;
4848
49#ifdef _LIBCPP_CXX03_LANG49#ifdef _LIBCPP_CXX03_LANG
50 static const result_type _Min = _Engine::_Min;50 static const result_type _Min = _Engine::_Min;
...@@ -110,12 +110,6 @@ public:...@@ -110,12 +110,6 @@ public:
110 operator>>(basic_istream<_CharT, _Traits>& __is, discard_block_engine<_Eng, _Pp, _Rp>& __x);110 operator>>(basic_istream<_CharT, _Traits>& __is, discard_block_engine<_Eng, _Pp, _Rp>& __x);
111};111};
112112
113template <class _Engine, size_t __p, size_t __r>
114_LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::block_size;
115
116template <class _Engine, size_t __p, size_t __r>
117_LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::used_block;
118
119template <class _Engine, size_t __p, size_t __r>113template <class _Engine, size_t __p, size_t __r>
120typename discard_block_engine<_Engine, __p, __r>::result_type discard_block_engine<_Engine, __p, __r>::operator()() {114typename discard_block_engine<_Engine, __p, __r>::result_type discard_block_engine<_Engine, __p, __r>::operator()() {
121 if (__n_ >= static_cast<int>(__r)) {115 if (__n_ >= static_cast<int>(__r)) {
lib/libcxx/include/__random/discrete_distribution.h+2-2
...@@ -13,10 +13,10 @@...@@ -13,10 +13,10 @@
13#include <__config>13#include <__config>
14#include <__random/is_valid.h>14#include <__random/is_valid.h>
15#include <__random/uniform_real_distribution.h>15#include <__random/uniform_real_distribution.h>
16#include <cstddef>16#include <__vector/vector.h>
17#include <initializer_list>
17#include <iosfwd>18#include <iosfwd>
18#include <numeric>19#include <numeric>
19#include <vector>
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
lib/libcxx/include/__random/independent_bits_engine.h+1-1
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#define _LIBCPP___RANDOM_INDEPENDENT_BITS_ENGINE_H10#define _LIBCPP___RANDOM_INDEPENDENT_BITS_ENGINE_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__fwd/istream.h>14#include <__fwd/istream.h>
14#include <__fwd/ostream.h>15#include <__fwd/ostream.h>
15#include <__random/is_seed_sequence.h>16#include <__random/is_seed_sequence.h>
...@@ -18,7 +19,6 @@...@@ -18,7 +19,6 @@
18#include <__type_traits/enable_if.h>19#include <__type_traits/enable_if.h>
19#include <__type_traits/is_convertible.h>20#include <__type_traits/is_convertible.h>
20#include <__utility/move.h>21#include <__utility/move.h>
21#include <cstddef>
22#include <limits>22#include <limits>
2323
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__random/is_valid.h+2-2
...@@ -66,12 +66,12 @@ struct __libcpp_random_is_valid_inttype<unsigned long> : true_type {};...@@ -66,12 +66,12 @@ struct __libcpp_random_is_valid_inttype<unsigned long> : true_type {};
66template <>66template <>
67struct __libcpp_random_is_valid_inttype<unsigned long long> : true_type {};67struct __libcpp_random_is_valid_inttype<unsigned long long> : true_type {};
6868
69#ifndef _LIBCPP_HAS_NO_INT12869#if _LIBCPP_HAS_INT128
70template <>70template <>
71struct __libcpp_random_is_valid_inttype<__int128_t> : true_type {}; // extension71struct __libcpp_random_is_valid_inttype<__int128_t> : true_type {}; // extension
72template <>72template <>
73struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {}; // extension73struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {}; // extension
74#endif // _LIBCPP_HAS_NO_INT12874#endif // _LIBCPP_HAS_INT128
7575
76// [rand.req.urng]/3:76// [rand.req.urng]/3:
77// A class G meets the uniform random bit generator requirements if G models77// A class G meets the uniform random bit generator requirements if G models
lib/libcxx/include/__random/linear_congruential_engine.h+6-22
...@@ -48,7 +48,7 @@ struct __lce_alg_picker {...@@ -48,7 +48,7 @@ struct __lce_alg_picker {
48 : _Schrage ? _LCE_Schrage48 : _Schrage ? _LCE_Schrage
49 : _LCE_Promote;49 : _LCE_Promote;
5050
51#ifdef _LIBCPP_HAS_NO_INT12851#if !_LIBCPP_HAS_INT128
52 static_assert(_Mp != (unsigned long long)(-1) || _Full || _Part || _Schrage,52 static_assert(_Mp != (unsigned long long)(-1) || _Full || _Part || _Schrage,
53 "The current values for a, c, and m are not currently supported on platforms without __int128");53 "The current values for a, c, and m are not currently supported on platforms without __int128");
54#endif54#endif
...@@ -63,7 +63,7 @@ struct __lce_ta;...@@ -63,7 +63,7 @@ struct __lce_ta;
6363
64// 6464// 64
6565
66#ifndef _LIBCPP_HAS_NO_INT12866#if _LIBCPP_HAS_INT128
67template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp>67template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp>
68struct __lce_ta<_Ap, _Cp, _Mp, (unsigned long long)(-1), _LCE_Promote> {68struct __lce_ta<_Ap, _Cp, _Mp, (unsigned long long)(-1), _LCE_Promote> {
69 typedef unsigned long long result_type;69 typedef unsigned long long result_type;
...@@ -251,12 +251,12 @@ public:...@@ -251,12 +251,12 @@ public:
251 static_assert(_Min < _Max, "linear_congruential_engine invalid parameters");251 static_assert(_Min < _Max, "linear_congruential_engine invalid parameters");
252252
253 // engine characteristics253 // engine characteristics
254 static _LIBCPP_CONSTEXPR const result_type multiplier = __a;254 static inline _LIBCPP_CONSTEXPR const result_type multiplier = __a;
255 static _LIBCPP_CONSTEXPR const result_type increment = __c;255 static inline _LIBCPP_CONSTEXPR const result_type increment = __c;
256 static _LIBCPP_CONSTEXPR const result_type modulus = __m;256 static inline _LIBCPP_CONSTEXPR const result_type modulus = __m;
257 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }257 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
258 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }258 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
259 static _LIBCPP_CONSTEXPR const result_type default_seed = 1u;259 static inline _LIBCPP_CONSTEXPR const result_type default_seed = 1u;
260260
261 // constructors and seeding functions261 // constructors and seeding functions
262#ifndef _LIBCPP_CXX03_LANG262#ifndef _LIBCPP_CXX03_LANG
...@@ -318,22 +318,6 @@ private:...@@ -318,22 +318,6 @@ private:
318 operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);318 operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);
319};319};
320320
321template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
322_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
323 linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier;
324
325template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
326_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
327 linear_congruential_engine<_UIntType, __a, __c, __m>::increment;
328
329template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
330_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
331 linear_congruential_engine<_UIntType, __a, __c, __m>::modulus;
332
333template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
334_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
335 linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed;
336
337template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>321template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
338template <class _Sseq>322template <class _Sseq>
339void linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, integral_constant<unsigned, 1>) {323void linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, integral_constant<unsigned, 1>) {
lib/libcxx/include/__random/log2.h+5-5
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___RANDOM_LOG2_H10#define _LIBCPP___RANDOM_LOG2_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__type_traits/conditional.h>14#include <__type_traits/conditional.h>
14#include <cstddef>
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
...@@ -38,7 +38,7 @@ struct __log2_imp<unsigned long long, 0, _Rp> {...@@ -38,7 +38,7 @@ struct __log2_imp<unsigned long long, 0, _Rp> {
38 static const size_t value = _Rp + 1;38 static const size_t value = _Rp + 1;
39};39};
4040
41#ifndef _LIBCPP_HAS_NO_INT12841#if _LIBCPP_HAS_INT128
4242
43template <__uint128_t _Xp, size_t _Rp>43template <__uint128_t _Xp, size_t _Rp>
44struct __log2_imp<__uint128_t, _Xp, _Rp> {44struct __log2_imp<__uint128_t, _Xp, _Rp> {
...@@ -47,16 +47,16 @@ struct __log2_imp<__uint128_t, _Xp, _Rp> {...@@ -47,16 +47,16 @@ struct __log2_imp<__uint128_t, _Xp, _Rp> {
47 : __log2_imp<unsigned long long, _Xp, 63>::value;47 : __log2_imp<unsigned long long, _Xp, 63>::value;
48};48};
4949
50#endif // _LIBCPP_HAS_NO_INT12850#endif // _LIBCPP_HAS_INT128
5151
52template <class _UIntType, _UIntType _Xp>52template <class _UIntType, _UIntType _Xp>
53struct __log2 {53struct __log2 {
54 static const size_t value = __log2_imp<54 static const size_t value = __log2_imp<
55#ifndef _LIBCPP_HAS_NO_INT12855#if _LIBCPP_HAS_INT128
56 __conditional_t<sizeof(_UIntType) <= sizeof(unsigned long long), unsigned long long, __uint128_t>,56 __conditional_t<sizeof(_UIntType) <= sizeof(unsigned long long), unsigned long long, __uint128_t>,
57#else57#else
58 unsigned long long,58 unsigned long long,
59#endif // _LIBCPP_HAS_NO_INT12859#endif // _LIBCPP_HAS_INT128
60 _Xp,60 _Xp,
61 sizeof(_UIntType) * __CHAR_BIT__ - 1>::value;61 sizeof(_UIntType) * __CHAR_BIT__ - 1>::value;
62};62};
lib/libcxx/include/__random/mersenne_twister_engine.h+16-338
...@@ -12,8 +12,9 @@...@@ -12,8 +12,9 @@
12#include <__algorithm/equal.h>12#include <__algorithm/equal.h>
13#include <__algorithm/min.h>13#include <__algorithm/min.h>
14#include <__config>14#include <__config>
15#include <__cstddef/size_t.h>
15#include <__random/is_seed_sequence.h>16#include <__random/is_seed_sequence.h>
16#include <cstddef>17#include <__type_traits/enable_if.h>
17#include <cstdint>18#include <cstdint>
18#include <iosfwd>19#include <iosfwd>
19#include <limits>20#include <limits>
...@@ -165,22 +166,22 @@ public:...@@ -165,22 +166,22 @@ public:
165 static_assert(__f <= _Max, "mersenne_twister_engine invalid parameters");166 static_assert(__f <= _Max, "mersenne_twister_engine invalid parameters");
166167
167 // engine characteristics168 // engine characteristics
168 static _LIBCPP_CONSTEXPR const size_t word_size = __w;169 static inline _LIBCPP_CONSTEXPR const size_t word_size = __w;
169 static _LIBCPP_CONSTEXPR const size_t state_size = __n;170 static inline _LIBCPP_CONSTEXPR const size_t state_size = __n;
170 static _LIBCPP_CONSTEXPR const size_t shift_size = __m;171 static inline _LIBCPP_CONSTEXPR const size_t shift_size = __m;
171 static _LIBCPP_CONSTEXPR const size_t mask_bits = __r;172 static inline _LIBCPP_CONSTEXPR const size_t mask_bits = __r;
172 static _LIBCPP_CONSTEXPR const result_type xor_mask = __a;173 static inline _LIBCPP_CONSTEXPR const result_type xor_mask = __a;
173 static _LIBCPP_CONSTEXPR const size_t tempering_u = __u;174 static inline _LIBCPP_CONSTEXPR const size_t tempering_u = __u;
174 static _LIBCPP_CONSTEXPR const result_type tempering_d = __d;175 static inline _LIBCPP_CONSTEXPR const result_type tempering_d = __d;
175 static _LIBCPP_CONSTEXPR const size_t tempering_s = __s;176 static inline _LIBCPP_CONSTEXPR const size_t tempering_s = __s;
176 static _LIBCPP_CONSTEXPR const result_type tempering_b = __b;177 static inline _LIBCPP_CONSTEXPR const result_type tempering_b = __b;
177 static _LIBCPP_CONSTEXPR const size_t tempering_t = __t;178 static inline _LIBCPP_CONSTEXPR const size_t tempering_t = __t;
178 static _LIBCPP_CONSTEXPR const result_type tempering_c = __c;179 static inline _LIBCPP_CONSTEXPR const result_type tempering_c = __c;
179 static _LIBCPP_CONSTEXPR const size_t tempering_l = __l;180 static inline _LIBCPP_CONSTEXPR const size_t tempering_l = __l;
180 static _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f;181 static inline _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f;
181 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }182 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
182 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }183 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
183 static _LIBCPP_CONSTEXPR const result_type default_seed = 5489u;184 static inline _LIBCPP_CONSTEXPR const result_type default_seed = 5489u;
184185
185 // constructors and seeding functions186 // constructors and seeding functions
186#ifndef _LIBCPP_CXX03_LANG187#ifndef _LIBCPP_CXX03_LANG
...@@ -309,329 +310,6 @@ private:...@@ -309,329 +310,6 @@ private:
309 }310 }
310};311};
311312
312template <class _UIntType,
313 size_t __w,
314 size_t __n,
315 size_t __m,
316 size_t __r,
317 _UIntType __a,
318 size_t __u,
319 _UIntType __d,
320 size_t __s,
321 _UIntType __b,
322 size_t __t,
323 _UIntType __c,
324 size_t __l,
325 _UIntType __f>
326_LIBCPP_CONSTEXPR const size_t
327 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::word_size;
328
329template <class _UIntType,
330 size_t __w,
331 size_t __n,
332 size_t __m,
333 size_t __r,
334 _UIntType __a,
335 size_t __u,
336 _UIntType __d,
337 size_t __s,
338 _UIntType __b,
339 size_t __t,
340 _UIntType __c,
341 size_t __l,
342 _UIntType __f>
343_LIBCPP_CONSTEXPR const size_t
344 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::state_size;
345
346template <class _UIntType,
347 size_t __w,
348 size_t __n,
349 size_t __m,
350 size_t __r,
351 _UIntType __a,
352 size_t __u,
353 _UIntType __d,
354 size_t __s,
355 _UIntType __b,
356 size_t __t,
357 _UIntType __c,
358 size_t __l,
359 _UIntType __f>
360_LIBCPP_CONSTEXPR const size_t
361 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::shift_size;
362
363template <class _UIntType,
364 size_t __w,
365 size_t __n,
366 size_t __m,
367 size_t __r,
368 _UIntType __a,
369 size_t __u,
370 _UIntType __d,
371 size_t __s,
372 _UIntType __b,
373 size_t __t,
374 _UIntType __c,
375 size_t __l,
376 _UIntType __f>
377_LIBCPP_CONSTEXPR const size_t
378 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mask_bits;
379
380template <class _UIntType,
381 size_t __w,
382 size_t __n,
383 size_t __m,
384 size_t __r,
385 _UIntType __a,
386 size_t __u,
387 _UIntType __d,
388 size_t __s,
389 _UIntType __b,
390 size_t __t,
391 _UIntType __c,
392 size_t __l,
393 _UIntType __f>
394_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
395 _UIntType,
396 __w,
397 __n,
398 __m,
399 __r,
400 __a,
401 __u,
402 __d,
403 __s,
404 __b,
405 __t,
406 __c,
407 __l,
408 __f>::result_type
409 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::xor_mask;
410
411template <class _UIntType,
412 size_t __w,
413 size_t __n,
414 size_t __m,
415 size_t __r,
416 _UIntType __a,
417 size_t __u,
418 _UIntType __d,
419 size_t __s,
420 _UIntType __b,
421 size_t __t,
422 _UIntType __c,
423 size_t __l,
424 _UIntType __f>
425_LIBCPP_CONSTEXPR const size_t
426 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_u;
427
428template <class _UIntType,
429 size_t __w,
430 size_t __n,
431 size_t __m,
432 size_t __r,
433 _UIntType __a,
434 size_t __u,
435 _UIntType __d,
436 size_t __s,
437 _UIntType __b,
438 size_t __t,
439 _UIntType __c,
440 size_t __l,
441 _UIntType __f>
442_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
443 _UIntType,
444 __w,
445 __n,
446 __m,
447 __r,
448 __a,
449 __u,
450 __d,
451 __s,
452 __b,
453 __t,
454 __c,
455 __l,
456 __f>::result_type
457 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_d;
458
459template <class _UIntType,
460 size_t __w,
461 size_t __n,
462 size_t __m,
463 size_t __r,
464 _UIntType __a,
465 size_t __u,
466 _UIntType __d,
467 size_t __s,
468 _UIntType __b,
469 size_t __t,
470 _UIntType __c,
471 size_t __l,
472 _UIntType __f>
473_LIBCPP_CONSTEXPR const size_t
474 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_s;
475
476template <class _UIntType,
477 size_t __w,
478 size_t __n,
479 size_t __m,
480 size_t __r,
481 _UIntType __a,
482 size_t __u,
483 _UIntType __d,
484 size_t __s,
485 _UIntType __b,
486 size_t __t,
487 _UIntType __c,
488 size_t __l,
489 _UIntType __f>
490_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
491 _UIntType,
492 __w,
493 __n,
494 __m,
495 __r,
496 __a,
497 __u,
498 __d,
499 __s,
500 __b,
501 __t,
502 __c,
503 __l,
504 __f>::result_type
505 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_b;
506
507template <class _UIntType,
508 size_t __w,
509 size_t __n,
510 size_t __m,
511 size_t __r,
512 _UIntType __a,
513 size_t __u,
514 _UIntType __d,
515 size_t __s,
516 _UIntType __b,
517 size_t __t,
518 _UIntType __c,
519 size_t __l,
520 _UIntType __f>
521_LIBCPP_CONSTEXPR const size_t
522 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_t;
523
524template <class _UIntType,
525 size_t __w,
526 size_t __n,
527 size_t __m,
528 size_t __r,
529 _UIntType __a,
530 size_t __u,
531 _UIntType __d,
532 size_t __s,
533 _UIntType __b,
534 size_t __t,
535 _UIntType __c,
536 size_t __l,
537 _UIntType __f>
538_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
539 _UIntType,
540 __w,
541 __n,
542 __m,
543 __r,
544 __a,
545 __u,
546 __d,
547 __s,
548 __b,
549 __t,
550 __c,
551 __l,
552 __f>::result_type
553 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_c;
554
555template <class _UIntType,
556 size_t __w,
557 size_t __n,
558 size_t __m,
559 size_t __r,
560 _UIntType __a,
561 size_t __u,
562 _UIntType __d,
563 size_t __s,
564 _UIntType __b,
565 size_t __t,
566 _UIntType __c,
567 size_t __l,
568 _UIntType __f>
569_LIBCPP_CONSTEXPR const size_t
570 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_l;
571
572template <class _UIntType,
573 size_t __w,
574 size_t __n,
575 size_t __m,
576 size_t __r,
577 _UIntType __a,
578 size_t __u,
579 _UIntType __d,
580 size_t __s,
581 _UIntType __b,
582 size_t __t,
583 _UIntType __c,
584 size_t __l,
585 _UIntType __f>
586_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
587 _UIntType,
588 __w,
589 __n,
590 __m,
591 __r,
592 __a,
593 __u,
594 __d,
595 __s,
596 __b,
597 __t,
598 __c,
599 __l,
600 __f>::result_type
601 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::
602 initialization_multiplier;
603
604template <class _UIntType,
605 size_t __w,
606 size_t __n,
607 size_t __m,
608 size_t __r,
609 _UIntType __a,
610 size_t __u,
611 _UIntType __d,
612 size_t __s,
613 _UIntType __b,
614 size_t __t,
615 _UIntType __c,
616 size_t __l,
617 _UIntType __f>
618_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
619 _UIntType,
620 __w,
621 __n,
622 __m,
623 __r,
624 __a,
625 __u,
626 __d,
627 __s,
628 __b,
629 __t,
630 __c,
631 __l,
632 __f>::result_type
633 mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::default_seed;
634
635template <class _UIntType,313template <class _UIntType,
636 size_t __w,314 size_t __w,
637 size_t __n,315 size_t __n,
lib/libcxx/include/__random/piecewise_constant_distribution.h+3-1
...@@ -11,11 +11,13 @@...@@ -11,11 +11,13 @@
1111
12#include <__algorithm/upper_bound.h>12#include <__algorithm/upper_bound.h>
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
14#include <__random/is_valid.h>15#include <__random/is_valid.h>
15#include <__random/uniform_real_distribution.h>16#include <__random/uniform_real_distribution.h>
17#include <__vector/vector.h>
18#include <initializer_list>
16#include <iosfwd>19#include <iosfwd>
17#include <numeric>20#include <numeric>
18#include <vector>
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
lib/libcxx/include/__random/piecewise_linear_distribution.h+4-1
...@@ -11,11 +11,14 @@...@@ -11,11 +11,14 @@
1111
12#include <__algorithm/upper_bound.h>12#include <__algorithm/upper_bound.h>
13#include <__config>13#include <__config>
14#include <__cstddef/ptrdiff_t.h>
14#include <__random/is_valid.h>15#include <__random/is_valid.h>
15#include <__random/uniform_real_distribution.h>16#include <__random/uniform_real_distribution.h>
17#include <__vector/comparison.h>
18#include <__vector/vector.h>
16#include <cmath>19#include <cmath>
20#include <initializer_list>
17#include <iosfwd>21#include <iosfwd>
18#include <vector>
1922
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header24# pragma GCC system_header
lib/libcxx/include/__random/random_device.h+2-2
...@@ -21,7 +21,7 @@ _LIBCPP_PUSH_MACROS...@@ -21,7 +21,7 @@ _LIBCPP_PUSH_MACROS
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24#if !defined(_LIBCPP_HAS_NO_RANDOM_DEVICE)24#if _LIBCPP_HAS_RANDOM_DEVICE
2525
26class _LIBCPP_EXPORTED_FROM_ABI random_device {26class _LIBCPP_EXPORTED_FROM_ABI random_device {
27# ifdef _LIBCPP_USING_DEV_RANDOM27# ifdef _LIBCPP_USING_DEV_RANDOM
...@@ -72,7 +72,7 @@ public:...@@ -72,7 +72,7 @@ public:
72 void operator=(const random_device&) = delete;72 void operator=(const random_device&) = delete;
73};73};
7474
75#endif // !_LIBCPP_HAS_NO_RANDOM_DEVICE75#endif // _LIBCPP_HAS_RANDOM_DEVICE
7676
77_LIBCPP_END_NAMESPACE_STD77_LIBCPP_END_NAMESPACE_STD
7878
lib/libcxx/include/__random/seed_seq.h+3-1
...@@ -14,10 +14,12 @@...@@ -14,10 +14,12 @@
14#include <__algorithm/max.h>14#include <__algorithm/max.h>
15#include <__config>15#include <__config>
16#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
17#include <__type_traits/enable_if.h>
18#include <__type_traits/is_integral.h>
17#include <__type_traits/is_unsigned.h>19#include <__type_traits/is_unsigned.h>
20#include <__vector/vector.h>
18#include <cstdint>21#include <cstdint>
19#include <initializer_list>22#include <initializer_list>
20#include <vector>
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
lib/libcxx/include/__random/shuffle_order_engine.h+2-5
...@@ -11,12 +11,12 @@...@@ -11,12 +11,12 @@
1111
12#include <__algorithm/equal.h>12#include <__algorithm/equal.h>
13#include <__config>13#include <__config>
14#include <__cstddef/size_t.h>
14#include <__random/is_seed_sequence.h>15#include <__random/is_seed_sequence.h>
15#include <__type_traits/enable_if.h>16#include <__type_traits/enable_if.h>
16#include <__type_traits/integral_constant.h>17#include <__type_traits/integral_constant.h>
17#include <__type_traits/is_convertible.h>18#include <__type_traits/is_convertible.h>
18#include <__utility/move.h>19#include <__utility/move.h>
19#include <cstddef>
20#include <cstdint>20#include <cstdint>
21#include <iosfwd>21#include <iosfwd>
2222
...@@ -66,7 +66,7 @@ private:...@@ -66,7 +66,7 @@ private:
6666
67public:67public:
68 // engine characteristics68 // engine characteristics
69 static _LIBCPP_CONSTEXPR const size_t table_size = __k;69 static inline _LIBCPP_CONSTEXPR const size_t table_size = __k;
7070
71#ifdef _LIBCPP_CXX03_LANG71#ifdef _LIBCPP_CXX03_LANG
72 static const result_type _Min = _Engine::_Min;72 static const result_type _Min = _Engine::_Min;
...@@ -173,9 +173,6 @@ private:...@@ -173,9 +173,6 @@ private:
173 }173 }
174};174};
175175
176template <class _Engine, size_t __k>
177_LIBCPP_CONSTEXPR const size_t shuffle_order_engine<_Engine, __k>::table_size;
178
179template <class _Eng, size_t _Kp>176template <class _Eng, size_t _Kp>
180_LIBCPP_HIDE_FROM_ABI bool177_LIBCPP_HIDE_FROM_ABI bool
181operator==(const shuffle_order_engine<_Eng, _Kp>& __x, const shuffle_order_engine<_Eng, _Kp>& __y) {178operator==(const shuffle_order_engine<_Eng, _Kp>& __x, const shuffle_order_engine<_Eng, _Kp>& __y) {
lib/libcxx/include/__random/subtract_with_carry_engine.h+6-18
...@@ -12,9 +12,10 @@...@@ -12,9 +12,10 @@
12#include <__algorithm/equal.h>12#include <__algorithm/equal.h>
13#include <__algorithm/min.h>13#include <__algorithm/min.h>
14#include <__config>14#include <__config>
15#include <__cstddef/size_t.h>
15#include <__random/is_seed_sequence.h>16#include <__random/is_seed_sequence.h>
16#include <__random/linear_congruential_engine.h>17#include <__random/linear_congruential_engine.h>
17#include <cstddef>18#include <__type_traits/enable_if.h>
18#include <cstdint>19#include <cstdint>
19#include <iosfwd>20#include <iosfwd>
20#include <limits>21#include <limits>
...@@ -71,12 +72,12 @@ public:...@@ -71,12 +72,12 @@ public:
71 static_assert(_Min < _Max, "subtract_with_carry_engine invalid parameters");72 static_assert(_Min < _Max, "subtract_with_carry_engine invalid parameters");
7273
73 // engine characteristics74 // engine characteristics
74 static _LIBCPP_CONSTEXPR const size_t word_size = __w;75 static inline _LIBCPP_CONSTEXPR const size_t word_size = __w;
75 static _LIBCPP_CONSTEXPR const size_t short_lag = __s;76 static inline _LIBCPP_CONSTEXPR const size_t short_lag = __s;
76 static _LIBCPP_CONSTEXPR const size_t long_lag = __r;77 static inline _LIBCPP_CONSTEXPR const size_t long_lag = __r;
77 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }78 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
78 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }79 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
79 static _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u;80 static inline _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u;
8081
81 // constructors and seeding functions82 // constructors and seeding functions
82#ifndef _LIBCPP_CXX03_LANG83#ifndef _LIBCPP_CXX03_LANG
...@@ -129,19 +130,6 @@ private:...@@ -129,19 +130,6 @@ private:
129 _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 2>);130 _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 2>);
130};131};
131132
132template <class _UIntType, size_t __w, size_t __s, size_t __r>
133_LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size;
134
135template <class _UIntType, size_t __w, size_t __s, size_t __r>
136_LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag;
137
138template <class _UIntType, size_t __w, size_t __s, size_t __r>
139_LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag;
140
141template <class _UIntType, size_t __w, size_t __s, size_t __r>
142_LIBCPP_CONSTEXPR const typename subtract_with_carry_engine<_UIntType, __w, __s, __r>::result_type
143 subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed;
144
145template <class _UIntType, size_t __w, size_t __s, size_t __r>133template <class _UIntType, size_t __w, size_t __s, size_t __r>
146void subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, integral_constant<unsigned, 1>) {134void subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, integral_constant<unsigned, 1>) {
147 linear_congruential_engine<result_type, 40014u, 0u, 2147483563u> __e(__sd == 0u ? default_seed : __sd);135 linear_congruential_engine<result_type, 40014u, 0u, 2147483563u> __e(__sd == 0u ? default_seed : __sd);
lib/libcxx/include/__random/uniform_int_distribution.h+1-1
...@@ -11,11 +11,11 @@...@@ -11,11 +11,11 @@
1111
12#include <__bit/countl.h>12#include <__bit/countl.h>
13#include <__config>13#include <__config>
14#include <__cstddef/size_t.h>
14#include <__random/is_valid.h>15#include <__random/is_valid.h>
15#include <__random/log2.h>16#include <__random/log2.h>
16#include <__type_traits/conditional.h>17#include <__type_traits/conditional.h>
17#include <__type_traits/make_unsigned.h>18#include <__type_traits/make_unsigned.h>
18#include <cstddef>
19#include <cstdint>19#include <cstdint>
20#include <iosfwd>20#include <iosfwd>
21#include <limits>21#include <limits>
lib/libcxx/include/__random/uniform_random_bit_generator.h+1-1
...@@ -13,8 +13,8 @@...@@ -13,8 +13,8 @@
13#include <__concepts/invocable.h>13#include <__concepts/invocable.h>
14#include <__concepts/same_as.h>14#include <__concepts/same_as.h>
15#include <__config>15#include <__config>
16#include <__functional/invoke.h>
17#include <__type_traits/integral_constant.h>16#include <__type_traits/integral_constant.h>
17#include <__type_traits/invoke.h>
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/__ranges/access.h+1-1
...@@ -12,6 +12,7 @@...@@ -12,6 +12,7 @@
1212
13#include <__concepts/class_or_enum.h>13#include <__concepts/class_or_enum.h>
14#include <__config>14#include <__config>
15#include <__cstddef/size_t.h>
15#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
16#include <__iterator/readable_traits.h>17#include <__iterator/readable_traits.h>
17#include <__ranges/enable_borrowed_range.h>18#include <__ranges/enable_borrowed_range.h>
...@@ -21,7 +22,6 @@...@@ -21,7 +22,6 @@
21#include <__type_traits/remove_reference.h>22#include <__type_traits/remove_reference.h>
22#include <__utility/auto_cast.h>23#include <__utility/auto_cast.h>
23#include <__utility/declval.h>24#include <__utility/declval.h>
24#include <cstddef>
2525
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header27# pragma GCC system_header
lib/libcxx/include/__ranges/chunk_by_view.h+2-2
...@@ -59,7 +59,7 @@ class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS chunk_by_view : public view_interface...@@ -59,7 +59,7 @@ class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS chunk_by_view : public view_interface
59 _LIBCPP_NO_UNIQUE_ADDRESS __movable_box<_Pred> __pred_;59 _LIBCPP_NO_UNIQUE_ADDRESS __movable_box<_Pred> __pred_;
6060
61 // We cache the result of begin() to allow providing an amortized O(1).61 // We cache the result of begin() to allow providing an amortized O(1).
62 using _Cache = __non_propagating_cache<iterator_t<_View>>;62 using _Cache _LIBCPP_NODEBUG = __non_propagating_cache<iterator_t<_View>>;
63 _Cache __cached_begin_;63 _Cache __cached_begin_;
6464
65 class __iterator;65 class __iterator;
...@@ -215,7 +215,7 @@ struct __fn {...@@ -215,7 +215,7 @@ struct __fn {
215 requires constructible_from<decay_t<_Pred>, _Pred>215 requires constructible_from<decay_t<_Pred>, _Pred>
216 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const216 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const
217 noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {217 noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {
218 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred)));218 return __pipeable(std::__bind_back(*this, std::forward<_Pred>(__pred)));
219 }219 }
220};220};
221} // namespace __chunk_by221} // namespace __chunk_by
lib/libcxx/include/__ranges/counted.h+1-1
...@@ -12,6 +12,7 @@...@@ -12,6 +12,7 @@
1212
13#include <__concepts/convertible_to.h>13#include <__concepts/convertible_to.h>
14#include <__config>14#include <__config>
15#include <__cstddef/size_t.h>
15#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
16#include <__iterator/counted_iterator.h>17#include <__iterator/counted_iterator.h>
17#include <__iterator/default_sentinel.h>18#include <__iterator/default_sentinel.h>
...@@ -22,7 +23,6 @@...@@ -22,7 +23,6 @@
22#include <__type_traits/decay.h>23#include <__type_traits/decay.h>
23#include <__utility/forward.h>24#include <__utility/forward.h>
24#include <__utility/move.h>25#include <__utility/move.h>
25#include <cstddef>
26#include <span>26#include <span>
2727
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__ranges/drop_view.h+4-4
...@@ -15,6 +15,7 @@...@@ -15,6 +15,7 @@
15#include <__concepts/constructible.h>15#include <__concepts/constructible.h>
16#include <__concepts/convertible_to.h>16#include <__concepts/convertible_to.h>
17#include <__config>17#include <__config>
18#include <__cstddef/size_t.h>
18#include <__functional/bind_back.h>19#include <__functional/bind_back.h>
19#include <__fwd/span.h>20#include <__fwd/span.h>
20#include <__fwd/string_view.h>21#include <__fwd/string_view.h>
...@@ -42,7 +43,6 @@...@@ -42,7 +43,6 @@
42#include <__utility/auto_cast.h>43#include <__utility/auto_cast.h>
43#include <__utility/forward.h>44#include <__utility/forward.h>
44#include <__utility/move.h>45#include <__utility/move.h>
45#include <cstddef>
4646
47#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)47#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
48# pragma GCC system_header48# pragma GCC system_header
...@@ -64,7 +64,7 @@ class drop_view : public view_interface<drop_view<_View>> {...@@ -64,7 +64,7 @@ class drop_view : public view_interface<drop_view<_View>> {
64 // Note: drop_view<input-range>::begin() is still trivially amortized O(1) because64 // Note: drop_view<input-range>::begin() is still trivially amortized O(1) because
65 // one can't call begin() on it more than once.65 // one can't call begin() on it more than once.
66 static constexpr bool _UseCache = forward_range<_View> && !(random_access_range<_View> && sized_range<_View>);66 static constexpr bool _UseCache = forward_range<_View> && !(random_access_range<_View> && sized_range<_View>);
67 using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;67 using _Cache _LIBCPP_NODEBUG = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
68 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();68 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
69 range_difference_t<_View> __count_ = 0;69 range_difference_t<_View> __count_ = 0;
70 _View __base_ = _View();70 _View __base_ = _View();
...@@ -204,7 +204,7 @@ struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {...@@ -204,7 +204,7 @@ struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
204};204};
205205
206template <class _Tp>206template <class _Tp>
207using __passthrough_type_t = typename __passthrough_type<_Tp>::type;207using __passthrough_type_t _LIBCPP_NODEBUG = typename __passthrough_type<_Tp>::type;
208208
209struct __fn {209struct __fn {
210 // [range.drop.overview]: the `empty_view` case.210 // [range.drop.overview]: the `empty_view` case.
...@@ -307,7 +307,7 @@ struct __fn {...@@ -307,7 +307,7 @@ struct __fn {
307 requires constructible_from<decay_t<_Np>, _Np>307 requires constructible_from<decay_t<_Np>, _Np>
308 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Np&& __n) const308 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Np&& __n) const
309 noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>) {309 noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>) {
310 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n)));310 return __pipeable(std::__bind_back(*this, std::forward<_Np>(__n)));
311 }311 }
312};312};
313313
lib/libcxx/include/__ranges/drop_while_view.h+2-2
...@@ -90,7 +90,7 @@ private:...@@ -90,7 +90,7 @@ private:
90 _LIBCPP_NO_UNIQUE_ADDRESS __movable_box<_Pred> __pred_;90 _LIBCPP_NO_UNIQUE_ADDRESS __movable_box<_Pred> __pred_;
9191
92 static constexpr bool _UseCache = forward_range<_View>;92 static constexpr bool _UseCache = forward_range<_View>;
93 using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;93 using _Cache _LIBCPP_NODEBUG = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
94 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();94 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
95};95};
9696
...@@ -115,7 +115,7 @@ struct __fn {...@@ -115,7 +115,7 @@ struct __fn {
115 requires constructible_from<decay_t<_Pred>, _Pred>115 requires constructible_from<decay_t<_Pred>, _Pred>
116 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const116 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const
117 noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {117 noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {
118 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred)));118 return __pipeable(std::__bind_back(*this, std::forward<_Pred>(__pred)));
119 }119 }
120};120};
121121
lib/libcxx/include/__ranges/elements_view.h+4-4
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <__concepts/derived_from.h>16#include <__concepts/derived_from.h>
17#include <__concepts/equality_comparable.h>17#include <__concepts/equality_comparable.h>
18#include <__config>18#include <__config>
19#include <__fwd/complex.h>19#include <__fwd/get.h>
20#include <__iterator/concepts.h>20#include <__iterator/concepts.h>
21#include <__iterator/iterator_traits.h>21#include <__iterator/iterator_traits.h>
22#include <__ranges/access.h>22#include <__ranges/access.h>
...@@ -37,7 +37,7 @@...@@ -37,7 +37,7 @@
37#include <__utility/declval.h>37#include <__utility/declval.h>
38#include <__utility/forward.h>38#include <__utility/forward.h>
39#include <__utility/move.h>39#include <__utility/move.h>
40#include <cstddef>40#include <tuple> // std::get
4141
42#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)42#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
43# pragma GCC system_header43# pragma GCC system_header
...@@ -171,7 +171,7 @@ class elements_view<_View, _Np>::__iterator...@@ -171,7 +171,7 @@ class elements_view<_View, _Np>::__iterator
171 template <bool>171 template <bool>
172 friend class __sentinel;172 friend class __sentinel;
173173
174 using _Base = __maybe_const<_Const, _View>;174 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
175175
176 iterator_t<_Base> __current_ = iterator_t<_Base>();176 iterator_t<_Base> __current_ = iterator_t<_Base>();
177177
...@@ -335,7 +335,7 @@ template <input_range _View, size_t _Np>...@@ -335,7 +335,7 @@ template <input_range _View, size_t _Np>
335template <bool _Const>335template <bool _Const>
336class elements_view<_View, _Np>::__sentinel {336class elements_view<_View, _Np>::__sentinel {
337private:337private:
338 using _Base = __maybe_const<_Const, _View>;338 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
339 _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>();339 _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>();
340340
341 template <bool>341 template <bool>
lib/libcxx/include/__ranges/empty_view.h+1-1
...@@ -11,10 +11,10 @@...@@ -11,10 +11,10 @@
11#define _LIBCPP___RANGES_EMPTY_VIEW_H11#define _LIBCPP___RANGES_EMPTY_VIEW_H
1212
13#include <__config>13#include <__config>
14#include <__cstddef/size_t.h>
14#include <__ranges/enable_borrowed_range.h>15#include <__ranges/enable_borrowed_range.h>
15#include <__ranges/view_interface.h>16#include <__ranges/view_interface.h>
16#include <__type_traits/is_object.h>17#include <__type_traits/is_object.h>
17#include <cstddef>
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/__ranges/filter_view.h+3-3
...@@ -61,7 +61,7 @@ class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS filter_view : public view_interface<f...@@ -61,7 +61,7 @@ class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS filter_view : public view_interface<f
61 // We cache the result of begin() to allow providing an amortized O(1) begin() whenever61 // We cache the result of begin() to allow providing an amortized O(1) begin() whenever
62 // the underlying range is at least a forward_range.62 // the underlying range is at least a forward_range.
63 static constexpr bool _UseCache = forward_range<_View>;63 static constexpr bool _UseCache = forward_range<_View>;
64 using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;64 using _Cache _LIBCPP_NODEBUG = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
65 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();65 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
6666
67 class __iterator;67 class __iterator;
...@@ -115,7 +115,7 @@ struct __filter_iterator_category {};...@@ -115,7 +115,7 @@ struct __filter_iterator_category {};
115115
116template <forward_range _View>116template <forward_range _View>
117struct __filter_iterator_category<_View> {117struct __filter_iterator_category<_View> {
118 using _Cat = typename iterator_traits<iterator_t<_View>>::iterator_category;118 using _Cat _LIBCPP_NODEBUG = typename iterator_traits<iterator_t<_View>>::iterator_category;
119 using iterator_category =119 using iterator_category =
120 _If<derived_from<_Cat, bidirectional_iterator_tag>,120 _If<derived_from<_Cat, bidirectional_iterator_tag>,
121 bidirectional_iterator_tag,121 bidirectional_iterator_tag,
...@@ -239,7 +239,7 @@ struct __fn {...@@ -239,7 +239,7 @@ struct __fn {
239 requires constructible_from<decay_t<_Pred>, _Pred>239 requires constructible_from<decay_t<_Pred>, _Pred>
240 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const240 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const
241 noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {241 noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {
242 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred)));242 return __pipeable(std::__bind_back(*this, std::forward<_Pred>(__pred)));
243 }243 }
244};244};
245} // namespace __filter245} // namespace __filter
lib/libcxx/include/__ranges/iota_view.h+1-1
...@@ -68,7 +68,7 @@ struct __get_wider_signed {...@@ -68,7 +68,7 @@ struct __get_wider_signed {
68};68};
6969
70template <class _Start>70template <class _Start>
71using _IotaDiffT =71using _IotaDiffT _LIBCPP_NODEBUG =
72 typename _If< (!integral<_Start> || sizeof(iter_difference_t<_Start>) > sizeof(_Start)),72 typename _If< (!integral<_Start> || sizeof(iter_difference_t<_Start>) > sizeof(_Start)),
73 type_identity<iter_difference_t<_Start>>,73 type_identity<iter_difference_t<_Start>>,
74 __get_wider_signed<_Start> >::type;74 __get_wider_signed<_Start> >::type;
lib/libcxx/include/__ranges/istream_view.h+2-2
...@@ -14,6 +14,7 @@...@@ -14,6 +14,7 @@
14#include <__concepts/derived_from.h>14#include <__concepts/derived_from.h>
15#include <__concepts/movable.h>15#include <__concepts/movable.h>
16#include <__config>16#include <__config>
17#include <__cstddef/ptrdiff_t.h>
17#include <__fwd/istream.h>18#include <__fwd/istream.h>
18#include <__fwd/string.h>19#include <__fwd/string.h>
19#include <__iterator/default_sentinel.h>20#include <__iterator/default_sentinel.h>
...@@ -22,7 +23,6 @@...@@ -22,7 +23,6 @@
22#include <__ranges/view_interface.h>23#include <__ranges/view_interface.h>
23#include <__type_traits/remove_cvref.h>24#include <__type_traits/remove_cvref.h>
24#include <__utility/forward.h>25#include <__utility/forward.h>
25#include <cstddef>
2626
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header28# pragma GCC system_header
...@@ -99,7 +99,7 @@ private:...@@ -99,7 +99,7 @@ private:
99template <class _Val>99template <class _Val>
100using istream_view = basic_istream_view<_Val, char>;100using istream_view = basic_istream_view<_Val, char>;
101101
102# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS102# if _LIBCPP_HAS_WIDE_CHARACTERS
103template <class _Val>103template <class _Val>
104using wistream_view = basic_istream_view<_Val, wchar_t>;104using wistream_view = basic_istream_view<_Val, wchar_t>;
105# endif105# endif
lib/libcxx/include/__ranges/join_view.h+18-17
...@@ -55,8 +55,8 @@ struct __join_view_iterator_category {};...@@ -55,8 +55,8 @@ struct __join_view_iterator_category {};
55template <class _View>55template <class _View>
56 requires is_reference_v<range_reference_t<_View>> && forward_range<_View> && forward_range<range_reference_t<_View>>56 requires is_reference_v<range_reference_t<_View>> && forward_range<_View> && forward_range<range_reference_t<_View>>
57struct __join_view_iterator_category<_View> {57struct __join_view_iterator_category<_View> {
58 using _OuterC = typename iterator_traits<iterator_t<_View>>::iterator_category;58 using _OuterC _LIBCPP_NODEBUG = typename iterator_traits<iterator_t<_View>>::iterator_category;
59 using _InnerC = typename iterator_traits<iterator_t<range_reference_t<_View>>>::iterator_category;59 using _InnerC _LIBCPP_NODEBUG = typename iterator_traits<iterator_t<range_reference_t<_View>>>::iterator_category;
6060
61 using iterator_category =61 using iterator_category =
62 _If< derived_from<_OuterC, bidirectional_iterator_tag> && derived_from<_InnerC, bidirectional_iterator_tag> &&62 _If< derived_from<_OuterC, bidirectional_iterator_tag> && derived_from<_InnerC, bidirectional_iterator_tag> &&
...@@ -71,7 +71,7 @@ template <input_range _View>...@@ -71,7 +71,7 @@ template <input_range _View>
71 requires view<_View> && input_range<range_reference_t<_View>>71 requires view<_View> && input_range<range_reference_t<_View>>
72class join_view : public view_interface<join_view<_View>> {72class join_view : public view_interface<join_view<_View>> {
73private:73private:
74 using _InnerRange = range_reference_t<_View>;74 using _InnerRange _LIBCPP_NODEBUG = range_reference_t<_View>;
7575
76 template <bool>76 template <bool>
77 struct __iterator;77 struct __iterator;
...@@ -85,11 +85,12 @@ private:...@@ -85,11 +85,12 @@ private:
85 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();85 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
8686
87 static constexpr bool _UseOuterCache = !forward_range<_View>;87 static constexpr bool _UseOuterCache = !forward_range<_View>;
88 using _OuterCache = _If<_UseOuterCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;88 using _OuterCache _LIBCPP_NODEBUG = _If<_UseOuterCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
89 _LIBCPP_NO_UNIQUE_ADDRESS _OuterCache __outer_;89 _LIBCPP_NO_UNIQUE_ADDRESS _OuterCache __outer_;
9090
91 static constexpr bool _UseInnerCache = !is_reference_v<_InnerRange>;91 static constexpr bool _UseInnerCache = !is_reference_v<_InnerRange>;
92 using _InnerCache = _If<_UseInnerCache, __non_propagating_cache<remove_cvref_t<_InnerRange>>, __empty_cache>;92 using _InnerCache _LIBCPP_NODEBUG =
93 _If<_UseInnerCache, __non_propagating_cache<remove_cvref_t<_InnerRange>>, __empty_cache>;
93 _LIBCPP_NO_UNIQUE_ADDRESS _InnerCache __inner_;94 _LIBCPP_NO_UNIQUE_ADDRESS _InnerCache __inner_;
9495
95public:96public:
...@@ -155,9 +156,9 @@ private:...@@ -155,9 +156,9 @@ private:
155 template <bool>156 template <bool>
156 friend struct __sentinel;157 friend struct __sentinel;
157158
158 using _Parent = __maybe_const<_Const, join_view>;159 using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, join_view>;
159 using _Base = __maybe_const<_Const, _View>;160 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
160 sentinel_t<_Base> __end_ = sentinel_t<_Base>();161 sentinel_t<_Base> __end_ = sentinel_t<_Base>();
161162
162public:163public:
163 _LIBCPP_HIDE_FROM_ABI __sentinel() = default;164 _LIBCPP_HIDE_FROM_ABI __sentinel() = default;
...@@ -190,18 +191,18 @@ struct join_view<_View>::__iterator final : public __join_view_iterator_category...@@ -190,18 +191,18 @@ struct join_view<_View>::__iterator final : public __join_view_iterator_category
190 static constexpr bool __is_join_view_iterator = true;191 static constexpr bool __is_join_view_iterator = true;
191192
192private:193private:
193 using _Parent = __maybe_const<_Const, join_view<_View>>;194 using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, join_view<_View>>;
194 using _Base = __maybe_const<_Const, _View>;195 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
195 using _Outer = iterator_t<_Base>;196 using _Outer _LIBCPP_NODEBUG = iterator_t<_Base>;
196 using _Inner = iterator_t<range_reference_t<_Base>>;197 using _Inner _LIBCPP_NODEBUG = iterator_t<range_reference_t<_Base>>;
197 using _InnerRange = range_reference_t<_View>;198 using _InnerRange _LIBCPP_NODEBUG = range_reference_t<_View>;
198199
199 static_assert(!_Const || forward_range<_Base>, "Const can only be true when Base models forward_range.");200 static_assert(!_Const || forward_range<_Base>, "Const can only be true when Base models forward_range.");
200201
201 static constexpr bool __ref_is_glvalue = is_reference_v<range_reference_t<_Base>>;202 static constexpr bool __ref_is_glvalue = is_reference_v<range_reference_t<_Base>>;
202203
203 static constexpr bool _OuterPresent = forward_range<_Base>;204 static constexpr bool _OuterPresent = forward_range<_Base>;
204 using _OuterType = _If<_OuterPresent, _Outer, std::__empty>;205 using _OuterType _LIBCPP_NODEBUG = _If<_OuterPresent, _Outer, std::__empty>;
205 _LIBCPP_NO_UNIQUE_ADDRESS _OuterType __outer_ = _OuterType();206 _LIBCPP_NO_UNIQUE_ADDRESS _OuterType __outer_ = _OuterType();
206207
207 optional<_Inner> __inner_;208 optional<_Inner> __inner_;
...@@ -377,9 +378,9 @@ template <class _JoinViewIterator>...@@ -377,9 +378,9 @@ template <class _JoinViewIterator>
377 __has_random_access_iterator_category<typename _JoinViewIterator::_Outer>::value &&378 __has_random_access_iterator_category<typename _JoinViewIterator::_Outer>::value &&
378 __has_random_access_iterator_category<typename _JoinViewIterator::_Inner>::value)379 __has_random_access_iterator_category<typename _JoinViewIterator::_Inner>::value)
379struct __segmented_iterator_traits<_JoinViewIterator> {380struct __segmented_iterator_traits<_JoinViewIterator> {
380 using __segment_iterator =381 using __segment_iterator _LIBCPP_NODEBUG =
381 _LIBCPP_NODEBUG __iterator_with_data<typename _JoinViewIterator::_Outer, typename _JoinViewIterator::_Parent*>;382 __iterator_with_data<typename _JoinViewIterator::_Outer, typename _JoinViewIterator::_Parent*>;
382 using __local_iterator = typename _JoinViewIterator::_Inner;383 using __local_iterator _LIBCPP_NODEBUG = typename _JoinViewIterator::_Inner;
383384
384 // TODO: Would it make sense to enable the optimization for other iterator types?385 // TODO: Would it make sense to enable the optimization for other iterator types?
385386
lib/libcxx/include/__ranges/lazy_split_view.h+7-6
...@@ -72,7 +72,8 @@ class lazy_split_view : public view_interface<lazy_split_view<_View, _Pattern>>...@@ -72,7 +72,8 @@ class lazy_split_view : public view_interface<lazy_split_view<_View, _Pattern>>
72 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();72 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
73 _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern();73 _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern();
7474
75 using _MaybeCurrent = _If<!forward_range<_View>, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;75 using _MaybeCurrent _LIBCPP_NODEBUG =
76 _If<!forward_range<_View>, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
76 _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent();77 _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent();
7778
78 template <bool>79 template <bool>
...@@ -146,11 +147,11 @@ private:...@@ -146,11 +147,11 @@ private:
146 friend struct __inner_iterator;147 friend struct __inner_iterator;
147 friend __outer_iterator<true>;148 friend __outer_iterator<true>;
148149
149 using _Parent = __maybe_const<_Const, lazy_split_view>;150 using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, lazy_split_view>;
150 using _Base = __maybe_const<_Const, _View>;151 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
151152
152 _Parent* __parent_ = nullptr;153 _Parent* __parent_ = nullptr;
153 using _MaybeCurrent = _If<forward_range<_View>, iterator_t<_Base>, __empty_cache>;154 using _MaybeCurrent _LIBCPP_NODEBUG = _If<forward_range<_View>, iterator_t<_Base>, __empty_cache>;
154 _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent();155 _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent();
155 bool __trailing_empty_ = false;156 bool __trailing_empty_ = false;
156157
...@@ -283,7 +284,7 @@ private:...@@ -283,7 +284,7 @@ private:
283 template <bool _Const>284 template <bool _Const>
284 struct __inner_iterator : __inner_iterator_category<__maybe_const<_Const, _View>> {285 struct __inner_iterator : __inner_iterator_category<__maybe_const<_Const, _View>> {
285 private:286 private:
286 using _Base = __maybe_const<_Const, _View>;287 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
287 // Workaround for a GCC issue.288 // Workaround for a GCC issue.
288 static constexpr bool _OuterConst = _Const;289 static constexpr bool _OuterConst = _Const;
289 __outer_iterator<_Const> __i_ = __outer_iterator<_OuterConst>();290 __outer_iterator<_Const> __i_ = __outer_iterator<_OuterConst>();
...@@ -420,7 +421,7 @@ struct __fn {...@@ -420,7 +421,7 @@ struct __fn {
420 requires constructible_from<decay_t<_Pattern>, _Pattern>421 requires constructible_from<decay_t<_Pattern>, _Pattern>
421 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const422 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const
422 noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) {423 noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) {
423 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));424 return __pipeable(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));
424 }425 }
425};426};
426} // namespace __lazy_split_view427} // namespace __lazy_split_view
lib/libcxx/include/__ranges/range_adaptor.h+8-10
...@@ -19,8 +19,10 @@...@@ -19,8 +19,10 @@
19#include <__functional/invoke.h>19#include <__functional/invoke.h>
20#include <__ranges/concepts.h>20#include <__ranges/concepts.h>
21#include <__type_traits/decay.h>21#include <__type_traits/decay.h>
22#include <__type_traits/invoke.h>
22#include <__type_traits/is_class.h>23#include <__type_traits/is_class.h>
23#include <__type_traits/is_nothrow_constructible.h>24#include <__type_traits/is_nothrow_constructible.h>
25#include <__type_traits/remove_cv.h>
24#include <__type_traits/remove_cvref.h>26#include <__type_traits/remove_cvref.h>
25#include <__utility/forward.h>27#include <__utility/forward.h>
26#include <__utility/move.h>28#include <__utility/move.h>
...@@ -45,15 +47,15 @@ namespace ranges {...@@ -45,15 +47,15 @@ namespace ranges {
45// - `f1 | f2` is an adaptor closure `g` such that `g(x)` is equivalent to `f2(f1(x))`47// - `f1 | f2` is an adaptor closure `g` such that `g(x)` is equivalent to `f2(f1(x))`
46template <class _Tp>48template <class _Tp>
47 requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>49 requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
48struct __range_adaptor_closure;50struct __range_adaptor_closure {};
4951
50// Type that wraps an arbitrary function object and makes it into a range adaptor closure,52// Type that wraps an arbitrary function object and makes it into a range adaptor closure,
51// i.e. something that can be called via the `x | f` notation.53// i.e. something that can be called via the `x | f` notation.
52template <class _Fn>54template <class _Fn>
53struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_closure_t<_Fn>> {55struct __pipeable : _Fn, __range_adaptor_closure<__pipeable<_Fn>> {
54 _LIBCPP_HIDE_FROM_ABI constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(std::move(__f)) {}56 _LIBCPP_HIDE_FROM_ABI constexpr explicit __pipeable(_Fn&& __f) : _Fn(std::move(__f)) {}
55};57};
56_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__range_adaptor_closure_t);58_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__pipeable);
5759
58template <class _Tp>60template <class _Tp>
59_Tp __derived_from_range_adaptor_closure(__range_adaptor_closure<_Tp>*);61_Tp __derived_from_range_adaptor_closure(__range_adaptor_closure<_Tp>*);
...@@ -77,17 +79,13 @@ template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure>...@@ -77,17 +79,13 @@ template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure>
77[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2) noexcept(79[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2) noexcept(
78 is_nothrow_constructible_v<decay_t<_Closure>, _Closure> &&80 is_nothrow_constructible_v<decay_t<_Closure>, _Closure> &&
79 is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>) {81 is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>) {
80 return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1)));82 return __pipeable(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1)));
81}83}
8284
83template <class _Tp>
84 requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
85struct __range_adaptor_closure {};
86
87# if _LIBCPP_STD_VER >= 2385# if _LIBCPP_STD_VER >= 23
88template <class _Tp>86template <class _Tp>
89 requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>87 requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
90class range_adaptor_closure : public __range_adaptor_closure<_Tp> {};88class _LIBCPP_NO_SPECIALIZATIONS range_adaptor_closure : public __range_adaptor_closure<_Tp> {};
91# endif // _LIBCPP_STD_VER >= 2389# endif // _LIBCPP_STD_VER >= 23
9290
93} // namespace ranges91} // namespace ranges
lib/libcxx/include/__ranges/repeat_view.h+3-2
...@@ -15,6 +15,7 @@...@@ -15,6 +15,7 @@
15#include <__concepts/same_as.h>15#include <__concepts/same_as.h>
16#include <__concepts/semiregular.h>16#include <__concepts/semiregular.h>
17#include <__config>17#include <__config>
18#include <__cstddef/ptrdiff_t.h>
18#include <__iterator/concepts.h>19#include <__iterator/concepts.h>
19#include <__iterator/iterator_traits.h>20#include <__iterator/iterator_traits.h>
20#include <__iterator/unreachable_sentinel.h>21#include <__iterator/unreachable_sentinel.h>
...@@ -60,7 +61,7 @@ struct __repeat_view_iterator_difference<_Tp> {...@@ -60,7 +61,7 @@ struct __repeat_view_iterator_difference<_Tp> {
60};61};
6162
62template <class _Tp>63template <class _Tp>
63using __repeat_view_iterator_difference_t = typename __repeat_view_iterator_difference<_Tp>::type;64using __repeat_view_iterator_difference_t _LIBCPP_NODEBUG = typename __repeat_view_iterator_difference<_Tp>::type;
6465
65namespace views::__drop {66namespace views::__drop {
66struct __fn;67struct __fn;
...@@ -138,7 +139,7 @@ template <move_constructible _Tp, semiregular _Bound>...@@ -138,7 +139,7 @@ template <move_constructible _Tp, semiregular _Bound>
138class repeat_view<_Tp, _Bound>::__iterator {139class repeat_view<_Tp, _Bound>::__iterator {
139 friend class repeat_view;140 friend class repeat_view;
140141
141 using _IndexT = conditional_t<same_as<_Bound, unreachable_sentinel_t>, ptrdiff_t, _Bound>;142 using _IndexT _LIBCPP_NODEBUG = conditional_t<same_as<_Bound, unreachable_sentinel_t>, ptrdiff_t, _Bound>;
142143
143 _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(const _Tp* __value, _IndexT __bound_sentinel = _IndexT())144 _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(const _Tp* __value, _IndexT __bound_sentinel = _IndexT())
144 : __value_(__value), __current_(__bound_sentinel) {}145 : __value_(__value), __current_(__bound_sentinel) {}
lib/libcxx/include/__ranges/reverse_view.h+2-1
...@@ -47,7 +47,8 @@ class reverse_view : public view_interface<reverse_view<_View>> {...@@ -47,7 +47,8 @@ class reverse_view : public view_interface<reverse_view<_View>> {
47 // We cache begin() whenever ranges::next is not guaranteed O(1) to provide an47 // We cache begin() whenever ranges::next is not guaranteed O(1) to provide an
48 // amortized O(1) begin() method.48 // amortized O(1) begin() method.
49 static constexpr bool _UseCache = !random_access_range<_View> && !common_range<_View>;49 static constexpr bool _UseCache = !random_access_range<_View> && !common_range<_View>;
50 using _Cache = _If<_UseCache, __non_propagating_cache<reverse_iterator<iterator_t<_View>>>, __empty_cache>;50 using _Cache _LIBCPP_NODEBUG =
51 _If<_UseCache, __non_propagating_cache<reverse_iterator<iterator_t<_View>>>, __empty_cache>;
51 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();52 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
52 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();53 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
5354
lib/libcxx/include/__ranges/single_view.h+2-1
...@@ -12,6 +12,8 @@...@@ -12,6 +12,8 @@
1212
13#include <__concepts/constructible.h>13#include <__concepts/constructible.h>
14#include <__config>14#include <__config>
15#include <__cstddef/ptrdiff_t.h>
16#include <__cstddef/size_t.h>
15#include <__ranges/movable_box.h>17#include <__ranges/movable_box.h>
16#include <__ranges/range_adaptor.h>18#include <__ranges/range_adaptor.h>
17#include <__ranges/view_interface.h>19#include <__ranges/view_interface.h>
...@@ -20,7 +22,6 @@...@@ -20,7 +22,6 @@
20#include <__utility/forward.h>22#include <__utility/forward.h>
21#include <__utility/in_place.h>23#include <__utility/in_place.h>
22#include <__utility/move.h>24#include <__utility/move.h>
23#include <cstddef>
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
lib/libcxx/include/__ranges/size.h+2-1
...@@ -13,6 +13,8 @@...@@ -13,6 +13,8 @@
13#include <__concepts/arithmetic.h>13#include <__concepts/arithmetic.h>
14#include <__concepts/class_or_enum.h>14#include <__concepts/class_or_enum.h>
15#include <__config>15#include <__config>
16#include <__cstddef/ptrdiff_t.h>
17#include <__cstddef/size_t.h>
16#include <__iterator/concepts.h>18#include <__iterator/concepts.h>
17#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
18#include <__ranges/access.h>20#include <__ranges/access.h>
...@@ -22,7 +24,6 @@...@@ -22,7 +24,6 @@
22#include <__type_traits/remove_cvref.h>24#include <__type_traits/remove_cvref.h>
23#include <__utility/auto_cast.h>25#include <__utility/auto_cast.h>
24#include <__utility/declval.h>26#include <__utility/declval.h>
25#include <cstddef>
2627
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header29# pragma GCC system_header
lib/libcxx/include/__ranges/split_view.h+2-2
...@@ -52,7 +52,7 @@ class split_view : public view_interface<split_view<_View, _Pattern>> {...@@ -52,7 +52,7 @@ class split_view : public view_interface<split_view<_View, _Pattern>> {
52private:52private:
53 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();53 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
54 _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern();54 _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern();
55 using _Cache = __non_propagating_cache<subrange<iterator_t<_View>>>;55 using _Cache _LIBCPP_NODEBUG = __non_propagating_cache<subrange<iterator_t<_View>>>;
56 _Cache __cached_begin_ = _Cache();56 _Cache __cached_begin_ = _Cache();
5757
58 template <class, class>58 template <class, class>
...@@ -211,7 +211,7 @@ struct __fn {...@@ -211,7 +211,7 @@ struct __fn {
211 requires constructible_from<decay_t<_Pattern>, _Pattern>211 requires constructible_from<decay_t<_Pattern>, _Pattern>
212 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const212 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const
213 noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) {213 noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) {
214 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));214 return __pipeable(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));
215 }215 }
216};216};
217} // namespace __split_view217} // namespace __split_view
lib/libcxx/include/__ranges/subrange.h+3-2
...@@ -17,6 +17,7 @@...@@ -17,6 +17,7 @@
17#include <__concepts/derived_from.h>17#include <__concepts/derived_from.h>
18#include <__concepts/different_from.h>18#include <__concepts/different_from.h>
19#include <__config>19#include <__config>
20#include <__cstddef/size_t.h>
20#include <__fwd/subrange.h>21#include <__fwd/subrange.h>
21#include <__iterator/advance.h>22#include <__iterator/advance.h>
22#include <__iterator/concepts.h>23#include <__iterator/concepts.h>
...@@ -33,13 +34,13 @@...@@ -33,13 +34,13 @@
33#include <__tuple/tuple_size.h>34#include <__tuple/tuple_size.h>
34#include <__type_traits/conditional.h>35#include <__type_traits/conditional.h>
35#include <__type_traits/decay.h>36#include <__type_traits/decay.h>
37#include <__type_traits/integral_constant.h>
36#include <__type_traits/is_pointer.h>38#include <__type_traits/is_pointer.h>
37#include <__type_traits/is_reference.h>39#include <__type_traits/is_reference.h>
38#include <__type_traits/make_unsigned.h>40#include <__type_traits/make_unsigned.h>
39#include <__type_traits/remove_const.h>41#include <__type_traits/remove_const.h>
40#include <__type_traits/remove_pointer.h>42#include <__type_traits/remove_pointer.h>
41#include <__utility/move.h>43#include <__utility/move.h>
42#include <cstddef>
4344
44#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)45#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
45# pragma GCC system_header46# pragma GCC system_header
...@@ -81,7 +82,7 @@ private:...@@ -81,7 +82,7 @@ private:
81 struct _Empty {82 struct _Empty {
82 _LIBCPP_HIDE_FROM_ABI constexpr _Empty(auto) noexcept {}83 _LIBCPP_HIDE_FROM_ABI constexpr _Empty(auto) noexcept {}
83 };84 };
84 using _Size = conditional_t<_StoreSize, make_unsigned_t<iter_difference_t<_Iter>>, _Empty>;85 using _Size _LIBCPP_NODEBUG = conditional_t<_StoreSize, make_unsigned_t<iter_difference_t<_Iter>>, _Empty>;
85 _LIBCPP_NO_UNIQUE_ADDRESS _Iter __begin_ = _Iter();86 _LIBCPP_NO_UNIQUE_ADDRESS _Iter __begin_ = _Iter();
86 _LIBCPP_NO_UNIQUE_ADDRESS _Sent __end_ = _Sent();87 _LIBCPP_NO_UNIQUE_ADDRESS _Sent __end_ = _Sent();
87 _LIBCPP_NO_UNIQUE_ADDRESS _Size __size_ = 0;88 _LIBCPP_NO_UNIQUE_ADDRESS _Size __size_ = 0;
lib/libcxx/include/__ranges/take_view.h+4-5
...@@ -42,7 +42,6 @@...@@ -42,7 +42,6 @@
42#include <__utility/auto_cast.h>42#include <__utility/auto_cast.h>
43#include <__utility/forward.h>43#include <__utility/forward.h>
44#include <__utility/move.h>44#include <__utility/move.h>
45#include <cstddef>
4645
47#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)46#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
48# pragma GCC system_header47# pragma GCC system_header
...@@ -162,9 +161,9 @@ public:...@@ -162,9 +161,9 @@ public:
162template <view _View>161template <view _View>
163template <bool _Const>162template <bool _Const>
164class take_view<_View>::__sentinel {163class take_view<_View>::__sentinel {
165 using _Base = __maybe_const<_Const, _View>;164 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
166 template <bool _OtherConst>165 template <bool _OtherConst>
167 using _Iter = counted_iterator<iterator_t<__maybe_const<_OtherConst, _View>>>;166 using _Iter _LIBCPP_NODEBUG = counted_iterator<iterator_t<__maybe_const<_OtherConst, _View>>>;
168 _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>();167 _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>();
169168
170 template <bool>169 template <bool>
...@@ -245,7 +244,7 @@ struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {...@@ -245,7 +244,7 @@ struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
245};244};
246245
247template <class _Tp>246template <class _Tp>
248using __passthrough_type_t = typename __passthrough_type<_Tp>::type;247using __passthrough_type_t _LIBCPP_NODEBUG = typename __passthrough_type<_Tp>::type;
249248
250struct __fn {249struct __fn {
251 // [range.take.overview]: the `empty_view` case.250 // [range.take.overview]: the `empty_view` case.
...@@ -347,7 +346,7 @@ struct __fn {...@@ -347,7 +346,7 @@ struct __fn {
347 requires constructible_from<decay_t<_Np>, _Np>346 requires constructible_from<decay_t<_Np>, _Np>
348 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Np&& __n) const347 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Np&& __n) const
349 noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>) {348 noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>) {
350 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n)));349 return __pipeable(std::__bind_back(*this, std::forward<_Np>(__n)));
351 }350 }
352};351};
353352
lib/libcxx/include/__ranges/take_while_view.h+2-2
...@@ -103,7 +103,7 @@ template <view _View, class _Pred>...@@ -103,7 +103,7 @@ template <view _View, class _Pred>
103 requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>>103 requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>>
104template <bool _Const>104template <bool _Const>
105class take_while_view<_View, _Pred>::__sentinel {105class take_while_view<_View, _Pred>::__sentinel {
106 using _Base = __maybe_const<_Const, _View>;106 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
107107
108 sentinel_t<_Base> __end_ = sentinel_t<_Base>();108 sentinel_t<_Base> __end_ = sentinel_t<_Base>();
109 const _Pred* __pred_ = nullptr;109 const _Pred* __pred_ = nullptr;
...@@ -149,7 +149,7 @@ struct __fn {...@@ -149,7 +149,7 @@ struct __fn {
149 requires constructible_from<decay_t<_Pred>, _Pred>149 requires constructible_from<decay_t<_Pred>, _Pred>
150 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const150 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const
151 noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {151 noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {
152 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred)));152 return __pipeable(std::__bind_back(*this, std::forward<_Pred>(__pred)));
153 }153 }
154};154};
155155
lib/libcxx/include/__ranges/to.h+20-19
...@@ -10,15 +10,13 @@...@@ -10,15 +10,13 @@
10#ifndef _LIBCPP___RANGES_TO_H10#ifndef _LIBCPP___RANGES_TO_H
11#define _LIBCPP___RANGES_TO_H11#define _LIBCPP___RANGES_TO_H
1212
13#include <__algorithm/ranges_copy.h>
14#include <__concepts/constructible.h>13#include <__concepts/constructible.h>
15#include <__concepts/convertible_to.h>14#include <__concepts/convertible_to.h>
16#include <__concepts/derived_from.h>15#include <__concepts/derived_from.h>
17#include <__concepts/same_as.h>16#include <__concepts/same_as.h>
18#include <__config>17#include <__config>
18#include <__cstddef/ptrdiff_t.h>
19#include <__functional/bind_back.h>19#include <__functional/bind_back.h>
20#include <__iterator/back_insert_iterator.h>
21#include <__iterator/insert_iterator.h>
22#include <__iterator/iterator_traits.h>20#include <__iterator/iterator_traits.h>
23#include <__ranges/access.h>21#include <__ranges/access.h>
24#include <__ranges/concepts.h>22#include <__ranges/concepts.h>
...@@ -33,7 +31,6 @@...@@ -33,7 +31,6 @@
33#include <__type_traits/type_identity.h>31#include <__type_traits/type_identity.h>
34#include <__utility/declval.h>32#include <__utility/declval.h>
35#include <__utility/forward.h>33#include <__utility/forward.h>
36#include <cstddef>
3734
38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)35#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
39# pragma GCC system_header36# pragma GCC system_header
...@@ -54,21 +51,14 @@ constexpr bool __reservable_container =...@@ -54,21 +51,14 @@ constexpr bool __reservable_container =
54 };51 };
5552
56template <class _Container, class _Ref>53template <class _Container, class _Ref>
57constexpr bool __container_insertable = requires(_Container& __c, _Ref&& __ref) {54constexpr bool __container_appendable = requires(_Container& __c, _Ref&& __ref) {
58 requires(55 requires(
56 requires { __c.emplace_back(std::forward<_Ref>(__ref)); } ||
59 requires { __c.push_back(std::forward<_Ref>(__ref)); } ||57 requires { __c.push_back(std::forward<_Ref>(__ref)); } ||
58 requires { __c.emplace(__c.end(), std::forward<_Ref>(__ref)); } ||
60 requires { __c.insert(__c.end(), std::forward<_Ref>(__ref)); });59 requires { __c.insert(__c.end(), std::forward<_Ref>(__ref)); });
61};60};
6261
63template <class _Ref, class _Container>
64_LIBCPP_HIDE_FROM_ABI constexpr auto __container_inserter(_Container& __c) {
65 if constexpr (requires { __c.push_back(std::declval<_Ref>()); }) {
66 return std::back_inserter(__c);
67 } else {
68 return std::inserter(__c, __c.end());
69 }
70}
71
72// Note: making this a concept allows short-circuiting the second condition.62// Note: making this a concept allows short-circuiting the second condition.
73template <class _Container, class _Range>63template <class _Container, class _Range>
74concept __try_non_recursive_conversion =64concept __try_non_recursive_conversion =
...@@ -113,14 +103,25 @@ template <class _Container, input_range _Range, class... _Args>...@@ -113,14 +103,25 @@ template <class _Container, input_range _Range, class... _Args>
113103
114 // Case 4 -- default-construct (or construct from the extra arguments) and insert, reserving the size if possible.104 // Case 4 -- default-construct (or construct from the extra arguments) and insert, reserving the size if possible.
115 else if constexpr (constructible_from<_Container, _Args...> &&105 else if constexpr (constructible_from<_Container, _Args...> &&
116 __container_insertable<_Container, range_reference_t<_Range>>) {106 __container_appendable<_Container, range_reference_t<_Range>>) {
117 _Container __result(std::forward<_Args>(__args)...);107 _Container __result(std::forward<_Args>(__args)...);
118 if constexpr (sized_range<_Range> && __reservable_container<_Container>) {108 if constexpr (sized_range<_Range> && __reservable_container<_Container>) {
119 __result.reserve(static_cast<range_size_t<_Container>>(ranges::size(__range)));109 __result.reserve(static_cast<range_size_t<_Container>>(ranges::size(__range)));
120 }110 }
121111
122 ranges::copy(__range, ranges::__container_inserter<range_reference_t<_Range>>(__result));112 for (auto&& __ref : __range) {
123113 using _Ref = decltype(__ref);
114 if constexpr (requires { __result.emplace_back(std::declval<_Ref>()); }) {
115 __result.emplace_back(std::forward<_Ref>(__ref));
116 } else if constexpr (requires { __result.push_back(std::declval<_Ref>()); }) {
117 __result.push_back(std::forward<_Ref>(__ref));
118 } else if constexpr (requires { __result.emplace(__result.end(), std::declval<_Ref>()); }) {
119 __result.emplace(__result.end(), std::forward<_Ref>(__ref));
120 } else {
121 static_assert(requires { __result.insert(__result.end(), std::declval<_Ref>()); });
122 __result.insert(__result.end(), std::forward<_Ref>(__ref));
123 }
124 }
124 return __result;125 return __result;
125126
126 } else {127 } else {
...@@ -214,7 +215,7 @@ template <class _Container, class... _Args>...@@ -214,7 +215,7 @@ template <class _Container, class... _Args>
214 }215 }
215 { return ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...); };216 { return ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...); };
216217
217 return __range_adaptor_closure_t(std::__bind_back(__to_func, std::forward<_Args>(__args)...));218 return __pipeable(std::__bind_back(__to_func, std::forward<_Args>(__args)...));
218}219}
219220
220// Range adaptor closure object 2 -- wrapping the `ranges::to` version where `_Container` is a template template221// Range adaptor closure object 2 -- wrapping the `ranges::to` version where `_Container` is a template template
...@@ -233,7 +234,7 @@ template <template <class...> class _Container, class... _Args>...@@ -233,7 +234,7 @@ template <template <class...> class _Container, class... _Args>
233 };234 };
234 // clang-format on235 // clang-format on
235236
236 return __range_adaptor_closure_t(std::__bind_back(__to_func, std::forward<_Args>(__args)...));237 return __pipeable(std::__bind_back(__to_func, std::forward<_Args>(__args)...));
237}238}
238239
239} // namespace ranges240} // namespace ranges
lib/libcxx/include/__ranges/transform_view.h+10-8
...@@ -34,6 +34,7 @@...@@ -34,6 +34,7 @@
34#include <__ranges/view_interface.h>34#include <__ranges/view_interface.h>
35#include <__type_traits/conditional.h>35#include <__type_traits/conditional.h>
36#include <__type_traits/decay.h>36#include <__type_traits/decay.h>
37#include <__type_traits/invoke.h>
37#include <__type_traits/is_nothrow_constructible.h>38#include <__type_traits/is_nothrow_constructible.h>
38#include <__type_traits/is_object.h>39#include <__type_traits/is_object.h>
39#include <__type_traits/is_reference.h>40#include <__type_traits/is_reference.h>
...@@ -158,7 +159,7 @@ struct __transform_view_iterator_category_base {};...@@ -158,7 +159,7 @@ struct __transform_view_iterator_category_base {};
158159
159template <forward_range _View, class _Fn>160template <forward_range _View, class _Fn>
160struct __transform_view_iterator_category_base<_View, _Fn> {161struct __transform_view_iterator_category_base<_View, _Fn> {
161 using _Cat = typename iterator_traits<iterator_t<_View>>::iterator_category;162 using _Cat _LIBCPP_NODEBUG = typename iterator_traits<iterator_t<_View>>::iterator_category;
162163
163 using iterator_category =164 using iterator_category =
164 conditional_t< is_reference_v<invoke_result_t<_Fn&, range_reference_t<_View>>>,165 conditional_t< is_reference_v<invoke_result_t<_Fn&, range_reference_t<_View>>>,
...@@ -173,10 +174,11 @@ template <input_range _View, copy_constructible _Fn>...@@ -173,10 +174,11 @@ template <input_range _View, copy_constructible _Fn>
173# endif174# endif
174 requires __transform_view_constraints<_View, _Fn>175 requires __transform_view_constraints<_View, _Fn>
175template <bool _Const>176template <bool _Const>
176class transform_view<_View, _Fn>::__iterator : public __transform_view_iterator_category_base<_View, _Fn> {177class transform_view<_View, _Fn>::__iterator
178 : public __transform_view_iterator_category_base<_View, __maybe_const<_Const, _Fn>> {
177179
178 using _Parent = __maybe_const<_Const, transform_view>;180 using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, transform_view>;
179 using _Base = __maybe_const<_Const, _View>;181 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
180182
181 _Parent* __parent_ = nullptr;183 _Parent* __parent_ = nullptr;
182184
...@@ -190,7 +192,7 @@ public:...@@ -190,7 +192,7 @@ public:
190 iterator_t<_Base> __current_ = iterator_t<_Base>();192 iterator_t<_Base> __current_ = iterator_t<_Base>();
191193
192 using iterator_concept = typename __transform_view_iterator_concept<_View>::type;194 using iterator_concept = typename __transform_view_iterator_concept<_View>::type;
193 using value_type = remove_cvref_t<invoke_result_t<_Fn&, range_reference_t<_Base>>>;195 using value_type = remove_cvref_t<invoke_result_t<__maybe_const<_Const, _Fn>&, range_reference_t<_Base>>>;
194 using difference_type = range_difference_t<_Base>;196 using difference_type = range_difference_t<_Base>;
195197
196 _LIBCPP_HIDE_FROM_ABI __iterator()198 _LIBCPP_HIDE_FROM_ABI __iterator()
...@@ -336,8 +338,8 @@ template <input_range _View, copy_constructible _Fn>...@@ -336,8 +338,8 @@ template <input_range _View, copy_constructible _Fn>
336 requires __transform_view_constraints<_View, _Fn>338 requires __transform_view_constraints<_View, _Fn>
337template <bool _Const>339template <bool _Const>
338class transform_view<_View, _Fn>::__sentinel {340class transform_view<_View, _Fn>::__sentinel {
339 using _Parent = __maybe_const<_Const, transform_view>;341 using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, transform_view>;
340 using _Base = __maybe_const<_Const, _View>;342 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
341343
342 sentinel_t<_Base> __end_ = sentinel_t<_Base>();344 sentinel_t<_Base> __end_ = sentinel_t<_Base>();
343345
...@@ -396,7 +398,7 @@ struct __fn {...@@ -396,7 +398,7 @@ struct __fn {
396 requires constructible_from<decay_t<_Fn>, _Fn>398 requires constructible_from<decay_t<_Fn>, _Fn>
397 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __f) const399 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __f) const
398 noexcept(is_nothrow_constructible_v<decay_t<_Fn>, _Fn>) {400 noexcept(is_nothrow_constructible_v<decay_t<_Fn>, _Fn>) {
399 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Fn>(__f)));401 return __pipeable(std::__bind_back(*this, std::forward<_Fn>(__f)));
400 }402 }
401};403};
402} // namespace __transform404} // namespace __transform
lib/libcxx/include/__ranges/zip_view.h+8-47
...@@ -36,7 +36,6 @@...@@ -36,7 +36,6 @@
36#include <__utility/forward.h>36#include <__utility/forward.h>
37#include <__utility/integer_sequence.h>37#include <__utility/integer_sequence.h>
38#include <__utility/move.h>38#include <__utility/move.h>
39#include <__utility/pair.h>
40#include <tuple>39#include <tuple>
4140
42#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)41#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -58,22 +57,11 @@ concept __zip_is_common =...@@ -58,22 +57,11 @@ concept __zip_is_common =
58 (!(bidirectional_range<_Ranges> && ...) && (common_range<_Ranges> && ...)) ||57 (!(bidirectional_range<_Ranges> && ...) && (common_range<_Ranges> && ...)) ||
59 ((random_access_range<_Ranges> && ...) && (sized_range<_Ranges> && ...));58 ((random_access_range<_Ranges> && ...) && (sized_range<_Ranges> && ...));
6059
61template <typename _Tp, typename _Up>
62auto __tuple_or_pair_test() -> pair<_Tp, _Up>;
63
64template <typename... _Types>
65 requires(sizeof...(_Types) != 2)
66auto __tuple_or_pair_test() -> tuple<_Types...>;
67
68template <class... _Types>
69using __tuple_or_pair = decltype(__tuple_or_pair_test<_Types...>());
70
71template <class _Fun, class _Tuple>60template <class _Fun, class _Tuple>
72_LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_transform(_Fun&& __f, _Tuple&& __tuple) {61_LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_transform(_Fun&& __f, _Tuple&& __tuple) {
73 return std::apply(62 return std::apply(
74 [&]<class... _Types>(_Types&&... __elements) {63 [&]<class... _Types>(_Types&&... __elements) {
75 return __tuple_or_pair<invoke_result_t<_Fun&, _Types>...>(64 return tuple<invoke_result_t<_Fun&, _Types>...>(std::invoke(__f, std::forward<_Types>(__elements))...);
76 std::invoke(__f, std::forward<_Types>(__elements))...);
77 },65 },
78 std::forward<_Tuple>(__tuple));66 std::forward<_Tuple>(__tuple));
79}67}
...@@ -88,7 +76,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __tuple_for_each(_Fun&& __f, _Tuple&& __tup...@@ -88,7 +76,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __tuple_for_each(_Fun&& __f, _Tuple&& __tup
88}76}
8977
90template <class _Fun, class _Tuple1, class _Tuple2, size_t... _Indices>78template <class _Fun, class _Tuple1, class _Tuple2, size_t... _Indices>
91_LIBCPP_HIDE_FROM_ABI constexpr __tuple_or_pair<79_LIBCPP_HIDE_FROM_ABI constexpr tuple<
92 invoke_result_t<_Fun&,80 invoke_result_t<_Fun&,
93 typename tuple_element<_Indices, remove_cvref_t<_Tuple1>>::type,81 typename tuple_element<_Indices, remove_cvref_t<_Tuple1>>::type,
94 typename tuple_element<_Indices, remove_cvref_t<_Tuple2>>::type>...>82 typename tuple_element<_Indices, remove_cvref_t<_Tuple2>>::type>...>
...@@ -250,10 +238,9 @@ template <input_range... _Views>...@@ -250,10 +238,9 @@ template <input_range... _Views>
250 requires(view<_Views> && ...) && (sizeof...(_Views) > 0)238 requires(view<_Views> && ...) && (sizeof...(_Views) > 0)
251template <bool _Const>239template <bool _Const>
252class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base<_Const, _Views...> {240class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base<_Const, _Views...> {
253 __tuple_or_pair<iterator_t<__maybe_const<_Const, _Views>>...> __current_;241 tuple<iterator_t<__maybe_const<_Const, _Views>>...> __current_;
254242
255 _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(243 _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(tuple<iterator_t<__maybe_const<_Const, _Views>>...> __current)
256 __tuple_or_pair<iterator_t<__maybe_const<_Const, _Views>>...> __current)
257 : __current_(std::move(__current)) {}244 : __current_(std::move(__current)) {}
258245
259 template <bool>246 template <bool>
...@@ -266,7 +253,7 @@ class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base...@@ -266,7 +253,7 @@ class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base
266253
267public:254public:
268 using iterator_concept = decltype(__get_zip_view_iterator_tag<_Const, _Views...>());255 using iterator_concept = decltype(__get_zip_view_iterator_tag<_Const, _Views...>());
269 using value_type = __tuple_or_pair<range_value_t<__maybe_const<_Const, _Views>>...>;256 using value_type = tuple<range_value_t<__maybe_const<_Const, _Views>>...>;
270 using difference_type = common_type_t<range_difference_t<__maybe_const<_Const, _Views>>...>;257 using difference_type = common_type_t<range_difference_t<__maybe_const<_Const, _Views>>...>;
271258
272 _LIBCPP_HIDE_FROM_ABI __iterator() = default;259 _LIBCPP_HIDE_FROM_ABI __iterator() = default;
...@@ -340,33 +327,8 @@ public:...@@ -340,33 +327,8 @@ public:
340 }327 }
341 }328 }
342329
343 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const __iterator& __x, const __iterator& __y)
344 requires __zip_all_random_access<_Const, _Views...>
345 {
346 return __x.__current_ < __y.__current_;
347 }
348
349 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const __iterator& __x, const __iterator& __y)
350 requires __zip_all_random_access<_Const, _Views...>
351 {
352 return __y < __x;
353 }
354
355 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y)
356 requires __zip_all_random_access<_Const, _Views...>
357 {
358 return !(__y < __x);
359 }
360
361 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y)
362 requires __zip_all_random_access<_Const, _Views...>
363 {
364 return !(__x < __y);
365 }
366
367 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y)330 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y)
368 requires __zip_all_random_access<_Const, _Views...> &&331 requires __zip_all_random_access<_Const, _Views...>
369 (three_way_comparable<iterator_t<__maybe_const<_Const, _Views>>> && ...)
370 {332 {
371 return __x.__current_ <=> __y.__current_;333 return __x.__current_ <=> __y.__current_;
372 }334 }
...@@ -427,10 +389,9 @@ template <input_range... _Views>...@@ -427,10 +389,9 @@ template <input_range... _Views>
427 requires(view<_Views> && ...) && (sizeof...(_Views) > 0)389 requires(view<_Views> && ...) && (sizeof...(_Views) > 0)
428template <bool _Const>390template <bool _Const>
429class zip_view<_Views...>::__sentinel {391class zip_view<_Views...>::__sentinel {
430 __tuple_or_pair<sentinel_t<__maybe_const<_Const, _Views>>...> __end_;392 tuple<sentinel_t<__maybe_const<_Const, _Views>>...> __end_;
431393
432 _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel(394 _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel(tuple<sentinel_t<__maybe_const<_Const, _Views>>...> __end)
433 __tuple_or_pair<sentinel_t<__maybe_const<_Const, _Views>>...> __end)
434 : __end_(__end) {}395 : __end_(__end) {}
435396
436 friend class zip_view<_Views...>;397 friend class zip_view<_Views...>;
lib/libcxx/include/__split_buffer+89-192
...@@ -23,7 +23,6 @@...@@ -23,7 +23,6 @@
23#include <__memory/compressed_pair.h>23#include <__memory/compressed_pair.h>
24#include <__memory/pointer_traits.h>24#include <__memory/pointer_traits.h>
25#include <__memory/swap_allocator.h>25#include <__memory/swap_allocator.h>
26#include <__type_traits/add_lvalue_reference.h>
27#include <__type_traits/conditional.h>26#include <__type_traits/conditional.h>
28#include <__type_traits/enable_if.h>27#include <__type_traits/enable_if.h>
29#include <__type_traits/integral_constant.h>28#include <__type_traits/integral_constant.h>
...@@ -35,7 +34,6 @@...@@ -35,7 +34,6 @@
35#include <__type_traits/remove_reference.h>34#include <__type_traits/remove_reference.h>
36#include <__utility/forward.h>35#include <__utility/forward.h>
37#include <__utility/move.h>36#include <__utility/move.h>
38#include <cstddef>
3937
40#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
41# pragma GCC system_header39# pragma GCC system_header
...@@ -47,30 +45,30 @@ _LIBCPP_PUSH_MACROS...@@ -47,30 +45,30 @@ _LIBCPP_PUSH_MACROS
47_LIBCPP_BEGIN_NAMESPACE_STD45_LIBCPP_BEGIN_NAMESPACE_STD
4846
49// __split_buffer allocates a contiguous chunk of memory and stores objects in the range [__begin_, __end_).47// __split_buffer allocates a contiguous chunk of memory and stores objects in the range [__begin_, __end_).
50// It has uninitialized memory in the ranges [__first_, __begin_) and [__end_, __end_cap_.first()). That allows48// It has uninitialized memory in the ranges [__first_, __begin_) and [__end_, __cap_). That allows
51// it to grow both in the front and back without having to move the data.49// it to grow both in the front and back without having to move the data.
5250
53template <class _Tp, class _Allocator = allocator<_Tp> >51template <class _Tp, class _Allocator = allocator<_Tp> >
54struct __split_buffer {52struct __split_buffer {
55public:53public:
56 using value_type = _Tp;54 using value_type = _Tp;
57 using allocator_type = _Allocator;55 using allocator_type = _Allocator;
58 using __alloc_rr = __libcpp_remove_reference_t<allocator_type>;56 using __alloc_rr _LIBCPP_NODEBUG = __libcpp_remove_reference_t<allocator_type>;
59 using __alloc_traits = allocator_traits<__alloc_rr>;57 using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<__alloc_rr>;
60 using reference = value_type&;58 using reference = value_type&;
61 using const_reference = const value_type&;59 using const_reference = const value_type&;
62 using size_type = typename __alloc_traits::size_type;60 using size_type = typename __alloc_traits::size_type;
63 using difference_type = typename __alloc_traits::difference_type;61 using difference_type = typename __alloc_traits::difference_type;
64 using pointer = typename __alloc_traits::pointer;62 using pointer = typename __alloc_traits::pointer;
65 using const_pointer = typename __alloc_traits::const_pointer;63 using const_pointer = typename __alloc_traits::const_pointer;
66 using iterator = pointer;64 using iterator = pointer;
67 using const_iterator = const_pointer;65 using const_iterator = const_pointer;
6866
69 // A __split_buffer contains the following members which may be trivially relocatable:67 // A __split_buffer contains the following members which may be trivially relocatable:
70 // - pointer: may be trivially relocatable, so it's checked68 // - pointer: may be trivially relocatable, so it's checked
71 // - allocator_type: may be trivially relocatable, so it's checked69 // - allocator_type: may be trivially relocatable, so it's checked
72 // __split_buffer doesn't have any self-references, so it's trivially relocatable if its members are.70 // __split_buffer doesn't have any self-references, so it's trivially relocatable if its members are.
73 using __trivially_relocatable = __conditional_t<71 using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<
74 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,72 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
75 __split_buffer,73 __split_buffer,
76 void>;74 void>;
...@@ -78,23 +76,20 @@ public:...@@ -78,23 +76,20 @@ public:
78 pointer __first_;76 pointer __first_;
79 pointer __begin_;77 pointer __begin_;
80 pointer __end_;78 pointer __end_;
81 __compressed_pair<pointer, allocator_type> __end_cap_;79 _LIBCPP_COMPRESSED_PAIR(pointer, __cap_, allocator_type, __alloc_);
82
83 using __alloc_ref = __add_lvalue_reference_t<allocator_type>;
84 using __alloc_const_ref = __add_lvalue_reference_t<allocator_type>;
8580
86 __split_buffer(const __split_buffer&) = delete;81 __split_buffer(const __split_buffer&) = delete;
87 __split_buffer& operator=(const __split_buffer&) = delete;82 __split_buffer& operator=(const __split_buffer&) = delete;
8883
89 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer()84 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer()
90 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)85 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
91 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __default_init_tag()) {}86 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr) {}
9287
93 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(__alloc_rr& __a)88 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(__alloc_rr& __a)
94 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) {}89 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr), __alloc_(__a) {}
9590
96 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(const __alloc_rr& __a)91 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(const __alloc_rr& __a)
97 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) {}92 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr), __alloc_(__a) {}
9893
99 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI94 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
100 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);95 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
...@@ -111,16 +106,6 @@ public:...@@ -111,16 +106,6 @@ public:
111106
112 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~__split_buffer();107 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~__split_buffer();
113108
114 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __alloc_rr& __alloc() _NOEXCEPT { return __end_cap_.second(); }
115 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const __alloc_rr& __alloc() const _NOEXCEPT {
116 return __end_cap_.second();
117 }
118
119 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT { return __end_cap_.first(); }
120 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const pointer& __end_cap() const _NOEXCEPT {
121 return __end_cap_.first();
122 }
123
124 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __begin_; }109 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __begin_; }
125 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __begin_; }110 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __begin_; }
126111
...@@ -136,7 +121,7 @@ public:...@@ -136,7 +121,7 @@ public:
136 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const { return __end_ == __begin_; }121 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const { return __end_ == __begin_; }
137122
138 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const {123 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const {
139 return static_cast<size_type>(__end_cap() - __first_);124 return static_cast<size_type>(__cap_ - __first_);
140 }125 }
141126
142 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __front_spare() const {127 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __front_spare() const {
...@@ -144,7 +129,7 @@ public:...@@ -144,7 +129,7 @@ public:
144 }129 }
145130
146 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const {131 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const {
147 return static_cast<size_type>(__end_cap() - __end_);132 return static_cast<size_type>(__cap_ - __end_);
148 }133 }
149134
150 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() { return *__begin_; }135 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() { return *__begin_; }
...@@ -152,13 +137,10 @@ public:...@@ -152,13 +137,10 @@ public:
152 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() { return *(__end_ - 1); }137 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() { return *(__end_ - 1); }
153 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const { return *(__end_ - 1); }138 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const { return *(__end_ - 1); }
154139
155 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
156 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;140 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
157 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(const_reference __x);
158 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x);
159 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x);
160 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);
161141
142 template <class... _Args>
143 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);
162 template <class... _Args>144 template <class... _Args>
163 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args);145 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args);
164146
...@@ -168,9 +150,6 @@ public:...@@ -168,9 +150,6 @@ public:
168 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);150 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);
169 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x);151 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x);
170152
171 template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> = 0>
172 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(_InputIter __first, _InputIter __last);
173
174 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>153 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
175 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void154 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
176 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);155 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
...@@ -205,7 +184,7 @@ public:...@@ -205,7 +184,7 @@ public:
205private:184private:
206 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer& __c, true_type)185 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer& __c, true_type)
207 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {186 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
208 __alloc() = std::move(__c.__alloc());187 __alloc_ = std::move(__c.__alloc_);
209 }188 }
210189
211 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT {}190 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT {}
...@@ -234,14 +213,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants...@@ -234,14 +213,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants
234 return false;213 return false;
235 if (__end_ != nullptr)214 if (__end_ != nullptr)
236 return false;215 return false;
237 if (__end_cap() != nullptr)216 if (__cap_ != nullptr)
238 return false;217 return false;
239 } else {218 } else {
240 if (__begin_ < __first_)219 if (__begin_ < __first_)
241 return false;220 return false;
242 if (__end_ < __begin_)221 if (__end_ < __begin_)
243 return false;222 return false;
244 if (__end_cap() < __end_)223 if (__cap_ < __end_)
245 return false;224 return false;
246 }225 }
247 return true;226 return true;
...@@ -256,7 +235,7 @@ template <class _Tp, class _Allocator>...@@ -256,7 +235,7 @@ template <class _Tp, class _Allocator>
256_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) {235_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) {
257 _ConstructTransaction __tx(&this->__end_, __n);236 _ConstructTransaction __tx(&this->__end_, __n);
258 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {237 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
259 __alloc_traits::construct(this->__alloc(), std::__to_address(__tx.__pos_));238 __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_));
260 }239 }
261}240}
262241
...@@ -271,29 +250,22 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void...@@ -271,29 +250,22 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void
271__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) {250__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) {
272 _ConstructTransaction __tx(&this->__end_, __n);251 _ConstructTransaction __tx(&this->__end_, __n);
273 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {252 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
274 __alloc_traits::construct(this->__alloc(), std::__to_address(__tx.__pos_), __x);253 __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), __x);
275 }254 }
276}255}
277256
278template <class _Tp, class _Allocator>
279template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> >
280_LIBCPP_CONSTEXPR_SINCE_CXX20 void
281__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last) {
282 __construct_at_end_with_sentinel(__first, __last);
283}
284
285template <class _Tp, class _Allocator>257template <class _Tp, class _Allocator>
286template <class _Iterator, class _Sentinel>258template <class _Iterator, class _Sentinel>
287_LIBCPP_CONSTEXPR_SINCE_CXX20 void259_LIBCPP_CONSTEXPR_SINCE_CXX20 void
288__split_buffer<_Tp, _Allocator>::__construct_at_end_with_sentinel(_Iterator __first, _Sentinel __last) {260__split_buffer<_Tp, _Allocator>::__construct_at_end_with_sentinel(_Iterator __first, _Sentinel __last) {
289 __alloc_rr& __a = this->__alloc();261 __alloc_rr& __a = __alloc_;
290 for (; __first != __last; ++__first) {262 for (; __first != __last; ++__first) {
291 if (__end_ == __end_cap()) {263 if (__end_ == __cap_) {
292 size_type __old_cap = __end_cap() - __first_;264 size_type __old_cap = __cap_ - __first_;
293 size_type __new_cap = std::max<size_type>(2 * __old_cap, 8);265 size_type __new_cap = std::max<size_type>(2 * __old_cap, 8);
294 __split_buffer __buf(__new_cap, 0, __a);266 __split_buffer __buf(__new_cap, 0, __a);
295 for (pointer __p = __begin_; __p != __end_; ++__p, (void)++__buf.__end_)267 for (pointer __p = __begin_; __p != __end_; ++__p, (void)++__buf.__end_)
296 __alloc_traits::construct(__buf.__alloc(), std::__to_address(__buf.__end_), std::move(*__p));268 __alloc_traits::construct(__buf.__alloc_, std::__to_address(__buf.__end_), std::move(*__p));
297 swap(__buf);269 swap(__buf);
298 }270 }
299 __alloc_traits::construct(__a, std::__to_address(this->__end_), *__first);271 __alloc_traits::construct(__a, std::__to_address(this->__end_), *__first);
...@@ -313,7 +285,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void...@@ -313,7 +285,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void
313__split_buffer<_Tp, _Allocator>::__construct_at_end_with_size(_ForwardIterator __first, size_type __n) {285__split_buffer<_Tp, _Allocator>::__construct_at_end_with_size(_ForwardIterator __first, size_type __n) {
314 _ConstructTransaction __tx(&this->__end_, __n);286 _ConstructTransaction __tx(&this->__end_, __n);
315 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__first) {287 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__first) {
316 __alloc_traits::construct(this->__alloc(), std::__to_address(__tx.__pos_), *__first);288 __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), *__first);
317 }289 }
318}290}
319291
...@@ -321,7 +293,7 @@ template <class _Tp, class _Allocator>...@@ -321,7 +293,7 @@ template <class _Tp, class _Allocator>
321_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void293_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
322__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) {294__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) {
323 while (__begin_ != __new_begin)295 while (__begin_ != __new_begin)
324 __alloc_traits::destroy(__alloc(), std::__to_address(__begin_++));296 __alloc_traits::destroy(__alloc_, std::__to_address(__begin_++));
325}297}
326298
327template <class _Tp, class _Allocator>299template <class _Tp, class _Allocator>
...@@ -334,7 +306,7 @@ template <class _Tp, class _Allocator>...@@ -334,7 +306,7 @@ template <class _Tp, class _Allocator>
334_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void306_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void
335__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT {307__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT {
336 while (__new_last != __end_)308 while (__new_last != __end_)
337 __alloc_traits::destroy(__alloc(), std::__to_address(--__end_));309 __alloc_traits::destroy(__alloc_, std::__to_address(--__end_));
338}310}
339311
340template <class _Tp, class _Allocator>312template <class _Tp, class _Allocator>
...@@ -346,23 +318,23 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type...@@ -346,23 +318,23 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type
346template <class _Tp, class _Allocator>318template <class _Tp, class _Allocator>
347_LIBCPP_CONSTEXPR_SINCE_CXX20319_LIBCPP_CONSTEXPR_SINCE_CXX20
348__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)320__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
349 : __end_cap_(nullptr, __a) {321 : __cap_(nullptr), __alloc_(__a) {
350 if (__cap == 0) {322 if (__cap == 0) {
351 __first_ = nullptr;323 __first_ = nullptr;
352 } else {324 } else {
353 auto __allocation = std::__allocate_at_least(__alloc(), __cap);325 auto __allocation = std::__allocate_at_least(__alloc_, __cap);
354 __first_ = __allocation.ptr;326 __first_ = __allocation.ptr;
355 __cap = __allocation.count;327 __cap = __allocation.count;
356 }328 }
357 __begin_ = __end_ = __first_ + __start;329 __begin_ = __end_ = __first_ + __start;
358 __end_cap() = __first_ + __cap;330 __cap_ = __first_ + __cap;
359}331}
360332
361template <class _Tp, class _Allocator>333template <class _Tp, class _Allocator>
362_LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::~__split_buffer() {334_LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::~__split_buffer() {
363 clear();335 clear();
364 if (__first_)336 if (__first_)
365 __alloc_traits::deallocate(__alloc(), __first_, capacity());337 __alloc_traits::deallocate(__alloc_, __first_, capacity());
366}338}
367339
368template <class _Tp, class _Allocator>340template <class _Tp, class _Allocator>
...@@ -371,31 +343,32 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::__split_buffer(__...@@ -371,31 +343,32 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::__split_buffer(__
371 : __first_(std::move(__c.__first_)),343 : __first_(std::move(__c.__first_)),
372 __begin_(std::move(__c.__begin_)),344 __begin_(std::move(__c.__begin_)),
373 __end_(std::move(__c.__end_)),345 __end_(std::move(__c.__end_)),
374 __end_cap_(std::move(__c.__end_cap_)) {346 __cap_(std::move(__c.__cap_)),
375 __c.__first_ = nullptr;347 __alloc_(std::move(__c.__alloc_)) {
376 __c.__begin_ = nullptr;348 __c.__first_ = nullptr;
377 __c.__end_ = nullptr;349 __c.__begin_ = nullptr;
378 __c.__end_cap() = nullptr;350 __c.__end_ = nullptr;
351 __c.__cap_ = nullptr;
379}352}
380353
381template <class _Tp, class _Allocator>354template <class _Tp, class _Allocator>
382_LIBCPP_CONSTEXPR_SINCE_CXX20355_LIBCPP_CONSTEXPR_SINCE_CXX20
383__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)356__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
384 : __end_cap_(nullptr, __a) {357 : __cap_(nullptr), __alloc_(__a) {
385 if (__a == __c.__alloc()) {358 if (__a == __c.__alloc_) {
386 __first_ = __c.__first_;359 __first_ = __c.__first_;
387 __begin_ = __c.__begin_;360 __begin_ = __c.__begin_;
388 __end_ = __c.__end_;361 __end_ = __c.__end_;
389 __end_cap() = __c.__end_cap();362 __cap_ = __c.__cap_;
390 __c.__first_ = nullptr;363 __c.__first_ = nullptr;
391 __c.__begin_ = nullptr;364 __c.__begin_ = nullptr;
392 __c.__end_ = nullptr;365 __c.__end_ = nullptr;
393 __c.__end_cap() = nullptr;366 __c.__cap_ = nullptr;
394 } else {367 } else {
395 auto __allocation = std::__allocate_at_least(__alloc(), __c.size());368 auto __allocation = std::__allocate_at_least(__alloc_, __c.size());
396 __first_ = __allocation.ptr;369 __first_ = __allocation.ptr;
397 __begin_ = __end_ = __first_;370 __begin_ = __end_ = __first_;
398 __end_cap() = __first_ + __allocation.count;371 __cap_ = __first_ + __allocation.count;
399 typedef move_iterator<iterator> _Ip;372 typedef move_iterator<iterator> _Ip;
400 __construct_at_end(_Ip(__c.begin()), _Ip(__c.end()));373 __construct_at_end(_Ip(__c.begin()), _Ip(__c.end()));
401 }374 }
...@@ -409,12 +382,12 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)...@@ -409,12 +382,12 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
409 !__alloc_traits::propagate_on_container_move_assignment::value) {382 !__alloc_traits::propagate_on_container_move_assignment::value) {
410 clear();383 clear();
411 shrink_to_fit();384 shrink_to_fit();
412 __first_ = __c.__first_;385 __first_ = __c.__first_;
413 __begin_ = __c.__begin_;386 __begin_ = __c.__begin_;
414 __end_ = __c.__end_;387 __end_ = __c.__end_;
415 __end_cap() = __c.__end_cap();388 __cap_ = __c.__cap_;
416 __move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());389 __move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
417 __c.__first_ = __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;390 __c.__first_ = __c.__begin_ = __c.__end_ = __c.__cap_ = nullptr;
418 return *this;391 return *this;
419}392}
420393
...@@ -424,151 +397,75 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::swap(__split...@@ -424,151 +397,75 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::swap(__split
424 std::swap(__first_, __x.__first_);397 std::swap(__first_, __x.__first_);
425 std::swap(__begin_, __x.__begin_);398 std::swap(__begin_, __x.__begin_);
426 std::swap(__end_, __x.__end_);399 std::swap(__end_, __x.__end_);
427 std::swap(__end_cap(), __x.__end_cap());400 std::swap(__cap_, __x.__cap_);
428 std::__swap_allocator(__alloc(), __x.__alloc());401 std::__swap_allocator(__alloc_, __x.__alloc_);
429}
430
431template <class _Tp, class _Allocator>
432_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::reserve(size_type __n) {
433 if (__n < capacity()) {
434 __split_buffer<value_type, __alloc_rr&> __t(__n, 0, __alloc());
435 __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
436 std::swap(__first_, __t.__first_);
437 std::swap(__begin_, __t.__begin_);
438 std::swap(__end_, __t.__end_);
439 std::swap(__end_cap(), __t.__end_cap());
440 }
441}402}
442403
443template <class _Tp, class _Allocator>404template <class _Tp, class _Allocator>
444_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT {405_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT {
445 if (capacity() > size()) {406 if (capacity() > size()) {
446#ifndef _LIBCPP_HAS_NO_EXCEPTIONS407#if _LIBCPP_HAS_EXCEPTIONS
447 try {408 try {
448#endif // _LIBCPP_HAS_NO_EXCEPTIONS409#endif // _LIBCPP_HAS_EXCEPTIONS
449 __split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc());410 __split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc_);
450 __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));411 if (__t.capacity() < capacity()) {
451 __t.__end_ = __t.__begin_ + (__end_ - __begin_);412 __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
452 std::swap(__first_, __t.__first_);413 __t.__end_ = __t.__begin_ + (__end_ - __begin_);
453 std::swap(__begin_, __t.__begin_);414 std::swap(__first_, __t.__first_);
454 std::swap(__end_, __t.__end_);415 std::swap(__begin_, __t.__begin_);
455 std::swap(__end_cap(), __t.__end_cap());416 std::swap(__end_, __t.__end_);
456#ifndef _LIBCPP_HAS_NO_EXCEPTIONS417 std::swap(__cap_, __t.__cap_);
418 }
419#if _LIBCPP_HAS_EXCEPTIONS
457 } catch (...) {420 } catch (...) {
458 }421 }
459#endif // _LIBCPP_HAS_NO_EXCEPTIONS422#endif // _LIBCPP_HAS_EXCEPTIONS
460 }423 }
461}424}
462425
463template <class _Tp, class _Allocator>426template <class _Tp, class _Allocator>
464_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::push_front(const_reference __x) {427template <class... _Args>
465 if (__begin_ == __first_) {428_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_front(_Args&&... __args) {
466 if (__end_ < __end_cap()) {
467 difference_type __d = __end_cap() - __end_;
468 __d = (__d + 1) / 2;
469 __begin_ = std::move_backward(__begin_, __end_, __end_ + __d);
470 __end_ += __d;
471 } else {
472 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
473 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());
474 __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
475 std::swap(__first_, __t.__first_);
476 std::swap(__begin_, __t.__begin_);
477 std::swap(__end_, __t.__end_);
478 std::swap(__end_cap(), __t.__end_cap());
479 }
480 }
481 __alloc_traits::construct(__alloc(), std::__to_address(__begin_ - 1), __x);
482 --__begin_;
483}
484
485template <class _Tp, class _Allocator>
486_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) {
487 if (__begin_ == __first_) {429 if (__begin_ == __first_) {
488 if (__end_ < __end_cap()) {430 if (__end_ < __cap_) {
489 difference_type __d = __end_cap() - __end_;431 difference_type __d = __cap_ - __end_;
490 __d = (__d + 1) / 2;432 __d = (__d + 1) / 2;
491 __begin_ = std::move_backward(__begin_, __end_, __end_ + __d);433 __begin_ = std::move_backward(__begin_, __end_, __end_ + __d);
492 __end_ += __d;434 __end_ += __d;
493 } else {435 } else {
494 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);436 size_type __c = std::max<size_type>(2 * static_cast<size_type>(__cap_ - __first_), 1);
495 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());437 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc_);
496 __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));438 __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
497 std::swap(__first_, __t.__first_);439 std::swap(__first_, __t.__first_);
498 std::swap(__begin_, __t.__begin_);440 std::swap(__begin_, __t.__begin_);
499 std::swap(__end_, __t.__end_);441 std::swap(__end_, __t.__end_);
500 std::swap(__end_cap(), __t.__end_cap());442 std::swap(__cap_, __t.__cap_);
501 }443 }
502 }444 }
503 __alloc_traits::construct(__alloc(), std::__to_address(__begin_ - 1), std::move(__x));445 __alloc_traits::construct(__alloc_, std::__to_address(__begin_ - 1), std::forward<_Args>(__args)...);
504 --__begin_;446 --__begin_;
505}447}
506448
507template <class _Tp, class _Allocator>
508_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void
509__split_buffer<_Tp, _Allocator>::push_back(const_reference __x) {
510 if (__end_ == __end_cap()) {
511 if (__begin_ > __first_) {
512 difference_type __d = __begin_ - __first_;
513 __d = (__d + 1) / 2;
514 __end_ = std::move(__begin_, __end_, __begin_ - __d);
515 __begin_ -= __d;
516 } else {
517 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
518 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
519 __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
520 std::swap(__first_, __t.__first_);
521 std::swap(__begin_, __t.__begin_);
522 std::swap(__end_, __t.__end_);
523 std::swap(__end_cap(), __t.__end_cap());
524 }
525 }
526 __alloc_traits::construct(__alloc(), std::__to_address(__end_), __x);
527 ++__end_;
528}
529
530template <class _Tp, class _Allocator>
531_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x) {
532 if (__end_ == __end_cap()) {
533 if (__begin_ > __first_) {
534 difference_type __d = __begin_ - __first_;
535 __d = (__d + 1) / 2;
536 __end_ = std::move(__begin_, __end_, __begin_ - __d);
537 __begin_ -= __d;
538 } else {
539 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
540 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
541 __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
542 std::swap(__first_, __t.__first_);
543 std::swap(__begin_, __t.__begin_);
544 std::swap(__end_, __t.__end_);
545 std::swap(__end_cap(), __t.__end_cap());
546 }
547 }
548 __alloc_traits::construct(__alloc(), std::__to_address(__end_), std::move(__x));
549 ++__end_;
550}
551
552template <class _Tp, class _Allocator>449template <class _Tp, class _Allocator>
553template <class... _Args>450template <class... _Args>
554_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) {451_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) {
555 if (__end_ == __end_cap()) {452 if (__end_ == __cap_) {
556 if (__begin_ > __first_) {453 if (__begin_ > __first_) {
557 difference_type __d = __begin_ - __first_;454 difference_type __d = __begin_ - __first_;
558 __d = (__d + 1) / 2;455 __d = (__d + 1) / 2;
559 __end_ = std::move(__begin_, __end_, __begin_ - __d);456 __end_ = std::move(__begin_, __end_, __begin_ - __d);
560 __begin_ -= __d;457 __begin_ -= __d;
561 } else {458 } else {
562 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);459 size_type __c = std::max<size_type>(2 * static_cast<size_type>(__cap_ - __first_), 1);
563 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());460 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc_);
564 __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));461 __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
565 std::swap(__first_, __t.__first_);462 std::swap(__first_, __t.__first_);
566 std::swap(__begin_, __t.__begin_);463 std::swap(__begin_, __t.__begin_);
567 std::swap(__end_, __t.__end_);464 std::swap(__end_, __t.__end_);
568 std::swap(__end_cap(), __t.__end_cap());465 std::swap(__cap_, __t.__cap_);
569 }466 }
570 }467 }
571 __alloc_traits::construct(__alloc(), std::__to_address(__end_), std::forward<_Args>(__args)...);468 __alloc_traits::construct(__alloc_, std::__to_address(__end_), std::forward<_Args>(__args)...);
572 ++__end_;469 ++__end_;
573}470}
574471
lib/libcxx/include/__stop_token/atomic_unique_lock.h+4-4
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H10#ifndef _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H
11#define _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H11#define _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H
1212
13#include <__bit/popcount.h>13#include <__bit/popcount.h>
14#include <__config>14#include <__config>
...@@ -133,8 +133,8 @@ private:...@@ -133,8 +133,8 @@ private:
133 _LIBCPP_HIDE_FROM_ABI static constexpr auto __set_locked_bit = [](_State __state) { return __state | _LockedBit; };133 _LIBCPP_HIDE_FROM_ABI static constexpr auto __set_locked_bit = [](_State __state) { return __state | _LockedBit; };
134};134};
135135
136#endif // _LIBCPP_STD_VER >= 20136#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
137137
138_LIBCPP_END_NAMESPACE_STD138_LIBCPP_END_NAMESPACE_STD
139139
140#endif // _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H140#endif // _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H
lib/libcxx/include/__stop_token/intrusive_shared_ptr.h+1-1
...@@ -13,10 +13,10 @@...@@ -13,10 +13,10 @@
13#include <__atomic/atomic.h>13#include <__atomic/atomic.h>
14#include <__atomic/memory_order.h>14#include <__atomic/memory_order.h>
15#include <__config>15#include <__config>
16#include <__cstddef/nullptr_t.h>
16#include <__type_traits/is_reference.h>17#include <__type_traits/is_reference.h>
17#include <__utility/move.h>18#include <__utility/move.h>
18#include <__utility/swap.h>19#include <__utility/swap.h>
19#include <cstddef>
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
lib/libcxx/include/__stop_token/stop_callback.h+3-3
...@@ -31,7 +31,7 @@ _LIBCPP_PUSH_MACROS...@@ -31,7 +31,7 @@ _LIBCPP_PUSH_MACROS
3131
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
34#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)34#if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
3535
36template <class _Callback>36template <class _Callback>
37class _LIBCPP_AVAILABILITY_SYNC stop_callback : private __stop_callback_base {37class _LIBCPP_AVAILABILITY_SYNC stop_callback : private __stop_callback_base {
...@@ -93,10 +93,10 @@ private:...@@ -93,10 +93,10 @@ private:
93template <class _Callback>93template <class _Callback>
94_LIBCPP_AVAILABILITY_SYNC stop_callback(stop_token, _Callback) -> stop_callback<_Callback>;94_LIBCPP_AVAILABILITY_SYNC stop_callback(stop_token, _Callback) -> stop_callback<_Callback>;
9595
96#endif // _LIBCPP_STD_VER >= 2096#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
9797
98_LIBCPP_END_NAMESPACE_STD98_LIBCPP_END_NAMESPACE_STD
9999
100_LIBCPP_POP_MACROS100_LIBCPP_POP_MACROS
101101
102#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)102#endif // _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H
lib/libcxx/include/__stop_token/stop_source.h+3-3
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)25#if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
2626
27struct nostopstate_t {27struct nostopstate_t {
28 explicit nostopstate_t() = default;28 explicit nostopstate_t() = default;
...@@ -84,8 +84,8 @@ private:...@@ -84,8 +84,8 @@ private:
84 __intrusive_shared_ptr<__stop_state> __state_;84 __intrusive_shared_ptr<__stop_state> __state_;
85};85};
8686
87#endif // _LIBCPP_STD_VER >= 2087#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
8888
89_LIBCPP_END_NAMESPACE_STD89_LIBCPP_END_NAMESPACE_STD
9090
91#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)91#endif // _LIBCPP___STOP_TOKEN_STOP_SOURCE_H
lib/libcxx/include/__stop_token/stop_state.h+6-6
...@@ -24,10 +24,10 @@...@@ -24,10 +24,10 @@
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS)27#if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
2828
29struct __stop_callback_base : __intrusive_node_base<__stop_callback_base> {29struct __stop_callback_base : __intrusive_node_base<__stop_callback_base> {
30 using __callback_fn_t = void(__stop_callback_base*) noexcept;30 using __callback_fn_t _LIBCPP_NODEBUG = void(__stop_callback_base*) noexcept;
31 _LIBCPP_HIDE_FROM_ABI explicit __stop_callback_base(__callback_fn_t* __callback_fn) : __callback_fn_(__callback_fn) {}31 _LIBCPP_HIDE_FROM_ABI explicit __stop_callback_base(__callback_fn_t* __callback_fn) : __callback_fn_(__callback_fn) {}
3232
33 _LIBCPP_HIDE_FROM_ABI void __invoke() noexcept { __callback_fn_(this); }33 _LIBCPP_HIDE_FROM_ABI void __invoke() noexcept { __callback_fn_(this); }
...@@ -58,9 +58,9 @@ class __stop_state {...@@ -58,9 +58,9 @@ class __stop_state {
58 // It is used by __intrusive_shared_ptr, but it is stored here for better layout58 // It is used by __intrusive_shared_ptr, but it is stored here for better layout
59 atomic<uint32_t> __ref_count_ = 0;59 atomic<uint32_t> __ref_count_ = 0;
6060
61 using __state_t = uint32_t;61 using __state_t _LIBCPP_NODEBUG = uint32_t;
62 using __callback_list_lock = __atomic_unique_lock<__state_t, __callback_list_locked_bit>;62 using __callback_list_lock _LIBCPP_NODEBUG = __atomic_unique_lock<__state_t, __callback_list_locked_bit>;
63 using __callback_list = __intrusive_list_view<__stop_callback_base>;63 using __callback_list _LIBCPP_NODEBUG = __intrusive_list_view<__stop_callback_base>;
6464
65 __callback_list __callback_list_;65 __callback_list __callback_list_;
66 __thread_id __requesting_thread_;66 __thread_id __requesting_thread_;
...@@ -229,7 +229,7 @@ struct __intrusive_shared_ptr_traits<__stop_state> {...@@ -229,7 +229,7 @@ struct __intrusive_shared_ptr_traits<__stop_state> {
229 }229 }
230};230};
231231
232#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS)232#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
233233
234_LIBCPP_END_NAMESPACE_STD234_LIBCPP_END_NAMESPACE_STD
235235
lib/libcxx/include/__stop_token/stop_token.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 >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)23#if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
2424
25class _LIBCPP_AVAILABILITY_SYNC stop_token {25class _LIBCPP_AVAILABILITY_SYNC stop_token {
26public:26public:
...@@ -56,7 +56,7 @@ private:...@@ -56,7 +56,7 @@ private:
56 _LIBCPP_HIDE_FROM_ABI explicit stop_token(const __intrusive_shared_ptr<__stop_state>& __state) : __state_(__state) {}56 _LIBCPP_HIDE_FROM_ABI explicit stop_token(const __intrusive_shared_ptr<__stop_state>& __state) : __state_(__state) {}
57};57};
5858
59#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)59#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
6060
61_LIBCPP_END_NAMESPACE_STD61_LIBCPP_END_NAMESPACE_STD
6262
lib/libcxx/include/__string/char_traits.h+7-6
...@@ -17,18 +17,19 @@...@@ -17,18 +17,19 @@
17#include <__assert>17#include <__assert>
18#include <__compare/ordering.h>18#include <__compare/ordering.h>
19#include <__config>19#include <__config>
20#include <__cstddef/ptrdiff_t.h>
20#include <__functional/hash.h>21#include <__functional/hash.h>
21#include <__functional/identity.h>22#include <__functional/identity.h>
22#include <__iterator/iterator_traits.h>23#include <__iterator/iterator_traits.h>
24#include <__std_mbstate_t.h>
23#include <__string/constexpr_c_functions.h>25#include <__string/constexpr_c_functions.h>
24#include <__type_traits/is_constant_evaluated.h>26#include <__type_traits/is_constant_evaluated.h>
25#include <__utility/is_pointer_in_range.h>27#include <__utility/is_pointer_in_range.h>
26#include <cstddef>
27#include <cstdint>28#include <cstdint>
28#include <cstdio>29#include <cstdio>
29#include <iosfwd>30#include <iosfwd>
3031
31#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS32#if _LIBCPP_HAS_WIDE_CHARACTERS
32# include <cwchar> // for wmemcpy33# include <cwchar> // for wmemcpy
33#endif34#endif
3435
...@@ -233,7 +234,7 @@ struct __char_traits_base {...@@ -233,7 +234,7 @@ struct __char_traits_base {
233234
234// char_traits<wchar_t>235// char_traits<wchar_t>
235236
236#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS237#if _LIBCPP_HAS_WIDE_CHARACTERS
237template <>238template <>
238struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wint_t>(WEOF)> {239struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wint_t>(WEOF)> {
239 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int240 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int
...@@ -254,9 +255,9 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, w...@@ -254,9 +255,9 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, w
254 return std::__constexpr_wmemchr(__s, __a, __n);255 return std::__constexpr_wmemchr(__s, __a, __n);
255 }256 }
256};257};
257#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS258#endif // _LIBCPP_HAS_WIDE_CHARACTERS
258259
259#ifndef _LIBCPP_HAS_NO_CHAR8_T260#if _LIBCPP_HAS_CHAR8_T
260261
261template <>262template <>
262struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>263struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
...@@ -276,7 +277,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>...@@ -276,7 +277,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
276 }277 }
277};278};
278279
279#endif // _LIBCPP_HAS_NO_CHAR8_T280#endif // _LIBCPP_HAS_CHAR8_T
280281
281template <>282template <>
282struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>283struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
lib/libcxx/include/__string/constexpr_c_functions.h+7-8
...@@ -10,20 +10,23 @@...@@ -10,20 +10,23 @@
10#define _LIBCPP___STRING_CONSTEXPR_C_FUNCTIONS_H10#define _LIBCPP___STRING_CONSTEXPR_C_FUNCTIONS_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__memory/addressof.h>14#include <__memory/addressof.h>
14#include <__memory/construct_at.h>15#include <__memory/construct_at.h>
15#include <__type_traits/datasizeof.h>16#include <__type_traits/datasizeof.h>
17#include <__type_traits/enable_if.h>
16#include <__type_traits/is_always_bitcastable.h>18#include <__type_traits/is_always_bitcastable.h>
17#include <__type_traits/is_assignable.h>19#include <__type_traits/is_assignable.h>
18#include <__type_traits/is_constant_evaluated.h>20#include <__type_traits/is_constant_evaluated.h>
19#include <__type_traits/is_constructible.h>21#include <__type_traits/is_constructible.h>
20#include <__type_traits/is_equality_comparable.h>22#include <__type_traits/is_equality_comparable.h>
23#include <__type_traits/is_integral.h>
21#include <__type_traits/is_same.h>24#include <__type_traits/is_same.h>
22#include <__type_traits/is_trivially_copyable.h>25#include <__type_traits/is_trivially_copyable.h>
23#include <__type_traits/is_trivially_lexicographically_comparable.h>26#include <__type_traits/is_trivially_lexicographically_comparable.h>
24#include <__type_traits/remove_cv.h>27#include <__type_traits/remove_cv.h>
28#include <__utility/element_count.h>
25#include <__utility/is_pointer_in_range.h>29#include <__utility/is_pointer_in_range.h>
26#include <cstddef>
2730
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)31#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header32# pragma GCC system_header
...@@ -31,17 +34,13 @@...@@ -31,17 +34,13 @@
3134
32_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3336
34// Type used to encode that a function takes an integer that represents a number
35// of elements as opposed to a number of bytes.
36enum class __element_count : size_t {};
37
38template <class _Tp>37template <class _Tp>
39inline const bool __is_char_type = false;38inline const bool __is_char_type = false;
4039
41template <>40template <>
42inline const bool __is_char_type<char> = true;41inline const bool __is_char_type<char> = true;
4342
44#ifndef _LIBCPP_HAS_NO_CHAR8_T43#if _LIBCPP_HAS_CHAR8_T
45template <>44template <>
46inline const bool __is_char_type<char8_t> = true;45inline const bool __is_char_type<char8_t> = true;
47#endif46#endif
...@@ -64,13 +63,13 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_st...@@ -64,13 +63,13 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_st
64 return __builtin_strlen(reinterpret_cast<const char*>(__str));63 return __builtin_strlen(reinterpret_cast<const char*>(__str));
65}64}
6665
67// Because of __libcpp_is_trivially_lexicographically_comparable we know that comparing the object representations is66// Because of __is_trivially_lexicographically_comparable_v we know that comparing the object representations is
68// equivalent to a std::memcmp. Since we have multiple objects contiguously in memory, we can call memcmp once instead67// equivalent to a std::memcmp. Since we have multiple objects contiguously in memory, we can call memcmp once instead
69// of invoking it on every object individually.68// of invoking it on every object individually.
70template <class _Tp, class _Up>69template <class _Tp, class _Up>
71_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int70_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
72__constexpr_memcmp(const _Tp* __lhs, const _Up* __rhs, __element_count __n) {71__constexpr_memcmp(const _Tp* __lhs, const _Up* __rhs, __element_count __n) {
73 static_assert(__libcpp_is_trivially_lexicographically_comparable<_Tp, _Up>::value,72 static_assert(__is_trivially_lexicographically_comparable_v<_Tp, _Up>,
74 "_Tp and _Up have to be trivially lexicographically comparable");73 "_Tp and _Up have to be trivially lexicographically comparable");
7574
76 auto __count = static_cast<size_t>(__n);75 auto __count = static_cast<size_t>(__n);
lib/libcxx/include/__support/xlocale/__nop_locale_mgmt.h+2-4
...@@ -15,13 +15,11 @@...@@ -15,13 +15,11 @@
15// Patch over lack of extended locale support15// Patch over lack of extended locale support
16typedef void* locale_t;16typedef void* locale_t;
1717
18inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return NULL; }18inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return nullptr; }
1919
20inline _LIBCPP_HIDE_FROM_ABI void freelocale(locale_t) {}20inline _LIBCPP_HIDE_FROM_ABI void freelocale(locale_t) {}
2121
22inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return NULL; }22inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return nullptr; }
23
24inline _LIBCPP_HIDE_FROM_ABI locale_t uselocale(locale_t) { return NULL; }
2523
26#define LC_COLLATE_MASK (1 << LC_COLLATE)24#define LC_COLLATE_MASK (1 << LC_COLLATE)
27#define LC_CTYPE_MASK (1 << LC_CTYPE)25#define LC_CTYPE_MASK (1 << LC_CTYPE)
lib/libcxx/include/__support/xlocale/__posix_l_fallback.h+6-22
...@@ -20,29 +20,15 @@...@@ -20,29 +20,15 @@
20#include <string.h>20#include <string.h>
21#include <time.h>21#include <time.h>
2222
23#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS23#if _LIBCPP_HAS_WIDE_CHARACTERS
24# include <wchar.h>24# include <wchar.h>
25# include <wctype.h>25# include <wctype.h>
26#endif26#endif
2727
28inline _LIBCPP_HIDE_FROM_ABI int isalnum_l(int __c, locale_t) { return ::isalnum(__c); }
29
30inline _LIBCPP_HIDE_FROM_ABI int isalpha_l(int __c, locale_t) { return ::isalpha(__c); }
31
32inline _LIBCPP_HIDE_FROM_ABI int iscntrl_l(int __c, locale_t) { return ::iscntrl(__c); }
33
34inline _LIBCPP_HIDE_FROM_ABI int isdigit_l(int __c, locale_t) { return ::isdigit(__c); }28inline _LIBCPP_HIDE_FROM_ABI int isdigit_l(int __c, locale_t) { return ::isdigit(__c); }
3529
36inline _LIBCPP_HIDE_FROM_ABI int isgraph_l(int __c, locale_t) { return ::isgraph(__c); }
37
38inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, locale_t) { return ::islower(__c); }30inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, locale_t) { return ::islower(__c); }
3931
40inline _LIBCPP_HIDE_FROM_ABI int isprint_l(int __c, locale_t) { return ::isprint(__c); }
41
42inline _LIBCPP_HIDE_FROM_ABI int ispunct_l(int __c, locale_t) { return ::ispunct(__c); }
43
44inline _LIBCPP_HIDE_FROM_ABI int isspace_l(int __c, locale_t) { return ::isspace(__c); }
45
46inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, locale_t) { return ::isupper(__c); }32inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, locale_t) { return ::isupper(__c); }
4733
48inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) { return ::isxdigit(__c); }34inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) { return ::isxdigit(__c); }
...@@ -51,8 +37,8 @@ inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) { return ::toupper...@@ -51,8 +37,8 @@ inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) { return ::toupper
5137
52inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) { return ::tolower(__c); }38inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) { return ::tolower(__c); }
5339
54#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS40#if _LIBCPP_HAS_WIDE_CHARACTERS
55inline _LIBCPP_HIDE_FROM_ABI int iswalnum_l(wint_t __c, locale_t) { return ::iswalnum(__c); }41inline _LIBCPP_HIDE_FROM_ABI int iswctype_l(wint_t __c, wctype_t __type, locale_t) { return ::iswctype(__c, __type); }
5642
57inline _LIBCPP_HIDE_FROM_ABI int iswalpha_l(wint_t __c, locale_t) { return ::iswalpha(__c); }43inline _LIBCPP_HIDE_FROM_ABI int iswalpha_l(wint_t __c, locale_t) { return ::iswalpha(__c); }
5844
...@@ -62,8 +48,6 @@ inline _LIBCPP_HIDE_FROM_ABI int iswcntrl_l(wint_t __c, locale_t) { return ::isw...@@ -62,8 +48,6 @@ inline _LIBCPP_HIDE_FROM_ABI int iswcntrl_l(wint_t __c, locale_t) { return ::isw
6248
63inline _LIBCPP_HIDE_FROM_ABI int iswdigit_l(wint_t __c, locale_t) { return ::iswdigit(__c); }49inline _LIBCPP_HIDE_FROM_ABI int iswdigit_l(wint_t __c, locale_t) { return ::iswdigit(__c); }
6450
65inline _LIBCPP_HIDE_FROM_ABI int iswgraph_l(wint_t __c, locale_t) { return ::iswgraph(__c); }
66
67inline _LIBCPP_HIDE_FROM_ABI int iswlower_l(wint_t __c, locale_t) { return ::iswlower(__c); }51inline _LIBCPP_HIDE_FROM_ABI int iswlower_l(wint_t __c, locale_t) { return ::iswlower(__c); }
6852
69inline _LIBCPP_HIDE_FROM_ABI int iswprint_l(wint_t __c, locale_t) { return ::iswprint(__c); }53inline _LIBCPP_HIDE_FROM_ABI int iswprint_l(wint_t __c, locale_t) { return ::iswprint(__c); }
...@@ -79,7 +63,7 @@ inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) { return ::is...@@ -79,7 +63,7 @@ inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) { return ::is
79inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) { return ::towupper(__c); }63inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) { return ::towupper(__c); }
8064
81inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) { return ::towlower(__c); }65inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) { return ::towlower(__c); }
82#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS66#endif // _LIBCPP_HAS_WIDE_CHARACTERS
8367
84inline _LIBCPP_HIDE_FROM_ABI int strcoll_l(const char* __s1, const char* __s2, locale_t) {68inline _LIBCPP_HIDE_FROM_ABI int strcoll_l(const char* __s1, const char* __s2, locale_t) {
85 return ::strcoll(__s1, __s2);69 return ::strcoll(__s1, __s2);
...@@ -94,7 +78,7 @@ strftime_l(char* __s, size_t __max, const char* __format, const struct tm* __tm,...@@ -94,7 +78,7 @@ strftime_l(char* __s, size_t __max, const char* __format, const struct tm* __tm,
94 return ::strftime(__s, __max, __format, __tm);78 return ::strftime(__s, __max, __format, __tm);
95}79}
9680
97#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS81#if _LIBCPP_HAS_WIDE_CHARACTERS
98inline _LIBCPP_HIDE_FROM_ABI int wcscoll_l(const wchar_t* __ws1, const wchar_t* __ws2, locale_t) {82inline _LIBCPP_HIDE_FROM_ABI int wcscoll_l(const wchar_t* __ws1, const wchar_t* __ws2, locale_t) {
99 return ::wcscoll(__ws1, __ws2);83 return ::wcscoll(__ws1, __ws2);
100}84}
...@@ -102,6 +86,6 @@ inline _LIBCPP_HIDE_FROM_ABI int wcscoll_l(const wchar_t* __ws1, const wchar_t*...@@ -102,6 +86,6 @@ inline _LIBCPP_HIDE_FROM_ABI int wcscoll_l(const wchar_t* __ws1, const wchar_t*
102inline _LIBCPP_HIDE_FROM_ABI size_t wcsxfrm_l(wchar_t* __dest, const wchar_t* __src, size_t __n, locale_t) {86inline _LIBCPP_HIDE_FROM_ABI size_t wcsxfrm_l(wchar_t* __dest, const wchar_t* __src, size_t __n, locale_t) {
103 return ::wcsxfrm(__dest, __src, __n);87 return ::wcsxfrm(__dest, __src, __n);
104}88}
105#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS89#endif // _LIBCPP_HAS_WIDE_CHARACTERS
10690
107#endif // _LIBCPP___SUPPORT_XLOCALE_POSIX_L_FALLBACK_H91#endif // _LIBCPP___SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
lib/libcxx/include/__support/xlocale/__strtonum_fallback.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18#include <__config>18#include <__config>
19#include <stdlib.h>19#include <stdlib.h>
2020
21#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS21#if _LIBCPP_HAS_WIDE_CHARACTERS
22# include <wchar.h>22# include <wchar.h>
23#endif23#endif
2424
lib/libcxx/include/__system_error/errc.h+1-1
...@@ -133,7 +133,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -133,7 +133,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
133// enum class errc133// enum class errc
134//134//
135// LWG3869 deprecates the UNIX STREAMS macros and enum values.135// LWG3869 deprecates the UNIX STREAMS macros and enum values.
136// This makes the code clumbersome:136// This makes the code cumbersome:
137// - the enum value is deprecated and should show a diagnostic,137// - the enum value is deprecated and should show a diagnostic,
138// - the macro is deprecated and should _not_ show a diagnostic in this138// - the macro is deprecated and should _not_ show a diagnostic in this
139// context, and139// context, and
lib/libcxx/include/__system_error/error_code.h-1
...@@ -17,7 +17,6 @@...@@ -17,7 +17,6 @@
17#include <__system_error/errc.h>17#include <__system_error/errc.h>
18#include <__system_error/error_category.h>18#include <__system_error/error_category.h>
19#include <__system_error/error_condition.h>19#include <__system_error/error_condition.h>
20#include <cstddef>
21#include <string>20#include <string>
2221
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__system_error/error_condition.h-1
...@@ -16,7 +16,6 @@...@@ -16,7 +16,6 @@
16#include <__functional/unary_function.h>16#include <__functional/unary_function.h>
17#include <__system_error/errc.h>17#include <__system_error/errc.h>
18#include <__system_error/error_category.h>18#include <__system_error/error_category.h>
19#include <cstddef>
20#include <string>19#include <string>
2120
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__system_error/system_error.h+6-3
...@@ -39,9 +39,12 @@ public:...@@ -39,9 +39,12 @@ public:
39 _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; }39 _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; }
40};40};
4141
42_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg);42// __ev is expected to be an error in the generic_category domain (e.g. from
43_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __throw_system_error(error_code __ec, const char* __what_arg) {43// errno, or std::errc::*), not system_category (e.g. from windows syscalls).
44#ifndef _LIBCPP_HAS_NO_EXCEPTIONS44[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg);
45
46[[__noreturn__]] _LIBCPP_HIDE_FROM_ABI inline void __throw_system_error(error_code __ec, const char* __what_arg) {
47#if _LIBCPP_HAS_EXCEPTIONS
45 throw system_error(__ec, __what_arg);48 throw system_error(__ec, __what_arg);
46#else49#else
47 _LIBCPP_VERBOSE_ABORT(50 _LIBCPP_VERBOSE_ABORT(
lib/libcxx/include/__system_error/throw_system_error.h created+25
...@@ -0,0 +1,25 @@
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___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H
11#define _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H
12
13#include <__config>
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[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg);
22
23_LIBCPP_END_NAMESPACE_STD
24
25#endif // _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H
lib/libcxx/include/__thread/formatter.h+2-2
...@@ -31,7 +31,7 @@...@@ -31,7 +31,7 @@
3131
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
34# ifndef _LIBCPP_HAS_NO_THREADS34# if _LIBCPP_HAS_THREADS
3535
36template <__fmt_char_type _CharT>36template <__fmt_char_type _CharT>
37struct _LIBCPP_TEMPLATE_VIS formatter<__thread_id, _CharT> {37struct _LIBCPP_TEMPLATE_VIS formatter<__thread_id, _CharT> {
...@@ -71,7 +71,7 @@ public:...@@ -71,7 +71,7 @@ public:
71 __format_spec::__parser<_CharT> __parser_{.__alignment_ = __format_spec::__alignment::__right};71 __format_spec::__parser<_CharT> __parser_{.__alignment_ = __format_spec::__alignment::__right};
72};72};
7373
74# endif // !_LIBCPP_HAS_NO_THREADS74# endif // _LIBCPP_HAS_THREADS
7575
76_LIBCPP_END_NAMESPACE_STD76_LIBCPP_END_NAMESPACE_STD
7777
lib/libcxx/include/__thread/id.h+2-2
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25#ifndef _LIBCPP_HAS_NO_THREADS25#if _LIBCPP_HAS_THREADS
26class _LIBCPP_EXPORTED_FROM_ABI __thread_id;26class _LIBCPP_EXPORTED_FROM_ABI __thread_id;
2727
28namespace this_thread {28namespace this_thread {
...@@ -114,7 +114,7 @@ inline _LIBCPP_HIDE_FROM_ABI __thread_id get_id() _NOEXCEPT { return __libcpp_th...@@ -114,7 +114,7 @@ inline _LIBCPP_HIDE_FROM_ABI __thread_id get_id() _NOEXCEPT { return __libcpp_th
114114
115} // namespace this_thread115} // namespace this_thread
116116
117#endif // !_LIBCPP_HAS_NO_THREADS117#endif // _LIBCPP_HAS_THREADS
118118
119_LIBCPP_END_NAMESPACE_STD119_LIBCPP_END_NAMESPACE_STD
120120
lib/libcxx/include/__thread/jthread.h+5-3
...@@ -11,17 +11,19 @@...@@ -11,17 +11,19 @@
11#define _LIBCPP___THREAD_JTHREAD_H11#define _LIBCPP___THREAD_JTHREAD_H
1212
13#include <__config>13#include <__config>
14#include <__functional/invoke.h>
15#include <__stop_token/stop_source.h>14#include <__stop_token/stop_source.h>
16#include <__stop_token/stop_token.h>15#include <__stop_token/stop_token.h>
16#include <__thread/id.h>
17#include <__thread/support.h>17#include <__thread/support.h>
18#include <__thread/thread.h>18#include <__thread/thread.h>
19#include <__type_traits/decay.h>19#include <__type_traits/decay.h>
20#include <__type_traits/invoke.h>
20#include <__type_traits/is_constructible.h>21#include <__type_traits/is_constructible.h>
21#include <__type_traits/is_same.h>22#include <__type_traits/is_same.h>
22#include <__type_traits/remove_cvref.h>23#include <__type_traits/remove_cvref.h>
23#include <__utility/forward.h>24#include <__utility/forward.h>
24#include <__utility/move.h>25#include <__utility/move.h>
26#include <__utility/swap.h>
2527
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header29# pragma GCC system_header
...@@ -30,7 +32,7 @@...@@ -30,7 +32,7 @@
30_LIBCPP_PUSH_MACROS32_LIBCPP_PUSH_MACROS
31#include <__undef_macros>33#include <__undef_macros>
3234
33#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN)35#if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
3436
35_LIBCPP_BEGIN_NAMESPACE_STD37_LIBCPP_BEGIN_NAMESPACE_STD
3638
...@@ -127,7 +129,7 @@ private:...@@ -127,7 +129,7 @@ private:
127129
128_LIBCPP_END_NAMESPACE_STD130_LIBCPP_END_NAMESPACE_STD
129131
130#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN)132#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
131133
132_LIBCPP_POP_MACROS134_LIBCPP_POP_MACROS
133135
lib/libcxx/include/__thread/support.h+6-6
...@@ -104,20 +104,20 @@ _LIBCPP_END_NAMESPACE_STD...@@ -104,20 +104,20 @@ _LIBCPP_END_NAMESPACE_STD
104104
105*/105*/
106106
107#if !defined(_LIBCPP_HAS_NO_THREADS)107#if _LIBCPP_HAS_THREADS
108108
109# if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)109# if _LIBCPP_HAS_THREAD_API_EXTERNAL
110# include <__thread/support/external.h>110# include <__thread/support/external.h>
111# elif defined(_LIBCPP_HAS_THREAD_API_PTHREAD)111# elif _LIBCPP_HAS_THREAD_API_PTHREAD
112# include <__thread/support/pthread.h>112# include <__thread/support/pthread.h>
113# elif defined(_LIBCPP_HAS_THREAD_API_C11)113# elif _LIBCPP_HAS_THREAD_API_C11
114# include <__thread/support/c11.h>114# include <__thread/support/c11.h>
115# elif defined(_LIBCPP_HAS_THREAD_API_WIN32)115# elif _LIBCPP_HAS_THREAD_API_WIN32
116# include <__thread/support/windows.h>116# include <__thread/support/windows.h>
117# else117# else
118# error "No threading API was selected"118# error "No threading API was selected"
119# endif119# endif
120120
121#endif // !_LIBCPP_HAS_NO_THREADS121#endif // _LIBCPP_HAS_THREADS
122122
123#endif // _LIBCPP___THREAD_SUPPORT_H123#endif // _LIBCPP___THREAD_SUPPORT_H
lib/libcxx/include/__thread/support/pthread.h+1-1
...@@ -39,7 +39,7 @@...@@ -39,7 +39,7 @@
3939
40_LIBCPP_BEGIN_NAMESPACE_STD40_LIBCPP_BEGIN_NAMESPACE_STD
4141
42using __libcpp_timespec_t = ::timespec;42using __libcpp_timespec_t _LIBCPP_NODEBUG = ::timespec;
4343
44//44//
45// Mutex45// Mutex
lib/libcxx/include/__thread/this_thread.h+5
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#ifndef _LIBCPP___THREAD_THIS_THREAD_H10#ifndef _LIBCPP___THREAD_THIS_THREAD_H
11#define _LIBCPP___THREAD_THIS_THREAD_H11#define _LIBCPP___THREAD_THIS_THREAD_H
1212
13#include <__chrono/duration.h>
13#include <__chrono/steady_clock.h>14#include <__chrono/steady_clock.h>
14#include <__chrono/time_point.h>15#include <__chrono/time_point.h>
15#include <__condition_variable/condition_variable.h>16#include <__condition_variable/condition_variable.h>
...@@ -29,6 +30,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,6 +30,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2930
30namespace this_thread {31namespace this_thread {
3132
33#if _LIBCPP_HAS_THREADS
34
32_LIBCPP_EXPORTED_FROM_ABI void sleep_for(const chrono::nanoseconds& __ns);35_LIBCPP_EXPORTED_FROM_ABI void sleep_for(const chrono::nanoseconds& __ns);
3336
34template <class _Rep, class _Period>37template <class _Rep, class _Period>
...@@ -65,6 +68,8 @@ inline _LIBCPP_HIDE_FROM_ABI void sleep_until(const chrono::time_point<chrono::s...@@ -65,6 +68,8 @@ inline _LIBCPP_HIDE_FROM_ABI void sleep_until(const chrono::time_point<chrono::s
6568
66inline _LIBCPP_HIDE_FROM_ABI void yield() _NOEXCEPT { __libcpp_thread_yield(); }69inline _LIBCPP_HIDE_FROM_ABI void yield() _NOEXCEPT { __libcpp_thread_yield(); }
6770
71#endif // _LIBCPP_HAS_THREADS
72
68} // namespace this_thread73} // namespace this_thread
6974
70_LIBCPP_END_NAMESPACE_STD75_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__thread/thread.h+19-10
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#ifndef _LIBCPP___THREAD_THREAD_H10#ifndef _LIBCPP___THREAD_THREAD_H
11#define _LIBCPP___THREAD_THREAD_H11#define _LIBCPP___THREAD_THREAD_H
1212
13#include <__assert>
13#include <__condition_variable/condition_variable.h>14#include <__condition_variable/condition_variable.h>
14#include <__config>15#include <__config>
15#include <__exception/terminate.h>16#include <__exception/terminate.h>
...@@ -17,13 +18,17 @@...@@ -17,13 +18,17 @@
17#include <__functional/unary_function.h>18#include <__functional/unary_function.h>
18#include <__memory/unique_ptr.h>19#include <__memory/unique_ptr.h>
19#include <__mutex/mutex.h>20#include <__mutex/mutex.h>
20#include <__system_error/system_error.h>21#include <__system_error/throw_system_error.h>
21#include <__thread/id.h>22#include <__thread/id.h>
22#include <__thread/support.h>23#include <__thread/support.h>
24#include <__type_traits/decay.h>
25#include <__type_traits/enable_if.h>
26#include <__type_traits/is_same.h>
27#include <__type_traits/remove_cvref.h>
23#include <__utility/forward.h>28#include <__utility/forward.h>
24#include <tuple>29#include <tuple>
2530
26#ifndef _LIBCPP_HAS_NO_LOCALIZATION31#if _LIBCPP_HAS_LOCALIZATION
27# include <locale>32# include <locale>
28# include <sstream>33# include <sstream>
29#endif34#endif
...@@ -37,6 +42,8 @@ _LIBCPP_PUSH_MACROS...@@ -37,6 +42,8 @@ _LIBCPP_PUSH_MACROS
3742
38_LIBCPP_BEGIN_NAMESPACE_STD43_LIBCPP_BEGIN_NAMESPACE_STD
3944
45#if _LIBCPP_HAS_THREADS
46
40template <class _Tp>47template <class _Tp>
41class __thread_specific_ptr;48class __thread_specific_ptr;
42class _LIBCPP_EXPORTED_FROM_ABI __thread_struct;49class _LIBCPP_EXPORTED_FROM_ABI __thread_struct;
...@@ -117,7 +124,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<__thread_id> : public __unary_function<__thread...@@ -117,7 +124,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<__thread_id> : public __unary_function<__thread
117 }124 }
118};125};
119126
120#ifndef _LIBCPP_HAS_NO_LOCALIZATION127# if _LIBCPP_HAS_LOCALIZATION
121template <class _CharT, class _Traits>128template <class _CharT, class _Traits>
122_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&129_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
123operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) {130operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) {
...@@ -142,7 +149,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) {...@@ -142,7 +149,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) {
142 __sstr << __id.__id_;149 __sstr << __id.__id_;
143 return __os << __sstr.str();150 return __os << __sstr.str();
144}151}
145#endif // _LIBCPP_HAS_NO_LOCALIZATION152# endif // _LIBCPP_HAS_LOCALIZATION
146153
147class _LIBCPP_EXPORTED_FROM_ABI thread {154class _LIBCPP_EXPORTED_FROM_ABI thread {
148 __libcpp_thread_t __t_;155 __libcpp_thread_t __t_;
...@@ -155,13 +162,13 @@ public:...@@ -155,13 +162,13 @@ public:
155 typedef __libcpp_thread_t native_handle_type;162 typedef __libcpp_thread_t native_handle_type;
156163
157 _LIBCPP_HIDE_FROM_ABI thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}164 _LIBCPP_HIDE_FROM_ABI thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
158#ifndef _LIBCPP_CXX03_LANG165# ifndef _LIBCPP_CXX03_LANG
159 template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> = 0>166 template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> = 0>
160 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp&& __f, _Args&&... __args);167 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp&& __f, _Args&&... __args);
161#else // _LIBCPP_CXX03_LANG168# else // _LIBCPP_CXX03_LANG
162 template <class _Fp>169 template <class _Fp>
163 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp __f);170 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp __f);
164#endif171# endif
165 ~thread();172 ~thread();
166173
167 _LIBCPP_HIDE_FROM_ABI thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) { __t.__t_ = _LIBCPP_NULL_THREAD; }174 _LIBCPP_HIDE_FROM_ABI thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) { __t.__t_ = _LIBCPP_NULL_THREAD; }
...@@ -185,7 +192,7 @@ public:...@@ -185,7 +192,7 @@ public:
185 static unsigned hardware_concurrency() _NOEXCEPT;192 static unsigned hardware_concurrency() _NOEXCEPT;
186};193};
187194
188#ifndef _LIBCPP_CXX03_LANG195# ifndef _LIBCPP_CXX03_LANG
189196
190template <class _TSp, class _Fp, class... _Args, size_t... _Indices>197template <class _TSp, class _Fp, class... _Args, size_t... _Indices>
191inline _LIBCPP_HIDE_FROM_ABI void __thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>) {198inline _LIBCPP_HIDE_FROM_ABI void __thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>) {
...@@ -215,7 +222,7 @@ thread::thread(_Fp&& __f, _Args&&... __args) {...@@ -215,7 +222,7 @@ thread::thread(_Fp&& __f, _Args&&... __args) {
215 __throw_system_error(__ec, "thread constructor failed");222 __throw_system_error(__ec, "thread constructor failed");
216}223}
217224
218#else // _LIBCPP_CXX03_LANG225# else // _LIBCPP_CXX03_LANG
219226
220template <class _Fp>227template <class _Fp>
221struct __thread_invoke_pair {228struct __thread_invoke_pair {
...@@ -247,10 +254,12 @@ thread::thread(_Fp __f) {...@@ -247,10 +254,12 @@ thread::thread(_Fp __f) {
247 __throw_system_error(__ec, "thread constructor failed");254 __throw_system_error(__ec, "thread constructor failed");
248}255}
249256
250#endif // _LIBCPP_CXX03_LANG257# endif // _LIBCPP_CXX03_LANG
251258
252inline _LIBCPP_HIDE_FROM_ABI void swap(thread& __x, thread& __y) _NOEXCEPT { __x.swap(__y); }259inline _LIBCPP_HIDE_FROM_ABI void swap(thread& __x, thread& __y) _NOEXCEPT { __x.swap(__y); }
253260
261#endif // _LIBCPP_HAS_THREADS
262
254_LIBCPP_END_NAMESPACE_STD263_LIBCPP_END_NAMESPACE_STD
255264
256_LIBCPP_POP_MACROS265_LIBCPP_POP_MACROS
lib/libcxx/include/__thread/timed_backoff_policy.h+2-2
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
1212
13#include <__config>13#include <__config>
1414
15#ifndef _LIBCPP_HAS_NO_THREADS15#if _LIBCPP_HAS_THREADS
1616
17# include <__chrono/duration.h>17# include <__chrono/duration.h>
18# include <__thread/support.h>18# include <__thread/support.h>
...@@ -39,6 +39,6 @@ struct __libcpp_timed_backoff_policy {...@@ -39,6 +39,6 @@ struct __libcpp_timed_backoff_policy {
3939
40_LIBCPP_END_NAMESPACE_STD40_LIBCPP_END_NAMESPACE_STD
4141
42#endif // _LIBCPP_HAS_NO_THREADS42#endif // _LIBCPP_HAS_THREADS
4343
44#endif // _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H44#endif // _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H
lib/libcxx/include/__tree+42-38
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__algorithm/min.h>13#include <__algorithm/min.h>
14#include <__assert>14#include <__assert>
15#include <__config>15#include <__config>
16#include <__functional/invoke.h>
17#include <__iterator/distance.h>16#include <__iterator/distance.h>
18#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
19#include <__iterator/next.h>18#include <__iterator/next.h>
...@@ -24,12 +23,12 @@...@@ -24,12 +23,12 @@
24#include <__memory/swap_allocator.h>23#include <__memory/swap_allocator.h>
25#include <__memory/unique_ptr.h>24#include <__memory/unique_ptr.h>
26#include <__type_traits/can_extract_key.h>25#include <__type_traits/can_extract_key.h>
27#include <__type_traits/conditional.h>26#include <__type_traits/enable_if.h>
27#include <__type_traits/invoke.h>
28#include <__type_traits/is_const.h>28#include <__type_traits/is_const.h>
29#include <__type_traits/is_constructible.h>29#include <__type_traits/is_constructible.h>
30#include <__type_traits/is_nothrow_assignable.h>30#include <__type_traits/is_nothrow_assignable.h>
31#include <__type_traits/is_nothrow_constructible.h>31#include <__type_traits/is_nothrow_constructible.h>
32#include <__type_traits/is_pointer.h>
33#include <__type_traits/is_same.h>32#include <__type_traits/is_same.h>
34#include <__type_traits/is_swappable.h>33#include <__type_traits/is_swappable.h>
35#include <__type_traits/remove_const_ref.h>34#include <__type_traits/remove_const_ref.h>
...@@ -566,11 +565,18 @@ struct __tree_node_base_types {...@@ -566,11 +565,18 @@ struct __tree_node_base_types {
566565
567 typedef __tree_end_node<__node_base_pointer> __end_node_type;566 typedef __tree_end_node<__node_base_pointer> __end_node_type;
568 typedef __rebind_pointer_t<_VoidPtr, __end_node_type> __end_node_pointer;567 typedef __rebind_pointer_t<_VoidPtr, __end_node_type> __end_node_pointer;
569#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB)
570 typedef __end_node_pointer __parent_pointer;568 typedef __end_node_pointer __parent_pointer;
571#else569
572 typedef __conditional_t< is_pointer<__end_node_pointer>::value, __end_node_pointer, __node_base_pointer>570// TODO(LLVM 22): Remove this check
573 __parent_pointer;571#ifndef _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
572 static_assert(sizeof(__node_base_pointer) == sizeof(__end_node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) ==
573 _LIBCPP_ALIGNOF(__end_node_pointer),
574 "It looks like you are using std::__tree (an implementation detail for (multi)map/set) with a fancy "
575 "pointer type that thas a different representation depending on whether it points to a __tree base "
576 "pointer or a __tree node pointer (both of which are implementation details of the standard library). "
577 "This means that your ABI is being broken between LLVM 19 and LLVM 20. If you don't care about your "
578 "ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to silence this "
579 "diagnostic.");
574#endif580#endif
575581
576private:582private:
...@@ -605,12 +611,7 @@ public:...@@ -605,12 +611,7 @@ public:
605 typedef _Tp __node_value_type;611 typedef _Tp __node_value_type;
606 typedef __rebind_pointer_t<_VoidPtr, __node_value_type> __node_value_type_pointer;612 typedef __rebind_pointer_t<_VoidPtr, __node_value_type> __node_value_type_pointer;
607 typedef __rebind_pointer_t<_VoidPtr, const __node_value_type> __const_node_value_type_pointer;613 typedef __rebind_pointer_t<_VoidPtr, const __node_value_type> __const_node_value_type_pointer;
608#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB)
609 typedef typename __base::__end_node_pointer __iter_pointer;614 typedef typename __base::__end_node_pointer __iter_pointer;
610#else
611 typedef __conditional_t< is_pointer<__node_pointer>::value, typename __base::__end_node_pointer, __node_pointer>
612 __iter_pointer;
613#endif
614615
615private:616private:
616 static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const");617 static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const");
...@@ -875,7 +876,7 @@ private:...@@ -875,7 +876,7 @@ private:
875876
876template <class _Tp, class _Compare>877template <class _Tp, class _Compare>
877#ifndef _LIBCPP_CXX03_LANG878#ifndef _LIBCPP_CXX03_LANG
878_LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value,879_LIBCPP_DIAGNOSE_WARNING(!__is_invocable_v<_Compare const&, _Tp const&, _Tp const&>,
879 "the specified comparator type does not provide a viable const call operator")880 "the specified comparator type does not provide a viable const call operator")
880#endif881#endif
881int __diagnose_non_const_comparator();882int __diagnose_non_const_comparator();
...@@ -932,21 +933,21 @@ private:...@@ -932,21 +933,21 @@ private:
932933
933private:934private:
934 __iter_pointer __begin_node_;935 __iter_pointer __begin_node_;
935 __compressed_pair<__end_node_t, __node_allocator> __pair1_;936 _LIBCPP_COMPRESSED_PAIR(__end_node_t, __end_node_, __node_allocator, __node_alloc_);
936 __compressed_pair<size_type, value_compare> __pair3_;937 _LIBCPP_COMPRESSED_PAIR(size_type, __size_, value_compare, __value_comp_);
937938
938public:939public:
939 _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() _NOEXCEPT {940 _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() _NOEXCEPT {
940 return static_cast<__iter_pointer>(pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first()));941 return static_cast<__iter_pointer>(pointer_traits<__end_node_ptr>::pointer_to(__end_node_));
941 }942 }
942 _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() const _NOEXCEPT {943 _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() const _NOEXCEPT {
943 return static_cast<__iter_pointer>(944 return static_cast<__iter_pointer>(
944 pointer_traits<__end_node_ptr>::pointer_to(const_cast<__end_node_t&>(__pair1_.first())));945 pointer_traits<__end_node_ptr>::pointer_to(const_cast<__end_node_t&>(__end_node_)));
945 }946 }
946 _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __pair1_.second(); }947 _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; }
947948
948private:949private:
949 _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __pair1_.second(); }950 _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; }
950 _LIBCPP_HIDE_FROM_ABI __iter_pointer& __begin_node() _NOEXCEPT { return __begin_node_; }951 _LIBCPP_HIDE_FROM_ABI __iter_pointer& __begin_node() _NOEXCEPT { return __begin_node_; }
951 _LIBCPP_HIDE_FROM_ABI const __iter_pointer& __begin_node() const _NOEXCEPT { return __begin_node_; }952 _LIBCPP_HIDE_FROM_ABI const __iter_pointer& __begin_node() const _NOEXCEPT { return __begin_node_; }
952953
...@@ -954,12 +955,12 @@ public:...@@ -954,12 +955,12 @@ public:
954 _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); }955 _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); }
955956
956private:957private:
957 _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __pair3_.first(); }958 _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; }
958959
959public:960public:
960 _LIBCPP_HIDE_FROM_ABI const size_type& size() const _NOEXCEPT { return __pair3_.first(); }961 _LIBCPP_HIDE_FROM_ABI const size_type& size() const _NOEXCEPT { return __size_; }
961 _LIBCPP_HIDE_FROM_ABI value_compare& value_comp() _NOEXCEPT { return __pair3_.second(); }962 _LIBCPP_HIDE_FROM_ABI value_compare& value_comp() _NOEXCEPT { return __value_comp_; }
962 _LIBCPP_HIDE_FROM_ABI const value_compare& value_comp() const _NOEXCEPT { return __pair3_.second(); }963 _LIBCPP_HIDE_FROM_ABI const value_compare& value_comp() const _NOEXCEPT { return __value_comp_; }
963964
964public:965public:
965 _LIBCPP_HIDE_FROM_ABI __node_pointer __root() const _NOEXCEPT {966 _LIBCPP_HIDE_FROM_ABI __node_pointer __root() const _NOEXCEPT {
...@@ -1324,21 +1325,19 @@ private:...@@ -1324,21 +1325,19 @@ private:
1324template <class _Tp, class _Compare, class _Allocator>1325template <class _Tp, class _Compare, class _Allocator>
1325__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT_(1326__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT_(
1326 is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value)1327 is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value)
1327 : __pair3_(0, __comp) {1328 : __size_(0), __value_comp_(__comp) {
1328 __begin_node() = __end_node();1329 __begin_node() = __end_node();
1329}1330}
13301331
1331template <class _Tp, class _Compare, class _Allocator>1332template <class _Tp, class _Compare, class _Allocator>
1332__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)1333__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
1333 : __begin_node_(__iter_pointer()),1334 : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0) {
1334 __pair1_(__default_init_tag(), __node_allocator(__a)),
1335 __pair3_(0, __default_init_tag()) {
1336 __begin_node() = __end_node();1335 __begin_node() = __end_node();
1337}1336}
13381337
1339template <class _Tp, class _Compare, class _Allocator>1338template <class _Tp, class _Compare, class _Allocator>
1340__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a)1339__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a)
1341 : __begin_node_(__iter_pointer()), __pair1_(__default_init_tag(), __node_allocator(__a)), __pair3_(0, __comp) {1340 : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) {
1342 __begin_node() = __end_node();1341 __begin_node() = __end_node();
1343}1342}
13441343
...@@ -1437,8 +1436,9 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _...@@ -1437,8 +1436,9 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _
1437template <class _Tp, class _Compare, class _Allocator>1436template <class _Tp, class _Compare, class _Allocator>
1438__tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)1437__tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
1439 : __begin_node_(__iter_pointer()),1438 : __begin_node_(__iter_pointer()),
1440 __pair1_(__default_init_tag(), __node_traits::select_on_container_copy_construction(__t.__node_alloc())),1439 __node_alloc_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())),
1441 __pair3_(0, __t.value_comp()) {1440 __size_(0),
1441 __value_comp_(__t.value_comp()) {
1442 __begin_node() = __end_node();1442 __begin_node() = __end_node();
1443}1443}
14441444
...@@ -1446,8 +1446,10 @@ template <class _Tp, class _Compare, class _Allocator>...@@ -1446,8 +1446,10 @@ template <class _Tp, class _Compare, class _Allocator>
1446__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(1446__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(
1447 is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value)1447 is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value)
1448 : __begin_node_(std::move(__t.__begin_node_)),1448 : __begin_node_(std::move(__t.__begin_node_)),
1449 __pair1_(std::move(__t.__pair1_)),1449 __end_node_(std::move(__t.__end_node_)),
1450 __pair3_(std::move(__t.__pair3_)) {1450 __node_alloc_(std::move(__t.__node_alloc_)),
1451 __size_(__t.__size_),
1452 __value_comp_(std::move(__t.__value_comp_)) {
1451 if (size() == 0)1453 if (size() == 0)
1452 __begin_node() = __end_node();1454 __begin_node() = __end_node();
1453 else {1455 else {
...@@ -1460,7 +1462,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(...@@ -1460,7 +1462,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(
14601462
1461template <class _Tp, class _Compare, class _Allocator>1463template <class _Tp, class _Compare, class _Allocator>
1462__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a)1464__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a)
1463 : __pair1_(__default_init_tag(), __node_allocator(__a)), __pair3_(0, std::move(__t.value_comp())) {1465 : __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(std::move(__t.value_comp())) {
1464 if (__a == __t.__alloc()) {1466 if (__a == __t.__alloc()) {
1465 if (__t.size() == 0)1467 if (__t.size() == 0)
1466 __begin_node() = __end_node();1468 __begin_node() = __end_node();
...@@ -1482,10 +1484,11 @@ template <class _Tp, class _Compare, class _Allocator>...@@ -1482,10 +1484,11 @@ template <class _Tp, class _Compare, class _Allocator>
1482void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)1484void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)
1483 _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value) {1485 _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value) {
1484 destroy(static_cast<__node_pointer>(__end_node()->__left_));1486 destroy(static_cast<__node_pointer>(__end_node()->__left_));
1485 __begin_node_ = __t.__begin_node_;1487 __begin_node_ = __t.__begin_node_;
1486 __pair1_.first() = __t.__pair1_.first();1488 __end_node_ = __t.__end_node_;
1487 __move_assign_alloc(__t);1489 __move_assign_alloc(__t);
1488 __pair3_ = std::move(__t.__pair3_);1490 __size_ = __t.__size_;
1491 __value_comp_ = std::move(__t.__value_comp_);
1489 if (size() == 0)1492 if (size() == 0)
1490 __begin_node() = __end_node();1493 __begin_node() = __end_node();
1491 else {1494 else {
...@@ -1554,9 +1557,10 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)...@@ -1554,9 +1557,10 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
1554{1557{
1555 using std::swap;1558 using std::swap;
1556 swap(__begin_node_, __t.__begin_node_);1559 swap(__begin_node_, __t.__begin_node_);
1557 swap(__pair1_.first(), __t.__pair1_.first());1560 swap(__end_node_, __t.__end_node_);
1558 std::__swap_allocator(__node_alloc(), __t.__node_alloc());1561 std::__swap_allocator(__node_alloc(), __t.__node_alloc());
1559 __pair3_.swap(__t.__pair3_);1562 swap(__size_, __t.__size_);
1563 swap(__value_comp_, __t.__value_comp_);
1560 if (size() == 0)1564 if (size() == 0)
1561 __begin_node() = __end_node();1565 __begin_node() = __end_node();
1562 else1566 else
lib/libcxx/include/__tuple/find_index.h+1-1
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___TUPLE_FIND_INDEX_H10#define _LIBCPP___TUPLE_FIND_INDEX_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__type_traits/is_same.h>14#include <__type_traits/is_same.h>
14#include <cstddef>
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/__tuple/make_tuple_types.h+9-9
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#define _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H10#define _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__fwd/array.h>14#include <__fwd/array.h>
14#include <__fwd/tuple.h>15#include <__fwd/tuple.h>
15#include <__tuple/tuple_element.h>16#include <__tuple/tuple_element.h>
...@@ -17,9 +18,8 @@...@@ -17,9 +18,8 @@
17#include <__tuple/tuple_size.h>18#include <__tuple/tuple_size.h>
18#include <__tuple/tuple_types.h>19#include <__tuple/tuple_types.h>
19#include <__type_traits/copy_cvref.h>20#include <__type_traits/copy_cvref.h>
20#include <__type_traits/remove_cv.h>21#include <__type_traits/remove_cvref.h>
21#include <__type_traits/remove_reference.h>22#include <__type_traits/remove_reference.h>
22#include <cstddef>
2323
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header25# pragma GCC system_header
...@@ -47,9 +47,9 @@ struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {...@@ -47,9 +47,9 @@ struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
47template <class _Vt, size_t _Np, size_t... _Idx>47template <class _Vt, size_t _Np, size_t... _Idx>
48struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {48struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
49 template <size_t>49 template <size_t>
50 using __value_type = _Vt;50 using __value_type _LIBCPP_NODEBUG = _Vt;
51 template <class _Tp>51 template <class _Tp>
52 using __apply_quals = __tuple_types<__copy_cvref_t<_Tp, __value_type<_Idx>>...>;52 using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__copy_cvref_t<_Tp, __value_type<_Idx>>...>;
53};53};
5454
55template <class _Tp,55template <class _Tp,
...@@ -58,19 +58,19 @@ template <class _Tp,...@@ -58,19 +58,19 @@ template <class _Tp,
58 bool _SameSize = (_Ep == tuple_size<__libcpp_remove_reference_t<_Tp> >::value)>58 bool _SameSize = (_Ep == tuple_size<__libcpp_remove_reference_t<_Tp> >::value)>
59struct __make_tuple_types {59struct __make_tuple_types {
60 static_assert(_Sp <= _Ep, "__make_tuple_types input error");60 static_assert(_Sp <= _Ep, "__make_tuple_types input error");
61 using _RawTp = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >;61 using _RawTp _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>;
62 using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;62 using _Maker _LIBCPP_NODEBUG = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
63 using type = typename _Maker::template __apply_quals<_Tp>;63 using type = typename _Maker::template __apply_quals<_Tp>;
64};64};
6565
66template <class... _Types, size_t _Ep>66template <class... _Types, size_t _Ep>
67struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {67struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
68 typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;68 using type _LIBCPP_NODEBUG = __tuple_types<_Types...>;
69};69};
7070
71template <class... _Types, size_t _Ep>71template <class... _Types, size_t _Ep>
72struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {72struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
73 typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;73 using type _LIBCPP_NODEBUG = __tuple_types<_Types...>;
74};74};
7575
76_LIBCPP_END_NAMESPACE_STD76_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__tuple/sfinae_helpers.h+3-3
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#define _LIBCPP___TUPLE_SFINAE_HELPERS_H10#define _LIBCPP___TUPLE_SFINAE_HELPERS_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__fwd/tuple.h>14#include <__fwd/tuple.h>
14#include <__tuple/make_tuple_types.h>15#include <__tuple/make_tuple_types.h>
15#include <__tuple/tuple_element.h>16#include <__tuple/tuple_element.h>
...@@ -23,7 +24,6 @@...@@ -23,7 +24,6 @@
23#include <__type_traits/is_same.h>24#include <__type_traits/is_same.h>
24#include <__type_traits/remove_cvref.h>25#include <__type_traits/remove_cvref.h>
25#include <__type_traits/remove_reference.h>26#include <__type_traits/remove_reference.h>
26#include <cstddef>
2727
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header29# pragma GCC system_header
...@@ -41,7 +41,7 @@ struct __tuple_sfinae_base {...@@ -41,7 +41,7 @@ struct __tuple_sfinae_base {
41 static auto __do_test(...) -> false_type;41 static auto __do_test(...) -> false_type;
4242
43 template <class _FromArgs, class _ToArgs>43 template <class _FromArgs, class _ToArgs>
44 using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));44 using __constructible _LIBCPP_NODEBUG = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
45};45};
4646
47// __tuple_constructible47// __tuple_constructible
...@@ -59,7 +59,7 @@ struct __tuple_constructible<_Tp, _Up, true, true>...@@ -59,7 +59,7 @@ struct __tuple_constructible<_Tp, _Up, true, true>
5959
60template <size_t _Ip, class... _Tp>60template <size_t _Ip, class... _Tp>
61struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> > {61struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> > {
62 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;62 using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, __tuple_types<_Tp...> >::type;
63};63};
6464
65struct _LIBCPP_EXPORTED_FROM_ABI __check_tuple_constructor_fail {65struct _LIBCPP_EXPORTED_FROM_ABI __check_tuple_constructor_fail {
lib/libcxx/include/__tuple/tuple_element.h+5-5
...@@ -10,9 +10,9 @@...@@ -10,9 +10,9 @@
10#define _LIBCPP___TUPLE_TUPLE_ELEMENT_H10#define _LIBCPP___TUPLE_TUPLE_ELEMENT_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__tuple/tuple_indices.h>14#include <__tuple/tuple_indices.h>
14#include <__tuple/tuple_types.h>15#include <__tuple/tuple_types.h>
15#include <cstddef>
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
...@@ -25,17 +25,17 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element;...@@ -25,17 +25,17 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element;
2525
26template <size_t _Ip, class _Tp>26template <size_t _Ip, class _Tp>
27struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> {27struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> {
28 typedef _LIBCPP_NODEBUG const typename tuple_element<_Ip, _Tp>::type type;28 using type _LIBCPP_NODEBUG = const typename tuple_element<_Ip, _Tp>::type;
29};29};
3030
31template <size_t _Ip, class _Tp>31template <size_t _Ip, class _Tp>
32struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> {32struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> {
33 typedef _LIBCPP_NODEBUG volatile typename tuple_element<_Ip, _Tp>::type type;33 using type _LIBCPP_NODEBUG = volatile typename tuple_element<_Ip, _Tp>::type;
34};34};
3535
36template <size_t _Ip, class _Tp>36template <size_t _Ip, class _Tp>
37struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> {37struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> {
38 typedef _LIBCPP_NODEBUG const volatile typename tuple_element<_Ip, _Tp>::type type;38 using type _LIBCPP_NODEBUG = const volatile typename tuple_element<_Ip, _Tp>::type;
39};39};
4040
41#ifndef _LIBCPP_CXX03_LANG41#ifndef _LIBCPP_CXX03_LANG
...@@ -43,7 +43,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> {...@@ -43,7 +43,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> {
43template <size_t _Ip, class... _Types>43template <size_t _Ip, class... _Types>
44struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > {44struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > {
45 static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");45 static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
46 typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type;46 using type _LIBCPP_NODEBUG = __type_pack_element<_Ip, _Types...>;
47};47};
4848
49# if _LIBCPP_STD_VER >= 1449# if _LIBCPP_STD_VER >= 14
lib/libcxx/include/__tuple/tuple_indices.h+1-1
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H10#define _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__utility/integer_sequence.h>14#include <__utility/integer_sequence.h>
14#include <cstddef>
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/__tuple/tuple_like_ext.h+1-1
...@@ -10,12 +10,12 @@...@@ -10,12 +10,12 @@
10#define _LIBCPP___TUPLE_TUPLE_LIKE_EXT_H10#define _LIBCPP___TUPLE_TUPLE_LIKE_EXT_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__fwd/array.h>14#include <__fwd/array.h>
14#include <__fwd/pair.h>15#include <__fwd/pair.h>
15#include <__fwd/tuple.h>16#include <__fwd/tuple.h>
16#include <__tuple/tuple_types.h>17#include <__tuple/tuple_types.h>
17#include <__type_traits/integral_constant.h>18#include <__type_traits/integral_constant.h>
18#include <cstddef>
1919
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header21# pragma GCC system_header
lib/libcxx/include/__tuple/tuple_like_no_subrange.h+1-1
...@@ -10,13 +10,13 @@...@@ -10,13 +10,13 @@
10#define _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H10#define _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__fwd/array.h>14#include <__fwd/array.h>
14#include <__fwd/complex.h>15#include <__fwd/complex.h>
15#include <__fwd/pair.h>16#include <__fwd/pair.h>
16#include <__fwd/tuple.h>17#include <__fwd/tuple.h>
17#include <__tuple/tuple_size.h>18#include <__tuple/tuple_size.h>
18#include <__type_traits/remove_cvref.h>19#include <__type_traits/remove_cvref.h>
19#include <cstddef>
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
lib/libcxx/include/__tuple/tuple_size.h+4-2
...@@ -10,11 +10,13 @@...@@ -10,11 +10,13 @@
10#define _LIBCPP___TUPLE_TUPLE_SIZE_H10#define _LIBCPP___TUPLE_TUPLE_SIZE_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__fwd/tuple.h>14#include <__fwd/tuple.h>
14#include <__tuple/tuple_types.h>15#include <__tuple/tuple_types.h>
16#include <__type_traits/enable_if.h>
17#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_const.h>18#include <__type_traits/is_const.h>
16#include <__type_traits/is_volatile.h>19#include <__type_traits/is_volatile.h>
17#include <cstddef>
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
...@@ -27,7 +29,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size;...@@ -27,7 +29,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size;
2729
28#if !defined(_LIBCPP_CXX03_LANG)30#if !defined(_LIBCPP_CXX03_LANG)
29template <class _Tp, class...>31template <class _Tp, class...>
30using __enable_if_tuple_size_imp = _Tp;32using __enable_if_tuple_size_imp _LIBCPP_NODEBUG = _Tp;
3133
32template <class _Tp>34template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< const _Tp,35struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< const _Tp,
lib/libcxx/include/__type_traits/add_const.h deleted-32
...@@ -1,32 +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___TYPE_TRAITS_ADD_CONST_H
10#define _LIBCPP___TYPE_TRAITS_ADD_CONST_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>
21struct _LIBCPP_TEMPLATE_VIS add_const {
22 typedef _LIBCPP_NODEBUG const _Tp type;
23};
24
25#if _LIBCPP_STD_VER >= 14
26template <class _Tp>
27using add_const_t = typename add_const<_Tp>::type;
28#endif
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_ADD_CONST_H
lib/libcxx/include/__type_traits/add_cv.h deleted-32
...@@ -1,32 +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___TYPE_TRAITS_ADD_CV_H
10#define _LIBCPP___TYPE_TRAITS_ADD_CV_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>
21struct _LIBCPP_TEMPLATE_VIS add_cv {
22 typedef _LIBCPP_NODEBUG const volatile _Tp type;
23};
24
25#if _LIBCPP_STD_VER >= 14
26template <class _Tp>
27using add_cv_t = typename add_cv<_Tp>::type;
28#endif
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_ADD_CV_H
lib/libcxx/include/__type_traits/add_cv_quals.h created+52
...@@ -0,0 +1,52 @@
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_ADD_CV_H
10#define _LIBCPP___TYPE_TRAITS_ADD_CV_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>
21struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_const {
22 using type _LIBCPP_NODEBUG = const _Tp;
23};
24
25#if _LIBCPP_STD_VER >= 14
26template <class _Tp>
27using add_const_t = typename add_const<_Tp>::type;
28#endif
29
30template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_cv {
32 using type _LIBCPP_NODEBUG = const volatile _Tp;
33};
34
35#if _LIBCPP_STD_VER >= 14
36template <class _Tp>
37using add_cv_t = typename add_cv<_Tp>::type;
38#endif
39
40template <class _Tp>
41struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_volatile {
42 using type _LIBCPP_NODEBUG = volatile _Tp;
43};
44
45#if _LIBCPP_STD_VER >= 14
46template <class _Tp>
47using add_volatile_t = typename add_volatile<_Tp>::type;
48#endif
49
50_LIBCPP_END_NAMESPACE_STD
51
52#endif // _LIBCPP___TYPE_TRAITS_ADD_CV_H
lib/libcxx/include/__type_traits/add_lvalue_reference.h+4-4
...@@ -21,17 +21,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,17 +21,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
21#if __has_builtin(__add_lvalue_reference)21#if __has_builtin(__add_lvalue_reference)
2222
23template <class _Tp>23template <class _Tp>
24using __add_lvalue_reference_t = __add_lvalue_reference(_Tp);24using __add_lvalue_reference_t _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp);
2525
26#else26#else
2727
28template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value>28template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value>
29struct __add_lvalue_reference_impl {29struct __add_lvalue_reference_impl {
30 typedef _LIBCPP_NODEBUG _Tp type;30 using type _LIBCPP_NODEBUG = _Tp;
31};31};
32template <class _Tp >32template <class _Tp >
33struct __add_lvalue_reference_impl<_Tp, true> {33struct __add_lvalue_reference_impl<_Tp, true> {
34 typedef _LIBCPP_NODEBUG _Tp& type;34 using type _LIBCPP_NODEBUG = _Tp&;
35};35};
3636
37template <class _Tp>37template <class _Tp>
...@@ -40,7 +40,7 @@ using __add_lvalue_reference_t = typename __add_lvalue_reference_impl<_Tp>::type...@@ -40,7 +40,7 @@ using __add_lvalue_reference_t = typename __add_lvalue_reference_impl<_Tp>::type
40#endif // __has_builtin(__add_lvalue_reference)40#endif // __has_builtin(__add_lvalue_reference)
4141
42template <class _Tp>42template <class _Tp>
43struct add_lvalue_reference {43struct _LIBCPP_NO_SPECIALIZATIONS add_lvalue_reference {
44 using type _LIBCPP_NODEBUG = __add_lvalue_reference_t<_Tp>;44 using type _LIBCPP_NODEBUG = __add_lvalue_reference_t<_Tp>;
45};45};
4646
lib/libcxx/include/__type_traits/add_pointer.h+4-4
...@@ -23,16 +23,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,16 +23,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
23#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)23#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)
2424
25template <class _Tp>25template <class _Tp>
26using __add_pointer_t = __add_pointer(_Tp);26using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp);
2727
28#else28#else
29template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value || is_void<_Tp>::value>29template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value || is_void<_Tp>::value>
30struct __add_pointer_impl {30struct __add_pointer_impl {
31 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp>* type;31 using type _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>*;
32};32};
33template <class _Tp>33template <class _Tp>
34struct __add_pointer_impl<_Tp, false> {34struct __add_pointer_impl<_Tp, false> {
35 typedef _LIBCPP_NODEBUG _Tp type;35 using type _LIBCPP_NODEBUG = _Tp;
36};36};
3737
38template <class _Tp>38template <class _Tp>
...@@ -41,7 +41,7 @@ using __add_pointer_t = typename __add_pointer_impl<_Tp>::type;...@@ -41,7 +41,7 @@ using __add_pointer_t = typename __add_pointer_impl<_Tp>::type;
41#endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)41#endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)
4242
43template <class _Tp>43template <class _Tp>
44struct add_pointer {44struct _LIBCPP_NO_SPECIALIZATIONS add_pointer {
45 using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>;45 using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>;
46};46};
4747
lib/libcxx/include/__type_traits/add_rvalue_reference.h+4-4
...@@ -21,17 +21,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,17 +21,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
21#if __has_builtin(__add_rvalue_reference)21#if __has_builtin(__add_rvalue_reference)
2222
23template <class _Tp>23template <class _Tp>
24using __add_rvalue_reference_t = __add_rvalue_reference(_Tp);24using __add_rvalue_reference_t _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);
2525
26#else26#else
2727
28template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value>28template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value>
29struct __add_rvalue_reference_impl {29struct __add_rvalue_reference_impl {
30 typedef _LIBCPP_NODEBUG _Tp type;30 using type _LIBCPP_NODEBUG = _Tp;
31};31};
32template <class _Tp >32template <class _Tp >
33struct __add_rvalue_reference_impl<_Tp, true> {33struct __add_rvalue_reference_impl<_Tp, true> {
34 typedef _LIBCPP_NODEBUG _Tp&& type;34 using type _LIBCPP_NODEBUG = _Tp&&;
35};35};
3636
37template <class _Tp>37template <class _Tp>
...@@ -40,7 +40,7 @@ using __add_rvalue_reference_t = typename __add_rvalue_reference_impl<_Tp>::type...@@ -40,7 +40,7 @@ using __add_rvalue_reference_t = typename __add_rvalue_reference_impl<_Tp>::type
40#endif // __has_builtin(__add_rvalue_reference)40#endif // __has_builtin(__add_rvalue_reference)
4141
42template <class _Tp>42template <class _Tp>
43struct add_rvalue_reference {43struct _LIBCPP_NO_SPECIALIZATIONS add_rvalue_reference {
44 using type = __add_rvalue_reference_t<_Tp>;44 using type = __add_rvalue_reference_t<_Tp>;
45};45};
4646
lib/libcxx/include/__type_traits/add_volatile.h deleted-32
...@@ -1,32 +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___TYPE_TRAITS_ADD_VOLATILE_H
10#define _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_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>
21struct _LIBCPP_TEMPLATE_VIS add_volatile {
22 typedef _LIBCPP_NODEBUG volatile _Tp type;
23};
24
25#if _LIBCPP_STD_VER >= 14
26template <class _Tp>
27using add_volatile_t = typename add_volatile<_Tp>::type;
28#endif
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H
lib/libcxx/include/__type_traits/aligned_storage.h+21-71
...@@ -10,11 +10,9 @@...@@ -10,11 +10,9 @@
10#define _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H10#define _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/conditional.h>13#include <__cstddef/size_t.h>
14#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
15#include <__type_traits/nat.h>
16#include <__type_traits/type_list.h>15#include <__type_traits/type_list.h>
17#include <cstddef>
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
...@@ -35,42 +33,23 @@ struct __struct_double4 {...@@ -35,42 +33,23 @@ struct __struct_double4 {
35 double __lx[4];33 double __lx[4];
36};34};
3735
38// clang-format off36using __all_types _LIBCPP_NODEBUG =
39typedef __type_list<__align_type<unsigned char>,37 __type_list<__align_type<unsigned char>,
40 __type_list<__align_type<unsigned short>,38 __align_type<unsigned short>,
41 __type_list<__align_type<unsigned int>,39 __align_type<unsigned int>,
42 __type_list<__align_type<unsigned long>,40 __align_type<unsigned long>,
43 __type_list<__align_type<unsigned long long>,41 __align_type<unsigned long long>,
44 __type_list<__align_type<double>,42 __align_type<double>,
45 __type_list<__align_type<long double>,43 __align_type<long double>,
46 __type_list<__align_type<__struct_double>,44 __align_type<__struct_double>,
47 __type_list<__align_type<__struct_double4>,45 __align_type<__struct_double4>,
48 __type_list<__align_type<int*>,46 __align_type<int*> >;
49 __nat
50 > > > > > > > > > > __all_types;
51// clang-format on
52
53template <size_t _Align>
54struct _ALIGNAS(_Align) __fallback_overaligned {};
55
56template <class _TL, size_t _Align>
57struct __find_pod;
58
59template <class _Hp, size_t _Align>
60struct __find_pod<__type_list<_Hp, __nat>, _Align> {
61 typedef __conditional_t<_Align == _Hp::value, typename _Hp::type, __fallback_overaligned<_Align> > type;
62};
63
64template <class _Hp, class _Tp, size_t _Align>
65struct __find_pod<__type_list<_Hp, _Tp>, _Align> {
66 typedef __conditional_t<_Align == _Hp::value, typename _Hp::type, typename __find_pod<_Tp, _Align>::type> type;
67};
6847
69template <class _TL, size_t _Len>48template <class _TL, size_t _Len>
70struct __find_max_align;49struct __find_max_align;
7150
72template <class _Hp, size_t _Len>51template <class _Head, size_t _Len>
73struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};52struct __find_max_align<__type_list<_Head>, _Len> : public integral_constant<size_t, _Head::value> {};
7453
75template <size_t _Len, size_t _A1, size_t _A2>54template <size_t _Len, size_t _A1, size_t _A2>
76struct __select_align {55struct __select_align {
...@@ -82,15 +61,15 @@ public:...@@ -82,15 +61,15 @@ public:
82 static const size_t value = _Len < __max ? __min : __max;61 static const size_t value = _Len < __max ? __min : __max;
83};62};
8463
85template <class _Hp, class _Tp, size_t _Len>64template <class _Head, class... _Tail, size_t _Len>
86struct __find_max_align<__type_list<_Hp, _Tp>, _Len>65struct __find_max_align<__type_list<_Head, _Tail...>, _Len>
87 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};66 : public integral_constant<
67 size_t,
68 __select_align<_Len, _Head::value, __find_max_align<__type_list<_Tail...>, _Len>::value>::value> {};
8869
89template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>70template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
90struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage {71struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS aligned_storage {
91 typedef typename __find_pod<__all_types, _Align>::type _Aligner;72 union _ALIGNAS(_Align) type {
92 union type {
93 _Aligner __align;
94 unsigned char __data[(_Len + _Align - 1) / _Align * _Align];73 unsigned char __data[(_Len + _Align - 1) / _Align * _Align];
95 };74 };
96};75};
...@@ -104,35 +83,6 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -104,35 +83,6 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
10483
105#endif84#endif
10685
107#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
108 template <size_t _Len> \
109 struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n> { \
110 struct _ALIGNAS(n) type { \
111 unsigned char __lx[(_Len + n - 1) / n * n]; \
112 }; \
113 }
114
115_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
116_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
117_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
118_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
119_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
120_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
121_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
122_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
123_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
124_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
125_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
126_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
127_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
128_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
129// PE/COFF does not support alignment beyond 8192 (=0x2000)
130#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
131_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
132#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
133
134#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
135
136_LIBCPP_END_NAMESPACE_STD86_LIBCPP_END_NAMESPACE_STD
13787
138#endif // _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H88#endif // _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H
lib/libcxx/include/__type_traits/aligned_union.h+2-3
...@@ -10,9 +10,8 @@...@@ -10,9 +10,8 @@
10#define _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H10#define _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__type_traits/aligned_storage.h>14#include <__type_traits/aligned_storage.h>
14#include <__type_traits/integral_constant.h>
15#include <cstddef>
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
...@@ -34,7 +33,7 @@ struct __static_max<_I0, _I1, _In...> {...@@ -34,7 +33,7 @@ struct __static_max<_I0, _I1, _In...> {
34};33};
3534
36template <size_t _Len, class _Type0, class... _Types>35template <size_t _Len, class _Type0, class... _Types>
37struct _LIBCPP_DEPRECATED_IN_CXX23 aligned_union {36struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_NO_SPECIALIZATIONS aligned_union {
38 static const size_t alignment_value =37 static const size_t alignment_value =
39 __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;38 __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
40 static const size_t __len = __static_max<_Len, sizeof(_Type0), sizeof(_Types)...>::value;39 static const size_t __len = __static_max<_Len, sizeof(_Type0), sizeof(_Types)...>::value;
lib/libcxx/include/__type_traits/alignment_of.h+4-3
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H10#define _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
14#include <cstddef>
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
...@@ -20,11 +20,12 @@...@@ -20,11 +20,12 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _Tp>22template <class _Tp>
23struct _LIBCPP_TEMPLATE_VIS alignment_of : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};23struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS alignment_of
24 : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
2425
25#if _LIBCPP_STD_VER >= 1726#if _LIBCPP_STD_VER >= 17
26template <class _Tp>27template <class _Tp>
27inline constexpr size_t alignment_of_v = _LIBCPP_ALIGNOF(_Tp);28_LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t alignment_of_v = _LIBCPP_ALIGNOF(_Tp);
28#endif29#endif
2930
30_LIBCPP_END_NAMESPACE_STD31_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/common_reference.h+10-11
...@@ -15,7 +15,6 @@...@@ -15,7 +15,6 @@
15#include <__type_traits/copy_cvref.h>15#include <__type_traits/copy_cvref.h>
16#include <__type_traits/is_convertible.h>16#include <__type_traits/is_convertible.h>
17#include <__type_traits/is_reference.h>17#include <__type_traits/is_reference.h>
18#include <__type_traits/remove_cv.h>
19#include <__type_traits/remove_cvref.h>18#include <__type_traits/remove_cvref.h>
20#include <__type_traits/remove_reference.h>19#include <__type_traits/remove_reference.h>
21#include <__utility/declval.h>20#include <__utility/declval.h>
...@@ -30,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -30,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
30#if _LIBCPP_STD_VER >= 2029#if _LIBCPP_STD_VER >= 20
31// Let COND_RES(X, Y) be:30// Let COND_RES(X, Y) be:
32template <class _Xp, class _Yp>31template <class _Xp, class _Yp>
33using __cond_res = decltype(false ? std::declval<_Xp (&)()>()() : std::declval<_Yp (&)()>()());32using __cond_res _LIBCPP_NODEBUG = decltype(false ? std::declval<_Xp (&)()>()() : std::declval<_Yp (&)()>()());
3433
35// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`34// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`
36// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type35// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type
...@@ -39,7 +38,7 @@ using __cond_res = decltype(false ? std::declval<_Xp (&)()>()() : std::declval<_...@@ -39,7 +38,7 @@ using __cond_res = decltype(false ? std::declval<_Xp (&)()>()() : std::declval<_
39template <class _Tp>38template <class _Tp>
40struct __xref {39struct __xref {
41 template <class _Up>40 template <class _Up>
42 using __apply = __copy_cvref_t<_Tp, _Up>;41 using __apply _LIBCPP_NODEBUG = __copy_cvref_t<_Tp, _Up>;
43};42};
4443
45// Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>,44// Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>,
...@@ -48,10 +47,10 @@ template <class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp =...@@ -48,10 +47,10 @@ template <class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp =
48struct __common_ref;47struct __common_ref;
4948
50template <class _Xp, class _Yp>49template <class _Xp, class _Yp>
51using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type;50using __common_ref_t _LIBCPP_NODEBUG = typename __common_ref<_Xp, _Yp>::__type;
5251
53template <class _Xp, class _Yp>52template <class _Xp, class _Yp>
54using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>;53using __cv_cond_res _LIBCPP_NODEBUG = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>;
5554
56// If A and B are both lvalue reference types, COMMON-REF(A, B) is55// If A and B are both lvalue reference types, COMMON-REF(A, B) is
57// COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type.56// COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type.
...@@ -61,13 +60,13 @@ template <class _Ap, class _Bp, class _Xp, class _Yp>...@@ -61,13 +60,13 @@ template <class _Ap, class _Bp, class _Xp, class _Yp>
61 requires { typename __cv_cond_res<_Xp, _Yp>; } &&60 requires { typename __cv_cond_res<_Xp, _Yp>; } &&
62 is_reference_v<__cv_cond_res<_Xp, _Yp>>61 is_reference_v<__cv_cond_res<_Xp, _Yp>>
63struct __common_ref<_Ap&, _Bp&, _Xp, _Yp> {62struct __common_ref<_Ap&, _Bp&, _Xp, _Yp> {
64 using __type = __cv_cond_res<_Xp, _Yp>;63 using __type _LIBCPP_NODEBUG = __cv_cond_res<_Xp, _Yp>;
65};64};
66// clang-format on65// clang-format on
6766
68// Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ...67// Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ...
69template <class _Xp, class _Yp>68template <class _Xp, class _Yp>
70using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&;69using __common_ref_C _LIBCPP_NODEBUG = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&;
7170
72// .... If A and B are both rvalue reference types, C is well-formed, and71// .... If A and B are both rvalue reference types, C is well-formed, and
73// is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C.72// is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C.
...@@ -78,13 +77,13 @@ template <class _Ap, class _Bp, class _Xp, class _Yp>...@@ -78,13 +77,13 @@ template <class _Ap, class _Bp, class _Xp, class _Yp>
78 is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> &&77 is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> &&
79 is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>>78 is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>>
80struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp> {79struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp> {
81 using __type = __common_ref_C<_Xp, _Yp>;80 using __type _LIBCPP_NODEBUG = __common_ref_C<_Xp, _Yp>;
82};81};
83// clang-format on82// clang-format on
8483
85// Otherwise, let D be COMMON-REF(const X&, Y&). ...84// Otherwise, let D be COMMON-REF(const X&, Y&). ...
86template <class _Tp, class _Up>85template <class _Tp, class _Up>
87using __common_ref_D = __common_ref_t<const _Tp&, _Up&>;86using __common_ref_D _LIBCPP_NODEBUG = __common_ref_t<const _Tp&, _Up&>;
8887
89// ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and88// ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and
90// is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D.89// is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D.
...@@ -94,7 +93,7 @@ template <class _Ap, class _Bp, class _Xp, class _Yp>...@@ -94,7 +93,7 @@ template <class _Ap, class _Bp, class _Xp, class _Yp>
94 requires { typename __common_ref_D<_Xp, _Yp>; } &&93 requires { typename __common_ref_D<_Xp, _Yp>; } &&
95 is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>>94 is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>>
96struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp> {95struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp> {
97 using __type = __common_ref_D<_Xp, _Yp>;96 using __type _LIBCPP_NODEBUG = __common_ref_D<_Xp, _Yp>;
98};97};
99// clang-format on98// clang-format on
10099
...@@ -150,7 +149,7 @@ template <class, class, template <class> class, template <class> class>...@@ -150,7 +149,7 @@ template <class, class, template <class> class, template <class> class>
150struct basic_common_reference {};149struct basic_common_reference {};
151150
152template <class _Tp, class _Up>151template <class _Tp, class _Up>
153using __basic_common_reference_t =152using __basic_common_reference_t _LIBCPP_NODEBUG =
154 typename basic_common_reference<remove_cvref_t<_Tp>,153 typename basic_common_reference<remove_cvref_t<_Tp>,
155 remove_cvref_t<_Up>,154 remove_cvref_t<_Up>,
156 __xref<_Tp>::template __apply,155 __xref<_Tp>::template __apply,
lib/libcxx/include/__type_traits/common_type.h+21-5
...@@ -14,8 +14,10 @@...@@ -14,8 +14,10 @@
14#include <__type_traits/decay.h>14#include <__type_traits/decay.h>
15#include <__type_traits/is_same.h>15#include <__type_traits/is_same.h>
16#include <__type_traits/remove_cvref.h>16#include <__type_traits/remove_cvref.h>
17#include <__type_traits/type_identity.h>
17#include <__type_traits/void_t.h>18#include <__type_traits/void_t.h>
18#include <__utility/declval.h>19#include <__utility/declval.h>
20#include <__utility/empty.h>
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
...@@ -23,10 +25,22 @@...@@ -23,10 +25,22 @@
2325
24_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2527
26#if _LIBCPP_STD_VER >= 2028#if __has_builtin(__builtin_common_type)
29
30template <class... _Args>
31struct common_type;
32
33template <class... _Args>
34using __common_type_t _LIBCPP_NODEBUG = typename common_type<_Args...>::type;
35
36template <class... _Args>
37struct common_type : __builtin_common_type<__common_type_t, __type_identity, __empty, _Args...> {};
38
39#else
40# if _LIBCPP_STD_VER >= 20
27// Let COND_RES(X, Y) be:41// Let COND_RES(X, Y) be:
28template <class _Tp, class _Up>42template <class _Tp, class _Up>
29using __cond_type = decltype(false ? std::declval<_Tp>() : std::declval<_Up>());43using __cond_type _LIBCPP_NODEBUG = decltype(false ? std::declval<_Tp>() : std::declval<_Up>());
3044
31template <class _Tp, class _Up, class = void>45template <class _Tp, class _Up, class = void>
32struct __common_type3 {};46struct __common_type3 {};
...@@ -39,15 +53,15 @@ struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> {...@@ -39,15 +53,15 @@ struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> {
3953
40template <class _Tp, class _Up, class = void>54template <class _Tp, class _Up, class = void>
41struct __common_type2_imp : __common_type3<_Tp, _Up> {};55struct __common_type2_imp : __common_type3<_Tp, _Up> {};
42#else56# else
43template <class _Tp, class _Up, class = void>57template <class _Tp, class _Up, class = void>
44struct __common_type2_imp {};58struct __common_type2_imp {};
45#endif59# endif
4660
47// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."61// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
48template <class _Tp, class _Up>62template <class _Tp, class _Up>
49struct __common_type2_imp<_Tp, _Up, __void_t<decltype(true ? std::declval<_Tp>() : std::declval<_Up>())> > {63struct __common_type2_imp<_Tp, _Up, __void_t<decltype(true ? std::declval<_Tp>() : std::declval<_Up>())> > {
50 typedef _LIBCPP_NODEBUG __decay_t<decltype(true ? std::declval<_Tp>() : std::declval<_Up>())> type;64 using type _LIBCPP_NODEBUG = __decay_t<decltype(true ? std::declval<_Tp>() : std::declval<_Up>())>;
51};65};
5266
53template <class, class = void>67template <class, class = void>
...@@ -92,6 +106,8 @@ template <class _Tp, class _Up, class _Vp, class... _Rest>...@@ -92,6 +106,8 @@ template <class _Tp, class _Up, class _Vp, class... _Rest>
92struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp, _Rest...>106struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp, _Rest...>
93 : __common_type_impl<__common_types<_Tp, _Up, _Vp, _Rest...> > {};107 : __common_type_impl<__common_types<_Tp, _Up, _Vp, _Rest...> > {};
94108
109#endif
110
95#if _LIBCPP_STD_VER >= 14111#if _LIBCPP_STD_VER >= 14
96template <class... _Tp>112template <class... _Tp>
97using common_type_t = typename common_type<_Tp...>::type;113using common_type_t = typename common_type<_Tp...>::type;
lib/libcxx/include/__type_traits/conditional.h+7-1
...@@ -36,13 +36,19 @@ template <bool _Cond, class _IfRes, class _ElseRes>...@@ -36,13 +36,19 @@ 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>
39struct _LIBCPP_TEMPLATE_VIS conditional {39struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS conditional {
40 using type _LIBCPP_NODEBUG = _If;40 using type _LIBCPP_NODEBUG = _If;
41};41};
42
43_LIBCPP_DIAGNOSTIC_PUSH
44#if __has_warning("-Winvalid-specialization")
45_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
46#endif
42template <class _If, class _Then>47template <class _If, class _Then>
43struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {48struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {
44 using type _LIBCPP_NODEBUG = _Then;49 using type _LIBCPP_NODEBUG = _Then;
45};50};
51_LIBCPP_DIAGNOSTIC_POP
4652
47#if _LIBCPP_STD_VER >= 1453#if _LIBCPP_STD_VER >= 14
48template <bool _Bp, class _IfRes, class _ElseRes>54template <bool _Bp, class _IfRes, class _ElseRes>
lib/libcxx/include/__type_traits/conjunction.h+8-3
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class...>24template <class...>
25using __expand_to_true = true_type;25using __expand_to_true _LIBCPP_NODEBUG = true_type;
2626
27template <class... _Pred>27template <class... _Pred>
28__expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);28__expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
...@@ -47,16 +47,21 @@ struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)......@@ -47,16 +47,21 @@ struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...
47#if _LIBCPP_STD_VER >= 1747#if _LIBCPP_STD_VER >= 17
4848
49template <class...>49template <class...>
50struct conjunction : true_type {};50struct _LIBCPP_NO_SPECIALIZATIONS conjunction : true_type {};
5151
52_LIBCPP_DIAGNOSTIC_PUSH
53# if __has_warning("-Winvalid-specialization")
54_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
55# endif
52template <class _Arg>56template <class _Arg>
53struct conjunction<_Arg> : _Arg {};57struct conjunction<_Arg> : _Arg {};
5458
55template <class _Arg, class... _Args>59template <class _Arg, class... _Args>
56struct conjunction<_Arg, _Args...> : conditional_t<!bool(_Arg::value), _Arg, conjunction<_Args...>> {};60struct conjunction<_Arg, _Args...> : conditional_t<!bool(_Arg::value), _Arg, conjunction<_Args...>> {};
61_LIBCPP_DIAGNOSTIC_POP
5762
58template <class... _Args>63template <class... _Args>
59inline constexpr bool conjunction_v = conjunction<_Args...>::value;64_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool conjunction_v = conjunction<_Args...>::value;
6065
61#endif // _LIBCPP_STD_VER >= 1766#endif // _LIBCPP_STD_VER >= 17
6267
lib/libcxx/include/__type_traits/container_traits.h created+43
...@@ -0,0 +1,43 @@
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_CONTAINER_TRAITS_H
11#define _LIBCPP___TYPE_TRAITS_CONTAINER_TRAITS_H
12
13#include <__config>
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// // __container_traits is a general purpose utility containing traits describing various containers operations.
22// It currently only has one trait: `__emplacement_has_strong_exception_safety_guarantee`, but it's
23// intended to be extended in the future.
24//
25// These traits should only be used for optimization or QoI purposes. In particular, since this is a libc++ internal
26// mechanism, no user-defined containers should be expected to specialize these traits (in fact it would be illegal for
27// them to do so). Hence, when using these traits to implement something, make sure that a container that fails to
28// specialize these traits does not result in non-conforming code.
29//
30// When a trait is nonsensical for a type, this class still provides a fallback value for that trait.
31// For example, `std::array` does not support `insert` or `emplace`, so
32// `__emplacement_has_strong_exception_safety_guarantee` is false for such types.
33template <class _Container>
34struct __container_traits {
35 // A trait that tells whether a single element insertion/emplacement via member function
36 // `insert(...)` or `emplace(...)` has strong exception guarantee, that is, if the function
37 // exits via an exception, the original container is unaffected
38 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = false;
39};
40
41_LIBCPP_END_NAMESPACE_STD
42
43#endif // _LIBCPP___TYPE_TRAITS_CONTAINER_TRAITS_H
lib/libcxx/include/__type_traits/copy_cv.h+5-5
...@@ -22,29 +22,29 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,29 +22,29 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22template <class _From>22template <class _From>
23struct __copy_cv {23struct __copy_cv {
24 template <class _To>24 template <class _To>
25 using __apply = _To;25 using __apply _LIBCPP_NODEBUG = _To;
26};26};
2727
28template <class _From>28template <class _From>
29struct __copy_cv<const _From> {29struct __copy_cv<const _From> {
30 template <class _To>30 template <class _To>
31 using __apply = const _To;31 using __apply _LIBCPP_NODEBUG = const _To;
32};32};
3333
34template <class _From>34template <class _From>
35struct __copy_cv<volatile _From> {35struct __copy_cv<volatile _From> {
36 template <class _To>36 template <class _To>
37 using __apply = volatile _To;37 using __apply _LIBCPP_NODEBUG = volatile _To;
38};38};
3939
40template <class _From>40template <class _From>
41struct __copy_cv<const volatile _From> {41struct __copy_cv<const volatile _From> {
42 template <class _To>42 template <class _To>
43 using __apply = const volatile _To;43 using __apply _LIBCPP_NODEBUG = const volatile _To;
44};44};
4545
46template <class _From, class _To>46template <class _From, class _To>
47using __copy_cv_t = typename __copy_cv<_From>::template __apply<_To>;47using __copy_cv_t _LIBCPP_NODEBUG = typename __copy_cv<_From>::template __apply<_To>;
4848
49_LIBCPP_END_NAMESPACE_STD49_LIBCPP_END_NAMESPACE_STD
5050
lib/libcxx/include/__type_traits/copy_cvref.h+12-9
...@@ -20,23 +20,26 @@...@@ -20,23 +20,26 @@
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _From, class _To>23template <class _From>
24struct __copy_cvref {24struct __copy_cvref {
25 using type = __copy_cv_t<_From, _To>;25 template <class _To>
26 using __apply _LIBCPP_NODEBUG = __copy_cv_t<_From, _To>;
26};27};
2728
28template <class _From, class _To>29template <class _From>
29struct __copy_cvref<_From&, _To> {30struct __copy_cvref<_From&> {
30 using type = __add_lvalue_reference_t<__copy_cv_t<_From, _To> >;31 template <class _To>
32 using __apply _LIBCPP_NODEBUG = __add_lvalue_reference_t<__copy_cv_t<_From, _To> >;
31};33};
3234
33template <class _From, class _To>35template <class _From>
34struct __copy_cvref<_From&&, _To> {36struct __copy_cvref<_From&&> {
35 using type = __add_rvalue_reference_t<__copy_cv_t<_From, _To> >;37 template <class _To>
38 using __apply _LIBCPP_NODEBUG = __add_rvalue_reference_t<__copy_cv_t<_From, _To> >;
36};39};
3740
38template <class _From, class _To>41template <class _From, class _To>
39using __copy_cvref_t = typename __copy_cvref<_From, _To>::type;42using __copy_cvref_t _LIBCPP_NODEBUG = typename __copy_cvref<_From>::template __apply<_To>;
4043
41_LIBCPP_END_NAMESPACE_STD44_LIBCPP_END_NAMESPACE_STD
4245
lib/libcxx/include/__type_traits/datasizeof.h+8-23
...@@ -10,9 +10,7 @@...@@ -10,9 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_DATASIZEOF_H10#define _LIBCPP___TYPE_TRAITS_DATASIZEOF_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/is_class.h>13#include <__cstddef/size_t.h>
14#include <__type_traits/is_final.h>
15#include <cstddef>
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
...@@ -26,39 +24,26 @@...@@ -26,39 +24,26 @@
2624
27_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2826
29#if __has_keyword(__datasizeof) || __has_extension(datasizeof)27// TODO: Enable this again once #94816 is fixed.
28#if (__has_keyword(__datasizeof) || __has_extension(datasizeof)) && 0
30template <class _Tp>29template <class _Tp>
31inline const size_t __datasizeof_v = __datasizeof(_Tp);30inline const size_t __datasizeof_v = __datasizeof(_Tp);
32#else31#else
33// NOLINTNEXTLINE(readability-redundant-preprocessor) This is https://llvm.org/PR64825
34# if __has_cpp_attribute(__no_unique_address__)
35template <class _Tp>32template <class _Tp>
36struct _FirstPaddingByte {33struct _FirstPaddingByte {
37 [[__no_unique_address__]] _Tp __v_;34 _LIBCPP_NO_UNIQUE_ADDRESS _Tp __v_;
38 char __first_padding_byte_;35 char __first_padding_byte_;
39};36};
40# else
41template <class _Tp, bool = __libcpp_is_final<_Tp>::value || !is_class<_Tp>::value>
42struct _FirstPaddingByte : _Tp {
43 char __first_padding_byte_;
44};
45
46template <class _Tp>
47struct _FirstPaddingByte<_Tp, true> {
48 _Tp __v_;
49 char __first_padding_byte_;
50};
51# endif // __has_cpp_attribute(__no_unique_address__)
5237
53// _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is UB in that case, but GCC and Clang allow38// _FirstPaddingByte<> is sometimes non-standard layout.
54// the use as an extension.39// It is conditionally-supported to use __builtin_offsetof in that case, but GCC and Clang allow it.
55_LIBCPP_DIAGNOSTIC_PUSH40_LIBCPP_DIAGNOSTIC_PUSH
56_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")41_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")
57_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")42_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")
58template <class _Tp>43template <class _Tp>
59inline const size_t __datasizeof_v = offsetof(_FirstPaddingByte<_Tp>, __first_padding_byte_);44inline const size_t __datasizeof_v = __builtin_offsetof(_FirstPaddingByte<_Tp>, __first_padding_byte_);
60_LIBCPP_DIAGNOSTIC_POP45_LIBCPP_DIAGNOSTIC_POP
61#endif // __has_extension(datasizeof)46#endif // __has_extension(datasizeof)
6247
63_LIBCPP_END_NAMESPACE_STD48_LIBCPP_END_NAMESPACE_STD
6449
lib/libcxx/include/__type_traits/decay.h+6-7
...@@ -30,33 +30,32 @@ template <class _Tp>...@@ -30,33 +30,32 @@ template <class _Tp>
30using __decay_t _LIBCPP_NODEBUG = __decay(_Tp);30using __decay_t _LIBCPP_NODEBUG = __decay(_Tp);
3131
32template <class _Tp>32template <class _Tp>
33struct decay {33struct _LIBCPP_NO_SPECIALIZATIONS decay {
34 using type _LIBCPP_NODEBUG = __decay_t<_Tp>;34 using type _LIBCPP_NODEBUG = __decay_t<_Tp>;
35};35};
3636
37#else37#else
38template <class _Up, bool>38template <class _Up, bool>
39struct __decay {39struct __decay {
40 typedef _LIBCPP_NODEBUG __remove_cv_t<_Up> type;40 using type _LIBCPP_NODEBUG = __remove_cv_t<_Up>;
41};41};
4242
43template <class _Up>43template <class _Up>
44struct __decay<_Up, true> {44struct __decay<_Up, true> {
45public:45public:
46 typedef _LIBCPP_NODEBUG46 using type _LIBCPP_NODEBUG =
47 __conditional_t<is_array<_Up>::value,47 __conditional_t<is_array<_Up>::value,
48 __add_pointer_t<__remove_extent_t<_Up> >,48 __add_pointer_t<__remove_extent_t<_Up> >,
49 __conditional_t<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> > >49 __conditional_t<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> > >;
50 type;
51};50};
5251
53template <class _Tp>52template <class _Tp>
54struct _LIBCPP_TEMPLATE_VIS decay {53struct _LIBCPP_TEMPLATE_VIS decay {
55private:54private:
56 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up;55 using _Up _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>;
5756
58public:57public:
59 typedef _LIBCPP_NODEBUG typename __decay<_Up, __libcpp_is_referenceable<_Up>::value>::type type;58 using type _LIBCPP_NODEBUG = typename __decay<_Up, __libcpp_is_referenceable<_Up>::value>::type;
60};59};
6160
62template <class _Tp>61template <class _Tp>
lib/libcxx/include/__type_traits/desugars_to.h+18-1
...@@ -17,11 +17,28 @@...@@ -17,11 +17,28 @@
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20// Tags to represent the canonical operations20// Tags to represent the canonical operations.
21
22// syntactically, the operation is equivalent to calling `a == b`
21struct __equal_tag {};23struct __equal_tag {};
24
25// syntactically, the operation is equivalent to calling `a + b`
22struct __plus_tag {};26struct __plus_tag {};
27
28// syntactically, the operation is equivalent to calling `a < b`
23struct __less_tag {};29struct __less_tag {};
2430
31// syntactically, the operation is equivalent to calling `a > b`
32struct __greater_tag {};
33
34// syntactically, the operation is equivalent to calling `a < b`, and these expressions
35// have to be true for any `a` and `b`:
36// - `(a < b) == (b > a)`
37// - `(!(a < b) && !(b < a)) == (a == b)`
38// For example, this is satisfied for std::less on integral types, but also for ranges::less on all types due to
39// additional semantic requirements on that operation.
40struct __totally_ordered_less_tag {};
41
25// This class template is used to determine whether an operation "desugars"42// This class template is used to determine whether an operation "desugars"
26// (or boils down) to a given canonical operation.43// (or boils down) to a given canonical operation.
27//44//
lib/libcxx/include/__type_traits/detected_or.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_TRAITS_DETECTED_OR_H
10#define _LIBCPP___TYPE_TRAITS_DETECTED_OR_H
11
12#include <__config>
13#include <__type_traits/void_t.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 _Default, class _Void, template <class...> class _Op, class... _Args>
22struct __detector {
23 using type _LIBCPP_NODEBUG = _Default;
24};
25
26template <class _Default, template <class...> class _Op, class... _Args>
27struct __detector<_Default, __void_t<_Op<_Args...> >, _Op, _Args...> {
28 using type _LIBCPP_NODEBUG = _Op<_Args...>;
29};
30
31template <class _Default, template <class...> class _Op, class... _Args>
32using __detected_or_t _LIBCPP_NODEBUG = typename __detector<_Default, void, _Op, _Args...>::type;
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_DETECTED_OR_H
lib/libcxx/include/__type_traits/disjunction.h+3-3
...@@ -31,7 +31,7 @@ struct _OrImpl<true> {...@@ -31,7 +31,7 @@ struct _OrImpl<true> {
31template <>31template <>
32struct _OrImpl<false> {32struct _OrImpl<false> {
33 template <class _Res, class...>33 template <class _Res, class...>
34 using _Result = _Res;34 using _Result _LIBCPP_NODEBUG = _Res;
35};35};
3636
37// _Or always performs lazy evaluation of its arguments.37// _Or always performs lazy evaluation of its arguments.
...@@ -46,10 +46,10 @@ using _Or _LIBCPP_NODEBUG = typename _OrImpl<sizeof...(_Args) != 0>::template _R...@@ -46,10 +46,10 @@ using _Or _LIBCPP_NODEBUG = typename _OrImpl<sizeof...(_Args) != 0>::template _R
46#if _LIBCPP_STD_VER >= 1746#if _LIBCPP_STD_VER >= 17
4747
48template <class... _Args>48template <class... _Args>
49struct disjunction : _Or<_Args...> {};49struct _LIBCPP_NO_SPECIALIZATIONS disjunction : _Or<_Args...> {};
5050
51template <class... _Args>51template <class... _Args>
52inline constexpr bool disjunction_v = _Or<_Args...>::value;52_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool disjunction_v = _Or<_Args...>::value;
5353
54#endif // _LIBCPP_STD_VER >= 1754#endif // _LIBCPP_STD_VER >= 17
5555
lib/libcxx/include/__type_traits/enable_if.h+7-1
...@@ -18,11 +18,17 @@...@@ -18,11 +18,17 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <bool, class _Tp = void>20template <bool, class _Tp = void>
21struct _LIBCPP_TEMPLATE_VIS enable_if {};21struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS enable_if{};
22
23_LIBCPP_DIAGNOSTIC_PUSH
24#if __has_warning("-Winvalid-specialization")
25_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
26#endif
22template <class _Tp>27template <class _Tp>
23struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {28struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {
24 typedef _Tp type;29 typedef _Tp type;
25};30};
31_LIBCPP_DIAGNOSTIC_POP
2632
27template <bool _Bp, class _Tp = void>33template <bool _Bp, class _Tp = void>
28using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type;34using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type;
lib/libcxx/include/__type_traits/extent.h+3-3
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___TYPE_TRAITS_EXTENT_H10#define _LIBCPP___TYPE_TRAITS_EXTENT_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
14#include <cstddef>
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
...@@ -22,11 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,11 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if __has_builtin(__array_extent)22#if __has_builtin(__array_extent)
2323
24template <class _Tp, size_t _Dim = 0>24template <class _Tp, size_t _Dim = 0>
25struct _LIBCPP_TEMPLATE_VIS extent : integral_constant<size_t, __array_extent(_Tp, _Dim)> {};25struct _LIBCPP_NO_SPECIALIZATIONS _LIBCPP_TEMPLATE_VIS extent : integral_constant<size_t, __array_extent(_Tp, _Dim)> {};
2626
27# if _LIBCPP_STD_VER >= 1727# if _LIBCPP_STD_VER >= 17
28template <class _Tp, unsigned _Ip = 0>28template <class _Tp, unsigned _Ip = 0>
29inline constexpr size_t extent_v = __array_extent(_Tp, _Ip);29_LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t extent_v = __array_extent(_Tp, _Ip);
30# endif30# endif
3131
32#else // __has_builtin(__array_extent)32#else // __has_builtin(__array_extent)
lib/libcxx/include/__type_traits/has_unique_object_representation.h+3-2
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if _LIBCPP_STD_VER >= 1722#if _LIBCPP_STD_VER >= 17
2323
24template <class _Tp>24template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations25struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS has_unique_object_representations
26 // TODO: We work around a Clang and GCC bug in __has_unique_object_representations by using remove_all_extents26 // TODO: We work around a Clang and GCC bug in __has_unique_object_representations by using remove_all_extents
27 // even though it should not be necessary. This was reported to the compilers:27 // even though it should not be necessary. This was reported to the compilers:
28 // - Clang: https://github.com/llvm/llvm-project/issues/9531128 // - Clang: https://github.com/llvm/llvm-project/issues/95311
...@@ -31,7 +31,8 @@ struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations...@@ -31,7 +31,8 @@ struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
31 : public integral_constant<bool, __has_unique_object_representations(remove_all_extents_t<_Tp>)> {};31 : public integral_constant<bool, __has_unique_object_representations(remove_all_extents_t<_Tp>)> {};
3232
33template <class _Tp>33template <class _Tp>
34inline constexpr bool has_unique_object_representations_v = __has_unique_object_representations(_Tp);34_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool has_unique_object_representations_v =
35 __has_unique_object_representations(_Tp);
3536
36#endif37#endif
3738
lib/libcxx/include/__type_traits/has_virtual_destructor.h+3-2
...@@ -19,11 +19,12 @@...@@ -19,11 +19,12 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS has_virtual_destructor
23 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
2324
24#if _LIBCPP_STD_VER >= 1725#if _LIBCPP_STD_VER >= 17
25template <class _Tp>26template <class _Tp>
26inline constexpr bool has_virtual_destructor_v = __has_virtual_destructor(_Tp);27_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool has_virtual_destructor_v = __has_virtual_destructor(_Tp);
27#endif28#endif
2829
29_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/integral_constant.h+2-5
...@@ -18,8 +18,8 @@...@@ -18,8 +18,8 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _Tp, _Tp __v>20template <class _Tp, _Tp __v>
21struct _LIBCPP_TEMPLATE_VIS integral_constant {21struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS integral_constant {
22 static _LIBCPP_CONSTEXPR const _Tp value = __v;22 static inline _LIBCPP_CONSTEXPR const _Tp value = __v;
23 typedef _Tp value_type;23 typedef _Tp value_type;
24 typedef integral_constant type;24 typedef integral_constant type;
25 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT { return value; }25 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT { return value; }
...@@ -28,9 +28,6 @@ struct _LIBCPP_TEMPLATE_VIS integral_constant {...@@ -28,9 +28,6 @@ struct _LIBCPP_TEMPLATE_VIS integral_constant {
28#endif28#endif
29};29};
3030
31template <class _Tp, _Tp __v>
32_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
33
34typedef integral_constant<bool, true> true_type;31typedef integral_constant<bool, true> true_type;
35typedef integral_constant<bool, false> false_type;32typedef integral_constant<bool, false> false_type;
3633
lib/libcxx/include/__type_traits/invoke.h+75-25
...@@ -29,6 +29,36 @@...@@ -29,6 +29,36 @@
29# pragma GCC system_header29# pragma GCC system_header
30#endif30#endif
3131
32// This file defines the following libc++-internal API (back-ported to C++03):
33//
34// template <class... Args>
35// decltype(auto) __invoke(Args&&... args) noexcept(noexcept(std::invoke(std::forward<Args>(args...)))) {
36// return std::invoke(std::forward<Args>(args)...);
37// }
38//
39// template <class Ret, class... Args>
40// Ret __invoke_r(Args&&... args) {
41// return std::invoke_r(std::forward<Args>(args)...);
42// }
43//
44// template <class Ret, class Func, class... Args>
45// inline const bool __is_invocable_r_v = is_invocable_r_v<Ret, Func, Args...>;
46//
47// template <class Func, class... Args>
48// struct __is_invocable : is_invocable<Func, Args...> {};
49//
50// template <class Func, class... Args>
51// inline const bool __is_invocable_v = is_invocable_v<Func, Args...>;
52//
53// template <class Func, class... Args>
54// inline const bool __is_nothrow_invocable_v = is_nothrow_invocable_v<Func, Args...>;
55//
56// template <class Func, class... Args>
57// struct __invoke_result : invoke_result {};
58//
59// template <class Func, class... Args>
60// using __invoke_result_t = invoke_result_t<Func, Args...>;
61
32_LIBCPP_BEGIN_NAMESPACE_STD62_LIBCPP_BEGIN_NAMESPACE_STD
3363
34template <class _DecayedFp>64template <class _DecayedFp>
...@@ -44,12 +74,12 @@ template <class _Fp,...@@ -44,12 +74,12 @@ template <class _Fp,
44 class _DecayFp = __decay_t<_Fp>,74 class _DecayFp = __decay_t<_Fp>,
45 class _DecayA0 = __decay_t<_A0>,75 class _DecayA0 = __decay_t<_A0>,
46 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>76 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
47using __enable_if_bullet1 =77using __enable_if_bullet1 _LIBCPP_NODEBUG =
48 __enable_if_t<is_member_function_pointer<_DecayFp>::value &&78 __enable_if_t<is_member_function_pointer<_DecayFp>::value &&
49 (is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value)>;79 (is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value)>;
5080
51template <class _Fp, class _A0, class _DecayFp = __decay_t<_Fp>, class _DecayA0 = __decay_t<_A0> >81template <class _Fp, class _A0, class _DecayFp = __decay_t<_Fp>, class _DecayA0 = __decay_t<_A0> >
52using __enable_if_bullet2 =82using __enable_if_bullet2 _LIBCPP_NODEBUG =
53 __enable_if_t<is_member_function_pointer<_DecayFp>::value && __is_reference_wrapper<_DecayA0>::value>;83 __enable_if_t<is_member_function_pointer<_DecayFp>::value && __is_reference_wrapper<_DecayA0>::value>;
5484
55template <class _Fp,85template <class _Fp,
...@@ -57,7 +87,7 @@ template <class _Fp,...@@ -57,7 +87,7 @@ template <class _Fp,
57 class _DecayFp = __decay_t<_Fp>,87 class _DecayFp = __decay_t<_Fp>,
58 class _DecayA0 = __decay_t<_A0>,88 class _DecayA0 = __decay_t<_A0>,
59 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>89 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
60using __enable_if_bullet3 =90using __enable_if_bullet3 _LIBCPP_NODEBUG =
61 __enable_if_t<is_member_function_pointer<_DecayFp>::value &&91 __enable_if_t<is_member_function_pointer<_DecayFp>::value &&
62 !(is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value) &&92 !(is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value) &&
63 !__is_reference_wrapper<_DecayA0>::value>;93 !__is_reference_wrapper<_DecayA0>::value>;
...@@ -67,12 +97,12 @@ template <class _Fp,...@@ -67,12 +97,12 @@ template <class _Fp,
67 class _DecayFp = __decay_t<_Fp>,97 class _DecayFp = __decay_t<_Fp>,
68 class _DecayA0 = __decay_t<_A0>,98 class _DecayA0 = __decay_t<_A0>,
69 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>99 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
70using __enable_if_bullet4 =100using __enable_if_bullet4 _LIBCPP_NODEBUG =
71 __enable_if_t<is_member_object_pointer<_DecayFp>::value &&101 __enable_if_t<is_member_object_pointer<_DecayFp>::value &&
72 (is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value)>;102 (is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value)>;
73103
74template <class _Fp, class _A0, class _DecayFp = __decay_t<_Fp>, class _DecayA0 = __decay_t<_A0> >104template <class _Fp, class _A0, class _DecayFp = __decay_t<_Fp>, class _DecayA0 = __decay_t<_A0> >
75using __enable_if_bullet5 =105using __enable_if_bullet5 _LIBCPP_NODEBUG =
76 __enable_if_t<is_member_object_pointer<_DecayFp>::value && __is_reference_wrapper<_DecayA0>::value>;106 __enable_if_t<is_member_object_pointer<_DecayFp>::value && __is_reference_wrapper<_DecayA0>::value>;
77107
78template <class _Fp,108template <class _Fp,
...@@ -80,7 +110,7 @@ template <class _Fp,...@@ -80,7 +110,7 @@ template <class _Fp,
80 class _DecayFp = __decay_t<_Fp>,110 class _DecayFp = __decay_t<_Fp>,
81 class _DecayA0 = __decay_t<_A0>,111 class _DecayA0 = __decay_t<_A0>,
82 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>112 class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
83using __enable_if_bullet6 =113using __enable_if_bullet6 _LIBCPP_NODEBUG =
84 __enable_if_t<is_member_object_pointer<_DecayFp>::value &&114 __enable_if_t<is_member_object_pointer<_DecayFp>::value &&
85 !(is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value) &&115 !(is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value) &&
86 !__is_reference_wrapper<_DecayA0>::value>;116 !__is_reference_wrapper<_DecayA0>::value>;
...@@ -159,7 +189,7 @@ struct __invokable_r {...@@ -159,7 +189,7 @@ struct __invokable_r {
159189
160 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,190 // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void,
161 // or incomplete array types as required by the standard.191 // or incomplete array types as required by the standard.
162 using _Result = decltype(__try_call<_Fp, _Args...>(0));192 using _Result _LIBCPP_NODEBUG = decltype(__try_call<_Fp, _Args...>(0));
163193
164 using type = __conditional_t<_IsNotSame<_Result, __nat>::value,194 using type = __conditional_t<_IsNotSame<_Result, __nat>::value,
165 __conditional_t<is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >,195 __conditional_t<is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >,
...@@ -167,7 +197,7 @@ struct __invokable_r {...@@ -167,7 +197,7 @@ struct __invokable_r {
167 static const bool value = type::value;197 static const bool value = type::value;
168};198};
169template <class _Fp, class... _Args>199template <class _Fp, class... _Args>
170using __invokable = __invokable_r<void, _Fp, _Args...>;200using __is_invocable _LIBCPP_NODEBUG = __invokable_r<void, _Fp, _Args...>;
171201
172template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class... _Args>202template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class... _Args>
173struct __nothrow_invokable_r_imp {203struct __nothrow_invokable_r_imp {
...@@ -199,15 +229,12 @@ struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...> {...@@ -199,15 +229,12 @@ struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...> {
199};229};
200230
201template <class _Ret, class _Fp, class... _Args>231template <class _Ret, class _Fp, class... _Args>
202using __nothrow_invokable_r =232using __nothrow_invokable_r _LIBCPP_NODEBUG =
203 __nothrow_invokable_r_imp<__invokable_r<_Ret, _Fp, _Args...>::value, is_void<_Ret>::value, _Ret, _Fp, _Args...>;233 __nothrow_invokable_r_imp<__invokable_r<_Ret, _Fp, _Args...>::value, is_void<_Ret>::value, _Ret, _Fp, _Args...>;
204234
205template <class _Fp, class... _Args>235template <class _Fp, class... _Args>
206using __nothrow_invokable = __nothrow_invokable_r_imp<__invokable<_Fp, _Args...>::value, true, void, _Fp, _Args...>;236using __nothrow_invokable _LIBCPP_NODEBUG =
207237 __nothrow_invokable_r_imp<__is_invocable<_Fp, _Args...>::value, true, void, _Fp, _Args...>;
208template <class _Fp, class... _Args>
209struct __invoke_of
210 : public enable_if<__invokable<_Fp, _Args...>::value, typename __invokable_r<void, _Fp, _Args...>::_Result> {};
211238
212template <class _Ret, bool = is_void<_Ret>::value>239template <class _Ret, bool = is_void<_Ret>::value>
213struct __invoke_void_return_wrapper {240struct __invoke_void_return_wrapper {
...@@ -225,40 +252,63 @@ struct __invoke_void_return_wrapper<_Ret, true> {...@@ -225,40 +252,63 @@ struct __invoke_void_return_wrapper<_Ret, true> {
225 }252 }
226};253};
227254
255template <class _Func, class... _Args>
256inline const bool __is_invocable_v = __is_invocable<_Func, _Args...>::value;
257
258template <class _Ret, class _Func, class... _Args>
259inline const bool __is_invocable_r_v = __invokable_r<_Ret, _Func, _Args...>::value;
260
261template <class _Func, class... _Args>
262inline const bool __is_nothrow_invocable_v = __nothrow_invokable<_Func, _Args...>::value;
263
264template <class _Func, class... _Args>
265struct __invoke_result
266 : enable_if<__is_invocable_v<_Func, _Args...>, typename __invokable_r<void, _Func, _Args...>::_Result> {};
267
268template <class _Func, class... _Args>
269using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Func, _Args...>::type;
270
271template <class _Ret, class... _Args>
272_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ret __invoke_r(_Args&&... __args) {
273 return __invoke_void_return_wrapper<_Ret>::__call(std::forward<_Args>(__args)...);
274}
275
228#if _LIBCPP_STD_VER >= 17276#if _LIBCPP_STD_VER >= 17
229277
230// is_invocable278// is_invocable
231279
232template <class _Fn, class... _Args>280template <class _Fn, class... _Args>
233struct _LIBCPP_TEMPLATE_VIS is_invocable : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};281struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_invocable : bool_constant<__is_invocable_v<_Fn, _Args...>> {};
234282
235template <class _Ret, class _Fn, class... _Args>283template <class _Ret, class _Fn, class... _Args>
236struct _LIBCPP_TEMPLATE_VIS is_invocable_r : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};284struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_invocable_r
285 : bool_constant<__is_invocable_r_v<_Ret, _Fn, _Args...>> {};
237286
238template <class _Fn, class... _Args>287template <class _Fn, class... _Args>
239inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;288_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_v = __is_invocable_v<_Fn, _Args...>;
240289
241template <class _Ret, class _Fn, class... _Args>290template <class _Ret, class _Fn, class... _Args>
242inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value;291_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_r_v = __is_invocable_r_v<_Ret, _Fn, _Args...>;
243292
244// is_nothrow_invocable293// is_nothrow_invocable
245294
246template <class _Fn, class... _Args>295template <class _Fn, class... _Args>
247struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {296struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable
248};297 : bool_constant<__nothrow_invokable<_Fn, _Args...>::value> {};
249298
250template <class _Ret, class _Fn, class... _Args>299template <class _Ret, class _Fn, class... _Args>
251struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r300struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable_r
252 : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};301 : bool_constant<__nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
253302
254template <class _Fn, class... _Args>303template <class _Fn, class... _Args>
255inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;304_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;
256305
257template <class _Ret, class _Fn, class... _Args>306template <class _Ret, class _Fn, class... _Args>
258inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;307_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_r_v =
308 is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
259309
260template <class _Fn, class... _Args>310template <class _Fn, class... _Args>
261struct _LIBCPP_TEMPLATE_VIS invoke_result : __invoke_of<_Fn, _Args...> {};311struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS invoke_result : __invoke_result<_Fn, _Args...> {};
262312
263template <class _Fn, class... _Args>313template <class _Fn, class... _Args>
264using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;314using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
lib/libcxx/include/__type_traits/is_abstract.h+3-2
...@@ -19,11 +19,12 @@...@@ -19,11 +19,12 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_abstract : public integral_constant<bool, __is_abstract(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_abstract
23 : public integral_constant<bool, __is_abstract(_Tp)> {};
2324
24#if _LIBCPP_STD_VER >= 1725#if _LIBCPP_STD_VER >= 17
25template <class _Tp>26template <class _Tp>
26inline constexpr bool is_abstract_v = __is_abstract(_Tp);27_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_abstract_v = __is_abstract(_Tp);
27#endif28#endif
2829
29_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_aggregate.h+3-2
...@@ -21,10 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,10 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
21#if _LIBCPP_STD_VER >= 1721#if _LIBCPP_STD_VER >= 17
2222
23template <class _Tp>23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {};24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_aggregate
25 : public integral_constant<bool, __is_aggregate(_Tp)> {};
2526
26template <class _Tp>27template <class _Tp>
27inline constexpr bool is_aggregate_v = __is_aggregate(_Tp);28_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_aggregate_v = __is_aggregate(_Tp);
2829
29#endif // _LIBCPP_STD_VER >= 1730#endif // _LIBCPP_STD_VER >= 17
3031
lib/libcxx/include/__type_traits/is_allocator.h+1-1
...@@ -10,10 +10,10 @@...@@ -10,10 +10,10 @@
10#define _LIBCPP___TYPE_IS_ALLOCATOR_H10#define _LIBCPP___TYPE_IS_ALLOCATOR_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
14#include <__type_traits/void_t.h>15#include <__type_traits/void_t.h>
15#include <__utility/declval.h>16#include <__utility/declval.h>
16#include <cstddef>
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/__type_traits/is_always_bitcastable.h+2-4
...@@ -10,9 +10,7 @@...@@ -10,9 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_IS_ALWAYS_BITCASTABLE_H10#define _LIBCPP___TYPE_TRAITS_IS_ALWAYS_BITCASTABLE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_integral.h>13#include <__type_traits/is_integral.h>
15#include <__type_traits/is_object.h>
16#include <__type_traits/is_same.h>14#include <__type_traits/is_same.h>
17#include <__type_traits/is_trivially_copyable.h>15#include <__type_traits/is_trivially_copyable.h>
18#include <__type_traits/remove_cv.h>16#include <__type_traits/remove_cv.h>
...@@ -31,8 +29,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -31,8 +29,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
31// considered bit-castable.29// considered bit-castable.
32template <class _From, class _To>30template <class _From, class _To>
33struct __is_always_bitcastable {31struct __is_always_bitcastable {
34 using _UnqualFrom = __remove_cv_t<_From>;32 using _UnqualFrom _LIBCPP_NODEBUG = __remove_cv_t<_From>;
35 using _UnqualTo = __remove_cv_t<_To>;33 using _UnqualTo _LIBCPP_NODEBUG = __remove_cv_t<_To>;
3634
37 // clang-format off35 // clang-format off
38 static const bool value =36 static const bool value =
lib/libcxx/include/__type_traits/is_arithmetic.h+2-2
...@@ -21,12 +21,12 @@...@@ -21,12 +21,12 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Tp>23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_arithmetic24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_arithmetic
25 : public integral_constant<bool, is_integral<_Tp>::value || is_floating_point<_Tp>::value> {};25 : public integral_constant<bool, is_integral<_Tp>::value || is_floating_point<_Tp>::value> {};
2626
27#if _LIBCPP_STD_VER >= 1727#if _LIBCPP_STD_VER >= 17
28template <class _Tp>28template <class _Tp>
29inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;29_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
30#endif30#endif
3131
32_LIBCPP_END_NAMESPACE_STD32_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_array.h+3-3
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H10#define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
14#include <cstddef>
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
...@@ -23,11 +23,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,11 +23,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
23 (!defined(_LIBCPP_COMPILER_CLANG_BASED) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1900))23 (!defined(_LIBCPP_COMPILER_CLANG_BASED) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1900))
2424
25template <class _Tp>25template <class _Tp>
26struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> {};26struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_array : _BoolConstant<__is_array(_Tp)> {};
2727
28# if _LIBCPP_STD_VER >= 1728# if _LIBCPP_STD_VER >= 17
29template <class _Tp>29template <class _Tp>
30inline constexpr bool is_array_v = __is_array(_Tp);30_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_array_v = __is_array(_Tp);
31# endif31# endif
3232
33#else33#else
lib/libcxx/include/__type_traits/is_assignable.h+6-6
...@@ -21,30 +21,30 @@...@@ -21,30 +21,30 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Tp, class _Up>23template <class _Tp, class _Up>
24struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> {};24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> {};
2525
26#if _LIBCPP_STD_VER >= 1726#if _LIBCPP_STD_VER >= 17
27template <class _Tp, class _Arg>27template <class _Tp, class _Arg>
28inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);28_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);
29#endif29#endif
3030
31template <class _Tp>31template <class _Tp>
32struct _LIBCPP_TEMPLATE_VIS is_copy_assignable32struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_copy_assignable
33 : public integral_constant<bool,33 : public integral_constant<bool,
34 __is_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};34 __is_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};
3535
36#if _LIBCPP_STD_VER >= 1736#if _LIBCPP_STD_VER >= 17
37template <class _Tp>37template <class _Tp>
38inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;38_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
39#endif39#endif
4040
41template <class _Tp>41template <class _Tp>
42struct _LIBCPP_TEMPLATE_VIS is_move_assignable42struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_move_assignable
43 : public integral_constant<bool, __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};43 : public integral_constant<bool, __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
4444
45#if _LIBCPP_STD_VER >= 1745#if _LIBCPP_STD_VER >= 17
46template <class _Tp>46template <class _Tp>
47inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;47_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
48#endif48#endif
4949
50_LIBCPP_END_NAMESPACE_STD50_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_base_of.h+16-2
...@@ -19,11 +19,25 @@...@@ -19,11 +19,25 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Bp, class _Dp>21template <class _Bp, class _Dp>
22struct _LIBCPP_TEMPLATE_VIS is_base_of : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_base_of
23 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
2324
24#if _LIBCPP_STD_VER >= 1725#if _LIBCPP_STD_VER >= 17
25template <class _Bp, class _Dp>26template <class _Bp, class _Dp>
26inline constexpr bool is_base_of_v = __is_base_of(_Bp, _Dp);27_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_base_of_v = __is_base_of(_Bp, _Dp);
28#endif
29
30#if _LIBCPP_STD_VER >= 26
31# if __has_builtin(__builtin_is_virtual_base_of)
32
33template <class _Base, class _Derived>
34struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_virtual_base_of
35 : public bool_constant<__builtin_is_virtual_base_of(_Base, _Derived)> {};
36
37template <class _Base, class _Derived>
38_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_virtual_base_of_v = __builtin_is_virtual_base_of(_Base, _Derived);
39
40# endif
27#endif41#endif
2842
29_LIBCPP_END_NAMESPACE_STD43_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_bounded_array.h+11-5
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H10#define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
14#include <cstddef>
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
...@@ -20,19 +20,25 @@...@@ -20,19 +20,25 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class>22template <class>
23struct _LIBCPP_TEMPLATE_VIS __libcpp_is_bounded_array : false_type {};23inline const bool __is_bounded_array_v = false;
24template <class _Tp, size_t _Np>24template <class _Tp, size_t _Np>
25struct _LIBCPP_TEMPLATE_VIS __libcpp_is_bounded_array<_Tp[_Np]> : true_type {};25inline const bool __is_bounded_array_v<_Tp[_Np]> = true;
2626
27#if _LIBCPP_STD_VER >= 2027#if _LIBCPP_STD_VER >= 20
2828
29template <class>29template <class>
30struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {};30struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_bounded_array : false_type {};
31
32_LIBCPP_DIAGNOSTIC_PUSH
33# if __has_warning("-Winvalid-specialization")
34_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
35# endif
31template <class _Tp, size_t _Np>36template <class _Tp, size_t _Np>
32struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {};37struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {};
38_LIBCPP_DIAGNOSTIC_POP
3339
34template <class _Tp>40template <class _Tp>
35inline constexpr bool is_bounded_array_v = is_bounded_array<_Tp>::value;41_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_bounded_array_v = is_bounded_array<_Tp>::value;
3642
37#endif43#endif
3844
lib/libcxx/include/__type_traits/is_char_like_type.h+1-1
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _CharT>23template <class _CharT>
24using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;24using _IsCharLikeType _LIBCPP_NODEBUG = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
2525
26_LIBCPP_END_NAMESPACE_STD26_LIBCPP_END_NAMESPACE_STD
2727
lib/libcxx/include/__type_traits/is_class.h+2-2
...@@ -19,11 +19,11 @@...@@ -19,11 +19,11 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_class : public integral_constant<bool, __is_class(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_class : public integral_constant<bool, __is_class(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
26inline constexpr bool is_class_v = __is_class(_Tp);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_class_v = __is_class(_Tp);
27#endif27#endif
2828
29_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_compound.h+2-2
...@@ -22,11 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,11 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if __has_builtin(__is_compound)22#if __has_builtin(__is_compound)
2323
24template <class _Tp>24template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> {};25struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_compound : _BoolConstant<__is_compound(_Tp)> {};
2626
27# if _LIBCPP_STD_VER >= 1727# if _LIBCPP_STD_VER >= 17
28template <class _Tp>28template <class _Tp>
29inline constexpr bool is_compound_v = __is_compound(_Tp);29_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_compound_v = __is_compound(_Tp);
30# endif30# endif
3131
32#else // __has_builtin(__is_compound)32#else // __has_builtin(__is_compound)
lib/libcxx/include/__type_traits/is_const.h+2-2
...@@ -21,11 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,11 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
21#if __has_builtin(__is_const)21#if __has_builtin(__is_const)
2222
23template <class _Tp>23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> {};24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_const : _BoolConstant<__is_const(_Tp)> {};
2525
26# if _LIBCPP_STD_VER >= 1726# if _LIBCPP_STD_VER >= 17
27template <class _Tp>27template <class _Tp>
28inline constexpr bool is_const_v = __is_const(_Tp);28_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_const_v = __is_const(_Tp);
29# endif29# endif
3030
31#else31#else
lib/libcxx/include/__type_traits/is_constructible.h+10-8
...@@ -21,37 +21,39 @@...@@ -21,37 +21,39 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Tp, class... _Args>23template <class _Tp, class... _Args>
24struct _LIBCPP_TEMPLATE_VIS is_constructible : public integral_constant<bool, __is_constructible(_Tp, _Args...)> {};24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_constructible
25 : public integral_constant<bool, __is_constructible(_Tp, _Args...)> {};
2526
26#if _LIBCPP_STD_VER >= 1727#if _LIBCPP_STD_VER >= 17
27template <class _Tp, class... _Args>28template <class _Tp, class... _Args>
28inline constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...);29_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...);
29#endif30#endif
3031
31template <class _Tp>32template <class _Tp>
32struct _LIBCPP_TEMPLATE_VIS is_copy_constructible33struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_copy_constructible
33 : public integral_constant<bool, __is_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};34 : public integral_constant<bool, __is_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};
3435
35#if _LIBCPP_STD_VER >= 1736#if _LIBCPP_STD_VER >= 17
36template <class _Tp>37template <class _Tp>
37inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;38_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
38#endif39#endif
3940
40template <class _Tp>41template <class _Tp>
41struct _LIBCPP_TEMPLATE_VIS is_move_constructible42struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_move_constructible
42 : public integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};43 : public integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
4344
44#if _LIBCPP_STD_VER >= 1745#if _LIBCPP_STD_VER >= 17
45template <class _Tp>46template <class _Tp>
46inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;47_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
47#endif48#endif
4849
49template <class _Tp>50template <class _Tp>
50struct _LIBCPP_TEMPLATE_VIS is_default_constructible : public integral_constant<bool, __is_constructible(_Tp)> {};51struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_default_constructible
52 : public integral_constant<bool, __is_constructible(_Tp)> {};
5153
52#if _LIBCPP_STD_VER >= 1754#if _LIBCPP_STD_VER >= 17
53template <class _Tp>55template <class _Tp>
54inline constexpr bool is_default_constructible_v = __is_constructible(_Tp);56_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_default_constructible_v = __is_constructible(_Tp);
55#endif57#endif
5658
57_LIBCPP_END_NAMESPACE_STD59_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_convertible.h+3-2
...@@ -19,11 +19,12 @@...@@ -19,11 +19,12 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _T1, class _T2>21template <class _T1, class _T2>
22struct _LIBCPP_TEMPLATE_VIS is_convertible : public integral_constant<bool, __is_convertible(_T1, _T2)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_convertible
23 : public integral_constant<bool, __is_convertible(_T1, _T2)> {};
2324
24#if _LIBCPP_STD_VER >= 1725#if _LIBCPP_STD_VER >= 17
25template <class _From, class _To>26template <class _From, class _To>
26inline constexpr bool is_convertible_v = __is_convertible(_From, _To);27_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_convertible_v = __is_convertible(_From, _To);
27#endif28#endif
2829
29_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_destructible.h+2-2
...@@ -25,11 +25,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -25,11 +25,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
25#if __has_builtin(__is_destructible)25#if __has_builtin(__is_destructible)
2626
27template <class _Tp>27template <class _Tp>
28struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> {};28struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_destructible : _BoolConstant<__is_destructible(_Tp)> {};
2929
30# if _LIBCPP_STD_VER >= 1730# if _LIBCPP_STD_VER >= 17
31template <class _Tp>31template <class _Tp>
32inline constexpr bool is_destructible_v = __is_destructible(_Tp);32_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_destructible_v = __is_destructible(_Tp);
33# endif33# endif
3434
35#else // __has_builtin(__is_destructible)35#else // __has_builtin(__is_destructible)
lib/libcxx/include/__type_traits/is_empty.h+2-2
...@@ -19,11 +19,11 @@...@@ -19,11 +19,11 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_empty : public integral_constant<bool, __is_empty(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_empty : public integral_constant<bool, __is_empty(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
26inline constexpr bool is_empty_v = __is_empty(_Tp);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_empty_v = __is_empty(_Tp);
27#endif27#endif
2828
29_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_enum.h+4-4
...@@ -19,20 +19,20 @@...@@ -19,20 +19,20 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_enum : public integral_constant<bool, __is_enum(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_enum : public integral_constant<bool, __is_enum(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
26inline constexpr bool is_enum_v = __is_enum(_Tp);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_enum_v = __is_enum(_Tp);
27#endif27#endif
2828
29#if _LIBCPP_STD_VER >= 2329#if _LIBCPP_STD_VER >= 23
3030
31template <class _Tp>31template <class _Tp>
32struct _LIBCPP_TEMPLATE_VIS is_scoped_enum : bool_constant<__is_scoped_enum(_Tp)> {};32struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_scoped_enum : bool_constant<__is_scoped_enum(_Tp)> {};
3333
34template <class _Tp>34template <class _Tp>
35inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp);35_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp);
3636
37#endif // _LIBCPP_STD_VER >= 2337#endif // _LIBCPP_STD_VER >= 23
3838
lib/libcxx/include/__type_traits/is_equality_comparable.h+1-1
...@@ -80,7 +80,7 @@ struct __libcpp_is_trivially_equality_comparable_impl<_Tp*, _Up*>...@@ -80,7 +80,7 @@ struct __libcpp_is_trivially_equality_comparable_impl<_Tp*, _Up*>
80};80};
8181
82template <class _Tp, class _Up>82template <class _Tp, class _Up>
83using __libcpp_is_trivially_equality_comparable =83using __libcpp_is_trivially_equality_comparable _LIBCPP_NODEBUG =
84 __libcpp_is_trivially_equality_comparable_impl<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >;84 __libcpp_is_trivially_equality_comparable_impl<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >;
8585
86_LIBCPP_END_NAMESPACE_STD86_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_execution_policy.h+2-2
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class>23template <class>
24inline constexpr bool is_execution_policy_v = false;24_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_execution_policy_v = false;
2525
26template <class>26template <class>
27inline constexpr bool __is_unsequenced_execution_policy_impl = false;27inline constexpr bool __is_unsequenced_execution_policy_impl = false;
...@@ -50,7 +50,7 @@ __remove_parallel_policy(const _ExecutionPolicy& = _ExecutionPolicy{execution::_...@@ -50,7 +50,7 @@ __remove_parallel_policy(const _ExecutionPolicy& = _ExecutionPolicy{execution::_
50// Removes the "parallel" part of an execution policy.50// Removes the "parallel" part of an execution policy.
51// For example, turns par_unseq into unseq, and par into seq.51// For example, turns par_unseq into unseq, and par into seq.
52template <class _ExecutionPolicy>52template <class _ExecutionPolicy>
53using __remove_parallel_policy_t = decltype(std::__remove_parallel_policy<_ExecutionPolicy>());53using __remove_parallel_policy_t _LIBCPP_NODEBUG = decltype(std::__remove_parallel_policy<_ExecutionPolicy>());
5454
55_LIBCPP_END_NAMESPACE_STD55_LIBCPP_END_NAMESPACE_STD
5656
lib/libcxx/include/__type_traits/is_final.h+2-2
...@@ -23,12 +23,12 @@ struct _LIBCPP_TEMPLATE_VIS __libcpp_is_final : public integral_constant<bool, _...@@ -23,12 +23,12 @@ struct _LIBCPP_TEMPLATE_VIS __libcpp_is_final : public integral_constant<bool, _
2323
24#if _LIBCPP_STD_VER >= 1424#if _LIBCPP_STD_VER >= 14
25template <class _Tp>25template <class _Tp>
26struct _LIBCPP_TEMPLATE_VIS is_final : public integral_constant<bool, __is_final(_Tp)> {};26struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_final : public integral_constant<bool, __is_final(_Tp)> {};
27#endif27#endif
2828
29#if _LIBCPP_STD_VER >= 1729#if _LIBCPP_STD_VER >= 17
30template <class _Tp>30template <class _Tp>
31inline constexpr bool is_final_v = __is_final(_Tp);31_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_final_v = __is_final(_Tp);
32#endif32#endif
3333
34_LIBCPP_END_NAMESPACE_STD34_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_floating_point.h+3-2
...@@ -27,11 +27,12 @@ template <> struct __libcpp_is_floating_point<long double> : public tru...@@ -27,11 +27,12 @@ template <> struct __libcpp_is_floating_point<long double> : public tru
27// clang-format on27// clang-format on
2828
29template <class _Tp>29template <class _Tp>
30struct _LIBCPP_TEMPLATE_VIS is_floating_point : public __libcpp_is_floating_point<__remove_cv_t<_Tp> > {};30struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_floating_point
31 : public __libcpp_is_floating_point<__remove_cv_t<_Tp> > {};
3132
32#if _LIBCPP_STD_VER >= 1733#if _LIBCPP_STD_VER >= 17
33template <class _Tp>34template <class _Tp>
34inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;35_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
35#endif36#endif
3637
37_LIBCPP_END_NAMESPACE_STD38_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_function.h+2-2
...@@ -19,11 +19,11 @@...@@ -19,11 +19,11 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_function : integral_constant<bool, __is_function(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_function : integral_constant<bool, __is_function(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
26inline constexpr bool is_function_v = __is_function(_Tp);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_function_v = __is_function(_Tp);
27#endif27#endif
2828
29_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_fundamental.h+2-2
...@@ -23,11 +23,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,11 +23,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
23#if __has_builtin(__is_fundamental)23#if __has_builtin(__is_fundamental)
2424
25template <class _Tp>25template <class _Tp>
26struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> {};26struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> {};
2727
28# if _LIBCPP_STD_VER >= 1728# if _LIBCPP_STD_VER >= 17
29template <class _Tp>29template <class _Tp>
30inline constexpr bool is_fundamental_v = __is_fundamental(_Tp);30_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_fundamental_v = __is_fundamental(_Tp);
31# endif31# endif
3232
33#else // __has_builtin(__is_fundamental)33#else // __has_builtin(__is_fundamental)
lib/libcxx/include/__type_traits/is_implicit_lifetime.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_TRAITS_IS_IMPLICIT_LIFETIME_H
10#define _LIBCPP___TYPE_TRAITS_IS_IMPLICIT_LIFETIME_H
11
12#include <__config>
13#include <__type_traits/integral_constant.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#if _LIBCPP_STD_VER >= 23
22# if __has_builtin(__builtin_is_implicit_lifetime)
23
24template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_implicit_lifetime
26 : public bool_constant<__builtin_is_implicit_lifetime(_Tp)> {};
27
28template <class _Tp>
29_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_implicit_lifetime_v = __builtin_is_implicit_lifetime(_Tp);
30
31# endif
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_IMPLICIT_LIFETIME_H
lib/libcxx/include/__type_traits/is_integral.h+5-5
...@@ -25,10 +25,10 @@ template <> struct __libcpp_is_integral<bool> { enum { va...@@ -25,10 +25,10 @@ template <> struct __libcpp_is_integral<bool> { enum { va
25template <> struct __libcpp_is_integral<char> { enum { value = 1 }; };25template <> struct __libcpp_is_integral<char> { enum { value = 1 }; };
26template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; };26template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; };
27template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; };27template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; };
28#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS28#if _LIBCPP_HAS_WIDE_CHARACTERS
29template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; };29template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; };
30#endif30#endif
31#ifndef _LIBCPP_HAS_NO_CHAR8_T31#if _LIBCPP_HAS_CHAR8_T
32template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; };32template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; };
33#endif33#endif
34template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; };34template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; };
...@@ -41,7 +41,7 @@ template <> struct __libcpp_is_integral<long> { enum { va...@@ -41,7 +41,7 @@ template <> struct __libcpp_is_integral<long> { enum { va
41template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; };41template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; };
42template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; };42template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; };
43template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; };43template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; };
44#ifndef _LIBCPP_HAS_NO_INT12844#if _LIBCPP_HAS_INT128
45template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; };45template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; };
46template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; };46template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; };
47#endif47#endif
...@@ -50,11 +50,11 @@ template <> struct __libcpp_is_integral<__uint128_t> { enum { va...@@ -50,11 +50,11 @@ template <> struct __libcpp_is_integral<__uint128_t> { enum { va
50#if __has_builtin(__is_integral)50#if __has_builtin(__is_integral)
5151
52template <class _Tp>52template <class _Tp>
53struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> {};53struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_integral : _BoolConstant<__is_integral(_Tp)> {};
5454
55# if _LIBCPP_STD_VER >= 1755# if _LIBCPP_STD_VER >= 17
56template <class _Tp>56template <class _Tp>
57inline constexpr bool is_integral_v = __is_integral(_Tp);57_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_integral_v = __is_integral(_Tp);
58# endif58# endif
5959
60#else60#else
lib/libcxx/include/__type_traits/is_literal_type.h+3-3
...@@ -20,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -20,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)21#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
22template <class _Tp>22template <class _Tp>
23struct _LIBCPP_TEMPLATE_VIS23struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS is_literal_type
24_LIBCPP_DEPRECATED_IN_CXX17 is_literal_type : public integral_constant<bool, __is_literal_type(_Tp)> {};24 : public integral_constant<bool, __is_literal_type(_Tp)> {};
2525
26# if _LIBCPP_STD_VER >= 1726# if _LIBCPP_STD_VER >= 17
27template <class _Tp>27template <class _Tp>
28_LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = __is_literal_type(_Tp);28_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_literal_type_v = __is_literal_type(_Tp);
29# endif // _LIBCPP_STD_VER >= 1729# endif // _LIBCPP_STD_VER >= 17
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_pointer.h+10-8
...@@ -19,24 +19,26 @@...@@ -19,24 +19,26 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {};
2323
24template <class _Tp>24template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer : _BoolConstant<__is_member_object_pointer(_Tp)> {};25struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_object_pointer
26 : _BoolConstant<__is_member_object_pointer(_Tp)> {};
2627
27template <class _Tp>28template <class _Tp>
28struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer : _BoolConstant<__is_member_function_pointer(_Tp)> {};29struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_function_pointer
30 : _BoolConstant<__is_member_function_pointer(_Tp)> {};
2931
30# if _LIBCPP_STD_VER >= 1732#if _LIBCPP_STD_VER >= 17
31template <class _Tp>33template <class _Tp>
32inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);34_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
3335
34template <class _Tp>36template <class _Tp>
35inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp);37_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp);
3638
37template <class _Tp>39template <class _Tp>
38inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp);40_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp);
39# endif41#endif
4042
41_LIBCPP_END_NAMESPACE_STD43_LIBCPP_END_NAMESPACE_STD
4244
lib/libcxx/include/__type_traits/is_nothrow_assignable.h+7-7
...@@ -21,34 +21,34 @@...@@ -21,34 +21,34 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Tp, class _Arg>23template <class _Tp, class _Arg>
24struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_assignable
25};25 : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
2626
27#if _LIBCPP_STD_VER >= 1727#if _LIBCPP_STD_VER >= 17
28template <class _Tp, class _Arg>28template <class _Tp, class _Arg>
29inline constexpr bool is_nothrow_assignable_v = __is_nothrow_assignable(_Tp, _Arg);29_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_assignable_v = __is_nothrow_assignable(_Tp, _Arg);
30#endif30#endif
3131
32template <class _Tp>32template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable33struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_copy_assignable
34 : public integral_constant<34 : public integral_constant<
35 bool,35 bool,
36 __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};36 __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};
3737
38#if _LIBCPP_STD_VER >= 1738#if _LIBCPP_STD_VER >= 17
39template <class _Tp>39template <class _Tp>
40inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value;40_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value;
41#endif41#endif
4242
43template <class _Tp>43template <class _Tp>
44struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable44struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_move_assignable
45 : public integral_constant<bool,45 : public integral_constant<bool,
46 __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {46 __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {
47};47};
4848
49#if _LIBCPP_STD_VER >= 1749#if _LIBCPP_STD_VER >= 17
50template <class _Tp>50template <class _Tp>
51inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value;51_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value;
52#endif52#endif
5353
54_LIBCPP_END_NAMESPACE_STD54_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_nothrow_constructible.h+11-8
...@@ -21,39 +21,42 @@...@@ -21,39 +21,42 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template < class _Tp, class... _Args>23template < class _Tp, class... _Args>
24struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_constructible
25 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};25 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
2626
27#if _LIBCPP_STD_VER >= 1727#if _LIBCPP_STD_VER >= 17
28template <class _Tp, class... _Args>28template <class _Tp, class... _Args>
29inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value;29_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_constructible_v =
30 is_nothrow_constructible<_Tp, _Args...>::value;
30#endif31#endif
3132
32template <class _Tp>33template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible34struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_copy_constructible
34 : public integral_constant< bool, __is_nothrow_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};35 : public integral_constant< bool, __is_nothrow_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};
3536
36#if _LIBCPP_STD_VER >= 1737#if _LIBCPP_STD_VER >= 17
37template <class _Tp>38template <class _Tp>
38inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value;39_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_constructible_v =
40 is_nothrow_copy_constructible<_Tp>::value;
39#endif41#endif
4042
41template <class _Tp>43template <class _Tp>
42struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible44struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_move_constructible
43 : public integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};45 : public integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
4446
45#if _LIBCPP_STD_VER >= 1747#if _LIBCPP_STD_VER >= 17
46template <class _Tp>48template <class _Tp>
47inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value;49_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_move_constructible_v =
50 is_nothrow_move_constructible<_Tp>::value;
48#endif51#endif
4952
50template <class _Tp>53template <class _Tp>
51struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible54struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_default_constructible
52 : public integral_constant<bool, __is_nothrow_constructible(_Tp)> {};55 : public integral_constant<bool, __is_nothrow_constructible(_Tp)> {};
5356
54#if _LIBCPP_STD_VER >= 1757#if _LIBCPP_STD_VER >= 17
55template <class _Tp>58template <class _Tp>
56inline constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(_Tp);59_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(_Tp);
57#endif60#endif
5861
59_LIBCPP_END_NAMESPACE_STD62_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_nothrow_convertible.h+2-2
...@@ -29,10 +29,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,10 +29,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
29# if __has_builtin(__is_nothrow_convertible)29# if __has_builtin(__is_nothrow_convertible)
3030
31template <class _Tp, class _Up>31template <class _Tp, class _Up>
32struct is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {};32struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {};
3333
34template <class _Tp, class _Up>34template <class _Tp, class _Up>
35inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up);35_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up);
3636
37# else // __has_builtin(__is_nothrow_convertible)37# else // __has_builtin(__is_nothrow_convertible)
3838
lib/libcxx/include/__type_traits/is_nothrow_destructible.h+4-3
...@@ -10,10 +10,10 @@...@@ -10,10 +10,10 @@
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 <__cstddef/size_t.h>
13#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_destructible.h>15#include <__type_traits/is_destructible.h>
15#include <__utility/declval.h>16#include <__utility/declval.h>
16#include <cstddef>
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
...@@ -24,7 +24,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,7 +24,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
24#if __has_builtin(__is_nothrow_destructible)24#if __has_builtin(__is_nothrow_destructible)
2525
26template <class _Tp>26template <class _Tp>
27struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible : integral_constant<bool, __is_nothrow_destructible(_Tp)> {};27struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_destructible
28 : integral_constant<bool, __is_nothrow_destructible(_Tp)> {};
2829
29#else30#else
3031
...@@ -55,7 +56,7 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> : public true_type {}...@@ -55,7 +56,7 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> : public true_type {}
5556
56#if _LIBCPP_STD_VER >= 1757#if _LIBCPP_STD_VER >= 17
57template <class _Tp>58template <class _Tp>
58inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value;59_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value;
59#endif60#endif
6061
61_LIBCPP_END_NAMESPACE_STD62_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_null_pointer.h+4-3
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H10#define _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/nullptr_t.h>
13#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
14#include <cstddef>
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
...@@ -24,11 +24,12 @@ inline const bool __is_null_pointer_v = __is_same(__remove_cv(_Tp), nullptr_t);...@@ -24,11 +24,12 @@ inline const bool __is_null_pointer_v = __is_same(__remove_cv(_Tp), nullptr_t);
2424
25#if _LIBCPP_STD_VER >= 1425#if _LIBCPP_STD_VER >= 14
26template <class _Tp>26template <class _Tp>
27struct _LIBCPP_TEMPLATE_VIS is_null_pointer : integral_constant<bool, __is_null_pointer_v<_Tp>> {};27struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_null_pointer
28 : integral_constant<bool, __is_null_pointer_v<_Tp>> {};
2829
29# if _LIBCPP_STD_VER >= 1730# if _LIBCPP_STD_VER >= 17
30template <class _Tp>31template <class _Tp>
31inline constexpr bool is_null_pointer_v = __is_null_pointer_v<_Tp>;32_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_null_pointer_v = __is_null_pointer_v<_Tp>;
32# endif33# endif
33#endif // _LIBCPP_STD_VER >= 1434#endif // _LIBCPP_STD_VER >= 14
3435
lib/libcxx/include/__type_traits/is_object.h+2-2
...@@ -19,11 +19,11 @@...@@ -19,11 +19,11 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_object : _BoolConstant<__is_object(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
26inline constexpr bool is_object_v = __is_object(_Tp);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_object_v = __is_object(_Tp);
27#endif27#endif
2828
29_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_pod.h+2-2
...@@ -19,11 +19,11 @@...@@ -19,11 +19,11 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_pod : public integral_constant<bool, __is_pod(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_pod : public integral_constant<bool, __is_pod(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
26inline constexpr bool is_pod_v = __is_pod(_Tp);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pod_v = __is_pod(_Tp);
27#endif27#endif
2828
29_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_pointer.h+3-3
...@@ -22,11 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,11 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if __has_builtin(__is_pointer)22#if __has_builtin(__is_pointer)
2323
24template <class _Tp>24template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> {};25struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_pointer : _BoolConstant<__is_pointer(_Tp)> {};
2626
27# if _LIBCPP_STD_VER >= 1727# if _LIBCPP_STD_VER >= 17
28template <class _Tp>28template <class _Tp>
29inline constexpr bool is_pointer_v = __is_pointer(_Tp);29_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pointer_v = __is_pointer(_Tp);
30# endif30# endif
3131
32#else // __has_builtin(__is_pointer)32#else // __has_builtin(__is_pointer)
...@@ -40,7 +40,7 @@ template <class _Tp>...@@ -40,7 +40,7 @@ template <class _Tp>
40struct __libcpp_remove_objc_qualifiers {40struct __libcpp_remove_objc_qualifiers {
41 typedef _Tp type;41 typedef _Tp type;
42};42};
43# if defined(_LIBCPP_HAS_OBJC_ARC)43# if _LIBCPP_HAS_OBJC_ARC
44// clang-format off44// clang-format off
45template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };45template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
46template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };46template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };
lib/libcxx/include/__type_traits/is_polymorphic.h+3-2
...@@ -19,11 +19,12 @@...@@ -19,11 +19,12 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_polymorphic : public integral_constant<bool, __is_polymorphic(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_polymorphic
23 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
2324
24#if _LIBCPP_STD_VER >= 1725#if _LIBCPP_STD_VER >= 17
25template <class _Tp>26template <class _Tp>
26inline constexpr bool is_polymorphic_v = __is_polymorphic(_Tp);27_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_polymorphic_v = __is_polymorphic(_Tp);
27#endif28#endif
2829
29_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_primary_template.h+3-2
...@@ -21,10 +21,11 @@...@@ -21,10 +21,11 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Tp>23template <class _Tp>
24using __test_for_primary_template = __enable_if_t<_IsSame<_Tp, typename _Tp::__primary_template>::value>;24using __test_for_primary_template _LIBCPP_NODEBUG =
25 __enable_if_t<_IsSame<_Tp, typename _Tp::__primary_template>::value>;
2526
26template <class _Tp>27template <class _Tp>
27using __is_primary_template = _IsValidExpansion<__test_for_primary_template, _Tp>;28using __is_primary_template _LIBCPP_NODEBUG = _IsValidExpansion<__test_for_primary_template, _Tp>;
2829
29_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
3031
lib/libcxx/include/__type_traits/is_reference.h+8-6
...@@ -19,26 +19,28 @@...@@ -19,26 +19,28 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_reference : _BoolConstant<__is_reference(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
26inline constexpr bool is_reference_v = __is_reference(_Tp);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_reference_v = __is_reference(_Tp);
27#endif27#endif
2828
29#if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference)29#if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference)
3030
31template <class _Tp>31template <class _Tp>
32struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {};32struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {
33};
3334
34template <class _Tp>35template <class _Tp>
35struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {};36struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {
37};
3638
37# if _LIBCPP_STD_VER >= 1739# if _LIBCPP_STD_VER >= 17
38template <class _Tp>40template <class _Tp>
39inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp);41_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp);
40template <class _Tp>42template <class _Tp>
41inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp);43_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp);
42# endif44# endif
4345
44#else // __has_builtin(__is_lvalue_reference)46#else // __has_builtin(__is_lvalue_reference)
lib/libcxx/include/__type_traits/is_same.h+4-4
...@@ -19,11 +19,11 @@...@@ -19,11 +19,11 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp, class _Up>21template <class _Tp, class _Up>
22struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_same : _BoolConstant<__is_same(_Tp, _Up)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp, class _Up>25template <class _Tp, class _Up>
26inline constexpr bool is_same_v = __is_same(_Tp, _Up);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_same_v = __is_same(_Tp, _Up);
27#endif27#endif
2828
29// _IsSame<T,U> has the same effect as is_same<T,U> but instantiates fewer types:29// _IsSame<T,U> has the same effect as is_same<T,U> but instantiates fewer types:
...@@ -34,10 +34,10 @@ inline constexpr bool is_same_v = __is_same(_Tp, _Up);...@@ -34,10 +34,10 @@ inline constexpr bool is_same_v = __is_same(_Tp, _Up);
34// (such as in a dependent return type).34// (such as in a dependent return type).
3535
36template <class _Tp, class _Up>36template <class _Tp, class _Up>
37using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>;37using _IsSame _LIBCPP_NODEBUG = _BoolConstant<__is_same(_Tp, _Up)>;
3838
39template <class _Tp, class _Up>39template <class _Tp, class _Up>
40using _IsNotSame = _BoolConstant<!__is_same(_Tp, _Up)>;40using _IsNotSame _LIBCPP_NODEBUG = _BoolConstant<!__is_same(_Tp, _Up)>;
4141
42_LIBCPP_END_NAMESPACE_STD42_LIBCPP_END_NAMESPACE_STD
4343
lib/libcxx/include/__type_traits/is_scalar.h+3-3
...@@ -26,18 +26,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,18 +26,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD
26#if __has_builtin(__is_scalar)26#if __has_builtin(__is_scalar)
2727
28template <class _Tp>28template <class _Tp>
29struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> {};29struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_scalar : _BoolConstant<__is_scalar(_Tp)> {};
3030
31# if _LIBCPP_STD_VER >= 1731# if _LIBCPP_STD_VER >= 17
32template <class _Tp>32template <class _Tp>
33inline constexpr bool is_scalar_v = __is_scalar(_Tp);33_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_scalar_v = __is_scalar(_Tp);
34# endif34# endif
3535
36#else // __has_builtin(__is_scalar)36#else // __has_builtin(__is_scalar)
3737
38template <class _Tp>38template <class _Tp>
39struct __is_block : false_type {};39struct __is_block : false_type {};
40# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)40# if _LIBCPP_HAS_EXTENSION_BLOCKS
41template <class _Rp, class... _Args>41template <class _Rp, class... _Args>
42struct __is_block<_Rp (^)(_Args...)> : true_type {};42struct __is_block<_Rp (^)(_Args...)> : true_type {};
43# endif43# endif
lib/libcxx/include/__type_traits/is_signed.h+2-2
...@@ -23,11 +23,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,11 +23,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
23#if __has_builtin(__is_signed)23#if __has_builtin(__is_signed)
2424
25template <class _Tp>25template <class _Tp>
26struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> {};26struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_signed : _BoolConstant<__is_signed(_Tp)> {};
2727
28# if _LIBCPP_STD_VER >= 1728# if _LIBCPP_STD_VER >= 17
29template <class _Tp>29template <class _Tp>
30inline constexpr bool is_signed_v = __is_signed(_Tp);30_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_signed_v = __is_signed(_Tp);
31# endif31# endif
3232
33#else // __has_builtin(__is_signed)33#else // __has_builtin(__is_signed)
lib/libcxx/include/__type_traits/is_signed_integer.h+1-1
...@@ -25,7 +25,7 @@ template <> struct __libcpp_is_signed_integer<signed short> : publi...@@ -25,7 +25,7 @@ template <> struct __libcpp_is_signed_integer<signed short> : publi
25template <> struct __libcpp_is_signed_integer<signed int> : public true_type {};25template <> struct __libcpp_is_signed_integer<signed int> : public true_type {};
26template <> struct __libcpp_is_signed_integer<signed long> : public true_type {};26template <> struct __libcpp_is_signed_integer<signed long> : public true_type {};
27template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {};27template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {};
28#ifndef _LIBCPP_HAS_NO_INT12828#if _LIBCPP_HAS_INT128
29template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {};29template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {};
30#endif30#endif
31// clang-format on31// clang-format on
lib/libcxx/include/__type_traits/is_standard_layout.h+3-2
...@@ -19,11 +19,12 @@...@@ -19,11 +19,12 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_standard_layout : public integral_constant<bool, __is_standard_layout(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_standard_layout
23 : public integral_constant<bool, __is_standard_layout(_Tp)> {};
2324
24#if _LIBCPP_STD_VER >= 1725#if _LIBCPP_STD_VER >= 17
25template <class _Tp>26template <class _Tp>
26inline constexpr bool is_standard_layout_v = __is_standard_layout(_Tp);27_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_standard_layout_v = __is_standard_layout(_Tp);
27#endif28#endif
2829
29_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_swappable.h+16-11
...@@ -10,15 +10,16 @@...@@ -10,15 +10,16 @@
10#define _LIBCPP___TYPE_TRAITS_IS_SWAPPABLE_H10#define _LIBCPP___TYPE_TRAITS_IS_SWAPPABLE_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__type_traits/add_lvalue_reference.h>14#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/enable_if.h>15#include <__type_traits/enable_if.h>
16#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_assignable.h>17#include <__type_traits/is_assignable.h>
16#include <__type_traits/is_constructible.h>18#include <__type_traits/is_constructible.h>
17#include <__type_traits/is_nothrow_assignable.h>19#include <__type_traits/is_nothrow_assignable.h>
18#include <__type_traits/is_nothrow_constructible.h>20#include <__type_traits/is_nothrow_constructible.h>
19#include <__type_traits/void_t.h>21#include <__type_traits/void_t.h>
20#include <__utility/declval.h>22#include <__utility/declval.h>
21#include <cstddef>
2223
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header25# pragma GCC system_header
...@@ -40,10 +41,11 @@ inline const bool __is_nothrow_swappable_v = __is_nothrow_swappable_with_v<_Tp&,...@@ -40,10 +41,11 @@ inline const bool __is_nothrow_swappable_v = __is_nothrow_swappable_with_v<_Tp&,
4041
41#ifndef _LIBCPP_CXX03_LANG42#ifndef _LIBCPP_CXX03_LANG
42template <class _Tp>43template <class _Tp>
43using __swap_result_t = __enable_if_t<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>;44using __swap_result_t _LIBCPP_NODEBUG =
45 __enable_if_t<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>;
44#else46#else
45template <class>47template <class>
46using __swap_result_t = void;48using __swap_result_t _LIBCPP_NODEBUG = void;
47#endif49#endif
4850
49template <class _Tp>51template <class _Tp>
...@@ -72,30 +74,33 @@ inline const bool __is_nothrow_swappable_with_v<_Tp, _Up, true> =...@@ -72,30 +74,33 @@ inline const bool __is_nothrow_swappable_with_v<_Tp, _Up, true> =
72#if _LIBCPP_STD_VER >= 1774#if _LIBCPP_STD_VER >= 17
7375
74template <class _Tp, class _Up>76template <class _Tp, class _Up>
75inline constexpr bool is_swappable_with_v = __is_swappable_with_v<_Tp, _Up>;77_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_swappable_with_v = __is_swappable_with_v<_Tp, _Up>;
7678
77template <class _Tp, class _Up>79template <class _Tp, class _Up>
78struct _LIBCPP_TEMPLATE_VIS is_swappable_with : bool_constant<is_swappable_with_v<_Tp, _Up>> {};80struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_swappable_with
81 : bool_constant<is_swappable_with_v<_Tp, _Up>> {};
7982
80template <class _Tp>83template <class _Tp>
81inline constexpr bool is_swappable_v =84_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_swappable_v =
82 is_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>;85 is_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>;
8386
84template <class _Tp>87template <class _Tp>
85struct _LIBCPP_TEMPLATE_VIS is_swappable : bool_constant<is_swappable_v<_Tp>> {};88struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_swappable : bool_constant<is_swappable_v<_Tp>> {};
8689
87template <class _Tp, class _Up>90template <class _Tp, class _Up>
88inline constexpr bool is_nothrow_swappable_with_v = __is_nothrow_swappable_with_v<_Tp, _Up>;91_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_with_v = __is_nothrow_swappable_with_v<_Tp, _Up>;
8992
90template <class _Tp, class _Up>93template <class _Tp, class _Up>
91struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with : bool_constant<is_nothrow_swappable_with_v<_Tp, _Up>> {};94struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_swappable_with
95 : bool_constant<is_nothrow_swappable_with_v<_Tp, _Up>> {};
9296
93template <class _Tp>97template <class _Tp>
94inline constexpr bool is_nothrow_swappable_v =98_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_v =
95 is_nothrow_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>;99 is_nothrow_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>;
96100
97template <class _Tp>101template <class _Tp>
98struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable : bool_constant<is_nothrow_swappable_v<_Tp>> {};102struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_swappable
103 : bool_constant<is_nothrow_swappable_v<_Tp>> {};
99104
100#endif // _LIBCPP_STD_VER >= 17105#endif // _LIBCPP_STD_VER >= 17
101106
lib/libcxx/include/__type_traits/is_trivial.h+3-2
...@@ -19,11 +19,12 @@...@@ -19,11 +19,12 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_trivial : public integral_constant<bool, __is_trivial(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivial : public integral_constant<bool, __is_trivial(_Tp)> {
23};
2324
24#if _LIBCPP_STD_VER >= 1725#if _LIBCPP_STD_VER >= 17
25template <class _Tp>26template <class _Tp>
26inline constexpr bool is_trivial_v = __is_trivial(_Tp);27_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivial_v = __is_trivial(_Tp);
27#endif28#endif
2829
29_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_trivially_assignable.h+9-7
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_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>
...@@ -22,33 +21,36 @@...@@ -22,33 +21,36 @@
22_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _Tp, class _Arg>23template <class _Tp, class _Arg>
25struct is_trivially_assignable : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> {};24struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_assignable
25 : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> {};
2626
27#if _LIBCPP_STD_VER >= 1727#if _LIBCPP_STD_VER >= 17
28template <class _Tp, class _Arg>28template <class _Tp, class _Arg>
29inline constexpr bool is_trivially_assignable_v = __is_trivially_assignable(_Tp, _Arg);29_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_assignable_v = __is_trivially_assignable(_Tp, _Arg);
30#endif30#endif
3131
32template <class _Tp>32template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable33struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_copy_assignable
34 : public integral_constant<34 : public integral_constant<
35 bool,35 bool,
36 __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};36 __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};
3737
38#if _LIBCPP_STD_VER >= 1738#if _LIBCPP_STD_VER >= 17
39template <class _Tp>39template <class _Tp>
40inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value;40_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copy_assignable_v =
41 is_trivially_copy_assignable<_Tp>::value;
41#endif42#endif
4243
43template <class _Tp>44template <class _Tp>
44struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable45struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_move_assignable
45 : public integral_constant<46 : public integral_constant<
46 bool,47 bool,
47 __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};48 __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
4849
49#if _LIBCPP_STD_VER >= 1750#if _LIBCPP_STD_VER >= 17
50template <class _Tp>51template <class _Tp>
51inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value;52_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_move_assignable_v =
53 is_trivially_move_assignable<_Tp>::value;
52#endif54#endif
5355
54_LIBCPP_END_NAMESPACE_STD56_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_trivially_constructible.h+12-8
...@@ -21,39 +21,43 @@...@@ -21,39 +21,43 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Tp, class... _Args>23template <class _Tp, class... _Args>
24struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_constructible
25 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> {};25 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> {};
2626
27#if _LIBCPP_STD_VER >= 1727#if _LIBCPP_STD_VER >= 17
28template <class _Tp, class... _Args>28template <class _Tp, class... _Args>
29inline constexpr bool is_trivially_constructible_v = __is_trivially_constructible(_Tp, _Args...);29_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_constructible_v =
30 __is_trivially_constructible(_Tp, _Args...);
30#endif31#endif
3132
32template <class _Tp>33template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible34struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_copy_constructible
34 : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};35 : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};
3536
36#if _LIBCPP_STD_VER >= 1737#if _LIBCPP_STD_VER >= 17
37template <class _Tp>38template <class _Tp>
38inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value;39_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copy_constructible_v =
40 is_trivially_copy_constructible<_Tp>::value;
39#endif41#endif
4042
41template <class _Tp>43template <class _Tp>
42struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible44struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_move_constructible
43 : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};45 : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
4446
45#if _LIBCPP_STD_VER >= 1747#if _LIBCPP_STD_VER >= 17
46template <class _Tp>48template <class _Tp>
47inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value;49_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_move_constructible_v =
50 is_trivially_move_constructible<_Tp>::value;
48#endif51#endif
4952
50template <class _Tp>53template <class _Tp>
51struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible54struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_default_constructible
52 : public integral_constant<bool, __is_trivially_constructible(_Tp)> {};55 : public integral_constant<bool, __is_trivially_constructible(_Tp)> {};
5356
54#if _LIBCPP_STD_VER >= 1757#if _LIBCPP_STD_VER >= 17
55template <class _Tp>58template <class _Tp>
56inline constexpr bool is_trivially_default_constructible_v = __is_trivially_constructible(_Tp);59_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_default_constructible_v =
60 __is_trivially_constructible(_Tp);
57#endif61#endif
5862
59_LIBCPP_END_NAMESPACE_STD63_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_trivially_copyable.h+4-5
...@@ -20,17 +20,16 @@...@@ -20,17 +20,16 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _Tp>22template <class _Tp>
23struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable : public integral_constant<bool, __is_trivially_copyable(_Tp)> {};23struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_copyable
24 : public integral_constant<bool, __is_trivially_copyable(_Tp)> {};
2425
25#if _LIBCPP_STD_VER >= 1726#if _LIBCPP_STD_VER >= 17
26template <class _Tp>27template <class _Tp>
27inline constexpr bool is_trivially_copyable_v = __is_trivially_copyable(_Tp);28_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copyable_v = __is_trivially_copyable(_Tp);
28#endif29#endif
2930
30#if _LIBCPP_STD_VER >= 20
31template <class _Tp>31template <class _Tp>
32inline constexpr bool __is_cheap_to_copy = is_trivially_copyable_v<_Tp> && sizeof(_Tp) <= sizeof(std::intmax_t);32inline const bool __is_cheap_to_copy = __is_trivially_copyable(_Tp) && sizeof(_Tp) <= sizeof(std::intmax_t);
33#endif
3433
35_LIBCPP_END_NAMESPACE_STD34_LIBCPP_END_NAMESPACE_STD
3635
lib/libcxx/include/__type_traits/is_trivially_destructible.h+2-2
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if __has_builtin(__is_trivially_destructible)22#if __has_builtin(__is_trivially_destructible)
2323
24template <class _Tp>24template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible25struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_destructible
26 : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};26 : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
2727
28#elif __has_builtin(__has_trivial_destructor)28#elif __has_builtin(__has_trivial_destructor)
...@@ -39,7 +39,7 @@ struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible...@@ -39,7 +39,7 @@ struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3939
40#if _LIBCPP_STD_VER >= 1740#if _LIBCPP_STD_VER >= 17
41template <class _Tp>41template <class _Tp>
42inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value;42_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value;
43#endif43#endif
4444
45_LIBCPP_END_NAMESPACE_STD45_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_trivially_lexicographically_comparable.h+15-5
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_LEXICOGRAPHICALLY_COMPARABLE_H10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_LEXICOGRAPHICALLY_COMPARABLE_H
1111
12#include <__config>12#include <__config>
13#include <__fwd/byte.h>
13#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_same.h>15#include <__type_traits/is_same.h>
15#include <__type_traits/is_unsigned.h>16#include <__type_traits/is_unsigned.h>
...@@ -40,13 +41,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -40,13 +41,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD
40// unsigned integer types with sizeof(T) > 1: depending on the endianness, the LSB might be the first byte to be41// unsigned integer types with sizeof(T) > 1: depending on the endianness, the LSB might be the first byte to be
41// compared. This means that when comparing unsigned(129) and unsigned(2)42// compared. This means that when comparing unsigned(129) and unsigned(2)
42// using memcmp(), the result would be that 2 > 129.43// using memcmp(), the result would be that 2 > 129.
43// TODO: Do we want to enable this on big-endian systems?44
45template <class _Tp>
46inline const bool __is_std_byte_v = false;
47
48#if _LIBCPP_STD_VER >= 17
49template <>
50inline const bool __is_std_byte_v<byte> = true;
51#endif
4452
45template <class _Tp, class _Up>53template <class _Tp, class _Up>
46struct __libcpp_is_trivially_lexicographically_comparable54inline const bool __is_trivially_lexicographically_comparable_v =
47 : integral_constant<bool,55 is_same<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >::value &&
48 is_same<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >::value && sizeof(_Tp) == 1 &&56#ifdef _LIBCPP_LITTLE_ENDIAN
49 is_unsigned<_Tp>::value> {};57 sizeof(_Tp) == 1 &&
58#endif
59 (is_unsigned<_Tp>::value || __is_std_byte_v<_Tp>);
5060
51_LIBCPP_END_NAMESPACE_STD61_LIBCPP_END_NAMESPACE_STD
5262
lib/libcxx/include/__type_traits/is_trivially_relocatable.h+5-3
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/enable_if.h>13#include <__type_traits/enable_if.h>
14#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_same.h>14#include <__type_traits/is_same.h>
16#include <__type_traits/is_trivially_copyable.h>15#include <__type_traits/is_trivially_copyable.h>
1716
...@@ -23,8 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,8 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2322
24// A type is trivially relocatable if a move construct + destroy of the original object is equivalent to23// A type is trivially relocatable if a move construct + destroy of the original object is equivalent to
25// `memcpy(dst, src, sizeof(T))`.24// `memcpy(dst, src, sizeof(T))`.
2625//
27#if __has_builtin(__is_trivially_relocatable)26// Note that we don't use the __is_trivially_relocatable Clang builtin right now because it does not
27// implement the semantics of any current or future trivial relocation proposal and it can lead to
28// incorrect optimizations on some platforms (Windows) and supported compilers (AppleClang).
29#if __has_builtin(__is_trivially_relocatable) && 0
28template <class _Tp, class = void>30template <class _Tp, class = void>
29struct __libcpp_is_trivially_relocatable : integral_constant<bool, __is_trivially_relocatable(_Tp)> {};31struct __libcpp_is_trivially_relocatable : integral_constant<bool, __is_trivially_relocatable(_Tp)> {};
30#else32#else
lib/libcxx/include/__type_traits/is_unbounded_array.h+10-4
...@@ -19,19 +19,25 @@...@@ -19,19 +19,25 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class>21template <class>
22struct _LIBCPP_TEMPLATE_VIS __libcpp_is_unbounded_array : false_type {};22inline const bool __is_unbounded_array_v = false;
23template <class _Tp>23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS __libcpp_is_unbounded_array<_Tp[]> : true_type {};24inline const bool __is_unbounded_array_v<_Tp[]> = true;
2525
26#if _LIBCPP_STD_VER >= 2026#if _LIBCPP_STD_VER >= 20
2727
28template <class>28template <class>
29struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {};29struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_unbounded_array : false_type {};
30
31_LIBCPP_DIAGNOSTIC_PUSH
32# if __has_warning("-Winvalid-specialization")
33_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
34# endif
30template <class _Tp>35template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {};36struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {};
37_LIBCPP_DIAGNOSTIC_POP
3238
33template <class _Tp>39template <class _Tp>
34inline constexpr bool is_unbounded_array_v = is_unbounded_array<_Tp>::value;40_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unbounded_array_v = is_unbounded_array<_Tp>::value;
3541
36#endif42#endif
3743
lib/libcxx/include/__type_traits/is_union.h+2-2
...@@ -19,11 +19,11 @@...@@ -19,11 +19,11 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_union : public integral_constant<bool, __is_union(_Tp)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_union : public integral_constant<bool, __is_union(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
26inline constexpr bool is_union_v = __is_union(_Tp);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_union_v = __is_union(_Tp);
27#endif27#endif
2828
29_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_unsigned.h+2-2
...@@ -23,11 +23,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,11 +23,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
23#if __has_builtin(__is_unsigned)23#if __has_builtin(__is_unsigned)
2424
25template <class _Tp>25template <class _Tp>
26struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> {};26struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> {};
2727
28# if _LIBCPP_STD_VER >= 1728# if _LIBCPP_STD_VER >= 17
29template <class _Tp>29template <class _Tp>
30inline constexpr bool is_unsigned_v = __is_unsigned(_Tp);30_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unsigned_v = __is_unsigned(_Tp);
31# endif31# endif
3232
33#else // __has_builtin(__is_unsigned)33#else // __has_builtin(__is_unsigned)
lib/libcxx/include/__type_traits/is_unsigned_integer.h+1-1
...@@ -25,7 +25,7 @@ template <> struct __libcpp_is_unsigned_integer<unsigned short> : p...@@ -25,7 +25,7 @@ template <> struct __libcpp_is_unsigned_integer<unsigned short> : p
25template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {};25template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {};
26template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {};26template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {};
27template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {};27template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {};
28#ifndef _LIBCPP_HAS_NO_INT12828#if _LIBCPP_HAS_INT128
29template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {};29template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {};
30#endif30#endif
31// clang-format on31// clang-format on
lib/libcxx/include/__type_traits/is_void.h+4-4
...@@ -19,12 +19,12 @@...@@ -19,12 +19,12 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {};22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_void : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {};
2323
24# if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
26inline constexpr bool is_void_v = __is_same(__remove_cv(_Tp), void);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_void_v = __is_same(__remove_cv(_Tp), void);
27# endif27#endif
2828
29_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
3030
lib/libcxx/include/__type_traits/is_volatile.h+2-2
...@@ -21,11 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,11 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
21#if __has_builtin(__is_volatile)21#if __has_builtin(__is_volatile)
2222
23template <class _Tp>23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> {};24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_volatile : _BoolConstant<__is_volatile(_Tp)> {};
2525
26# if _LIBCPP_STD_VER >= 1726# if _LIBCPP_STD_VER >= 17
27template <class _Tp>27template <class _Tp>
28inline constexpr bool is_volatile_v = __is_volatile(_Tp);28_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_volatile_v = __is_volatile(_Tp);
29# endif29# endif
3030
31#else31#else
lib/libcxx/include/__type_traits/make_32_64_or_128_bit.h+2-2
...@@ -31,11 +31,11 @@ template <class _Tp>...@@ -31,11 +31,11 @@ template <class _Tp>
31 requires(is_signed_v<_Tp> || is_unsigned_v<_Tp> || is_same_v<_Tp, char>)31 requires(is_signed_v<_Tp> || is_unsigned_v<_Tp> || is_same_v<_Tp, char>)
32#endif32#endif
33// clang-format off33// clang-format off
34using __make_32_64_or_128_bit_t =34using __make_32_64_or_128_bit_t _LIBCPP_NODEBUG =
35 __copy_unsigned_t<_Tp,35 __copy_unsigned_t<_Tp,
36 __conditional_t<sizeof(_Tp) <= sizeof(int32_t), int32_t,36 __conditional_t<sizeof(_Tp) <= sizeof(int32_t), int32_t,
37 __conditional_t<sizeof(_Tp) <= sizeof(int64_t), int64_t,37 __conditional_t<sizeof(_Tp) <= sizeof(int64_t), int64_t,
38#ifndef _LIBCPP_HAS_NO_INT12838#if _LIBCPP_HAS_INT128
39 __conditional_t<sizeof(_Tp) <= sizeof(__int128_t), __int128_t,39 __conditional_t<sizeof(_Tp) <= sizeof(__int128_t), __int128_t,
40 /* else */ void>40 /* else */ void>
41#else41#else
lib/libcxx/include/__type_traits/make_const_lvalue_ref.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>
22using __make_const_lvalue_ref = const __libcpp_remove_reference_t<_Tp>&;22using __make_const_lvalue_ref _LIBCPP_NODEBUG = const __libcpp_remove_reference_t<_Tp>&;
2323
24_LIBCPP_END_NAMESPACE_STD24_LIBCPP_END_NAMESPACE_STD
2525
lib/libcxx/include/__type_traits/make_signed.h+13-18
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__type_traits/copy_cv.h>13#include <__type_traits/copy_cv.h>
14#include <__type_traits/is_enum.h>14#include <__type_traits/is_enum.h>
15#include <__type_traits/is_integral.h>15#include <__type_traits/is_integral.h>
16#include <__type_traits/nat.h>
17#include <__type_traits/remove_cv.h>16#include <__type_traits/remove_cv.h>
18#include <__type_traits/type_list.h>17#include <__type_traits/type_list.h>
1918
...@@ -26,24 +25,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,24 +25,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD
26#if __has_builtin(__make_signed)25#if __has_builtin(__make_signed)
2726
28template <class _Tp>27template <class _Tp>
29using __make_signed_t = __make_signed(_Tp);28using __make_signed_t _LIBCPP_NODEBUG = __make_signed(_Tp);
3029
31#else30#else
32// clang-format off31using __signed_types =
33typedef __type_list<signed char,32 __type_list<signed char,
34 __type_list<signed short,33 signed short,
35 __type_list<signed int,34 signed int,
36 __type_list<signed long,35 signed long,
37 __type_list<signed long long,36 signed long long
38# ifndef _LIBCPP_HAS_NO_INT12837# if _LIBCPP_HAS_INT128
39 __type_list<__int128_t,38 ,
40# endif39 __int128_t
41 __nat
42# ifndef _LIBCPP_HAS_NO_INT128
43 >
44# endif40# endif
45 > > > > > __signed_types;41 >;
46// clang-format on
4742
48template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>43template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
49struct __make_signed{};44struct __make_signed{};
...@@ -63,7 +58,7 @@ template <> struct __make_signed< signed long, true> {typedef long ty...@@ -63,7 +58,7 @@ template <> struct __make_signed< signed long, true> {typedef long ty
63template <> struct __make_signed<unsigned long, true> {typedef long type;};58template <> struct __make_signed<unsigned long, true> {typedef long type;};
64template <> struct __make_signed< signed long long, true> {typedef long long type;};59template <> struct __make_signed< signed long long, true> {typedef long long type;};
65template <> struct __make_signed<unsigned long long, true> {typedef long long type;};60template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
66# ifndef _LIBCPP_HAS_NO_INT12861# if _LIBCPP_HAS_INT128
67template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};62template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
68template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};63template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
69# endif64# endif
...@@ -75,7 +70,7 @@ using __make_signed_t = __copy_cv_t<_Tp, typename __make_signed<__remove_cv_t<_T...@@ -75,7 +70,7 @@ using __make_signed_t = __copy_cv_t<_Tp, typename __make_signed<__remove_cv_t<_T
75#endif // __has_builtin(__make_signed)70#endif // __has_builtin(__make_signed)
7671
77template <class _Tp>72template <class _Tp>
78struct make_signed {73struct _LIBCPP_NO_SPECIALIZATIONS make_signed {
79 using type _LIBCPP_NODEBUG = __make_signed_t<_Tp>;74 using type _LIBCPP_NODEBUG = __make_signed_t<_Tp>;
80};75};
8176
lib/libcxx/include/__type_traits/make_unsigned.h+15-22
...@@ -15,7 +15,6 @@...@@ -15,7 +15,6 @@
15#include <__type_traits/is_enum.h>15#include <__type_traits/is_enum.h>
16#include <__type_traits/is_integral.h>16#include <__type_traits/is_integral.h>
17#include <__type_traits/is_unsigned.h>17#include <__type_traits/is_unsigned.h>
18#include <__type_traits/nat.h>
19#include <__type_traits/remove_cv.h>18#include <__type_traits/remove_cv.h>
20#include <__type_traits/type_list.h>19#include <__type_traits/type_list.h>
2120
...@@ -28,24 +27,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -28,24 +27,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD
28#if __has_builtin(__make_unsigned)27#if __has_builtin(__make_unsigned)
2928
30template <class _Tp>29template <class _Tp>
31using __make_unsigned_t = __make_unsigned(_Tp);30using __make_unsigned_t _LIBCPP_NODEBUG = __make_unsigned(_Tp);
3231
33#else32#else
34// clang-format off33using __unsigned_types =
35typedef __type_list<unsigned char,34 __type_list<unsigned char,
36 __type_list<unsigned short,35 unsigned short,
37 __type_list<unsigned int,36 unsigned int,
38 __type_list<unsigned long,37 unsigned long,
39 __type_list<unsigned long long,38 unsigned long long
40# ifndef _LIBCPP_HAS_NO_INT12839# if _LIBCPP_HAS_INT128
41 __type_list<__uint128_t,40 ,
42# endif41 __uint128_t
43 __nat
44# ifndef _LIBCPP_HAS_NO_INT128
45 >
46# endif42# endif
47 > > > > > __unsigned_types;43 >;
48// clang-format on
4944
50template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>45template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
51struct __make_unsigned{};46struct __make_unsigned{};
...@@ -65,7 +60,7 @@ template <> struct __make_unsigned< signed long, true> {typedef unsigned l...@@ -65,7 +60,7 @@ template <> struct __make_unsigned< signed long, true> {typedef unsigned l
65template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};60template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
66template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};61template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
67template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};62template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
68# ifndef _LIBCPP_HAS_NO_INT12863# if _LIBCPP_HAS_INT128
69template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};64template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
70template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};65template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
71# endif66# endif
...@@ -77,7 +72,7 @@ using __make_unsigned_t = __copy_cv_t<_Tp, typename __make_unsigned<__remove_cv_...@@ -77,7 +72,7 @@ using __make_unsigned_t = __copy_cv_t<_Tp, typename __make_unsigned<__remove_cv_
77#endif // __has_builtin(__make_unsigned)72#endif // __has_builtin(__make_unsigned)
7873
79template <class _Tp>74template <class _Tp>
80struct make_unsigned {75struct _LIBCPP_NO_SPECIALIZATIONS make_unsigned {
81 using type _LIBCPP_NODEBUG = __make_unsigned_t<_Tp>;76 using type _LIBCPP_NODEBUG = __make_unsigned_t<_Tp>;
82};77};
8378
...@@ -86,15 +81,13 @@ template <class _Tp>...@@ -86,15 +81,13 @@ template <class _Tp>
86using make_unsigned_t = __make_unsigned_t<_Tp>;81using make_unsigned_t = __make_unsigned_t<_Tp>;
87#endif82#endif
8883
89#ifndef _LIBCPP_CXX03_LANG
90template <class _Tp>84template <class _Tp>
91_LIBCPP_HIDE_FROM_ABI constexpr __make_unsigned_t<_Tp> __to_unsigned_like(_Tp __x) noexcept {85_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __make_unsigned_t<_Tp> __to_unsigned_like(_Tp __x) _NOEXCEPT {
92 return static_cast<__make_unsigned_t<_Tp> >(__x);86 return static_cast<__make_unsigned_t<_Tp> >(__x);
93}87}
94#endif
9588
96template <class _Tp, class _Up>89template <class _Tp, class _Up>
97using __copy_unsigned_t = __conditional_t<is_unsigned<_Tp>::value, __make_unsigned_t<_Up>, _Up>;90using __copy_unsigned_t _LIBCPP_NODEBUG = __conditional_t<is_unsigned<_Tp>::value, __make_unsigned_t<_Up>, _Up>;
9891
99_LIBCPP_END_NAMESPACE_STD92_LIBCPP_END_NAMESPACE_STD
10093
lib/libcxx/include/__type_traits/maybe_const.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <bool _Const, class _Tp>21template <bool _Const, class _Tp>
22using __maybe_const = __conditional_t<_Const, const _Tp, _Tp>;22using __maybe_const _LIBCPP_NODEBUG = __conditional_t<_Const, const _Tp, _Tp>;
2323
24_LIBCPP_END_NAMESPACE_STD24_LIBCPP_END_NAMESPACE_STD
2525
lib/libcxx/include/__type_traits/negation.h+2-2
...@@ -23,9 +23,9 @@ struct _Not : _BoolConstant<!_Pred::value> {};...@@ -23,9 +23,9 @@ struct _Not : _BoolConstant<!_Pred::value> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
26struct negation : _Not<_Tp> {};26struct _LIBCPP_NO_SPECIALIZATIONS negation : _Not<_Tp> {};
27template <class _Tp>27template <class _Tp>
28inline constexpr bool negation_v = !_Tp::value;28_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool negation_v = !_Tp::value;
29#endif // _LIBCPP_STD_VER >= 1729#endif // _LIBCPP_STD_VER >= 17
3030
31_LIBCPP_END_NAMESPACE_STD31_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/noexcept_move_assign_container.h deleted-37
...@@ -1,37 +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___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_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
25 : public integral_constant<bool,
26 _Traits::propagate_on_container_move_assignment::value
27#if _LIBCPP_STD_VER >= 17
28 || _Traits::is_always_equal::value
29#else
30 && is_nothrow_move_assignable<_Alloc>::value
31#endif
32 > {
33};
34
35_LIBCPP_END_NAMESPACE_STD
36
37#endif // _LIBCPP___TYPE_TRAITS_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H
lib/libcxx/include/__type_traits/promote.h+2-83
...@@ -13,20 +13,12 @@...@@ -13,20 +13,12 @@
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_arithmetic.h>14#include <__type_traits/is_arithmetic.h>
1515
16#if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER == 1700
17# include <__type_traits/is_same.h>
18# include <__utility/declval.h>
19#endif
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header17# pragma GCC system_header
23#endif18#endif
2419
25_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2621
27// TODO(LLVM-20): Remove this workaround
28#if !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER != 1700
29
30template <class... _Args>22template <class... _Args>
31class __promote {23class __promote {
32 static_assert((is_arithmetic<_Args>::value && ...));24 static_assert((is_arithmetic<_Args>::value && ...));
...@@ -39,10 +31,10 @@ class __promote {...@@ -39,10 +31,10 @@ class __promote {
39 static double __test(unsigned long);31 static double __test(unsigned long);
40 static double __test(long long);32 static double __test(long long);
41 static double __test(unsigned long long);33 static double __test(unsigned long long);
42# ifndef _LIBCPP_HAS_NO_INT12834#if _LIBCPP_HAS_INT128
43 static double __test(__int128_t);35 static double __test(__int128_t);
44 static double __test(__uint128_t);36 static double __test(__uint128_t);
45# endif37#endif
46 static double __test(double);38 static double __test(double);
47 static long double __test(long double);39 static long double __test(long double);
4840
...@@ -50,79 +42,6 @@ public:...@@ -50,79 +42,6 @@ public:
50 using type = decltype((__test(_Args()) + ...));42 using type = decltype((__test(_Args()) + ...));
51};43};
5244
53#else
54
55template <class _Tp>
56struct __numeric_type {
57 static void __test(...);
58 static float __test(float);
59 static double __test(char);
60 static double __test(int);
61 static double __test(unsigned);
62 static double __test(long);
63 static double __test(unsigned long);
64 static double __test(long long);
65 static double __test(unsigned long long);
66# ifndef _LIBCPP_HAS_NO_INT128
67 static double __test(__int128_t);
68 static double __test(__uint128_t);
69# endif
70 static double __test(double);
71 static long double __test(long double);
72
73 typedef decltype(__test(std::declval<_Tp>())) type;
74 static const bool value = _IsNotSame<type, void>::value;
75};
76
77template <>
78struct __numeric_type<void> {
79 static const bool value = true;
80};
81
82template <class _A1,
83 class _A2 = void,
84 class _A3 = void,
85 bool = __numeric_type<_A1>::value && __numeric_type<_A2>::value && __numeric_type<_A3>::value>
86class __promote_imp {
87public:
88 static const bool value = false;
89};
90
91template <class _A1, class _A2, class _A3>
92class __promote_imp<_A1, _A2, _A3, true> {
93private:
94 typedef typename __promote_imp<_A1>::type __type1;
95 typedef typename __promote_imp<_A2>::type __type2;
96 typedef typename __promote_imp<_A3>::type __type3;
97
98public:
99 typedef decltype(__type1() + __type2() + __type3()) type;
100 static const bool value = true;
101};
102
103template <class _A1, class _A2>
104class __promote_imp<_A1, _A2, void, true> {
105private:
106 typedef typename __promote_imp<_A1>::type __type1;
107 typedef typename __promote_imp<_A2>::type __type2;
108
109public:
110 typedef decltype(__type1() + __type2()) type;
111 static const bool value = true;
112};
113
114template <class _A1>
115class __promote_imp<_A1, void, void, true> {
116public:
117 typedef typename __numeric_type<_A1>::type type;
118 static const bool value = true;
119};
120
121template <class _A1, class _A2 = void, class _A3 = void>
122class __promote : public __promote_imp<_A1, _A2, _A3> {};
123
124#endif // !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 1700
125
126_LIBCPP_END_NAMESPACE_STD45_LIBCPP_END_NAMESPACE_STD
12746
128#endif // _LIBCPP___TYPE_TRAITS_PROMOTE_H47#endif // _LIBCPP___TYPE_TRAITS_PROMOTE_H
lib/libcxx/include/__type_traits/rank.h+9-3
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___TYPE_TRAITS_RANK_H10#define _LIBCPP___TYPE_TRAITS_RANK_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
14#include <cstddef>
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
...@@ -28,17 +28,23 @@ struct rank : integral_constant<size_t, __array_rank(_Tp)> {};...@@ -28,17 +28,23 @@ struct rank : integral_constant<size_t, __array_rank(_Tp)> {};
28#else28#else
2929
30template <class _Tp>30template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS rank : public integral_constant<size_t, 0> {};31struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS rank : public integral_constant<size_t, 0> {};
32
33_LIBCPP_DIAGNOSTIC_PUSH
34# if __has_warning("-Winvalid-specialization")
35_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
36# endif
32template <class _Tp>37template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> : public integral_constant<size_t, rank<_Tp>::value + 1> {};38struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> : public integral_constant<size_t, rank<_Tp>::value + 1> {};
34template <class _Tp, size_t _Np>39template <class _Tp, size_t _Np>
35struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> : public integral_constant<size_t, rank<_Tp>::value + 1> {};40struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> : public integral_constant<size_t, rank<_Tp>::value + 1> {};
41_LIBCPP_DIAGNOSTIC_POP
3642
37#endif // __has_builtin(__array_rank)43#endif // __has_builtin(__array_rank)
3844
39#if _LIBCPP_STD_VER >= 1745#if _LIBCPP_STD_VER >= 17
40template <class _Tp>46template <class _Tp>
41inline constexpr size_t rank_v = rank<_Tp>::value;47_LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t rank_v = rank<_Tp>::value;
42#endif48#endif
4349
44_LIBCPP_END_NAMESPACE_STD50_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_all_extents.h+3-3
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H10#define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
1111
12#include <__config>12#include <__config>
13#include <cstddef>13#include <__cstddef/size_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
...@@ -20,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -20,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if __has_builtin(__remove_all_extents)21#if __has_builtin(__remove_all_extents)
22template <class _Tp>22template <class _Tp>
23struct remove_all_extents {23struct _LIBCPP_NO_SPECIALIZATIONS remove_all_extents {
24 using type _LIBCPP_NODEBUG = __remove_all_extents(_Tp);24 using type _LIBCPP_NODEBUG = __remove_all_extents(_Tp);
25};25};
2626
27template <class _Tp>27template <class _Tp>
28using __remove_all_extents_t = __remove_all_extents(_Tp);28using __remove_all_extents_t _LIBCPP_NODEBUG = __remove_all_extents(_Tp);
29#else29#else
30template <class _Tp>30template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS remove_all_extents {31struct _LIBCPP_TEMPLATE_VIS remove_all_extents {
lib/libcxx/include/__type_traits/remove_const.h+2-2
...@@ -19,12 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -19,12 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
1919
20#if __has_builtin(__remove_const)20#if __has_builtin(__remove_const)
21template <class _Tp>21template <class _Tp>
22struct remove_const {22struct _LIBCPP_NO_SPECIALIZATIONS remove_const {
23 using type _LIBCPP_NODEBUG = __remove_const(_Tp);23 using type _LIBCPP_NODEBUG = __remove_const(_Tp);
24};24};
2525
26template <class _Tp>26template <class _Tp>
27using __remove_const_t = __remove_const(_Tp);27using __remove_const_t _LIBCPP_NODEBUG = __remove_const(_Tp);
28#else28#else
29template <class _Tp>29template <class _Tp>
30struct _LIBCPP_TEMPLATE_VIS remove_const {30struct _LIBCPP_TEMPLATE_VIS remove_const {
lib/libcxx/include/__type_traits/remove_const_ref.h+1-1
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _Tp>22template <class _Tp>
23using __remove_const_ref_t = __remove_const_t<__libcpp_remove_reference_t<_Tp> >;23using __remove_const_ref_t _LIBCPP_NODEBUG = __remove_const_t<__libcpp_remove_reference_t<_Tp> >;
2424
25_LIBCPP_END_NAMESPACE_STD25_LIBCPP_END_NAMESPACE_STD
2626
lib/libcxx/include/__type_traits/remove_cv.h+5-12
...@@ -10,8 +10,6 @@...@@ -10,8 +10,6 @@
10#define _LIBCPP___TYPE_TRAITS_REMOVE_CV_H10#define _LIBCPP___TYPE_TRAITS_REMOVE_CV_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/remove_const.h>
14#include <__type_traits/remove_volatile.h>
1513
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header15# pragma GCC system_header
...@@ -19,23 +17,18 @@...@@ -19,23 +17,18 @@
1917
20_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
2119
22#if __has_builtin(__remove_cv) && !defined(_LIBCPP_COMPILER_GCC)
23template <class _Tp>20template <class _Tp>
24struct remove_cv {21struct _LIBCPP_NO_SPECIALIZATIONS remove_cv {
25 using type _LIBCPP_NODEBUG = __remove_cv(_Tp);22 using type _LIBCPP_NODEBUG = __remove_cv(_Tp);
26};23};
2724
25#if defined(_LIBCPP_COMPILER_GCC)
28template <class _Tp>26template <class _Tp>
29using __remove_cv_t = __remove_cv(_Tp);27using __remove_cv_t _LIBCPP_NODEBUG = typename remove_cv<_Tp>::type;
30#else28#else
31template <class _Tp>29template <class _Tp>
32struct _LIBCPP_TEMPLATE_VIS remove_cv {30using __remove_cv_t _LIBCPP_NODEBUG = __remove_cv(_Tp);
33 typedef __remove_volatile_t<__remove_const_t<_Tp> > type;31#endif
34};
35
36template <class _Tp>
37using __remove_cv_t = __remove_volatile_t<__remove_const_t<_Tp> >;
38#endif // __has_builtin(__remove_cv)
3932
40#if _LIBCPP_STD_VER >= 1433#if _LIBCPP_STD_VER >= 14
41template <class _Tp>34template <class _Tp>
lib/libcxx/include/__type_traits/remove_cvref.h+11-8
...@@ -11,8 +11,6 @@...@@ -11,8 +11,6 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/is_same.h>13#include <__type_traits/is_same.h>
14#include <__type_traits/remove_cv.h>
15#include <__type_traits/remove_reference.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
...@@ -20,21 +18,26 @@...@@ -20,21 +18,26 @@
2018
21_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2220
23#if __has_builtin(__remove_cvref) && !defined(_LIBCPP_COMPILER_GCC)21#if defined(_LIBCPP_COMPILER_GCC)
24template <class _Tp>22template <class _Tp>
25using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp);23struct __remove_cvref_gcc {
24 using type = __remove_cvref(_Tp);
25};
26
27template <class _Tp>
28using __remove_cvref_t _LIBCPP_NODEBUG = typename __remove_cvref_gcc<_Tp>::type;
26#else29#else
27template <class _Tp>30template <class _Tp>
28using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >;31using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp);
29#endif // __has_builtin(__remove_cvref)32#endif // __has_builtin(__remove_cvref)
3033
31template <class _Tp, class _Up>34template <class _Tp, class _Up>
32struct __is_same_uncvref : _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> > {};35using __is_same_uncvref _LIBCPP_NODEBUG = _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> >;
3336
34#if _LIBCPP_STD_VER >= 2037#if _LIBCPP_STD_VER >= 20
35template <class _Tp>38template <class _Tp>
36struct remove_cvref {39struct _LIBCPP_NO_SPECIALIZATIONS remove_cvref {
37 using type _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>;40 using type _LIBCPP_NODEBUG = __remove_cvref(_Tp);
38};41};
3942
40template <class _Tp>43template <class _Tp>
lib/libcxx/include/__type_traits/remove_extent.h+3-3
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H10#define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H
1111
12#include <__config>12#include <__config>
13#include <cstddef>13#include <__cstddef/size_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
...@@ -20,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -20,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if __has_builtin(__remove_extent)21#if __has_builtin(__remove_extent)
22template <class _Tp>22template <class _Tp>
23struct remove_extent {23struct _LIBCPP_NO_SPECIALIZATIONS remove_extent {
24 using type _LIBCPP_NODEBUG = __remove_extent(_Tp);24 using type _LIBCPP_NODEBUG = __remove_extent(_Tp);
25};25};
2626
27template <class _Tp>27template <class _Tp>
28using __remove_extent_t = __remove_extent(_Tp);28using __remove_extent_t _LIBCPP_NODEBUG = __remove_extent(_Tp);
29#else29#else
30template <class _Tp>30template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS remove_extent {31struct _LIBCPP_TEMPLATE_VIS remove_extent {
lib/libcxx/include/__type_traits/remove_pointer.h+8-8
...@@ -19,24 +19,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -19,24 +19,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD
1919
20#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__remove_pointer)20#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__remove_pointer)
21template <class _Tp>21template <class _Tp>
22struct remove_pointer {22struct _LIBCPP_NO_SPECIALIZATIONS remove_pointer {
23 using type _LIBCPP_NODEBUG = __remove_pointer(_Tp);23 using type _LIBCPP_NODEBUG = __remove_pointer(_Tp);
24};24};
2525
26# ifdef _LIBCPP_COMPILER_GCC26# ifdef _LIBCPP_COMPILER_GCC
27template <class _Tp>27template <class _Tp>
28using __remove_pointer_t = typename remove_pointer<_Tp>::type;28using __remove_pointer_t _LIBCPP_NODEBUG = typename remove_pointer<_Tp>::type;
29# else29# else
30template <class _Tp>30template <class _Tp>
31using __remove_pointer_t = __remove_pointer(_Tp);31using __remove_pointer_t _LIBCPP_NODEBUG = __remove_pointer(_Tp);
32# endif32# endif
33#else33#else
34// clang-format off34// clang-format off
35template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;};35template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {using type _LIBCPP_NODEBUG = _Tp;};
36template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;};36template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {using type _LIBCPP_NODEBUG = _Tp;};
37template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;};37template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {using type _LIBCPP_NODEBUG = _Tp;};
38template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;};38template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {using type _LIBCPP_NODEBUG = _Tp;};
39template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;};39template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {using type _LIBCPP_NODEBUG = _Tp;};
40// clang-format on40// clang-format on
4141
42template <class _Tp>42template <class _Tp>
lib/libcxx/include/__type_traits/remove_reference.h+2-2
...@@ -19,12 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -19,12 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
1919
20#if __has_builtin(__remove_reference_t)20#if __has_builtin(__remove_reference_t)
21template <class _Tp>21template <class _Tp>
22struct remove_reference {22struct _LIBCPP_NO_SPECIALIZATIONS remove_reference {
23 using type _LIBCPP_NODEBUG = __remove_reference_t(_Tp);23 using type _LIBCPP_NODEBUG = __remove_reference_t(_Tp);
24};24};
2525
26template <class _Tp>26template <class _Tp>
27using __libcpp_remove_reference_t = __remove_reference_t(_Tp);27using __libcpp_remove_reference_t _LIBCPP_NODEBUG = __remove_reference_t(_Tp);
28#elif __has_builtin(__remove_reference)28#elif __has_builtin(__remove_reference)
29template <class _Tp>29template <class _Tp>
30struct remove_reference {30struct remove_reference {
lib/libcxx/include/__type_traits/remove_volatile.h+2-2
...@@ -19,12 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -19,12 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
1919
20#if __has_builtin(__remove_volatile)20#if __has_builtin(__remove_volatile)
21template <class _Tp>21template <class _Tp>
22struct remove_volatile {22struct _LIBCPP_NO_SPECIALIZATIONS remove_volatile {
23 using type _LIBCPP_NODEBUG = __remove_volatile(_Tp);23 using type _LIBCPP_NODEBUG = __remove_volatile(_Tp);
24};24};
2525
26template <class _Tp>26template <class _Tp>
27using __remove_volatile_t = __remove_volatile(_Tp);27using __remove_volatile_t _LIBCPP_NODEBUG = __remove_volatile(_Tp);
28#else28#else
29template <class _Tp>29template <class _Tp>
30struct _LIBCPP_TEMPLATE_VIS remove_volatile {30struct _LIBCPP_TEMPLATE_VIS remove_volatile {
lib/libcxx/include/__type_traits/result_of.h+8-3
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_RESULT_OF_H10#define _LIBCPP___TYPE_TRAITS_RESULT_OF_H
1111
12#include <__config>12#include <__config>
13#include <__functional/invoke.h>13#include <__type_traits/invoke.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
...@@ -22,10 +22,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,10 +22,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)23#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
24template <class _Callable>24template <class _Callable>
25class _LIBCPP_DEPRECATED_IN_CXX17 result_of;25struct _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS result_of;
2626
27_LIBCPP_DIAGNOSTIC_PUSH
28#if __has_warning("-Winvalid-specialization")
29_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
30#endif
27template <class _Fp, class... _Args>31template <class _Fp, class... _Args>
28class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> : public __invoke_of<_Fp, _Args...> {};32struct _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> : __invoke_result<_Fp, _Args...> {};
33_LIBCPP_DIAGNOSTIC_POP
2934
30# if _LIBCPP_STD_VER >= 1435# if _LIBCPP_STD_VER >= 14
31template <class _Tp>36template <class _Tp>
lib/libcxx/include/__type_traits/type_identity.h+1-1
...@@ -27,7 +27,7 @@ using __type_identity_t _LIBCPP_NODEBUG = typename __type_identity<_Tp>::type;...@@ -27,7 +27,7 @@ using __type_identity_t _LIBCPP_NODEBUG = typename __type_identity<_Tp>::type;
2727
28#if _LIBCPP_STD_VER >= 2028#if _LIBCPP_STD_VER >= 20
29template <class _Tp>29template <class _Tp>
30struct type_identity {30struct _LIBCPP_NO_SPECIALIZATIONS type_identity {
31 typedef _Tp type;31 typedef _Tp type;
32};32};
33template <class _Tp>33template <class _Tp>
lib/libcxx/include/__type_traits/type_list.h+17-12
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_TYPE_LIST_H10#define _LIBCPP___TYPE_TRAITS_TYPE_LIST_H
1111
12#include <__config>12#include <__config>
13#include <cstddef>13#include <__cstddef/size_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
...@@ -18,23 +18,28 @@...@@ -18,23 +18,28 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Hp, class _Tp>21template <class... _Types>
22struct __type_list {22struct __type_list {};
23 typedef _Hp _Head;23
24 typedef _Tp _Tail;24template <class>
25struct __type_list_head;
26
27template <class _Head, class... _Tail>
28struct __type_list_head<__type_list<_Head, _Tail...> > {
29 using type _LIBCPP_NODEBUG = _Head;
25};30};
2631
27template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)>32template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename __type_list_head<_TypeList>::type)>
28struct __find_first;33struct __find_first;
2934
30template <class _Hp, class _Tp, size_t _Size>35template <class _Head, class... _Tail, size_t _Size>
31struct __find_first<__type_list<_Hp, _Tp>, _Size, true> {36struct __find_first<__type_list<_Head, _Tail...>, _Size, true> {
32 typedef _LIBCPP_NODEBUG _Hp type;37 using type _LIBCPP_NODEBUG = _Head;
33};38};
3439
35template <class _Hp, class _Tp, size_t _Size>40template <class _Head, class... _Tail, size_t _Size>
36struct __find_first<__type_list<_Hp, _Tp>, _Size, false> {41struct __find_first<__type_list<_Head, _Tail...>, _Size, false> {
37 typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type;42 using type _LIBCPP_NODEBUG = typename __find_first<__type_list<_Tail...>, _Size>::type;
38};43};
3944
40_LIBCPP_END_NAMESPACE_STD45_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/underlying_type.h+1-1
...@@ -30,7 +30,7 @@ struct __underlying_type_impl<_Tp, true> {...@@ -30,7 +30,7 @@ struct __underlying_type_impl<_Tp, true> {
30};30};
3131
32template <class _Tp>32template <class _Tp>
33struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};33struct _LIBCPP_NO_SPECIALIZATIONS underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};
3434
35#if _LIBCPP_STD_VER >= 1435#if _LIBCPP_STD_VER >= 14
36template <class _Tp>36template <class _Tp>
lib/libcxx/include/__type_traits/unwrap_ref.h+8-15
...@@ -21,38 +21,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,38 +21,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _Tp>22template <class _Tp>
23struct __unwrap_reference {23struct __unwrap_reference {
24 typedef _LIBCPP_NODEBUG _Tp type;24 using type _LIBCPP_NODEBUG = _Tp;
25};25};
2626
27template <class _Tp>27template <class _Tp>
28struct __unwrap_reference<reference_wrapper<_Tp> > {28struct __unwrap_reference<reference_wrapper<_Tp> > {
29 typedef _LIBCPP_NODEBUG _Tp& type;29 using type _LIBCPP_NODEBUG = _Tp&;
30};30};
3131
32template <class _Tp>
33using __unwrap_ref_decay_t _LIBCPP_NODEBUG = typename __unwrap_reference<__decay_t<_Tp> >::type;
34
32#if _LIBCPP_STD_VER >= 2035#if _LIBCPP_STD_VER >= 20
33template <class _Tp>36template <class _Tp>
34struct unwrap_reference : __unwrap_reference<_Tp> {};37struct _LIBCPP_NO_SPECIALIZATIONS unwrap_reference : __unwrap_reference<_Tp> {};
3538
36template <class _Tp>39template <class _Tp>
37using unwrap_reference_t = typename unwrap_reference<_Tp>::type;40using unwrap_reference_t = typename unwrap_reference<_Tp>::type;
3841
39template <class _Tp>42template <class _Tp>
40struct unwrap_ref_decay : unwrap_reference<__decay_t<_Tp> > {};43struct _LIBCPP_NO_SPECIALIZATIONS unwrap_ref_decay : unwrap_reference<__decay_t<_Tp> > {};
4144
42template <class _Tp>45template <class _Tp>
43using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type;46using unwrap_ref_decay_t = __unwrap_ref_decay_t<_Tp>;
44#endif // _LIBCPP_STD_VER >= 2047#endif // _LIBCPP_STD_VER >= 20
4548
46template <class _Tp>
47struct __unwrap_ref_decay
48#if _LIBCPP_STD_VER >= 20
49 : unwrap_ref_decay<_Tp>
50#else
51 : __unwrap_reference<__decay_t<_Tp> >
52#endif
53{
54};
55
56_LIBCPP_END_NAMESPACE_STD49_LIBCPP_END_NAMESPACE_STD
5750
58#endif // _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H51#endif // _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H
lib/libcxx/include/__type_traits/void_t.h+1-1
...@@ -23,7 +23,7 @@ using void_t = void;...@@ -23,7 +23,7 @@ using void_t = void;
23#endif23#endif
2424
25template <class...>25template <class...>
26using __void_t = void;26using __void_t _LIBCPP_NODEBUG = void;
2727
28_LIBCPP_END_NAMESPACE_STD28_LIBCPP_END_NAMESPACE_STD
2929
lib/libcxx/include/__utility/as_const.h+1-4
...@@ -10,9 +10,6 @@...@@ -10,9 +10,6 @@
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>
14#include <__utility/forward.h>
15#include <__utility/move.h>
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
...@@ -22,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2219
23#if _LIBCPP_STD_VER >= 1720#if _LIBCPP_STD_VER >= 17
24template <class _Tp>21template <class _Tp>
25[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept {22[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& as_const(_Tp& __t) noexcept {
26 return __t;23 return __t;
27}24}
2825
lib/libcxx/include/__utility/convert_to_integral.h+1-1
...@@ -42,7 +42,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long long __convert_to_integral(_...@@ -42,7 +42,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long long __convert_to_integral(_
42 return __val;42 return __val;
43}43}
4444
45#ifndef _LIBCPP_HAS_NO_INT12845#if _LIBCPP_HAS_INT128
46inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __int128_t __convert_to_integral(__int128_t __val) { return __val; }46inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __int128_t __convert_to_integral(__int128_t __val) { return __val; }
4747
48inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }48inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
lib/libcxx/include/__utility/element_count.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___UTILITY_ELEMENT_COUNT_H
10#define _LIBCPP___UTILITY_ELEMENT_COUNT_H
11
12#include <__config>
13#include <__cstddef/size_t.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// Type used to encode that a function takes an integer that represents a number
22// of elements as opposed to a number of bytes.
23enum class __element_count : size_t {};
24
25_LIBCPP_END_NAMESPACE_STD
26
27#endif // _LIBCPP___UTILITY_ELEMENT_COUNT_H
lib/libcxx/include/__utility/exception_guard.h+9-9
...@@ -44,7 +44,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -44,7 +44,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
44// less common, especially one that tries to catch an exception through -fno-exceptions code.44// less common, especially one that tries to catch an exception through -fno-exceptions code.
45//45//
46// __exception_guard can help greatly simplify code that would normally be cluttered by46// __exception_guard can help greatly simplify code that would normally be cluttered by
47// `#if _LIBCPP_HAS_NO_EXCEPTIONS`. For example:47// `#if _LIBCPP_HAS_EXCEPTIONS`. For example:
48//48//
49// template <class Iterator, class Size, class OutputIterator>49// template <class Iterator, class Size, class OutputIterator>
50// Iterator uninitialized_copy_n(Iterator iter, Size n, OutputIterator out) {50// Iterator uninitialized_copy_n(Iterator iter, Size n, OutputIterator out) {
...@@ -96,10 +96,10 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard_exceptions);...@@ -96,10 +96,10 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard_exceptions);
96template <class _Rollback>96template <class _Rollback>
97struct __exception_guard_noexceptions {97struct __exception_guard_noexceptions {
98 __exception_guard_noexceptions() = delete;98 __exception_guard_noexceptions() = delete;
99 _LIBCPP_HIDE_FROM_ABI99 _LIBCPP_NODEBUG _LIBCPP_HIDE_FROM_ABI
100 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG explicit __exception_guard_noexceptions(_Rollback) {}100 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __exception_guard_noexceptions(_Rollback) {}
101101
102 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG102 _LIBCPP_NODEBUG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
103 __exception_guard_noexceptions(__exception_guard_noexceptions&& __other)103 __exception_guard_noexceptions(__exception_guard_noexceptions&& __other)
104 _NOEXCEPT_(is_nothrow_move_constructible<_Rollback>::value)104 _NOEXCEPT_(is_nothrow_move_constructible<_Rollback>::value)
105 : __completed_(__other.__completed_) {105 : __completed_(__other.__completed_) {
...@@ -110,11 +110,11 @@ struct __exception_guard_noexceptions {...@@ -110,11 +110,11 @@ struct __exception_guard_noexceptions {
110 __exception_guard_noexceptions& operator=(__exception_guard_noexceptions const&) = delete;110 __exception_guard_noexceptions& operator=(__exception_guard_noexceptions const&) = delete;
111 __exception_guard_noexceptions& operator=(__exception_guard_noexceptions&&) = delete;111 __exception_guard_noexceptions& operator=(__exception_guard_noexceptions&&) = delete;
112112
113 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG void __complete() _NOEXCEPT {113 _LIBCPP_NODEBUG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __complete() _NOEXCEPT {
114 __completed_ = true;114 __completed_ = true;
115 }115 }
116116
117 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG ~__exception_guard_noexceptions() {117 _LIBCPP_NODEBUG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__exception_guard_noexceptions() {
118 _LIBCPP_ASSERT_INTERNAL(__completed_, "__exception_guard not completed with exceptions disabled");118 _LIBCPP_ASSERT_INTERNAL(__completed_, "__exception_guard not completed with exceptions disabled");
119 }119 }
120120
...@@ -124,12 +124,12 @@ private:...@@ -124,12 +124,12 @@ private:
124124
125_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard_noexceptions);125_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard_noexceptions);
126126
127#ifdef _LIBCPP_HAS_NO_EXCEPTIONS127#if !_LIBCPP_HAS_EXCEPTIONS
128template <class _Rollback>128template <class _Rollback>
129using __exception_guard = __exception_guard_noexceptions<_Rollback>;129using __exception_guard _LIBCPP_NODEBUG = __exception_guard_noexceptions<_Rollback>;
130#else130#else
131template <class _Rollback>131template <class _Rollback>
132using __exception_guard = __exception_guard_exceptions<_Rollback>;132using __exception_guard _LIBCPP_NODEBUG = __exception_guard_exceptions<_Rollback>;
133#endif133#endif
134134
135template <class _Rollback>135template <class _Rollback>
lib/libcxx/include/__utility/forward.h+2-2
...@@ -21,13 +21,13 @@...@@ -21,13 +21,13 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Tp>23template <class _Tp>
24_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&24[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&
25forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>& __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 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&30[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&
31forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>&& __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);
lib/libcxx/include/__utility/forward_like.h+20-3
...@@ -12,6 +12,7 @@...@@ -12,6 +12,7 @@
1212
13#include <__config>13#include <__config>
14#include <__type_traits/conditional.h>14#include <__type_traits/conditional.h>
15#include <__type_traits/is_base_of.h>
15#include <__type_traits/is_const.h>16#include <__type_traits/is_const.h>
16#include <__type_traits/is_reference.h>17#include <__type_traits/is_reference.h>
17#include <__type_traits/remove_reference.h>18#include <__type_traits/remove_reference.h>
...@@ -25,13 +26,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -25,13 +26,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
25#if _LIBCPP_STD_VER >= 2326#if _LIBCPP_STD_VER >= 23
2627
27template <class _Ap, class _Bp>28template <class _Ap, class _Bp>
28using _CopyConst = _If<is_const_v<_Ap>, const _Bp, _Bp>;29using _CopyConst _LIBCPP_NODEBUG = _If<is_const_v<_Ap>, const _Bp, _Bp>;
2930
30template <class _Ap, class _Bp>31template <class _Ap, class _Bp>
31using _OverrideRef = _If<is_rvalue_reference_v<_Ap>, remove_reference_t<_Bp>&&, _Bp&>;32using _OverrideRef _LIBCPP_NODEBUG = _If<is_rvalue_reference_v<_Ap>, remove_reference_t<_Bp>&&, _Bp&>;
3233
33template <class _Ap, class _Bp>34template <class _Ap, class _Bp>
34using _ForwardLike = _OverrideRef<_Ap&&, _CopyConst<remove_reference_t<_Ap>, remove_reference_t<_Bp>>>;35using _ForwardLike _LIBCPP_NODEBUG = _OverrideRef<_Ap&&, _CopyConst<remove_reference_t<_Ap>, remove_reference_t<_Bp>>>;
3536
36template <class _Tp, class _Up>37template <class _Tp, class _Up>
37[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto38[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto
...@@ -39,6 +40,22 @@ forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept -> _ForwardLike<_Tp, _Up...@@ -39,6 +40,22 @@ forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept -> _ForwardLike<_Tp, _Up
39 return static_cast<_ForwardLike<_Tp, _Up>>(__ux);40 return static_cast<_ForwardLike<_Tp, _Up>>(__ux);
40}41}
4142
43// This function is used for `deducing this` cases where you want to make sure the operation is performed on the class
44// itself and not on a derived class. For example
45// struct S {
46// template <class Self>
47// void func(Self&& self) {
48// // This will always call `do_something` of S instead of any class derived from S.
49// std::__forward_as<Self, S>(self).do_something();
50// }
51// };
52template <class _Tp, class _As, class _Up>
53[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _ForwardLike<_Tp, _As>
54__forward_as(_LIBCPP_LIFETIMEBOUND _Up&& __val) noexcept {
55 static_assert(is_base_of_v<_As, remove_reference_t<_Up>>);
56 return static_cast<_ForwardLike<_Tp, _As>>(__val);
57}
58
42#endif // _LIBCPP_STD_VER >= 2359#endif // _LIBCPP_STD_VER >= 23
4360
44_LIBCPP_END_NAMESPACE_STD61_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__utility/in_place.h+4-3
...@@ -10,8 +10,9 @@...@@ -10,8 +10,9 @@
10#define _LIBCPP___UTILITY_IN_PLACE_H10#define _LIBCPP___UTILITY_IN_PLACE_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__type_traits/integral_constant.h>
13#include <__type_traits/remove_cvref.h>15#include <__type_traits/remove_cvref.h>
14#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
...@@ -46,7 +47,7 @@ template <class _Tp>...@@ -46,7 +47,7 @@ template <class _Tp>
46struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {};47struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {};
4748
48template <class _Tp>49template <class _Tp>
49using __is_inplace_type = __is_inplace_type_imp<__remove_cvref_t<_Tp>>;50using __is_inplace_type _LIBCPP_NODEBUG = __is_inplace_type_imp<__remove_cvref_t<_Tp>>;
5051
51template <class _Tp>52template <class _Tp>
52struct __is_inplace_index_imp : false_type {};53struct __is_inplace_index_imp : false_type {};
...@@ -54,7 +55,7 @@ template <size_t _Idx>...@@ -54,7 +55,7 @@ template <size_t _Idx>
54struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {};55struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {};
5556
56template <class _Tp>57template <class _Tp>
57using __is_inplace_index = __is_inplace_index_imp<__remove_cvref_t<_Tp>>;58using __is_inplace_index _LIBCPP_NODEBUG = __is_inplace_index_imp<__remove_cvref_t<_Tp>>;
5859
59#endif // _LIBCPP_STD_VER >= 1760#endif // _LIBCPP_STD_VER >= 17
6061
lib/libcxx/include/__utility/integer_sequence.h+5-5
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___UTILITY_INTEGER_SEQUENCE_H10#define _LIBCPP___UTILITY_INTEGER_SEQUENCE_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
13#include <__type_traits/is_integral.h>14#include <__type_traits/is_integral.h>
14#include <cstddef>
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
...@@ -25,19 +25,19 @@ struct __tuple_indices;...@@ -25,19 +25,19 @@ struct __tuple_indices;
25template <class _IdxType, _IdxType... _Values>25template <class _IdxType, _IdxType... _Values>
26struct __integer_sequence {26struct __integer_sequence {
27 template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>27 template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>
28 using __convert = _ToIndexSeq<_ToIndexType, _Values...>;28 using __convert _LIBCPP_NODEBUG = _ToIndexSeq<_ToIndexType, _Values...>;
2929
30 template <size_t _Sp>30 template <size_t _Sp>
31 using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;31 using __to_tuple_indices _LIBCPP_NODEBUG = __tuple_indices<(_Values + _Sp)...>;
32};32};
3333
34#if __has_builtin(__make_integer_seq)34#if __has_builtin(__make_integer_seq)
35template <size_t _Ep, size_t _Sp>35template <size_t _Ep, size_t _Sp>
36using __make_indices_imp =36using __make_indices_imp _LIBCPP_NODEBUG =
37 typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template __to_tuple_indices<_Sp>;37 typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template __to_tuple_indices<_Sp>;
38#elif __has_builtin(__integer_pack)38#elif __has_builtin(__integer_pack)
39template <size_t _Ep, size_t _Sp>39template <size_t _Ep, size_t _Sp>
40using __make_indices_imp =40using __make_indices_imp _LIBCPP_NODEBUG =
41 typename __integer_sequence<size_t, __integer_pack(_Ep - _Sp)...>::template __to_tuple_indices<_Sp>;41 typename __integer_sequence<size_t, __integer_pack(_Ep - _Sp)...>::template __to_tuple_indices<_Sp>;
42#else42#else
43# error "No known way to get an integer pack from the compiler"43# error "No known way to get an integer pack from the compiler"
lib/libcxx/include/__utility/is_pointer_in_range.h+8
...@@ -57,6 +57,14 @@ __is_pointer_in_range(const _Tp* __begin, const _Tp* __end, const _Up* __ptr) {...@@ -57,6 +57,14 @@ __is_pointer_in_range(const _Tp* __begin, const _Tp* __end, const _Up* __ptr) {
57 reinterpret_cast<const char*>(__ptr) < reinterpret_cast<const char*>(__end);57 reinterpret_cast<const char*>(__ptr) < reinterpret_cast<const char*>(__end);
58}58}
5959
60template <class _Tp, class _Up>
61_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
62__is_overlapping_range(const _Tp* __begin, const _Tp* __end, const _Up* __begin2) {
63 auto __size = __end - __begin;
64 auto __end2 = __begin2 + __size;
65 return std::__is_pointer_in_range(__begin, __end, __begin2) || std::__is_pointer_in_range(__begin2, __end2, __begin);
66}
67
60_LIBCPP_END_NAMESPACE_STD68_LIBCPP_END_NAMESPACE_STD
6169
62#endif // _LIBCPP___UTILITY_IS_POINTER_IN_RANGE_H70#endif // _LIBCPP___UTILITY_IS_POINTER_IN_RANGE_H
lib/libcxx/include/__utility/move.h+4-4
...@@ -26,18 +26,18 @@ _LIBCPP_PUSH_MACROS...@@ -26,18 +26,18 @@ _LIBCPP_PUSH_MACROS
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28template <class _Tp>28template <class _Tp>
29_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __libcpp_remove_reference_t<_Tp>&&29[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __libcpp_remove_reference_t<_Tp>&&
30move(_LIBCPP_LIFETIMEBOUND _Tp&& __t) _NOEXCEPT {30move(_LIBCPP_LIFETIMEBOUND _Tp&& __t) _NOEXCEPT {
31 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up;31 using _Up _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>;
32 return static_cast<_Up&&>(__t);32 return static_cast<_Up&&>(__t);
33}33}
3434
35template <class _Tp>35template <class _Tp>
36using __move_if_noexcept_result_t =36using __move_if_noexcept_result_t _LIBCPP_NODEBUG =
37 __conditional_t<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&, _Tp&&>;37 __conditional_t<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&, _Tp&&>;
3838
39template <class _Tp>39template <class _Tp>
40_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __move_if_noexcept_result_t<_Tp>40[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __move_if_noexcept_result_t<_Tp>
41move_if_noexcept(_LIBCPP_LIFETIMEBOUND _Tp& __x) _NOEXCEPT {41move_if_noexcept(_LIBCPP_LIFETIMEBOUND _Tp& __x) _NOEXCEPT {
42 return std::move(__x);42 return std::move(__x);
43}43}
lib/libcxx/include/__utility/no_destroy.h+1-1
...@@ -10,9 +10,9 @@...@@ -10,9 +10,9 @@
10#define _LIBCPP___UTILITY_NO_DESTROY_H10#define _LIBCPP___UTILITY_NO_DESTROY_H
1111
12#include <__config>12#include <__config>
13#include <__new/placement_new_delete.h>
13#include <__type_traits/is_constant_evaluated.h>14#include <__type_traits/is_constant_evaluated.h>
14#include <__utility/forward.h>15#include <__utility/forward.h>
15#include <new>
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/__utility/pair.h+11-51
...@@ -13,11 +13,10 @@...@@ -13,11 +13,10 @@
13#include <__compare/synth_three_way.h>13#include <__compare/synth_three_way.h>
14#include <__concepts/different_from.h>14#include <__concepts/different_from.h>
15#include <__config>15#include <__config>
16#include <__cstddef/size_t.h>
16#include <__fwd/array.h>17#include <__fwd/array.h>
17#include <__fwd/pair.h>18#include <__fwd/pair.h>
18#include <__fwd/tuple.h>19#include <__fwd/tuple.h>
19#include <__tuple/sfinae_helpers.h>
20#include <__tuple/tuple_element.h>
21#include <__tuple/tuple_indices.h>20#include <__tuple/tuple_indices.h>
22#include <__tuple/tuple_like_no_subrange.h>21#include <__tuple/tuple_like_no_subrange.h>
23#include <__tuple/tuple_size.h>22#include <__tuple/tuple_size.h>
...@@ -25,6 +24,7 @@...@@ -25,6 +24,7 @@
25#include <__type_traits/common_type.h>24#include <__type_traits/common_type.h>
26#include <__type_traits/conditional.h>25#include <__type_traits/conditional.h>
27#include <__type_traits/decay.h>26#include <__type_traits/decay.h>
27#include <__type_traits/enable_if.h>
28#include <__type_traits/integral_constant.h>28#include <__type_traits/integral_constant.h>
29#include <__type_traits/is_assignable.h>29#include <__type_traits/is_assignable.h>
30#include <__type_traits/is_constructible.h>30#include <__type_traits/is_constructible.h>
...@@ -32,7 +32,6 @@...@@ -32,7 +32,6 @@
32#include <__type_traits/is_implicitly_default_constructible.h>32#include <__type_traits/is_implicitly_default_constructible.h>
33#include <__type_traits/is_nothrow_assignable.h>33#include <__type_traits/is_nothrow_assignable.h>
34#include <__type_traits/is_nothrow_constructible.h>34#include <__type_traits/is_nothrow_constructible.h>
35#include <__type_traits/is_reference.h>
36#include <__type_traits/is_same.h>35#include <__type_traits/is_same.h>
37#include <__type_traits/is_swappable.h>36#include <__type_traits/is_swappable.h>
38#include <__type_traits/is_trivially_relocatable.h>37#include <__type_traits/is_trivially_relocatable.h>
...@@ -43,7 +42,6 @@...@@ -43,7 +42,6 @@
43#include <__utility/forward.h>42#include <__utility/forward.h>
44#include <__utility/move.h>43#include <__utility/move.h>
45#include <__utility/piecewise_construct.h>44#include <__utility/piecewise_construct.h>
46#include <cstddef>
4745
48#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)46#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
49# pragma GCC system_header47# pragma GCC system_header
...@@ -73,7 +71,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -73,7 +71,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
73 _T1 first;71 _T1 first;
74 _T2 second;72 _T2 second;
7573
76 using __trivially_relocatable =74 using __trivially_relocatable _LIBCPP_NODEBUG =
77 __conditional_t<__libcpp_is_trivially_relocatable<_T1>::value && __libcpp_is_trivially_relocatable<_T2>::value,75 __conditional_t<__libcpp_is_trivially_relocatable<_T1>::value && __libcpp_is_trivially_relocatable<_T2>::value,
78 pair,76 pair,
79 void>;77 void>;
...@@ -81,38 +79,6 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -81,38 +79,6 @@ struct _LIBCPP_TEMPLATE_VIS pair
81 _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default;79 _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default;
82 _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default;80 _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default;
8381
84 // When we are requested for pair to be trivially copyable by the ABI macro, we use defaulted members
85 // if it is both legal to do it (i.e. no references) and we have a way to actually implement it, which requires
86 // the __enable_if__ attribute before C++20.
87#ifdef _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR
88 // FIXME: This should really just be a static constexpr variable. It's in a struct to avoid gdb printing the value
89 // when printing a pair
90 struct __has_defaulted_members {
91 static const bool value = !is_reference<first_type>::value && !is_reference<second_type>::value;
92 };
93# if _LIBCPP_STD_VER >= 20
94 _LIBCPP_HIDE_FROM_ABI constexpr pair& operator=(const pair&)
95 requires __has_defaulted_members::value
96 = default;
97
98 _LIBCPP_HIDE_FROM_ABI constexpr pair& operator=(pair&&)
99 requires __has_defaulted_members::value
100 = default;
101# elif __has_attribute(__enable_if__)
102 _LIBCPP_HIDE_FROM_ABI pair& operator=(const pair&)
103 __attribute__((__enable_if__(__has_defaulted_members::value, ""))) = default;
104
105 _LIBCPP_HIDE_FROM_ABI pair& operator=(pair&&)
106 __attribute__((__enable_if__(__has_defaulted_members::value, ""))) = default;
107# else
108# error "_LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR isn't supported with this compiler"
109# endif
110#else
111 struct __has_defaulted_members {
112 static const bool value = false;
113 };
114#endif // defined(_LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR) && __has_attribute(__enable_if__)
115
116#ifdef _LIBCPP_CXX03_LANG82#ifdef _LIBCPP_CXX03_LANG
117 _LIBCPP_HIDE_FROM_ABI pair() : first(), second() {}83 _LIBCPP_HIDE_FROM_ABI pair() : first(), second() {}
11884
...@@ -164,8 +130,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -164,8 +130,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
164 };130 };
165131
166 template <bool _MaybeEnable>132 template <bool _MaybeEnable>
167 using _CheckArgsDep _LIBCPP_NODEBUG =133 using _CheckArgsDep _LIBCPP_NODEBUG = __conditional_t<_MaybeEnable, _CheckArgs, void>;
168 typename conditional< _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type;
169134
170 template <bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_default(), int> = 0>135 template <bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_default(), int> = 0>
171 explicit(!_CheckArgsDep<_Dummy>::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept(136 explicit(!_CheckArgsDep<_Dummy>::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept(
...@@ -258,8 +223,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -258,8 +223,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
258 typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}223 typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}
259224
260 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair&225 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair&
261 operator=(__conditional_t<!__has_defaulted_members::value && is_copy_assignable<first_type>::value &&226 operator=(__conditional_t<is_copy_assignable<first_type>::value && is_copy_assignable<second_type>::value,
262 is_copy_assignable<second_type>::value,
263 pair,227 pair,
264 __nat> const& __p) noexcept(is_nothrow_copy_assignable<first_type>::value &&228 __nat> const& __p) noexcept(is_nothrow_copy_assignable<first_type>::value &&
265 is_nothrow_copy_assignable<second_type>::value) {229 is_nothrow_copy_assignable<second_type>::value) {
...@@ -268,12 +232,10 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -268,12 +232,10 @@ struct _LIBCPP_TEMPLATE_VIS pair
268 return *this;232 return *this;
269 }233 }
270234
271 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair&235 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(
272 operator=(__conditional_t<!__has_defaulted_members::value && is_move_assignable<first_type>::value &&236 __conditional_t<is_move_assignable<first_type>::value && is_move_assignable<second_type>::value, pair, __nat>&&
273 is_move_assignable<second_type>::value,237 __p) noexcept(is_nothrow_move_assignable<first_type>::value &&
274 pair,238 is_nothrow_move_assignable<second_type>::value) {
275 __nat>&& __p) noexcept(is_nothrow_move_assignable<first_type>::value &&
276 is_nothrow_move_assignable<second_type>::value) {
277 first = std::forward<first_type>(__p.first);239 first = std::forward<first_type>(__p.first);
278 second = std::forward<second_type>(__p.second);240 second = std::forward<second_type>(__p.second);
279 return *this;241 return *this;
...@@ -570,11 +532,9 @@ swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x...@@ -570,11 +532,9 @@ swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x
570#endif532#endif
571533
572template <class _T1, class _T2>534template <class _T1, class _T2>
573inline _LIBCPP_HIDE_FROM_ABI535inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> >
574_LIBCPP_CONSTEXPR_SINCE_CXX14 pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>
575make_pair(_T1&& __t1, _T2&& __t2) {536make_pair(_T1&& __t1, _T2&& __t2) {
576 return pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>(537 return pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> >(std::forward<_T1>(__t1), std::forward<_T2>(__t2));
577 std::forward<_T1>(__t1), std::forward<_T2>(__t2));
578}538}
579539
580template <class _T1, class _T2>540template <class _T1, class _T2>
lib/libcxx/include/__utility/priority_tag.h+1-1
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#define _LIBCPP___UTILITY_PRIORITY_TAG_H10#define _LIBCPP___UTILITY_PRIORITY_TAG_H
1111
12#include <__config>12#include <__config>
13#include <cstddef>13#include <__cstddef/size_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
lib/libcxx/include/__utility/scope_guard.h created+56
...@@ -0,0 +1,56 @@
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_SCOPE_GUARD_H
11#define _LIBCPP___UTILITY_SCOPE_GUARD_H
12
13#include <__assert>
14#include <__config>
15#include <__utility/move.h>
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
26template <class _Func>
27class __scope_guard {
28 _Func __func_;
29
30public:
31 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __scope_guard(_Func __func) : __func_(std::move(__func)) {}
32 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__scope_guard() { __func_(); }
33
34 __scope_guard(const __scope_guard&) = delete;
35 __scope_guard& operator=(const __scope_guard&) = delete;
36 __scope_guard& operator=(__scope_guard&&) = delete;
37
38// C++14 doesn't have mandatory RVO, so we have to provide a declaration even though no compiler will ever generate
39// a call to the move constructor.
40#if _LIBCPP_STD_VER <= 14
41 __scope_guard(__scope_guard&&);
42#else
43 __scope_guard(__scope_guard&&) = delete;
44#endif
45};
46
47template <class _Func>
48_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __scope_guard<_Func> __make_scope_guard(_Func __func) {
49 return __scope_guard<_Func>(std::move(__func));
50}
51
52_LIBCPP_END_NAMESPACE_STD
53
54_LIBCPP_POP_MACROS
55
56#endif // _LIBCPP___UTILITY_SCOPE_GUARD_H
lib/libcxx/include/__utility/small_buffer.h+6-4
...@@ -10,14 +10,16 @@...@@ -10,14 +10,16 @@
10#define _LIBCPP___UTILITY_SMALL_BUFFER_H10#define _LIBCPP___UTILITY_SMALL_BUFFER_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/byte.h>
14#include <__cstddef/size_t.h>
13#include <__memory/construct_at.h>15#include <__memory/construct_at.h>
16#include <__new/allocate.h>
17#include <__new/launder.h>
14#include <__type_traits/decay.h>18#include <__type_traits/decay.h>
15#include <__type_traits/is_trivially_constructible.h>19#include <__type_traits/is_trivially_constructible.h>
16#include <__type_traits/is_trivially_destructible.h>20#include <__type_traits/is_trivially_destructible.h>
17#include <__utility/exception_guard.h>21#include <__utility/exception_guard.h>
18#include <__utility/forward.h>22#include <__utility/forward.h>
19#include <cstddef>
20#include <new>
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
...@@ -66,7 +68,7 @@ public:...@@ -66,7 +68,7 @@ public:
66 if constexpr (__fits_in_buffer<_Stored>) {68 if constexpr (__fits_in_buffer<_Stored>) {
67 return std::launder(reinterpret_cast<_Stored*>(__buffer_));69 return std::launder(reinterpret_cast<_Stored*>(__buffer_));
68 } else {70 } else {
69 byte* __allocation = static_cast<byte*>(::operator new[](sizeof(_Stored), align_val_t{alignof(_Stored)}));71 byte* __allocation = reinterpret_cast<byte*>(std::__libcpp_allocate<_Stored>(__element_count(1)));
70 std::construct_at(reinterpret_cast<byte**>(__buffer_), __allocation);72 std::construct_at(reinterpret_cast<byte**>(__buffer_), __allocation);
71 return std::launder(reinterpret_cast<_Stored*>(__allocation));73 return std::launder(reinterpret_cast<_Stored*>(__allocation));
72 }74 }
...@@ -75,7 +77,7 @@ public:...@@ -75,7 +77,7 @@ public:
75 template <class _Stored>77 template <class _Stored>
76 _LIBCPP_HIDE_FROM_ABI void __dealloc() noexcept {78 _LIBCPP_HIDE_FROM_ABI void __dealloc() noexcept {
77 if constexpr (!__fits_in_buffer<_Stored>)79 if constexpr (!__fits_in_buffer<_Stored>)
78 ::operator delete[](*reinterpret_cast<void**>(__buffer_), sizeof(_Stored), align_val_t{alignof(_Stored)});80 std::__libcpp_deallocate<_Stored>(__get<_Stored>(), __element_count(1));
79 }81 }
8082
81 template <class _Stored, class... _Args>83 template <class _Stored, class... _Args>
lib/libcxx/include/__utility/swap.h+5-3
...@@ -10,6 +10,8 @@...@@ -10,6 +10,8 @@
10#define _LIBCPP___UTILITY_SWAP_H10#define _LIBCPP___UTILITY_SWAP_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__type_traits/enable_if.h>
13#include <__type_traits/is_assignable.h>15#include <__type_traits/is_assignable.h>
14#include <__type_traits/is_constructible.h>16#include <__type_traits/is_constructible.h>
15#include <__type_traits/is_nothrow_assignable.h>17#include <__type_traits/is_nothrow_assignable.h>
...@@ -17,7 +19,6 @@...@@ -17,7 +19,6 @@
17#include <__type_traits/is_swappable.h>19#include <__type_traits/is_swappable.h>
18#include <__utility/declval.h>20#include <__utility/declval.h>
19#include <__utility/move.h>21#include <__utility/move.h>
20#include <cstddef>
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
...@@ -30,10 +31,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -30,10 +31,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3031
31#ifndef _LIBCPP_CXX03_LANG32#ifndef _LIBCPP_CXX03_LANG
32template <class _Tp>33template <class _Tp>
33using __swap_result_t = __enable_if_t<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>;34using __swap_result_t _LIBCPP_NODEBUG =
35 __enable_if_t<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>;
34#else36#else
35template <class>37template <class>
36using __swap_result_t = void;38using __swap_result_t _LIBCPP_NODEBUG = void;
37#endif39#endif
3840
39template <class _Tp>41template <class _Tp>
lib/libcxx/include/__utility/unreachable.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable() {21[[__noreturn__]] _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable() {
22 _LIBCPP_ASSERT_INTERNAL(false, "std::unreachable() was reached");22 _LIBCPP_ASSERT_INTERNAL(false, "std::unreachable() was reached");
23 __builtin_unreachable();23 __builtin_unreachable();
24}24}
lib/libcxx/include/__variant/monostate.h+1-1
...@@ -12,8 +12,8 @@...@@ -12,8 +12,8 @@
1212
13#include <__compare/ordering.h>13#include <__compare/ordering.h>
14#include <__config>14#include <__config>
15#include <__cstddef/size_t.h>
15#include <__functional/hash.h>16#include <__functional/hash.h>
16#include <cstddef>
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/__vector/comparison.h created+71
...@@ -0,0 +1,71 @@
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___VECTOR_COMPARISON_H
10#define _LIBCPP___VECTOR_COMPARISON_H
11
12#include <__algorithm/equal.h>
13#include <__algorithm/lexicographical_compare.h>
14#include <__algorithm/lexicographical_compare_three_way.h>
15#include <__compare/synth_three_way.h>
16#include <__config>
17#include <__fwd/vector.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
25template <class _Tp, class _Allocator>
26_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI bool
27operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
28 const typename vector<_Tp, _Allocator>::size_type __sz = __x.size();
29 return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
30}
31
32#if _LIBCPP_STD_VER <= 17
33
34template <class _Tp, class _Allocator>
35inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
36 return !(__x == __y);
37}
38
39template <class _Tp, class _Allocator>
40inline _LIBCPP_HIDE_FROM_ABI bool operator<(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
41 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
42}
43
44template <class _Tp, class _Allocator>
45inline _LIBCPP_HIDE_FROM_ABI bool operator>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
46 return __y < __x;
47}
48
49template <class _Tp, class _Allocator>
50inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
51 return !(__x < __y);
52}
53
54template <class _Tp, class _Allocator>
55inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
56 return !(__y < __x);
57}
58
59#else // _LIBCPP_STD_VER <= 17
60
61template <class _Tp, class _Allocator>
62_LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
63operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
64 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
65}
66
67#endif // _LIBCPP_STD_VER <= 17
68
69_LIBCPP_END_NAMESPACE_STD
70
71#endif // _LIBCPP___VECTOR_COMPARISON_H
lib/libcxx/include/__vector/container_traits.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___VECTOR_CONTAINER_TRAITS_H
10#define _LIBCPP___VECTOR_CONTAINER_TRAITS_H
11
12#include <__config>
13#include <__fwd/vector.h>
14#include <__memory/allocator_traits.h>
15#include <__type_traits/container_traits.h>
16#include <__type_traits/disjunction.h>
17#include <__type_traits/is_nothrow_constructible.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
25template <class _Tp, class _Allocator>
26struct __container_traits<vector<_Tp, _Allocator> > {
27 // http://eel.is/c++draft/vector.modifiers#2
28 // If an exception is thrown other than by the copy constructor, move constructor, assignment operator, or move
29 // assignment operator of T or by any InputIterator operation, there are no effects. If an exception is thrown while
30 // inserting a single element at the end and T is Cpp17CopyInsertable or is_nothrow_move_constructible_v<T> is true,
31 // there are no effects. Otherwise, if an exception is thrown by the move constructor of a non-Cpp17CopyInsertable T,
32 // the effects are unspecified.
33 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
34 _Or<is_nothrow_move_constructible<_Tp>, __is_cpp17_copy_insertable<_Allocator> >::value;
35};
36
37_LIBCPP_END_NAMESPACE_STD
38
39#endif // _LIBCPP___VECTOR_CONTAINER_TRAITS_H
lib/libcxx/include/__vector/erase.h created+50
...@@ -0,0 +1,50 @@
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___VECTOR_ERASE_H
10#define _LIBCPP___VECTOR_ERASE_H
11
12#include <__algorithm/remove.h>
13#include <__algorithm/remove_if.h>
14#include <__config>
15#include <__fwd/vector.h>
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#if _LIBCPP_STD_VER >= 20
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28template <class _Tp, class _Allocator, class _Up>
29_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
30erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
31 auto __old_size = __c.size();
32 __c.erase(std::remove(__c.begin(), __c.end(), __v), __c.end());
33 return __old_size - __c.size();
34}
35
36template <class _Tp, class _Allocator, class _Predicate>
37_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
38erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {
39 auto __old_size = __c.size();
40 __c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end());
41 return __old_size - __c.size();
42}
43
44_LIBCPP_END_NAMESPACE_STD
45
46#endif // _LIBCPP_STD_VER >= 20
47
48_LIBCPP_POP_MACROS
49
50#endif // _LIBCPP___VECTOR_ERASE_H
lib/libcxx/include/__vector/pmr.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___VECTOR_PMR_H
10#define _LIBCPP___VECTOR_PMR_H
11
12#include <__config>
13#include <__fwd/vector.h>
14#include <__memory_resource/polymorphic_allocator.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20#if _LIBCPP_STD_VER >= 17
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24namespace pmr {
25template <class _ValueT>
26using vector _LIBCPP_AVAILABILITY_PMR = std::vector<_ValueT, polymorphic_allocator<_ValueT>>;
27} // namespace pmr
28
29_LIBCPP_END_NAMESPACE_STD
30
31#endif
32
33#endif // _LIBCPP___VECTOR_PMR_H
lib/libcxx/include/__vector/swap.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___VECTOR_SWAP_H
10#define _LIBCPP___VECTOR_SWAP_H
11
12#include <__config>
13#include <__fwd/vector.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, class _Allocator>
22_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void
23swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
24 __x.swap(__y);
25}
26
27_LIBCPP_END_NAMESPACE_STD
28
29#endif // _LIBCPP___VECTOR_SWAP_H
lib/libcxx/include/__vector/vector.h created+1416
...@@ -0,0 +1,1416 @@
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___VECTOR_VECTOR_H
10#define _LIBCPP___VECTOR_VECTOR_H
11
12#include <__algorithm/copy.h>
13#include <__algorithm/copy_n.h>
14#include <__algorithm/fill_n.h>
15#include <__algorithm/max.h>
16#include <__algorithm/min.h>
17#include <__algorithm/move.h>
18#include <__algorithm/move_backward.h>
19#include <__algorithm/ranges_copy_n.h>
20#include <__algorithm/rotate.h>
21#include <__assert>
22#include <__config>
23#include <__debug_utils/sanitizers.h>
24#include <__format/enable_insertable.h>
25#include <__fwd/vector.h>
26#include <__iterator/advance.h>
27#include <__iterator/bounded_iter.h>
28#include <__iterator/concepts.h>
29#include <__iterator/distance.h>
30#include <__iterator/iterator_traits.h>
31#include <__iterator/move_iterator.h>
32#include <__iterator/next.h>
33#include <__iterator/reverse_iterator.h>
34#include <__iterator/wrap_iter.h>
35#include <__memory/addressof.h>
36#include <__memory/allocate_at_least.h>
37#include <__memory/allocator.h>
38#include <__memory/allocator_traits.h>
39#include <__memory/compressed_pair.h>
40#include <__memory/noexcept_move_assign_container.h>
41#include <__memory/pointer_traits.h>
42#include <__memory/swap_allocator.h>
43#include <__memory/temp_value.h>
44#include <__memory/uninitialized_algorithms.h>
45#include <__ranges/access.h>
46#include <__ranges/concepts.h>
47#include <__ranges/container_compatible_range.h>
48#include <__ranges/from_range.h>
49#include <__split_buffer>
50#include <__type_traits/conditional.h>
51#include <__type_traits/enable_if.h>
52#include <__type_traits/is_allocator.h>
53#include <__type_traits/is_constant_evaluated.h>
54#include <__type_traits/is_constructible.h>
55#include <__type_traits/is_nothrow_assignable.h>
56#include <__type_traits/is_nothrow_constructible.h>
57#include <__type_traits/is_pointer.h>
58#include <__type_traits/is_same.h>
59#include <__type_traits/is_trivially_relocatable.h>
60#include <__type_traits/type_identity.h>
61#include <__utility/exception_guard.h>
62#include <__utility/forward.h>
63#include <__utility/is_pointer_in_range.h>
64#include <__utility/move.h>
65#include <__utility/pair.h>
66#include <__utility/swap.h>
67#include <initializer_list>
68#include <limits>
69#include <stdexcept>
70
71// These headers define parts of vectors definition, since they define ADL functions or class specializations.
72#include <__vector/comparison.h>
73#include <__vector/container_traits.h>
74#include <__vector/swap.h>
75
76#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
77# pragma GCC system_header
78#endif
79
80_LIBCPP_PUSH_MACROS
81#include <__undef_macros>
82
83_LIBCPP_BEGIN_NAMESPACE_STD
84
85template <class _Tp, class _Allocator /* = allocator<_Tp> */>
86class _LIBCPP_TEMPLATE_VIS vector {
87private:
88 typedef allocator<_Tp> __default_allocator_type;
89
90public:
91 //
92 // Types
93 //
94 typedef vector __self;
95 typedef _Tp value_type;
96 typedef _Allocator allocator_type;
97 typedef allocator_traits<allocator_type> __alloc_traits;
98 typedef value_type& reference;
99 typedef const value_type& const_reference;
100 typedef typename __alloc_traits::size_type size_type;
101 typedef typename __alloc_traits::difference_type difference_type;
102 typedef typename __alloc_traits::pointer pointer;
103 typedef typename __alloc_traits::const_pointer const_pointer;
104#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
105 // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's
106 // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is
107 // considered contiguous.
108 typedef __bounded_iter<__wrap_iter<pointer> > iterator;
109 typedef __bounded_iter<__wrap_iter<const_pointer> > const_iterator;
110#else
111 typedef __wrap_iter<pointer> iterator;
112 typedef __wrap_iter<const_pointer> const_iterator;
113#endif
114 typedef std::reverse_iterator<iterator> reverse_iterator;
115 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
116
117 // A vector containers the following members which may be trivially relocatable:
118 // - pointer: may be trivially relocatable, so it's checked
119 // - allocator_type: may be trivially relocatable, so it's checked
120 // vector doesn't contain any self-references, so it's trivially relocatable if its members are.
121 using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<
122 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
123 vector,
124 void>;
125
126 static_assert(__check_valid_allocator<allocator_type>::value, "");
127 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
128 "Allocator::value_type must be same type as value_type");
129
130 //
131 // [vector.cons], construct/copy/destroy
132 //
133 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector()
134 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) {}
135 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a)
136#if _LIBCPP_STD_VER <= 14
137 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
138#else
139 noexcept
140#endif
141 : __alloc_(__a) {
142 }
143
144 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n) {
145 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
146 if (__n > 0) {
147 __vallocate(__n);
148 __construct_at_end(__n);
149 }
150 __guard.__complete();
151 }
152
153#if _LIBCPP_STD_VER >= 14
154 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a)
155 : __alloc_(__a) {
156 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
157 if (__n > 0) {
158 __vallocate(__n);
159 __construct_at_end(__n);
160 }
161 __guard.__complete();
162 }
163#endif
164
165 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x) {
166 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
167 if (__n > 0) {
168 __vallocate(__n);
169 __construct_at_end(__n, __x);
170 }
171 __guard.__complete();
172 }
173
174 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>
175 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
176 vector(size_type __n, const value_type& __x, const allocator_type& __a)
177 : __alloc_(__a) {
178 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
179 if (__n > 0) {
180 __vallocate(__n);
181 __construct_at_end(__n, __x);
182 }
183 __guard.__complete();
184 }
185
186 template <class _InputIterator,
187 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
188 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
189 int> = 0>
190 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last) {
191 __init_with_sentinel(__first, __last);
192 }
193
194 template <class _InputIterator,
195 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
196 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
197 int> = 0>
198 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
199 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
200 : __alloc_(__a) {
201 __init_with_sentinel(__first, __last);
202 }
203
204 template <
205 class _ForwardIterator,
206 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
207 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
208 int> = 0>
209 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last) {
210 size_type __n = static_cast<size_type>(std::distance(__first, __last));
211 __init_with_size(__first, __last, __n);
212 }
213
214 template <
215 class _ForwardIterator,
216 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
217 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
218 int> = 0>
219 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
220 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a)
221 : __alloc_(__a) {
222 size_type __n = static_cast<size_type>(std::distance(__first, __last));
223 __init_with_size(__first, __last, __n);
224 }
225
226#if _LIBCPP_STD_VER >= 23
227 template <_ContainerCompatibleRange<_Tp> _Range>
228 _LIBCPP_HIDE_FROM_ABI constexpr vector(
229 from_range_t, _Range&& __range, const allocator_type& __alloc = allocator_type())
230 : __alloc_(__alloc) {
231 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
232 auto __n = static_cast<size_type>(ranges::distance(__range));
233 __init_with_size(ranges::begin(__range), ranges::end(__range), __n);
234
235 } else {
236 __init_with_sentinel(ranges::begin(__range), ranges::end(__range));
237 }
238 }
239#endif
240
241private:
242 class __destroy_vector {
243 public:
244 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __destroy_vector(vector& __vec) : __vec_(__vec) {}
245
246 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {
247 if (__vec_.__begin_ != nullptr) {
248 __vec_.clear();
249 __vec_.__annotate_delete();
250 __alloc_traits::deallocate(__vec_.__alloc_, __vec_.__begin_, __vec_.capacity());
251 }
252 }
253
254 private:
255 vector& __vec_;
256 };
257
258public:
259 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { __destroy_vector (*this)(); }
260
261 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x)
262 : __alloc_(__alloc_traits::select_on_container_copy_construction(__x.__alloc_)) {
263 __init_with_size(__x.__begin_, __x.__end_, __x.size());
264 }
265 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
266 vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
267 : __alloc_(__a) {
268 __init_with_size(__x.__begin_, __x.__end_, __x.size());
269 }
270 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(const vector& __x);
271
272#ifndef _LIBCPP_CXX03_LANG
273 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(initializer_list<value_type> __il) {
274 __init_with_size(__il.begin(), __il.end(), __il.size());
275 }
276
277 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
278 vector(initializer_list<value_type> __il, const allocator_type& __a)
279 : __alloc_(__a) {
280 __init_with_size(__il.begin(), __il.end(), __il.size());
281 }
282
283 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(initializer_list<value_type> __il) {
284 assign(__il.begin(), __il.end());
285 return *this;
286 }
287#endif // !_LIBCPP_CXX03_LANG
288
289 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(vector&& __x)
290#if _LIBCPP_STD_VER >= 17
291 noexcept;
292#else
293 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
294#endif
295
296 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
297 vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
298 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(vector&& __x)
299 _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
300 __move_assign(__x, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
301 return *this;
302 }
303
304 template <class _InputIterator,
305 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
306 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
307 int> = 0>
308 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_InputIterator __first, _InputIterator __last) {
309 __assign_with_sentinel(__first, __last);
310 }
311 template <
312 class _ForwardIterator,
313 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
314 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
315 int> = 0>
316 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_ForwardIterator __first, _ForwardIterator __last) {
317 __assign_with_size(__first, __last, std::distance(__first, __last));
318 }
319
320#if _LIBCPP_STD_VER >= 23
321 template <_ContainerCompatibleRange<_Tp> _Range>
322 _LIBCPP_HIDE_FROM_ABI constexpr void assign_range(_Range&& __range) {
323 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
324 auto __n = static_cast<size_type>(ranges::distance(__range));
325 __assign_with_size(ranges::begin(__range), ranges::end(__range), __n);
326
327 } else {
328 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));
329 }
330 }
331#endif
332
333 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const_reference __u);
334
335#ifndef _LIBCPP_CXX03_LANG
336 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) {
337 assign(__il.begin(), __il.end());
338 }
339#endif
340
341 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
342 return this->__alloc_;
343 }
344
345 //
346 // Iterators
347 //
348 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT {
349 return __make_iter(__add_alignment_assumption(this->__begin_));
350 }
351 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {
352 return __make_iter(__add_alignment_assumption(this->__begin_));
353 }
354 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT {
355 return __make_iter(__add_alignment_assumption(this->__end_));
356 }
357 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT {
358 return __make_iter(__add_alignment_assumption(this->__end_));
359 }
360
361 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT {
362 return reverse_iterator(end());
363 }
364 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {
365 return const_reverse_iterator(end());
366 }
367 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT {
368 return reverse_iterator(begin());
369 }
370 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT {
371 return const_reverse_iterator(begin());
372 }
373
374 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }
375 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }
376 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT {
377 return rbegin();
378 }
379 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
380
381 //
382 // [vector.capacity], capacity
383 //
384 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT {
385 return static_cast<size_type>(this->__end_ - this->__begin_);
386 }
387 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT {
388 return static_cast<size_type>(this->__cap_ - this->__begin_);
389 }
390 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {
391 return this->__begin_ == this->__end_;
392 }
393 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
394 return std::min<size_type>(__alloc_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max());
395 }
396 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
397 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
398
399 //
400 // element access
401 //
402 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT {
403 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds");
404 return this->__begin_[__n];
405 }
406 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const _NOEXCEPT {
407 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds");
408 return this->__begin_[__n];
409 }
410 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n) {
411 if (__n >= size())
412 this->__throw_out_of_range();
413 return this->__begin_[__n];
414 }
415 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const {
416 if (__n >= size())
417 this->__throw_out_of_range();
418 return this->__begin_[__n];
419 }
420
421 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT {
422 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector");
423 return *this->__begin_;
424 }
425 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT {
426 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector");
427 return *this->__begin_;
428 }
429 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT {
430 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector");
431 return *(this->__end_ - 1);
432 }
433 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT {
434 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector");
435 return *(this->__end_ - 1);
436 }
437
438 //
439 // [vector.data], data access
440 //
441 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI value_type* data() _NOEXCEPT {
442 return std::__to_address(this->__begin_);
443 }
444
445 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const value_type* data() const _NOEXCEPT {
446 return std::__to_address(this->__begin_);
447 }
448
449 //
450 // [vector.modifiers], modifiers
451 //
452 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x) { emplace_back(__x); }
453
454 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x) { emplace_back(std::move(__x)); }
455
456 template <class... _Args>
457 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
458#if _LIBCPP_STD_VER >= 17
459 reference
460 emplace_back(_Args&&... __args);
461#else
462 void
463 emplace_back(_Args&&... __args);
464#endif
465
466#if _LIBCPP_STD_VER >= 23
467 template <_ContainerCompatibleRange<_Tp> _Range>
468 _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) {
469 insert_range(end(), std::forward<_Range>(__range));
470 }
471#endif
472
473 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back() {
474 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector::pop_back called on an empty vector");
475 this->__destruct_at_end(this->__end_ - 1);
476 }
477
478 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, const_reference __x);
479
480 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, value_type&& __x);
481 template <class... _Args>
482 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __position, _Args&&... __args);
483
484 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
485 insert(const_iterator __position, size_type __n, const_reference __x);
486
487 template <class _InputIterator,
488 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
489 is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value,
490 int> = 0>
491 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
492 insert(const_iterator __position, _InputIterator __first, _InputIterator __last) {
493 return __insert_with_sentinel(__position, __first, __last);
494 }
495
496 template <
497 class _ForwardIterator,
498 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
499 is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
500 int> = 0>
501 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
502 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) {
503 return __insert_with_size(__position, __first, __last, std::distance(__first, __last));
504 }
505
506#if _LIBCPP_STD_VER >= 23
507 template <_ContainerCompatibleRange<_Tp> _Range>
508 _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) {
509 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
510 auto __n = static_cast<size_type>(ranges::distance(__range));
511 return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n);
512
513 } else {
514 return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));
515 }
516 }
517#endif
518
519#ifndef _LIBCPP_CXX03_LANG
520 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
521 insert(const_iterator __position, initializer_list<value_type> __il) {
522 return insert(__position, __il.begin(), __il.end());
523 }
524#endif
525
526 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position);
527 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last);
528
529 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT {
530 size_type __old_size = size();
531 __base_destruct_at_end(this->__begin_);
532 __annotate_shrink(__old_size);
533 }
534
535 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz);
536 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz, const_reference __x);
537
538 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(vector&)
539#if _LIBCPP_STD_VER >= 14
540 _NOEXCEPT;
541#else
542 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
543#endif
544
545 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
546
547private:
548 pointer __begin_ = nullptr;
549 pointer __end_ = nullptr;
550 _LIBCPP_COMPRESSED_PAIR(pointer, __cap_ = nullptr, allocator_type, __alloc_);
551
552 // Allocate space for __n objects
553 // throws length_error if __n > max_size()
554 // throws (probably bad_alloc) if memory run out
555 // Precondition: __begin_ == __end_ == __cap_ == nullptr
556 // Precondition: __n > 0
557 // Postcondition: capacity() >= __n
558 // Postcondition: size() == 0
559 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
560 if (__n > max_size())
561 __throw_length_error();
562 auto __allocation = std::__allocate_at_least(this->__alloc_, __n);
563 __begin_ = __allocation.ptr;
564 __end_ = __allocation.ptr;
565 __cap_ = __begin_ + __allocation.count;
566 __annotate_new(0);
567 }
568
569 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vdeallocate() _NOEXCEPT;
570 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __recommend(size_type __new_size) const;
571 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);
572 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x);
573
574 template <class _InputIterator, class _Sentinel>
575 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
576 __init_with_size(_InputIterator __first, _Sentinel __last, size_type __n) {
577 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
578
579 if (__n > 0) {
580 __vallocate(__n);
581 __construct_at_end(std::move(__first), std::move(__last), __n);
582 }
583
584 __guard.__complete();
585 }
586
587 template <class _InputIterator, class _Sentinel>
588 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
589 __init_with_sentinel(_InputIterator __first, _Sentinel __last) {
590 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
591
592 for (; __first != __last; ++__first)
593 emplace_back(*__first);
594
595 __guard.__complete();
596 }
597
598 template <class _Iterator, class _Sentinel>
599 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last);
600
601 // The `_Iterator` in `*_with_size` functions can be input-only only if called from `*_range` (since C++23).
602 // Otherwise, `_Iterator` is a forward iterator.
603
604 template <class _Iterator, class _Sentinel>
605 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
606 __assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n);
607
608 template <class _InputIterator, class _Sentinel>
609 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
610 __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last);
611
612 template <class _Iterator, class _Sentinel>
613 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
614 __insert_with_size(const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n);
615
616 template <class _InputIterator, class _Sentinel>
617 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
618 __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n);
619
620 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n);
621 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x);
622
623 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT {
624#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
625 // Bound the iterator according to the capacity, rather than the size.
626 //
627 // Vector guarantees that iterators stay valid as long as no reallocation occurs even if new elements are inserted
628 // into the container; for these cases, we need to make sure that the newly-inserted elements can be accessed
629 // through the bounded iterator without failing checks. The downside is that the bounded iterator won't catch
630 // access that is logically out-of-bounds, i.e., goes beyond the size, but is still within the capacity. With the
631 // current implementation, there is no connection between a bounded iterator and its associated container, so we
632 // don't have a way to update existing valid iterators when the container is resized and thus have to go with
633 // a laxer approach.
634 return std::__make_bounded_iter(
635 std::__wrap_iter<pointer>(__p),
636 std::__wrap_iter<pointer>(this->__begin_),
637 std::__wrap_iter<pointer>(this->__cap_));
638#else
639 return iterator(__p);
640#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
641 }
642
643 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT {
644#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
645 // Bound the iterator according to the capacity, rather than the size.
646 return std::__make_bounded_iter(
647 std::__wrap_iter<const_pointer>(__p),
648 std::__wrap_iter<const_pointer>(this->__begin_),
649 std::__wrap_iter<const_pointer>(this->__cap_));
650#else
651 return const_iterator(__p);
652#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
653 }
654
655 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
656 __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
657 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer
658 __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
659 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
660 __move_range(pointer __from_s, pointer __from_e, pointer __to);
661 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type)
662 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
663 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, false_type)
664 _NOEXCEPT_(__alloc_traits::is_always_equal::value);
665 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last) _NOEXCEPT {
666 size_type __old_size = size();
667 __base_destruct_at_end(__new_last);
668 __annotate_shrink(__old_size);
669 }
670
671 template <class... _Args>
672 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI inline pointer __emplace_back_slow_path(_Args&&... __args);
673
674 // The following functions are no-ops outside of AddressSanitizer mode.
675 // We call annotations for every allocator, unless explicitly disabled.
676 //
677 // To disable annotations for a particular allocator, change value of
678 // __asan_annotate_container_with_allocator to false.
679 // For more details, see the "Using libc++" documentation page or
680 // the documentation for __sanitizer_annotate_contiguous_container.
681
682 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
683 __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {
684 std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity(), __old_mid, __new_mid);
685 }
686
687 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {
688 (void)__current_size;
689#if _LIBCPP_HAS_ASAN
690 __annotate_contiguous_container(data() + capacity(), data() + __current_size);
691#endif
692 }
693
694 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {
695#if _LIBCPP_HAS_ASAN
696 __annotate_contiguous_container(data() + size(), data() + capacity());
697#endif
698 }
699
700 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT {
701 (void)__n;
702#if _LIBCPP_HAS_ASAN
703 __annotate_contiguous_container(data() + size(), data() + size() + __n);
704#endif
705 }
706
707 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT {
708 (void)__old_size;
709#if _LIBCPP_HAS_ASAN
710 __annotate_contiguous_container(data() + __old_size, data() + size());
711#endif
712 }
713
714 struct _ConstructTransaction {
715 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n)
716 : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
717#if _LIBCPP_HAS_ASAN
718 __v_.__annotate_increase(__n);
719#endif
720 }
721
722 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
723 __v_.__end_ = __pos_;
724#if _LIBCPP_HAS_ASAN
725 if (__pos_ != __new_end_) {
726 __v_.__annotate_shrink(__new_end_ - __v_.__begin_);
727 }
728#endif
729 }
730
731 vector& __v_;
732 pointer __pos_;
733 const_pointer const __new_end_;
734
735 _ConstructTransaction(_ConstructTransaction const&) = delete;
736 _ConstructTransaction& operator=(_ConstructTransaction const&) = delete;
737 };
738
739 template <class... _Args>
740 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_one_at_end(_Args&&... __args) {
741 _ConstructTransaction __tx(*this, 1);
742 __alloc_traits::construct(this->__alloc_, std::__to_address(__tx.__pos_), std::forward<_Args>(__args)...);
743 ++__tx.__pos_;
744 }
745
746 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {
747 pointer __soon_to_be_end = this->__end_;
748 while (__new_last != __soon_to_be_end)
749 __alloc_traits::destroy(this->__alloc_, std::__to_address(--__soon_to_be_end));
750 this->__end_ = __new_last;
751 }
752
753 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c) {
754 __copy_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_copy_assignment::value>());
755 }
756
757 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector& __c)
758 _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value ||
759 is_nothrow_move_assignable<allocator_type>::value) {
760 __move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
761 }
762
763 [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_length_error() { std::__throw_length_error("vector"); }
764
765 [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_out_of_range() { std::__throw_out_of_range("vector"); }
766
767 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c, true_type) {
768 if (this->__alloc_ != __c.__alloc_) {
769 clear();
770 __annotate_delete();
771 __alloc_traits::deallocate(this->__alloc_, this->__begin_, capacity());
772 this->__begin_ = this->__end_ = this->__cap_ = nullptr;
773 }
774 this->__alloc_ = __c.__alloc_;
775 }
776
777 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector&, false_type) {}
778
779 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector& __c, true_type)
780 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
781 this->__alloc_ = std::move(__c.__alloc_);
782 }
783
784 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector&, false_type) _NOEXCEPT {}
785
786 template <class _Ptr = pointer, __enable_if_t<is_pointer<_Ptr>::value, int> = 0>
787 static _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI pointer
788 __add_alignment_assumption(_Ptr __p) _NOEXCEPT {
789 if (!__libcpp_is_constant_evaluated()) {
790 return static_cast<pointer>(__builtin_assume_aligned(__p, _LIBCPP_ALIGNOF(decltype(*__p))));
791 }
792 return __p;
793 }
794
795 template <class _Ptr = pointer, __enable_if_t<!is_pointer<_Ptr>::value, int> = 0>
796 static _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI pointer
797 __add_alignment_assumption(_Ptr __p) _NOEXCEPT {
798 return __p;
799 }
800};
801
802#if _LIBCPP_STD_VER >= 17
803template <class _InputIterator,
804 class _Alloc = allocator<__iter_value_type<_InputIterator>>,
805 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
806 class = enable_if_t<__is_allocator<_Alloc>::value> >
807vector(_InputIterator, _InputIterator) -> vector<__iter_value_type<_InputIterator>, _Alloc>;
808
809template <class _InputIterator,
810 class _Alloc,
811 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
812 class = enable_if_t<__is_allocator<_Alloc>::value> >
813vector(_InputIterator, _InputIterator, _Alloc) -> vector<__iter_value_type<_InputIterator>, _Alloc>;
814#endif
815
816#if _LIBCPP_STD_VER >= 23
817template <ranges::input_range _Range,
818 class _Alloc = allocator<ranges::range_value_t<_Range>>,
819 class = enable_if_t<__is_allocator<_Alloc>::value> >
820vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_t<_Range>, _Alloc>;
821#endif
822
823// __swap_out_circular_buffer relocates the objects in [__begin_, __end_) into the front of __v and swaps the buffers of
824// *this and __v. It is assumed that __v provides space for exactly (__end_ - __begin_) objects in the front. This
825// function has a strong exception guarantee.
826template <class _Tp, class _Allocator>
827_LIBCPP_CONSTEXPR_SINCE_CXX20 void
828vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) {
829 __annotate_delete();
830 auto __new_begin = __v.__begin_ - (__end_ - __begin_);
831 std::__uninitialized_allocator_relocate(
832 this->__alloc_, std::__to_address(__begin_), std::__to_address(__end_), std::__to_address(__new_begin));
833 __v.__begin_ = __new_begin;
834 __end_ = __begin_; // All the objects have been destroyed by relocating them.
835 std::swap(this->__begin_, __v.__begin_);
836 std::swap(this->__end_, __v.__end_);
837 std::swap(this->__cap_, __v.__cap_);
838 __v.__first_ = __v.__begin_;
839 __annotate_new(size());
840}
841
842// __swap_out_circular_buffer relocates the objects in [__begin_, __p) into the front of __v, the objects in
843// [__p, __end_) into the back of __v and swaps the buffers of *this and __v. It is assumed that __v provides space for
844// exactly (__p - __begin_) objects in the front and space for at least (__end_ - __p) objects in the back. This
845// function has a strong exception guarantee if __begin_ == __p || __end_ == __p.
846template <class _Tp, class _Allocator>
847_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer
848vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) {
849 __annotate_delete();
850 pointer __ret = __v.__begin_;
851
852 // Relocate [__p, __end_) first to avoid having a hole in [__begin_, __end_)
853 // in case something in [__begin_, __p) throws.
854 std::__uninitialized_allocator_relocate(
855 this->__alloc_, std::__to_address(__p), std::__to_address(__end_), std::__to_address(__v.__end_));
856 __v.__end_ += (__end_ - __p);
857 __end_ = __p; // The objects in [__p, __end_) have been destroyed by relocating them.
858 auto __new_begin = __v.__begin_ - (__p - __begin_);
859
860 std::__uninitialized_allocator_relocate(
861 this->__alloc_, std::__to_address(__begin_), std::__to_address(__p), std::__to_address(__new_begin));
862 __v.__begin_ = __new_begin;
863 __end_ = __begin_; // All the objects have been destroyed by relocating them.
864
865 std::swap(this->__begin_, __v.__begin_);
866 std::swap(this->__end_, __v.__end_);
867 std::swap(this->__cap_, __v.__cap_);
868 __v.__first_ = __v.__begin_;
869 __annotate_new(size());
870 return __ret;
871}
872
873template <class _Tp, class _Allocator>
874_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT {
875 if (this->__begin_ != nullptr) {
876 clear();
877 __annotate_delete();
878 __alloc_traits::deallocate(this->__alloc_, this->__begin_, capacity());
879 this->__begin_ = this->__end_ = this->__cap_ = nullptr;
880 }
881}
882
883// Precondition: __new_size > capacity()
884template <class _Tp, class _Allocator>
885_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
886vector<_Tp, _Allocator>::__recommend(size_type __new_size) const {
887 const size_type __ms = max_size();
888 if (__new_size > __ms)
889 this->__throw_length_error();
890 const size_type __cap = capacity();
891 if (__cap >= __ms / 2)
892 return __ms;
893 return std::max<size_type>(2 * __cap, __new_size);
894}
895
896// Default constructs __n objects starting at __end_
897// throws if construction throws
898// Precondition: __n > 0
899// Precondition: size() + __n <= capacity()
900// Postcondition: size() == size() + __n
901template <class _Tp, class _Allocator>
902_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__construct_at_end(size_type __n) {
903 _ConstructTransaction __tx(*this, __n);
904 const_pointer __new_end = __tx.__new_end_;
905 for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {
906 __alloc_traits::construct(this->__alloc_, std::__to_address(__pos));
907 }
908}
909
910// Copy constructs __n objects starting at __end_ from __x
911// throws if construction throws
912// Precondition: __n > 0
913// Precondition: size() + __n <= capacity()
914// Postcondition: size() == old size() + __n
915// Postcondition: [i] == __x for all i in [size() - __n, __n)
916template <class _Tp, class _Allocator>
917_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
918vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) {
919 _ConstructTransaction __tx(*this, __n);
920 const_pointer __new_end = __tx.__new_end_;
921 for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {
922 __alloc_traits::construct(this->__alloc_, std::__to_address(__pos), __x);
923 }
924}
925
926template <class _Tp, class _Allocator>
927template <class _InputIterator, class _Sentinel>
928_LIBCPP_CONSTEXPR_SINCE_CXX20 void
929vector<_Tp, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) {
930 _ConstructTransaction __tx(*this, __n);
931 __tx.__pos_ = std::__uninitialized_allocator_copy(this->__alloc_, std::move(__first), std::move(__last), __tx.__pos_);
932}
933
934// Default constructs __n objects starting at __end_
935// throws if construction throws
936// Postcondition: size() == size() + __n
937// Exception safety: strong.
938template <class _Tp, class _Allocator>
939_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n) {
940 if (static_cast<size_type>(this->__cap_ - this->__end_) >= __n)
941 this->__construct_at_end(__n);
942 else {
943 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), this->__alloc_);
944 __v.__construct_at_end(__n);
945 __swap_out_circular_buffer(__v);
946 }
947}
948
949// Default constructs __n objects starting at __end_
950// throws if construction throws
951// Postcondition: size() == size() + __n
952// Exception safety: strong.
953template <class _Tp, class _Allocator>
954_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) {
955 if (static_cast<size_type>(this->__cap_ - this->__end_) >= __n)
956 this->__construct_at_end(__n, __x);
957 else {
958 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), this->__alloc_);
959 __v.__construct_at_end(__n, __x);
960 __swap_out_circular_buffer(__v);
961 }
962}
963
964template <class _Tp, class _Allocator>
965_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>::vector(vector&& __x)
966#if _LIBCPP_STD_VER >= 17
967 noexcept
968#else
969 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
970#endif
971 : __alloc_(std::move(__x.__alloc_)) {
972 this->__begin_ = __x.__begin_;
973 this->__end_ = __x.__end_;
974 this->__cap_ = __x.__cap_;
975 __x.__begin_ = __x.__end_ = __x.__cap_ = nullptr;
976}
977
978template <class _Tp, class _Allocator>
979_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI
980vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a)
981 : __alloc_(__a) {
982 if (__a == __x.__alloc_) {
983 this->__begin_ = __x.__begin_;
984 this->__end_ = __x.__end_;
985 this->__cap_ = __x.__cap_;
986 __x.__begin_ = __x.__end_ = __x.__cap_ = nullptr;
987 } else {
988 typedef move_iterator<iterator> _Ip;
989 __init_with_size(_Ip(__x.begin()), _Ip(__x.end()), __x.size());
990 }
991}
992
993template <class _Tp, class _Allocator>
994_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
995 _NOEXCEPT_(__alloc_traits::is_always_equal::value) {
996 if (this->__alloc_ != __c.__alloc_) {
997 typedef move_iterator<iterator> _Ip;
998 assign(_Ip(__c.begin()), _Ip(__c.end()));
999 } else
1000 __move_assign(__c, true_type());
1001}
1002
1003template <class _Tp, class _Allocator>
1004_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
1005 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
1006 __vdeallocate();
1007 __move_assign_alloc(__c); // this can throw
1008 this->__begin_ = __c.__begin_;
1009 this->__end_ = __c.__end_;
1010 this->__cap_ = __c.__cap_;
1011 __c.__begin_ = __c.__end_ = __c.__cap_ = nullptr;
1012}
1013
1014template <class _Tp, class _Allocator>
1015_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>&
1016vector<_Tp, _Allocator>::operator=(const vector& __x) {
1017 if (this != std::addressof(__x)) {
1018 __copy_assign_alloc(__x);
1019 assign(__x.__begin_, __x.__end_);
1020 }
1021 return *this;
1022}
1023
1024template <class _Tp, class _Allocator>
1025template <class _Iterator, class _Sentinel>
1026_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
1027vector<_Tp, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __last) {
1028 pointer __cur = __begin_;
1029 for (; __first != __last && __cur != __end_; ++__first, (void)++__cur)
1030 *__cur = *__first;
1031 if (__cur != __end_) {
1032 __destruct_at_end(__cur);
1033 } else {
1034 for (; __first != __last; ++__first)
1035 emplace_back(*__first);
1036 }
1037}
1038
1039template <class _Tp, class _Allocator>
1040template <class _Iterator, class _Sentinel>
1041_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
1042vector<_Tp, _Allocator>::__assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n) {
1043 size_type __new_size = static_cast<size_type>(__n);
1044 if (__new_size <= capacity()) {
1045 if (__new_size > size()) {
1046#if _LIBCPP_STD_VER >= 23
1047 auto __mid = ranges::copy_n(std::move(__first), size(), this->__begin_).in;
1048 __construct_at_end(std::move(__mid), std::move(__last), __new_size - size());
1049#else
1050 _Iterator __mid = std::next(__first, size());
1051 std::copy(__first, __mid, this->__begin_);
1052 __construct_at_end(__mid, __last, __new_size - size());
1053#endif
1054 } else {
1055 pointer __m = std::__copy(std::move(__first), __last, this->__begin_).second;
1056 this->__destruct_at_end(__m);
1057 }
1058 } else {
1059 __vdeallocate();
1060 __vallocate(__recommend(__new_size));
1061 __construct_at_end(std::move(__first), std::move(__last), __new_size);
1062 }
1063}
1064
1065template <class _Tp, class _Allocator>
1066_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) {
1067 if (__n <= capacity()) {
1068 size_type __s = size();
1069 std::fill_n(this->__begin_, std::min(__n, __s), __u);
1070 if (__n > __s)
1071 __construct_at_end(__n - __s, __u);
1072 else
1073 this->__destruct_at_end(this->__begin_ + __n);
1074 } else {
1075 __vdeallocate();
1076 __vallocate(__recommend(static_cast<size_type>(__n)));
1077 __construct_at_end(__n, __u);
1078 }
1079}
1080
1081template <class _Tp, class _Allocator>
1082_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::reserve(size_type __n) {
1083 if (__n > capacity()) {
1084 if (__n > max_size())
1085 this->__throw_length_error();
1086 __split_buffer<value_type, allocator_type&> __v(__n, size(), this->__alloc_);
1087 __swap_out_circular_buffer(__v);
1088 }
1089}
1090
1091template <class _Tp, class _Allocator>
1092_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT {
1093 if (capacity() > size()) {
1094#if _LIBCPP_HAS_EXCEPTIONS
1095 try {
1096#endif // _LIBCPP_HAS_EXCEPTIONS
1097 __split_buffer<value_type, allocator_type&> __v(size(), size(), this->__alloc_);
1098 // The Standard mandates shrink_to_fit() does not increase the capacity.
1099 // With equal capacity keep the existing buffer. This avoids extra work
1100 // due to swapping the elements.
1101 if (__v.capacity() < capacity())
1102 __swap_out_circular_buffer(__v);
1103#if _LIBCPP_HAS_EXCEPTIONS
1104 } catch (...) {
1105 }
1106#endif // _LIBCPP_HAS_EXCEPTIONS
1107 }
1108}
1109
1110template <class _Tp, class _Allocator>
1111template <class... _Args>
1112_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer
1113vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) {
1114 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), this->__alloc_);
1115 // __v.emplace_back(std::forward<_Args>(__args)...);
1116 __alloc_traits::construct(this->__alloc_, std::__to_address(__v.__end_), std::forward<_Args>(__args)...);
1117 __v.__end_++;
1118 __swap_out_circular_buffer(__v);
1119 return this->__end_;
1120}
1121
1122template <class _Tp, class _Allocator>
1123template <class... _Args>
1124_LIBCPP_CONSTEXPR_SINCE_CXX20 inline
1125#if _LIBCPP_STD_VER >= 17
1126 typename vector<_Tp, _Allocator>::reference
1127#else
1128 void
1129#endif
1130 vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) {
1131 pointer __end = this->__end_;
1132 if (__end < this->__cap_) {
1133 __construct_one_at_end(std::forward<_Args>(__args)...);
1134 ++__end;
1135 } else {
1136 __end = __emplace_back_slow_path(std::forward<_Args>(__args)...);
1137 }
1138 this->__end_ = __end;
1139#if _LIBCPP_STD_VER >= 17
1140 return *(__end - 1);
1141#endif
1142}
1143
1144template <class _Tp, class _Allocator>
1145_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator
1146vector<_Tp, _Allocator>::erase(const_iterator __position) {
1147 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
1148 __position != end(), "vector::erase(iterator) called with a non-dereferenceable iterator");
1149 difference_type __ps = __position - cbegin();
1150 pointer __p = this->__begin_ + __ps;
1151 this->__destruct_at_end(std::move(__p + 1, this->__end_, __p));
1152 return __make_iter(__p);
1153}
1154
1155template <class _Tp, class _Allocator>
1156_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1157vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) {
1158 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, "vector::erase(first, last) called with invalid range");
1159 pointer __p = this->__begin_ + (__first - begin());
1160 if (__first != __last) {
1161 this->__destruct_at_end(std::move(__p + (__last - __first), this->__end_, __p));
1162 }
1163 return __make_iter(__p);
1164}
1165
1166template <class _Tp, class _Allocator>
1167_LIBCPP_CONSTEXPR_SINCE_CXX20 void
1168vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) {
1169 pointer __old_last = this->__end_;
1170 difference_type __n = __old_last - __to;
1171 {
1172 pointer __i = __from_s + __n;
1173 _ConstructTransaction __tx(*this, __from_e - __i);
1174 for (pointer __pos = __tx.__pos_; __i < __from_e; ++__i, (void)++__pos, __tx.__pos_ = __pos) {
1175 __alloc_traits::construct(this->__alloc_, std::__to_address(__pos), std::move(*__i));
1176 }
1177 }
1178 std::move_backward(__from_s, __from_s + __n, __old_last);
1179}
1180
1181template <class _Tp, class _Allocator>
1182_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1183vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) {
1184 pointer __p = this->__begin_ + (__position - begin());
1185 if (this->__end_ < this->__cap_) {
1186 if (__p == this->__end_) {
1187 __construct_one_at_end(__x);
1188 } else {
1189 __move_range(__p, this->__end_, __p + 1);
1190 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
1191 if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x)))
1192 ++__xr;
1193 *__p = *__xr;
1194 }
1195 } else {
1196 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);
1197 __v.emplace_back(__x);
1198 __p = __swap_out_circular_buffer(__v, __p);
1199 }
1200 return __make_iter(__p);
1201}
1202
1203template <class _Tp, class _Allocator>
1204_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1205vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) {
1206 pointer __p = this->__begin_ + (__position - begin());
1207 if (this->__end_ < this->__cap_) {
1208 if (__p == this->__end_) {
1209 __construct_one_at_end(std::move(__x));
1210 } else {
1211 __move_range(__p, this->__end_, __p + 1);
1212 *__p = std::move(__x);
1213 }
1214 } else {
1215 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);
1216 __v.emplace_back(std::move(__x));
1217 __p = __swap_out_circular_buffer(__v, __p);
1218 }
1219 return __make_iter(__p);
1220}
1221
1222template <class _Tp, class _Allocator>
1223template <class... _Args>
1224_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1225vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) {
1226 pointer __p = this->__begin_ + (__position - begin());
1227 if (this->__end_ < this->__cap_) {
1228 if (__p == this->__end_) {
1229 __construct_one_at_end(std::forward<_Args>(__args)...);
1230 } else {
1231 __temp_value<value_type, _Allocator> __tmp(this->__alloc_, std::forward<_Args>(__args)...);
1232 __move_range(__p, this->__end_, __p + 1);
1233 *__p = std::move(__tmp.get());
1234 }
1235 } else {
1236 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);
1237 __v.emplace_back(std::forward<_Args>(__args)...);
1238 __p = __swap_out_circular_buffer(__v, __p);
1239 }
1240 return __make_iter(__p);
1241}
1242
1243template <class _Tp, class _Allocator>
1244_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1245vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) {
1246 pointer __p = this->__begin_ + (__position - begin());
1247 if (__n > 0) {
1248 // We can't compare unrelated pointers inside constant expressions
1249 if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__cap_ - this->__end_)) {
1250 size_type __old_n = __n;
1251 pointer __old_last = this->__end_;
1252 if (__n > static_cast<size_type>(this->__end_ - __p)) {
1253 size_type __cx = __n - (this->__end_ - __p);
1254 __construct_at_end(__cx, __x);
1255 __n -= __cx;
1256 }
1257 if (__n > 0) {
1258 __move_range(__p, __old_last, __p + __old_n);
1259 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
1260 if (__p <= __xr && __xr < this->__end_)
1261 __xr += __old_n;
1262 std::fill_n(__p, __n, *__xr);
1263 }
1264 } else {
1265 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_);
1266 __v.__construct_at_end(__n, __x);
1267 __p = __swap_out_circular_buffer(__v, __p);
1268 }
1269 }
1270 return __make_iter(__p);
1271}
1272
1273template <class _Tp, class _Allocator>
1274template <class _InputIterator, class _Sentinel>
1275_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator
1276vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last) {
1277 difference_type __off = __position - begin();
1278 pointer __p = this->__begin_ + __off;
1279 pointer __old_last = this->__end_;
1280 for (; this->__end_ != this->__cap_ && __first != __last; ++__first)
1281 __construct_one_at_end(*__first);
1282
1283 if (__first == __last)
1284 (void)std::rotate(__p, __old_last, this->__end_);
1285 else {
1286 __split_buffer<value_type, allocator_type&> __v(__alloc_);
1287 auto __guard = std::__make_exception_guard(
1288 _AllocatorDestroyRangeReverse<allocator_type, pointer>(__alloc_, __old_last, this->__end_));
1289 __v.__construct_at_end_with_sentinel(std::move(__first), std::move(__last));
1290 __split_buffer<value_type, allocator_type&> __merged(
1291 __recommend(size() + __v.size()), __off, __alloc_); // has `__off` positions available at the front
1292 std::__uninitialized_allocator_relocate(
1293 __alloc_, std::__to_address(__old_last), std::__to_address(this->__end_), std::__to_address(__merged.__end_));
1294 __guard.__complete(); // Release the guard once objects in [__old_last_, __end_) have been successfully relocated.
1295 __merged.__end_ += this->__end_ - __old_last;
1296 this->__end_ = __old_last;
1297 std::__uninitialized_allocator_relocate(
1298 __alloc_, std::__to_address(__v.__begin_), std::__to_address(__v.__end_), std::__to_address(__merged.__end_));
1299 __merged.__end_ += __v.size();
1300 __v.__end_ = __v.__begin_;
1301 __p = __swap_out_circular_buffer(__merged, __p);
1302 }
1303 return __make_iter(__p);
1304}
1305
1306template <class _Tp, class _Allocator>
1307template <class _Iterator, class _Sentinel>
1308_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator
1309vector<_Tp, _Allocator>::__insert_with_size(
1310 const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n) {
1311 pointer __p = this->__begin_ + (__position - begin());
1312 if (__n > 0) {
1313 if (__n <= this->__cap_ - this->__end_) {
1314 pointer __old_last = this->__end_;
1315 difference_type __dx = this->__end_ - __p;
1316 if (__n > __dx) {
1317#if _LIBCPP_STD_VER >= 23
1318 if constexpr (!forward_iterator<_Iterator>) {
1319 __construct_at_end(std::move(__first), std::move(__last), __n);
1320 std::rotate(__p, __old_last, this->__end_);
1321 } else
1322#endif
1323 {
1324 _Iterator __m = std::next(__first, __dx);
1325 __construct_at_end(__m, __last, __n - __dx);
1326 if (__dx > 0) {
1327 __move_range(__p, __old_last, __p + __n);
1328 std::copy(__first, __m, __p);
1329 }
1330 }
1331 } else {
1332 __move_range(__p, __old_last, __p + __n);
1333#if _LIBCPP_STD_VER >= 23
1334 if constexpr (!forward_iterator<_Iterator>) {
1335 ranges::copy_n(std::move(__first), __n, __p);
1336 } else
1337#endif
1338 {
1339 std::copy_n(__first, __n, __p);
1340 }
1341 }
1342 } else {
1343 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_);
1344 __v.__construct_at_end_with_size(std::move(__first), __n);
1345 __p = __swap_out_circular_buffer(__v, __p);
1346 }
1347 }
1348 return __make_iter(__p);
1349}
1350
1351template <class _Tp, class _Allocator>
1352_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz) {
1353 size_type __cs = size();
1354 if (__cs < __sz)
1355 this->__append(__sz - __cs);
1356 else if (__cs > __sz)
1357 this->__destruct_at_end(this->__begin_ + __sz);
1358}
1359
1360template <class _Tp, class _Allocator>
1361_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) {
1362 size_type __cs = size();
1363 if (__cs < __sz)
1364 this->__append(__sz - __cs, __x);
1365 else if (__cs > __sz)
1366 this->__destruct_at_end(this->__begin_ + __sz);
1367}
1368
1369template <class _Tp, class _Allocator>
1370_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::swap(vector& __x)
1371#if _LIBCPP_STD_VER >= 14
1372 _NOEXCEPT
1373#else
1374 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
1375#endif
1376{
1377 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1378 __alloc_traits::propagate_on_container_swap::value || this->__alloc_ == __x.__alloc_,
1379 "vector::swap: Either propagate_on_container_swap must be true"
1380 " or the allocators must compare equal");
1381 std::swap(this->__begin_, __x.__begin_);
1382 std::swap(this->__end_, __x.__end_);
1383 std::swap(this->__cap_, __x.__cap_);
1384 std::__swap_allocator(this->__alloc_, __x.__alloc_);
1385}
1386
1387template <class _Tp, class _Allocator>
1388_LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<_Tp, _Allocator>::__invariants() const {
1389 if (this->__begin_ == nullptr) {
1390 if (this->__end_ != nullptr || this->__cap_ != nullptr)
1391 return false;
1392 } else {
1393 if (this->__begin_ > this->__end_)
1394 return false;
1395 if (this->__begin_ == this->__cap_)
1396 return false;
1397 if (this->__end_ > this->__cap_)
1398 return false;
1399 }
1400 return true;
1401}
1402
1403#if _LIBCPP_STD_VER >= 20
1404template <>
1405inline constexpr bool __format::__enable_insertable<vector<char>> = true;
1406# if _LIBCPP_HAS_WIDE_CHARACTERS
1407template <>
1408inline constexpr bool __format::__enable_insertable<vector<wchar_t>> = true;
1409# endif
1410#endif // _LIBCPP_STD_VER >= 20
1411
1412_LIBCPP_END_NAMESPACE_STD
1413
1414_LIBCPP_POP_MACROS
1415
1416#endif // _LIBCPP___VECTOR_VECTOR_H
lib/libcxx/include/__vector/vector_bool.h created+1131
...@@ -0,0 +1,1131 @@
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___VECTOR_VECTOR_BOOL_H
10#define _LIBCPP___VECTOR_VECTOR_BOOL_H
11
12#include <__algorithm/copy.h>
13#include <__algorithm/fill_n.h>
14#include <__algorithm/iterator_operations.h>
15#include <__algorithm/max.h>
16#include <__assert>
17#include <__bit_reference>
18#include <__config>
19#include <__functional/unary_function.h>
20#include <__fwd/bit_reference.h>
21#include <__fwd/functional.h>
22#include <__fwd/vector.h>
23#include <__iterator/distance.h>
24#include <__iterator/iterator_traits.h>
25#include <__iterator/reverse_iterator.h>
26#include <__memory/addressof.h>
27#include <__memory/allocate_at_least.h>
28#include <__memory/allocator.h>
29#include <__memory/allocator_traits.h>
30#include <__memory/compressed_pair.h>
31#include <__memory/construct_at.h>
32#include <__memory/noexcept_move_assign_container.h>
33#include <__memory/pointer_traits.h>
34#include <__memory/swap_allocator.h>
35#include <__ranges/access.h>
36#include <__ranges/concepts.h>
37#include <__ranges/container_compatible_range.h>
38#include <__ranges/from_range.h>
39#include <__type_traits/enable_if.h>
40#include <__type_traits/is_constant_evaluated.h>
41#include <__type_traits/is_nothrow_assignable.h>
42#include <__type_traits/is_nothrow_constructible.h>
43#include <__type_traits/type_identity.h>
44#include <__utility/exception_guard.h>
45#include <__utility/forward.h>
46#include <__utility/move.h>
47#include <__utility/swap.h>
48#include <climits>
49#include <initializer_list>
50#include <limits>
51#include <stdexcept>
52
53// These headers define parts of vectors definition, since they define ADL functions or class specializations.
54#include <__vector/comparison.h>
55#include <__vector/container_traits.h>
56#include <__vector/swap.h>
57
58#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
59# pragma GCC system_header
60#endif
61
62_LIBCPP_PUSH_MACROS
63#include <__undef_macros>
64
65_LIBCPP_BEGIN_NAMESPACE_STD
66
67template <class _Allocator>
68struct hash<vector<bool, _Allocator> >;
69
70template <class _Allocator>
71struct __has_storage_type<vector<bool, _Allocator> > {
72 static const bool value = true;
73};
74
75template <class _Allocator>
76class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator> {
77public:
78 typedef vector __self;
79 typedef bool value_type;
80 typedef _Allocator allocator_type;
81 typedef allocator_traits<allocator_type> __alloc_traits;
82 typedef typename __alloc_traits::size_type size_type;
83 typedef typename __alloc_traits::difference_type difference_type;
84 typedef size_type __storage_type;
85 typedef __bit_iterator<vector, false> pointer;
86 typedef __bit_iterator<vector, true> const_pointer;
87 typedef pointer iterator;
88 typedef const_pointer const_iterator;
89 typedef std::reverse_iterator<iterator> reverse_iterator;
90 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
91
92private:
93 typedef __rebind_alloc<__alloc_traits, __storage_type> __storage_allocator;
94 typedef allocator_traits<__storage_allocator> __storage_traits;
95 typedef typename __storage_traits::pointer __storage_pointer;
96 typedef typename __storage_traits::const_pointer __const_storage_pointer;
97
98 __storage_pointer __begin_;
99 size_type __size_;
100 _LIBCPP_COMPRESSED_PAIR(size_type, __cap_, __storage_allocator, __alloc_);
101
102public:
103 typedef __bit_reference<vector> reference;
104#ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
105 using const_reference = bool;
106#else
107 typedef __bit_const_reference<vector> const_reference;
108#endif
109
110private:
111 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
112
113 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type
114 __internal_cap_to_external(size_type __n) _NOEXCEPT {
115 return __n * __bits_per_word;
116 }
117 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type
118 __external_cap_to_internal(size_type __n) _NOEXCEPT {
119 return __n > 0 ? (__n - 1) / __bits_per_word + 1 : size_type(0);
120 }
121
122public:
123 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector()
124 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
125
126 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(const allocator_type& __a)
127#if _LIBCPP_STD_VER <= 14
128 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
129#else
130 _NOEXCEPT;
131#endif
132
133private:
134 class __destroy_vector {
135 public:
136 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __destroy_vector(vector& __vec) : __vec_(__vec) {}
137
138 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {
139 if (__vec_.__begin_ != nullptr)
140 __storage_traits::deallocate(__vec_.__alloc_, __vec_.__begin_, __vec_.__cap_);
141 }
142
143 private:
144 vector& __vec_;
145 };
146
147public:
148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~vector() { __destroy_vector (*this)(); }
149
150 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n);
151#if _LIBCPP_STD_VER >= 14
152 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n, const allocator_type& __a);
153#endif
154 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v);
155 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
156 vector(size_type __n, const value_type& __v, const allocator_type& __a);
157 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
158 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last);
159 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
160 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
161 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
162 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
163 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last);
164 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
165 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
166 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a);
167
168#if _LIBCPP_STD_VER >= 23
169 template <_ContainerCompatibleRange<bool> _Range>
170 _LIBCPP_HIDE_FROM_ABI constexpr vector(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())
171 : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) {
172 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
173 auto __n = static_cast<size_type>(ranges::distance(__range));
174 __init_with_size(ranges::begin(__range), ranges::end(__range), __n);
175
176 } else {
177 __init_with_sentinel(ranges::begin(__range), ranges::end(__range));
178 }
179 }
180#endif
181
182 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v);
183 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v, const allocator_type& __a);
184 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(const vector& __v);
185
186#ifndef _LIBCPP_CXX03_LANG
187 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(initializer_list<value_type> __il);
188 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
189 vector(initializer_list<value_type> __il, const allocator_type& __a);
190
191 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(initializer_list<value_type> __il) {
192 assign(__il.begin(), __il.end());
193 return *this;
194 }
195
196#endif // !_LIBCPP_CXX03_LANG
197
198 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(vector&& __v)
199#if _LIBCPP_STD_VER >= 17
200 noexcept;
201#else
202 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
203#endif
204 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
205 vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
206 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(vector&& __v)
207 _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value);
208
209 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
210 void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_InputIterator __first, _InputIterator __last);
211 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
212 void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_ForwardIterator __first, _ForwardIterator __last);
213
214#if _LIBCPP_STD_VER >= 23
215 template <_ContainerCompatibleRange<bool> _Range>
216 _LIBCPP_HIDE_FROM_ABI constexpr void assign_range(_Range&& __range) {
217 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
218 auto __n = static_cast<size_type>(ranges::distance(__range));
219 __assign_with_size(ranges::begin(__range), ranges::end(__range), __n);
220
221 } else {
222 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));
223 }
224 }
225#endif
226
227 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void assign(size_type __n, const value_type& __x);
228
229#ifndef _LIBCPP_CXX03_LANG
230 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void assign(initializer_list<value_type> __il) {
231 assign(__il.begin(), __il.end());
232 }
233#endif
234
235 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT {
236 return allocator_type(this->__alloc_);
237 }
238
239 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT;
240 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type capacity() const _NOEXCEPT {
241 return __internal_cap_to_external(__cap_);
242 }
243 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT { return __size_; }
244 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT {
245 return __size_ == 0;
246 }
247 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n);
248 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;
249
250 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { return __make_iter(0); }
251 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator begin() const _NOEXCEPT { return __make_iter(0); }
252 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() _NOEXCEPT { return __make_iter(__size_); }
253 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT {
254 return __make_iter(__size_);
255 }
256
257 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rbegin() _NOEXCEPT {
258 return reverse_iterator(end());
259 }
260 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rbegin() const _NOEXCEPT {
261 return const_reverse_iterator(end());
262 }
263 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rend() _NOEXCEPT {
264 return reverse_iterator(begin());
265 }
266 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rend() const _NOEXCEPT {
267 return const_reverse_iterator(begin());
268 }
269
270 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cbegin() const _NOEXCEPT { return __make_iter(0); }
271 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cend() const _NOEXCEPT {
272 return __make_iter(__size_);
273 }
274 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crbegin() const _NOEXCEPT {
275 return rbegin();
276 }
277 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
278
279 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __n) {
280 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector<bool>::operator[] index out of bounds");
281 return __make_ref(__n);
282 }
283 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __n) const {
284 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector<bool>::operator[] index out of bounds");
285 return __make_ref(__n);
286 }
287 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference at(size_type __n);
288 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference at(size_type __n) const;
289
290 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() {
291 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::front() called on an empty vector");
292 return __make_ref(0);
293 }
294 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const {
295 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::front() called on an empty vector");
296 return __make_ref(0);
297 }
298 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() {
299 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::back() called on an empty vector");
300 return __make_ref(__size_ - 1);
301 }
302 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const {
303 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::back() called on an empty vector");
304 return __make_ref(__size_ - 1);
305 }
306
307 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(const value_type& __x);
308#if _LIBCPP_STD_VER >= 14
309 template <class... _Args>
310# if _LIBCPP_STD_VER >= 17
311 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference emplace_back(_Args&&... __args)
312# else
313 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args)
314# endif
315 {
316 push_back(value_type(std::forward<_Args>(__args)...));
317# if _LIBCPP_STD_VER >= 17
318 return this->back();
319# endif
320 }
321#endif
322
323#if _LIBCPP_STD_VER >= 23
324 template <_ContainerCompatibleRange<bool> _Range>
325 _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) {
326 insert_range(end(), std::forward<_Range>(__range));
327 }
328#endif
329
330 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back() {
331 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::pop_back called on an empty vector");
332 --__size_;
333 }
334
335#if _LIBCPP_STD_VER >= 14
336 template <class... _Args>
337 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator emplace(const_iterator __position, _Args&&... __args) {
338 return insert(__position, value_type(std::forward<_Args>(__args)...));
339 }
340#endif
341
342 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, const value_type& __x);
343 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
344 insert(const_iterator __position, size_type __n, const value_type& __x);
345 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
346 iterator _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
347 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
348 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
349 iterator _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
350 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
351
352#if _LIBCPP_STD_VER >= 23
353 template <_ContainerCompatibleRange<bool> _Range>
354 _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) {
355 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
356 auto __n = static_cast<size_type>(ranges::distance(__range));
357 return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n);
358
359 } else {
360 return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));
361 }
362 }
363#endif
364
365#ifndef _LIBCPP_CXX03_LANG
366 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
367 insert(const_iterator __position, initializer_list<value_type> __il) {
368 return insert(__position, __il.begin(), __il.end());
369 }
370#endif
371
372 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __position);
373 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __first, const_iterator __last);
374
375 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT { __size_ = 0; }
376
377 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(vector&)
378#if _LIBCPP_STD_VER >= 14
379 _NOEXCEPT;
380#else
381 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
382#endif
383 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void swap(reference __x, reference __y) _NOEXCEPT {
384 std::swap(__x, __y);
385 }
386
387 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __sz, value_type __x = false);
388 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT;
389
390 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const;
391
392private:
393 [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_length_error() { std::__throw_length_error("vector"); }
394
395 [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_out_of_range() { std::__throw_out_of_range("vector"); }
396
397 template <class _InputIterator, class _Sentinel>
398 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
399 __init_with_size(_InputIterator __first, _Sentinel __last, size_type __n) {
400 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
401
402 if (__n > 0) {
403 __vallocate(__n);
404 __construct_at_end(std::move(__first), std::move(__last), __n);
405 }
406
407 __guard.__complete();
408 }
409
410 template <class _InputIterator, class _Sentinel>
411 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
412 __init_with_sentinel(_InputIterator __first, _Sentinel __last) {
413 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
414
415 for (; __first != __last; ++__first)
416 push_back(*__first);
417
418 __guard.__complete();
419 }
420
421 template <class _Iterator, class _Sentinel>
422 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last);
423
424 // The `_Iterator` in `*_with_size` functions can be input-only only if called from `*_range` (since C++23).
425 // Otherwise, `_Iterator` is a forward iterator.
426
427 template <class _Iterator, class _Sentinel>
428 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
429 __assign_with_size(_Iterator __first, _Sentinel __last, difference_type __ns);
430
431 template <class _InputIterator, class _Sentinel>
432 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
433 __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last);
434
435 template <class _Iterator, class _Sentinel>
436 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
437 __insert_with_size(const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n);
438
439 // Allocate space for __n objects
440 // throws length_error if __n > max_size()
441 // throws (probably bad_alloc) if memory run out
442 // Precondition: __begin_ == __end_ == __cap_ == nullptr
443 // Precondition: __n > 0
444 // Postcondition: capacity() >= __n
445 // Postcondition: size() == 0
446 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vallocate(size_type __n) {
447 if (__n > max_size())
448 __throw_length_error();
449 auto __allocation = std::__allocate_at_least(__alloc_, __external_cap_to_internal(__n));
450 __begin_ = __allocation.ptr;
451 __size_ = 0;
452 __cap_ = __allocation.count;
453 if (__libcpp_is_constant_evaluated()) {
454 for (size_type __i = 0; __i != __cap_; ++__i)
455 std::__construct_at(std::__to_address(__begin_) + __i);
456 }
457 }
458
459 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vdeallocate() _NOEXCEPT;
460 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type __align_it(size_type __new_size) _NOEXCEPT {
461 return (__new_size + (__bits_per_word - 1)) & ~((size_type)__bits_per_word - 1);
462 }
463 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __new_size) const;
464 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_at_end(size_type __n, bool __x);
465 template <class _InputIterator, class _Sentinel>
466 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
467 __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n);
468 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference __make_ref(size_type __pos) _NOEXCEPT {
469 return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);
470 }
471 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference __make_ref(size_type __pos) const _NOEXCEPT {
472 return __bit_const_reference<vector>(
473 __begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);
474 }
475 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iter(size_type __pos) _NOEXCEPT {
476 return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));
477 }
478 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_iter(size_type __pos) const _NOEXCEPT {
479 return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));
480 }
481 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT {
482 return begin() + (__p - cbegin());
483 }
484
485 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector& __v) {
486 __copy_assign_alloc(
487 __v, integral_constant<bool, __storage_traits::propagate_on_container_copy_assignment::value>());
488 }
489 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector& __c, true_type) {
490 if (__alloc_ != __c.__alloc_)
491 __vdeallocate();
492 __alloc_ = __c.__alloc_;
493 }
494
495 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector&, false_type) {}
496
497 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, false_type);
498 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, true_type)
499 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
500 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector& __c)
501 _NOEXCEPT_(!__storage_traits::propagate_on_container_move_assignment::value ||
502 is_nothrow_move_assignable<allocator_type>::value) {
503 __move_assign_alloc(
504 __c, integral_constant<bool, __storage_traits::propagate_on_container_move_assignment::value>());
505 }
506 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector& __c, true_type)
507 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
508 __alloc_ = std::move(__c.__alloc_);
509 }
510
511 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector&, false_type) _NOEXCEPT {}
512
513 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t __hash_code() const _NOEXCEPT;
514
515 friend class __bit_reference<vector>;
516 friend class __bit_const_reference<vector>;
517 friend class __bit_iterator<vector, false>;
518 friend class __bit_iterator<vector, true>;
519 friend struct __bit_array<vector>;
520 friend struct _LIBCPP_TEMPLATE_VIS hash<vector>;
521};
522
523template <class _Allocator>
524_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT {
525 if (this->__begin_ != nullptr) {
526 __storage_traits::deallocate(this->__alloc_, this->__begin_, __cap_);
527 this->__begin_ = nullptr;
528 this->__size_ = this->__cap_ = 0;
529 }
530}
531
532template <class _Allocator>
533_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type
534vector<bool, _Allocator>::max_size() const _NOEXCEPT {
535 size_type __amax = __storage_traits::max_size(__alloc_);
536 size_type __nmax = numeric_limits<size_type>::max() / 2; // end() >= begin(), always
537 if (__nmax / __bits_per_word <= __amax)
538 return __nmax;
539 return __internal_cap_to_external(__amax);
540}
541
542// Precondition: __new_size > capacity()
543template <class _Allocator>
544inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type
545vector<bool, _Allocator>::__recommend(size_type __new_size) const {
546 const size_type __ms = max_size();
547 if (__new_size > __ms)
548 this->__throw_length_error();
549 const size_type __cap = capacity();
550 if (__cap >= __ms / 2)
551 return __ms;
552 return std::max(2 * __cap, __align_it(__new_size));
553}
554
555// Default constructs __n objects starting at __end_
556// Precondition: __n > 0
557// Precondition: size() + __n <= capacity()
558// Postcondition: size() == size() + __n
559template <class _Allocator>
560inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
561vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) {
562 size_type __old_size = this->__size_;
563 this->__size_ += __n;
564 if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) {
565 if (this->__size_ <= __bits_per_word)
566 this->__begin_[0] = __storage_type(0);
567 else
568 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
569 }
570 std::fill_n(__make_iter(__old_size), __n, __x);
571}
572
573template <class _Allocator>
574template <class _InputIterator, class _Sentinel>
575_LIBCPP_CONSTEXPR_SINCE_CXX20 void
576vector<bool, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) {
577 size_type __old_size = this->__size_;
578 this->__size_ += __n;
579 if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) {
580 if (this->__size_ <= __bits_per_word)
581 this->__begin_[0] = __storage_type(0);
582 else
583 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
584 }
585 std::__copy(std::move(__first), std::move(__last), __make_iter(__old_size));
586}
587
588template <class _Allocator>
589inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector()
590 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
591 : __begin_(nullptr), __size_(0), __cap_(0) {}
592
593template <class _Allocator>
594inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const allocator_type& __a)
595#if _LIBCPP_STD_VER <= 14
596 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
597#else
598 _NOEXCEPT
599#endif
600 : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) {
601}
602
603template <class _Allocator>
604_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n)
605 : __begin_(nullptr), __size_(0), __cap_(0) {
606 if (__n > 0) {
607 __vallocate(__n);
608 __construct_at_end(__n, false);
609 }
610}
611
612#if _LIBCPP_STD_VER >= 14
613template <class _Allocator>
614_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
615 : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) {
616 if (__n > 0) {
617 __vallocate(__n);
618 __construct_at_end(__n, false);
619 }
620}
621#endif
622
623template <class _Allocator>
624_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
625 : __begin_(nullptr), __size_(0), __cap_(0) {
626 if (__n > 0) {
627 __vallocate(__n);
628 __construct_at_end(__n, __x);
629 }
630}
631
632template <class _Allocator>
633_LIBCPP_CONSTEXPR_SINCE_CXX20
634vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
635 : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) {
636 if (__n > 0) {
637 __vallocate(__n);
638 __construct_at_end(__n, __x);
639 }
640}
641
642template <class _Allocator>
643template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
644_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last)
645 : __begin_(nullptr), __size_(0), __cap_(0) {
646 __init_with_sentinel(__first, __last);
647}
648
649template <class _Allocator>
650template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
651_LIBCPP_CONSTEXPR_SINCE_CXX20
652vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
653 : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) {
654 __init_with_sentinel(__first, __last);
655}
656
657template <class _Allocator>
658template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
659_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last)
660 : __begin_(nullptr), __size_(0), __cap_(0) {
661 auto __n = static_cast<size_type>(std::distance(__first, __last));
662 __init_with_size(__first, __last, __n);
663}
664
665template <class _Allocator>
666template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
667_LIBCPP_CONSTEXPR_SINCE_CXX20
668vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a)
669 : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) {
670 auto __n = static_cast<size_type>(std::distance(__first, __last));
671 __init_with_size(__first, __last, __n);
672}
673
674#ifndef _LIBCPP_CXX03_LANG
675
676template <class _Allocator>
677_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
678 : __begin_(nullptr), __size_(0), __cap_(0) {
679 size_type __n = static_cast<size_type>(__il.size());
680 if (__n > 0) {
681 __vallocate(__n);
682 __construct_at_end(__il.begin(), __il.end(), __n);
683 }
684}
685
686template <class _Allocator>
687_LIBCPP_CONSTEXPR_SINCE_CXX20
688vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
689 : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) {
690 size_type __n = static_cast<size_type>(__il.size());
691 if (__n > 0) {
692 __vallocate(__n);
693 __construct_at_end(__il.begin(), __il.end(), __n);
694 }
695}
696
697#endif // _LIBCPP_CXX03_LANG
698
699template <class _Allocator>
700_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v)
701 : __begin_(nullptr),
702 __size_(0),
703 __cap_(0),
704 __alloc_(__storage_traits::select_on_container_copy_construction(__v.__alloc_)) {
705 if (__v.size() > 0) {
706 __vallocate(__v.size());
707 __construct_at_end(__v.begin(), __v.end(), __v.size());
708 }
709}
710
711template <class _Allocator>
712_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
713 : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(__a) {
714 if (__v.size() > 0) {
715 __vallocate(__v.size());
716 __construct_at_end(__v.begin(), __v.end(), __v.size());
717 }
718}
719
720template <class _Allocator>
721_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>& vector<bool, _Allocator>::operator=(const vector& __v) {
722 if (this != std::addressof(__v)) {
723 __copy_assign_alloc(__v);
724 if (__v.__size_) {
725 if (__v.__size_ > capacity()) {
726 __vdeallocate();
727 __vallocate(__v.__size_);
728 }
729 std::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_);
730 }
731 __size_ = __v.__size_;
732 }
733 return *this;
734}
735
736template <class _Allocator>
737inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(vector&& __v)
738#if _LIBCPP_STD_VER >= 17
739 _NOEXCEPT
740#else
741 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
742#endif
743 : __begin_(__v.__begin_),
744 __size_(__v.__size_),
745 __cap_(__v.__cap_),
746 __alloc_(std::move(__v.__alloc_)) {
747 __v.__begin_ = nullptr;
748 __v.__size_ = 0;
749 __v.__cap_ = 0;
750}
751
752template <class _Allocator>
753_LIBCPP_CONSTEXPR_SINCE_CXX20
754vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a)
755 : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(__a) {
756 if (__a == allocator_type(__v.__alloc_)) {
757 this->__begin_ = __v.__begin_;
758 this->__size_ = __v.__size_;
759 this->__cap_ = __v.__cap_;
760 __v.__begin_ = nullptr;
761 __v.__cap_ = __v.__size_ = 0;
762 } else if (__v.size() > 0) {
763 __vallocate(__v.size());
764 __construct_at_end(__v.begin(), __v.end(), __v.size());
765 }
766}
767
768template <class _Allocator>
769inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>&
770vector<bool, _Allocator>::operator=(vector&& __v)
771 _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
772 __move_assign(__v, integral_constant<bool, __storage_traits::propagate_on_container_move_assignment::value>());
773 return *this;
774}
775
776template <class _Allocator>
777_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__move_assign(vector& __c, false_type) {
778 if (__alloc_ != __c.__alloc_)
779 assign(__c.begin(), __c.end());
780 else
781 __move_assign(__c, true_type());
782}
783
784template <class _Allocator>
785_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
786 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
787 __vdeallocate();
788 __move_assign_alloc(__c);
789 this->__begin_ = __c.__begin_;
790 this->__size_ = __c.__size_;
791 this->__cap_ = __c.__cap_;
792 __c.__begin_ = nullptr;
793 __c.__cap_ = __c.__size_ = 0;
794}
795
796template <class _Allocator>
797_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) {
798 __size_ = 0;
799 if (__n > 0) {
800 size_type __c = capacity();
801 if (__n <= __c)
802 __size_ = __n;
803 else {
804 vector __v(get_allocator());
805 __v.reserve(__recommend(__n));
806 __v.__size_ = __n;
807 swap(__v);
808 }
809 std::fill_n(begin(), __n, __x);
810 }
811}
812
813template <class _Allocator>
814template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
815_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last) {
816 __assign_with_sentinel(__first, __last);
817}
818
819template <class _Allocator>
820template <class _Iterator, class _Sentinel>
821_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
822vector<bool, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __last) {
823 clear();
824 for (; __first != __last; ++__first)
825 push_back(*__first);
826}
827
828template <class _Allocator>
829template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
830_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) {
831 __assign_with_size(__first, __last, std::distance(__first, __last));
832}
833
834template <class _Allocator>
835template <class _Iterator, class _Sentinel>
836_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
837vector<bool, _Allocator>::__assign_with_size(_Iterator __first, _Sentinel __last, difference_type __ns) {
838 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__ns >= 0, "invalid range specified");
839
840 clear();
841
842 const size_t __n = static_cast<size_type>(__ns);
843 if (__n) {
844 if (__n > capacity()) {
845 __vdeallocate();
846 __vallocate(__n);
847 }
848 __construct_at_end(std::move(__first), std::move(__last), __n);
849 }
850}
851
852template <class _Allocator>
853_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::reserve(size_type __n) {
854 if (__n > capacity()) {
855 if (__n > max_size())
856 this->__throw_length_error();
857 vector __v(this->get_allocator());
858 __v.__vallocate(__n);
859 __v.__construct_at_end(this->begin(), this->end(), this->size());
860 swap(__v);
861 }
862}
863
864template <class _Allocator>
865_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT {
866 if (__external_cap_to_internal(size()) < __cap_) {
867#if _LIBCPP_HAS_EXCEPTIONS
868 try {
869#endif // _LIBCPP_HAS_EXCEPTIONS
870 vector __v(*this, allocator_type(__alloc_));
871 if (__v.__cap_ < __cap_)
872 __v.swap(*this);
873#if _LIBCPP_HAS_EXCEPTIONS
874 } catch (...) {
875 }
876#endif // _LIBCPP_HAS_EXCEPTIONS
877 }
878}
879
880template <class _Allocator>
881_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::reference vector<bool, _Allocator>::at(size_type __n) {
882 if (__n >= size())
883 this->__throw_out_of_range();
884 return (*this)[__n];
885}
886
887template <class _Allocator>
888_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::const_reference
889vector<bool, _Allocator>::at(size_type __n) const {
890 if (__n >= size())
891 this->__throw_out_of_range();
892 return (*this)[__n];
893}
894
895template <class _Allocator>
896_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::push_back(const value_type& __x) {
897 if (this->__size_ == this->capacity())
898 reserve(__recommend(this->__size_ + 1));
899 ++this->__size_;
900 back() = __x;
901}
902
903template <class _Allocator>
904_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
905vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x) {
906 iterator __r;
907 if (size() < capacity()) {
908 const_iterator __old_end = end();
909 ++__size_;
910 std::copy_backward(__position, __old_end, end());
911 __r = __const_iterator_cast(__position);
912 } else {
913 vector __v(get_allocator());
914 __v.reserve(__recommend(__size_ + 1));
915 __v.__size_ = __size_ + 1;
916 __r = std::copy(cbegin(), __position, __v.begin());
917 std::copy_backward(__position, cend(), __v.end());
918 swap(__v);
919 }
920 *__r = __x;
921 return __r;
922}
923
924template <class _Allocator>
925_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
926vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x) {
927 iterator __r;
928 size_type __c = capacity();
929 if (__n <= __c && size() <= __c - __n) {
930 const_iterator __old_end = end();
931 __size_ += __n;
932 std::copy_backward(__position, __old_end, end());
933 __r = __const_iterator_cast(__position);
934 } else {
935 vector __v(get_allocator());
936 __v.reserve(__recommend(__size_ + __n));
937 __v.__size_ = __size_ + __n;
938 __r = std::copy(cbegin(), __position, __v.begin());
939 std::copy_backward(__position, cend(), __v.end());
940 swap(__v);
941 }
942 std::fill_n(__r, __n, __x);
943 return __r;
944}
945
946template <class _Allocator>
947template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
948_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
949vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) {
950 return __insert_with_sentinel(__position, __first, __last);
951}
952
953template <class _Allocator>
954template <class _InputIterator, class _Sentinel>
955_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<bool, _Allocator>::iterator
956vector<bool, _Allocator>::__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last) {
957 difference_type __off = __position - begin();
958 iterator __p = __const_iterator_cast(__position);
959 iterator __old_end = end();
960 for (; size() != capacity() && __first != __last; ++__first) {
961 ++this->__size_;
962 back() = *__first;
963 }
964 vector __v(get_allocator());
965 if (__first != __last) {
966#if _LIBCPP_HAS_EXCEPTIONS
967 try {
968#endif // _LIBCPP_HAS_EXCEPTIONS
969 __v.__assign_with_sentinel(std::move(__first), std::move(__last));
970 difference_type __old_size = static_cast<difference_type>(__old_end - begin());
971 difference_type __old_p = __p - begin();
972 reserve(__recommend(size() + __v.size()));
973 __p = begin() + __old_p;
974 __old_end = begin() + __old_size;
975#if _LIBCPP_HAS_EXCEPTIONS
976 } catch (...) {
977 erase(__old_end, end());
978 throw;
979 }
980#endif // _LIBCPP_HAS_EXCEPTIONS
981 }
982 __p = std::rotate(__p, __old_end, end());
983 insert(__p, __v.begin(), __v.end());
984 return begin() + __off;
985}
986
987template <class _Allocator>
988template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
989_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
990vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) {
991 return __insert_with_size(__position, __first, __last, std::distance(__first, __last));
992}
993
994template <class _Allocator>
995template <class _Iterator, class _Sentinel>
996_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<bool, _Allocator>::iterator
997vector<bool, _Allocator>::__insert_with_size(
998 const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n_signed) {
999 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__n_signed >= 0, "invalid range specified");
1000 const size_type __n = static_cast<size_type>(__n_signed);
1001 iterator __r;
1002 size_type __c = capacity();
1003 if (__n <= __c && size() <= __c - __n) {
1004 const_iterator __old_end = end();
1005 __size_ += __n;
1006 std::copy_backward(__position, __old_end, end());
1007 __r = __const_iterator_cast(__position);
1008 } else {
1009 vector __v(get_allocator());
1010 __v.reserve(__recommend(__size_ + __n));
1011 __v.__size_ = __size_ + __n;
1012 __r = std::copy(cbegin(), __position, __v.begin());
1013 std::copy_backward(__position, cend(), __v.end());
1014 swap(__v);
1015 }
1016 std::__copy(std::move(__first), std::move(__last), __r);
1017 return __r;
1018}
1019
1020template <class _Allocator>
1021inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
1022vector<bool, _Allocator>::erase(const_iterator __position) {
1023 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
1024 __position != end(), "vector<bool>::erase(iterator) called with a non-dereferenceable iterator");
1025 iterator __r = __const_iterator_cast(__position);
1026 std::copy(__position + 1, this->cend(), __r);
1027 --__size_;
1028 return __r;
1029}
1030
1031template <class _Allocator>
1032_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
1033vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last) {
1034 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
1035 __first <= __last, "vector<bool>::erase(iterator, iterator) called with an invalid range");
1036 iterator __r = __const_iterator_cast(__first);
1037 difference_type __d = __last - __first;
1038 std::copy(__last, this->cend(), __r);
1039 __size_ -= __d;
1040 return __r;
1041}
1042
1043template <class _Allocator>
1044_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::swap(vector& __x)
1045#if _LIBCPP_STD_VER >= 14
1046 _NOEXCEPT
1047#else
1048 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
1049#endif
1050{
1051 std::swap(this->__begin_, __x.__begin_);
1052 std::swap(this->__size_, __x.__size_);
1053 std::swap(this->__cap_, __x.__cap_);
1054 std::__swap_allocator(this->__alloc_, __x.__alloc_);
1055}
1056
1057template <class _Allocator>
1058_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::resize(size_type __sz, value_type __x) {
1059 size_type __cs = size();
1060 if (__cs < __sz) {
1061 iterator __r;
1062 size_type __c = capacity();
1063 size_type __n = __sz - __cs;
1064 if (__n <= __c && __cs <= __c - __n) {
1065 __r = end();
1066 __size_ += __n;
1067 } else {
1068 vector __v(get_allocator());
1069 __v.reserve(__recommend(__size_ + __n));
1070 __v.__size_ = __size_ + __n;
1071 __r = std::copy(cbegin(), cend(), __v.begin());
1072 swap(__v);
1073 }
1074 std::fill_n(__r, __n, __x);
1075 } else
1076 __size_ = __sz;
1077}
1078
1079template <class _Allocator>
1080_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::flip() _NOEXCEPT {
1081 // Flip each storage word entirely, including the last potentially partial word.
1082 // The unused bits in the last word are safe to flip as they won't be accessed.
1083 __storage_pointer __p = __begin_;
1084 for (size_type __n = __external_cap_to_internal(size()); __n != 0; ++__p, --__n)
1085 *__p = ~*__p;
1086}
1087
1088template <class _Allocator>
1089_LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<bool, _Allocator>::__invariants() const {
1090 if (this->__begin_ == nullptr) {
1091 if (this->__size_ != 0 || this->__cap_ != 0)
1092 return false;
1093 } else {
1094 if (this->__cap_ == 0)
1095 return false;
1096 if (this->__size_ > this->capacity())
1097 return false;
1098 }
1099 return true;
1100}
1101
1102template <class _Allocator>
1103_LIBCPP_CONSTEXPR_SINCE_CXX20 size_t vector<bool, _Allocator>::__hash_code() const _NOEXCEPT {
1104 size_t __h = 0;
1105 // do middle whole words
1106 size_type __n = __size_;
1107 __storage_pointer __p = __begin_;
1108 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
1109 __h ^= *__p;
1110 // do last partial word
1111 if (__n > 0) {
1112 const __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
1113 __h ^= *__p & __m;
1114 }
1115 return __h;
1116}
1117
1118template <class _Allocator>
1119struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
1120 : public __unary_function<vector<bool, _Allocator>, size_t> {
1121 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t
1122 operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT {
1123 return __vec.__hash_code();
1124 }
1125};
1126
1127_LIBCPP_END_NAMESPACE_STD
1128
1129_LIBCPP_POP_MACROS
1130
1131#endif // _LIBCPP___VECTOR_VECTOR_BOOL_H
lib/libcxx/include/__vector/vector_bool_formatter.h created+49
...@@ -0,0 +1,49 @@
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___VECTOR_VECTOR_BOOL_FORMATTER_H
10#define _LIBCPP___VECTOR_VECTOR_BOOL_FORMATTER_H
11
12#include <__concepts/same_as.h>
13#include <__config>
14#include <__format/formatter.h>
15#include <__format/formatter_bool.h>
16#include <__fwd/vector.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22#if _LIBCPP_STD_VER >= 23
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26template <class _Tp, class _CharT>
27// Since is-vector-bool-reference is only used once it's inlined here.
28 requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>>
29struct _LIBCPP_TEMPLATE_VIS formatter<_Tp, _CharT> {
30private:
31 formatter<bool, _CharT> __underlying_;
32
33public:
34 template <class _ParseContext>
35 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
36 return __underlying_.parse(__ctx);
37 }
38
39 template <class _FormatContext>
40 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _Tp& __ref, _FormatContext& __ctx) const {
41 return __underlying_.format(__ref, __ctx);
42 }
43};
44
45_LIBCPP_END_NAMESPACE_STD
46
47#endif // _LIBCPP_STD_VER >= 23
48
49#endif // _LIBCPP___VECTOR_VECTOR_BOOL_FORMATTER_H
lib/libcxx/include/__verbose_abort+8-2
...@@ -18,10 +18,16 @@...@@ -18,10 +18,16 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if defined(_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT)
22# define _LIBCPP_VERBOSE_ABORT_NOEXCEPT
23#else
24# define _LIBCPP_VERBOSE_ABORT_NOEXCEPT _NOEXCEPT
25#endif
26
21// This function should never be called directly from the code -- it should only be called through27// This function should never be called directly from the code -- it should only be called through
22// the _LIBCPP_VERBOSE_ABORT macro.28// the _LIBCPP_VERBOSE_ABORT macro.
23_LIBCPP_NORETURN _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS29[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(
24_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...);30 __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT;
2531
26// _LIBCPP_VERBOSE_ABORT(format, args...)32// _LIBCPP_VERBOSE_ABORT(format, args...)
27//33//
lib/libcxx/include/algorithm+250-237
...@@ -313,6 +313,9 @@ namespace ranges {...@@ -313,6 +313,9 @@ namespace ranges {
313 template<class I, class F>313 template<class I, class F>
314 using for_each_result = in_fun_result<I, F>; // since C++20314 using for_each_result = in_fun_result<I, F>; // since C++20
315315
316 template<class I, class F>
317 using for_each_n_result = in_fun_result<I, F>; // since C++20
318
316 template<input_iterator I, sentinel_for<I> S, class Proj = identity,319 template<input_iterator I, sentinel_for<I> S, class Proj = identity,
317 indirectly_unary_invocable<projected<I, Proj>> Fun>320 indirectly_unary_invocable<projected<I, Proj>> Fun>
318 constexpr ranges::for_each_result<I, Fun>321 constexpr ranges::for_each_result<I, Fun>
...@@ -700,6 +703,12 @@ namespace ranges {...@@ -700,6 +703,12 @@ namespace ranges {
700 ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {},703 ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {},
701 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20704 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
702705
706 template<class I, class O>
707 using move_result = in_out_result<I, O>; // since C++20
708
709 template<class I, class O>
710 using move_backward_result = in_out_result<I, O>; // since C++20
711
703 template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>712 template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
704 requires indirectly_movable<I1, I2>713 requires indirectly_movable<I1, I2>
705 constexpr ranges::move_backward_result<I1, I2>714 constexpr ranges::move_backward_result<I1, I2>
...@@ -1228,9 +1237,9 @@ template <class InputIterator1, class InputIterator2>...@@ -1228,9 +1237,9 @@ template <class InputIterator1, class InputIterator2>
1228 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);1237 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
12291238
1230template <class InputIterator1, class InputIterator2>1239template <class InputIterator1, class InputIterator2>
1231 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++201240 constexpr pair<InputIterator1, InputIterator2>
1232 mismatch(InputIterator1 first1, InputIterator1 last1,1241 mismatch(InputIterator1 first1, InputIterator1 last1,
1233 InputIterator2 first2, InputIterator2 last2); // **C++14**1242 InputIterator2 first2, InputIterator2 last2); // since C++14, constexpr in C++20
12341243
1235template <class InputIterator1, class InputIterator2, class BinaryPredicate>1244template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1236 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++201245 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
...@@ -1238,19 +1247,19 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate>...@@ -1238,19 +1247,19 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1238 InputIterator2 first2, BinaryPredicate pred);1247 InputIterator2 first2, BinaryPredicate pred);
12391248
1240template <class InputIterator1, class InputIterator2, class BinaryPredicate>1249template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1241 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++201250 constexpr pair<InputIterator1, InputIterator2>
1242 mismatch(InputIterator1 first1, InputIterator1 last1,1251 mismatch(InputIterator1 first1, InputIterator1 last1,
1243 InputIterator2 first2, InputIterator2 last2,1252 InputIterator2 first2, InputIterator2 last2,
1244 BinaryPredicate pred); // **C++14**1253 BinaryPredicate pred); // since C++14, constexpr in C++20
12451254
1246template <class InputIterator1, class InputIterator2>1255template <class InputIterator1, class InputIterator2>
1247 constexpr bool // constexpr in C++201256 constexpr bool // constexpr in C++20
1248 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);1257 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
12491258
1250template <class InputIterator1, class InputIterator2>1259template <class InputIterator1, class InputIterator2>
1251 constexpr bool // constexpr in C++201260 constexpr bool
1252 equal(InputIterator1 first1, InputIterator1 last1,1261 equal(InputIterator1 first1, InputIterator1 last1,
1253 InputIterator2 first2, InputIterator2 last2); // **C++14**1262 InputIterator2 first2, InputIterator2 last2); // since C++14, constexpr in C++20
12541263
1255template <class InputIterator1, class InputIterator2, class BinaryPredicate>1264template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1256 constexpr bool // constexpr in C++201265 constexpr bool // constexpr in C++20
...@@ -1258,10 +1267,10 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate>...@@ -1258,10 +1267,10 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1258 InputIterator2 first2, BinaryPredicate pred);1267 InputIterator2 first2, BinaryPredicate pred);
12591268
1260template <class InputIterator1, class InputIterator2, class BinaryPredicate>1269template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1261 constexpr bool // constexpr in C++201270 constexpr bool
1262 equal(InputIterator1 first1, InputIterator1 last1,1271 equal(InputIterator1 first1, InputIterator1 last1,
1263 InputIterator2 first2, InputIterator2 last2,1272 InputIterator2 first2, InputIterator2 last2,
1264 BinaryPredicate pred); // **C++14**1273 BinaryPredicate pred); // since C++14, constexpr in C++20
12651274
1266template<class ForwardIterator1, class ForwardIterator2>1275template<class ForwardIterator1, class ForwardIterator2>
1267 constexpr bool // constexpr in C++201276 constexpr bool // constexpr in C++20
...@@ -1269,9 +1278,9 @@ template<class ForwardIterator1, class ForwardIterator2>...@@ -1269,9 +1278,9 @@ template<class ForwardIterator1, class ForwardIterator2>
1269 ForwardIterator2 first2);1278 ForwardIterator2 first2);
12701279
1271template<class ForwardIterator1, class ForwardIterator2>1280template<class ForwardIterator1, class ForwardIterator2>
1272 constexpr bool // constexpr in C++201281 constexpr bool
1273 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,1282 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
1274 ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**1283 ForwardIterator2 first2, ForwardIterator2 last2); // since C++14, constexpr in C++20
12751284
1276template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>1285template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1277 constexpr bool // constexpr in C++201286 constexpr bool // constexpr in C++20
...@@ -1279,10 +1288,10 @@ template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>...@@ -1279,10 +1288,10 @@ template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1279 ForwardIterator2 first2, BinaryPredicate pred);1288 ForwardIterator2 first2, BinaryPredicate pred);
12801289
1281template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>1290template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1282 constexpr bool // constexpr in C++201291 constexpr bool
1283 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,1292 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
1284 ForwardIterator2 first2, ForwardIterator2 last2,1293 ForwardIterator2 first2, ForwardIterator2 last2,
1285 BinaryPredicate pred); // **C++14**1294 BinaryPredicate pred); // since C++14, constexpr in C++20
12861295
1287template <class ForwardIterator1, class ForwardIterator2>1296template <class ForwardIterator1, class ForwardIterator2>
1288 constexpr ForwardIterator1 // constexpr in C++201297 constexpr ForwardIterator1 // constexpr in C++20
...@@ -1521,11 +1530,11 @@ template <class RandomAccessIterator, class Compare>...@@ -1521,11 +1530,11 @@ template <class RandomAccessIterator, class Compare>
1521 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);1530 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
15221531
1523template <class RandomAccessIterator>1532template <class RandomAccessIterator>
1524 void1533 constexpr void // constexpr in C++26
1525 stable_sort(RandomAccessIterator first, RandomAccessIterator last);1534 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
15261535
1527template <class RandomAccessIterator, class Compare>1536template <class RandomAccessIterator, class Compare>
1528 void1537 constexpr void // constexpr in C++26
1529 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);1538 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
15301539
1531template <class RandomAccessIterator>1540template <class RandomAccessIterator>
...@@ -1818,232 +1827,236 @@ template <class BidirectionalIterator, class Compare>...@@ -1818,232 +1827,236 @@ template <class BidirectionalIterator, class Compare>
18181827
1819*/1828*/
18201829
1821#include <__config>1830#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
18221831# include <__cxx03/algorithm>
1823#include <__algorithm/adjacent_find.h>1832#else
1824#include <__algorithm/all_of.h>1833# include <__config>
1825#include <__algorithm/any_of.h>1834
1826#include <__algorithm/binary_search.h>1835# include <__algorithm/adjacent_find.h>
1827#include <__algorithm/copy.h>1836# include <__algorithm/all_of.h>
1828#include <__algorithm/copy_backward.h>1837# include <__algorithm/any_of.h>
1829#include <__algorithm/copy_if.h>1838# include <__algorithm/binary_search.h>
1830#include <__algorithm/copy_n.h>1839# include <__algorithm/copy.h>
1831#include <__algorithm/count.h>1840# include <__algorithm/copy_backward.h>
1832#include <__algorithm/count_if.h>1841# include <__algorithm/copy_if.h>
1833#include <__algorithm/equal.h>1842# include <__algorithm/copy_n.h>
1834#include <__algorithm/equal_range.h>1843# include <__algorithm/count.h>
1835#include <__algorithm/fill.h>1844# include <__algorithm/count_if.h>
1836#include <__algorithm/fill_n.h>1845# include <__algorithm/equal.h>
1837#include <__algorithm/find.h>1846# include <__algorithm/equal_range.h>
1838#include <__algorithm/find_end.h>1847# include <__algorithm/fill.h>
1839#include <__algorithm/find_first_of.h>1848# include <__algorithm/fill_n.h>
1840#include <__algorithm/find_if.h>1849# include <__algorithm/find.h>
1841#include <__algorithm/find_if_not.h>1850# include <__algorithm/find_end.h>
1842#include <__algorithm/for_each.h>1851# include <__algorithm/find_first_of.h>
1843#include <__algorithm/generate.h>1852# include <__algorithm/find_if.h>
1844#include <__algorithm/generate_n.h>1853# include <__algorithm/find_if_not.h>
1845#include <__algorithm/includes.h>1854# include <__algorithm/for_each.h>
1846#include <__algorithm/inplace_merge.h>1855# include <__algorithm/generate.h>
1847#include <__algorithm/is_heap.h>1856# include <__algorithm/generate_n.h>
1848#include <__algorithm/is_heap_until.h>1857# include <__algorithm/includes.h>
1849#include <__algorithm/is_partitioned.h>1858# include <__algorithm/inplace_merge.h>
1850#include <__algorithm/is_permutation.h>1859# include <__algorithm/is_heap.h>
1851#include <__algorithm/is_sorted.h>1860# include <__algorithm/is_heap_until.h>
1852#include <__algorithm/is_sorted_until.h>1861# include <__algorithm/is_partitioned.h>
1853#include <__algorithm/iter_swap.h>1862# include <__algorithm/is_permutation.h>
1854#include <__algorithm/lexicographical_compare.h>1863# include <__algorithm/is_sorted.h>
1855#include <__algorithm/lower_bound.h>1864# include <__algorithm/is_sorted_until.h>
1856#include <__algorithm/make_heap.h>1865# include <__algorithm/iter_swap.h>
1857#include <__algorithm/max.h>1866# include <__algorithm/lexicographical_compare.h>
1858#include <__algorithm/max_element.h>1867# include <__algorithm/lower_bound.h>
1859#include <__algorithm/merge.h>1868# include <__algorithm/make_heap.h>
1860#include <__algorithm/min.h>1869# include <__algorithm/max.h>
1861#include <__algorithm/min_element.h>1870# include <__algorithm/max_element.h>
1862#include <__algorithm/minmax.h>1871# include <__algorithm/merge.h>
1863#include <__algorithm/minmax_element.h>1872# include <__algorithm/min.h>
1864#include <__algorithm/mismatch.h>1873# include <__algorithm/min_element.h>
1865#include <__algorithm/move.h>1874# include <__algorithm/minmax.h>
1866#include <__algorithm/move_backward.h>1875# include <__algorithm/minmax_element.h>
1867#include <__algorithm/next_permutation.h>1876# include <__algorithm/mismatch.h>
1868#include <__algorithm/none_of.h>1877# include <__algorithm/move.h>
1869#include <__algorithm/nth_element.h>1878# include <__algorithm/move_backward.h>
1870#include <__algorithm/partial_sort.h>1879# include <__algorithm/next_permutation.h>
1871#include <__algorithm/partial_sort_copy.h>1880# include <__algorithm/none_of.h>
1872#include <__algorithm/partition.h>1881# include <__algorithm/nth_element.h>
1873#include <__algorithm/partition_copy.h>1882# include <__algorithm/partial_sort.h>
1874#include <__algorithm/partition_point.h>1883# include <__algorithm/partial_sort_copy.h>
1875#include <__algorithm/pop_heap.h>1884# include <__algorithm/partition.h>
1876#include <__algorithm/prev_permutation.h>1885# include <__algorithm/partition_copy.h>
1877#include <__algorithm/push_heap.h>1886# include <__algorithm/partition_point.h>
1878#include <__algorithm/remove.h>1887# include <__algorithm/pop_heap.h>
1879#include <__algorithm/remove_copy.h>1888# include <__algorithm/prev_permutation.h>
1880#include <__algorithm/remove_copy_if.h>1889# include <__algorithm/push_heap.h>
1881#include <__algorithm/remove_if.h>1890# include <__algorithm/remove.h>
1882#include <__algorithm/replace.h>1891# include <__algorithm/remove_copy.h>
1883#include <__algorithm/replace_copy.h>1892# include <__algorithm/remove_copy_if.h>
1884#include <__algorithm/replace_copy_if.h>1893# include <__algorithm/remove_if.h>
1885#include <__algorithm/replace_if.h>1894# include <__algorithm/replace.h>
1886#include <__algorithm/reverse.h>1895# include <__algorithm/replace_copy.h>
1887#include <__algorithm/reverse_copy.h>1896# include <__algorithm/replace_copy_if.h>
1888#include <__algorithm/rotate.h>1897# include <__algorithm/replace_if.h>
1889#include <__algorithm/rotate_copy.h>1898# include <__algorithm/reverse.h>
1890#include <__algorithm/search.h>1899# include <__algorithm/reverse_copy.h>
1891#include <__algorithm/search_n.h>1900# include <__algorithm/rotate.h>
1892#include <__algorithm/set_difference.h>1901# include <__algorithm/rotate_copy.h>
1893#include <__algorithm/set_intersection.h>1902# include <__algorithm/search.h>
1894#include <__algorithm/set_symmetric_difference.h>1903# include <__algorithm/search_n.h>
1895#include <__algorithm/set_union.h>1904# include <__algorithm/set_difference.h>
1896#include <__algorithm/shuffle.h>1905# include <__algorithm/set_intersection.h>
1897#include <__algorithm/sort.h>1906# include <__algorithm/set_symmetric_difference.h>
1898#include <__algorithm/sort_heap.h>1907# include <__algorithm/set_union.h>
1899#include <__algorithm/stable_partition.h>1908# include <__algorithm/shuffle.h>
1900#include <__algorithm/stable_sort.h>1909# include <__algorithm/sort.h>
1901#include <__algorithm/swap_ranges.h>1910# include <__algorithm/sort_heap.h>
1902#include <__algorithm/transform.h>1911# include <__algorithm/stable_partition.h>
1903#include <__algorithm/unique.h>1912# include <__algorithm/stable_sort.h>
1904#include <__algorithm/unique_copy.h>1913# include <__algorithm/swap_ranges.h>
1905#include <__algorithm/upper_bound.h>1914# include <__algorithm/transform.h>
19061915# include <__algorithm/unique.h>
1907#if _LIBCPP_STD_VER >= 171916# include <__algorithm/unique_copy.h>
1908# include <__algorithm/clamp.h>1917# include <__algorithm/upper_bound.h>
1909# include <__algorithm/for_each_n.h>1918
1910# include <__algorithm/pstl.h>1919# if _LIBCPP_STD_VER >= 17
1911# include <__algorithm/sample.h>1920# include <__algorithm/clamp.h>
1912#endif // _LIBCPP_STD_VER >= 171921# include <__algorithm/for_each_n.h>
19131922# include <__algorithm/pstl.h>
1914#if _LIBCPP_STD_VER >= 201923# include <__algorithm/sample.h>
1915# include <__algorithm/in_found_result.h>1924# endif // _LIBCPP_STD_VER >= 17
1916# include <__algorithm/in_fun_result.h>1925
1917# include <__algorithm/in_in_out_result.h>1926# if _LIBCPP_STD_VER >= 20
1918# include <__algorithm/in_in_result.h>1927# include <__algorithm/in_found_result.h>
1919# include <__algorithm/in_out_out_result.h>1928# include <__algorithm/in_fun_result.h>
1920# include <__algorithm/in_out_result.h>1929# include <__algorithm/in_in_out_result.h>
1921# include <__algorithm/lexicographical_compare_three_way.h>1930# include <__algorithm/in_in_result.h>
1922# include <__algorithm/min_max_result.h>1931# include <__algorithm/in_out_out_result.h>
1923# include <__algorithm/ranges_adjacent_find.h>1932# include <__algorithm/in_out_result.h>
1924# include <__algorithm/ranges_all_of.h>1933# include <__algorithm/lexicographical_compare_three_way.h>
1925# include <__algorithm/ranges_any_of.h>1934# include <__algorithm/min_max_result.h>
1926# include <__algorithm/ranges_binary_search.h>1935# include <__algorithm/ranges_adjacent_find.h>
1927# include <__algorithm/ranges_clamp.h>1936# include <__algorithm/ranges_all_of.h>
1928# include <__algorithm/ranges_contains.h>1937# include <__algorithm/ranges_any_of.h>
1929# include <__algorithm/ranges_copy.h>1938# include <__algorithm/ranges_binary_search.h>
1930# include <__algorithm/ranges_copy_backward.h>1939# include <__algorithm/ranges_clamp.h>
1931# include <__algorithm/ranges_copy_if.h>1940# include <__algorithm/ranges_contains.h>
1932# include <__algorithm/ranges_copy_n.h>1941# include <__algorithm/ranges_copy.h>
1933# include <__algorithm/ranges_count.h>1942# include <__algorithm/ranges_copy_backward.h>
1934# include <__algorithm/ranges_count_if.h>1943# include <__algorithm/ranges_copy_if.h>
1935# include <__algorithm/ranges_equal.h>1944# include <__algorithm/ranges_copy_n.h>
1936# include <__algorithm/ranges_equal_range.h>1945# include <__algorithm/ranges_count.h>
1937# include <__algorithm/ranges_fill.h>1946# include <__algorithm/ranges_count_if.h>
1938# include <__algorithm/ranges_fill_n.h>1947# include <__algorithm/ranges_equal.h>
1939# include <__algorithm/ranges_find.h>1948# include <__algorithm/ranges_equal_range.h>
1940# include <__algorithm/ranges_find_end.h>1949# include <__algorithm/ranges_fill.h>
1941# include <__algorithm/ranges_find_first_of.h>1950# include <__algorithm/ranges_fill_n.h>
1942# include <__algorithm/ranges_find_if.h>1951# include <__algorithm/ranges_find.h>
1943# include <__algorithm/ranges_find_if_not.h>1952# include <__algorithm/ranges_find_end.h>
1944# include <__algorithm/ranges_for_each.h>1953# include <__algorithm/ranges_find_first_of.h>
1945# include <__algorithm/ranges_for_each_n.h>1954# include <__algorithm/ranges_find_if.h>
1946# include <__algorithm/ranges_generate.h>1955# include <__algorithm/ranges_find_if_not.h>
1947# include <__algorithm/ranges_generate_n.h>1956# include <__algorithm/ranges_for_each.h>
1948# include <__algorithm/ranges_includes.h>1957# include <__algorithm/ranges_for_each_n.h>
1949# include <__algorithm/ranges_inplace_merge.h>1958# include <__algorithm/ranges_generate.h>
1950# include <__algorithm/ranges_is_heap.h>1959# include <__algorithm/ranges_generate_n.h>
1951# include <__algorithm/ranges_is_heap_until.h>1960# include <__algorithm/ranges_includes.h>
1952# include <__algorithm/ranges_is_partitioned.h>1961# include <__algorithm/ranges_inplace_merge.h>
1953# include <__algorithm/ranges_is_permutation.h>1962# include <__algorithm/ranges_is_heap.h>
1954# include <__algorithm/ranges_is_sorted.h>1963# include <__algorithm/ranges_is_heap_until.h>
1955# include <__algorithm/ranges_is_sorted_until.h>1964# include <__algorithm/ranges_is_partitioned.h>
1956# include <__algorithm/ranges_lexicographical_compare.h>1965# include <__algorithm/ranges_is_permutation.h>
1957# include <__algorithm/ranges_lower_bound.h>1966# include <__algorithm/ranges_is_sorted.h>
1958# include <__algorithm/ranges_make_heap.h>1967# include <__algorithm/ranges_is_sorted_until.h>
1959# include <__algorithm/ranges_max.h>1968# include <__algorithm/ranges_lexicographical_compare.h>
1960# include <__algorithm/ranges_max_element.h>1969# include <__algorithm/ranges_lower_bound.h>
1961# include <__algorithm/ranges_merge.h>1970# include <__algorithm/ranges_make_heap.h>
1962# include <__algorithm/ranges_min.h>1971# include <__algorithm/ranges_max.h>
1963# include <__algorithm/ranges_min_element.h>1972# include <__algorithm/ranges_max_element.h>
1964# include <__algorithm/ranges_minmax.h>1973# include <__algorithm/ranges_merge.h>
1965# include <__algorithm/ranges_minmax_element.h>1974# include <__algorithm/ranges_min.h>
1966# include <__algorithm/ranges_mismatch.h>1975# include <__algorithm/ranges_min_element.h>
1967# include <__algorithm/ranges_move.h>1976# include <__algorithm/ranges_minmax.h>
1968# include <__algorithm/ranges_move_backward.h>1977# include <__algorithm/ranges_minmax_element.h>
1969# include <__algorithm/ranges_next_permutation.h>1978# include <__algorithm/ranges_mismatch.h>
1970# include <__algorithm/ranges_none_of.h>1979# include <__algorithm/ranges_move.h>
1971# include <__algorithm/ranges_nth_element.h>1980# include <__algorithm/ranges_move_backward.h>
1972# include <__algorithm/ranges_partial_sort.h>1981# include <__algorithm/ranges_next_permutation.h>
1973# include <__algorithm/ranges_partial_sort_copy.h>1982# include <__algorithm/ranges_none_of.h>
1974# include <__algorithm/ranges_partition.h>1983# include <__algorithm/ranges_nth_element.h>
1975# include <__algorithm/ranges_partition_copy.h>1984# include <__algorithm/ranges_partial_sort.h>
1976# include <__algorithm/ranges_partition_point.h>1985# include <__algorithm/ranges_partial_sort_copy.h>
1977# include <__algorithm/ranges_pop_heap.h>1986# include <__algorithm/ranges_partition.h>
1978# include <__algorithm/ranges_prev_permutation.h>1987# include <__algorithm/ranges_partition_copy.h>
1979# include <__algorithm/ranges_push_heap.h>1988# include <__algorithm/ranges_partition_point.h>
1980# include <__algorithm/ranges_remove.h>1989# include <__algorithm/ranges_pop_heap.h>
1981# include <__algorithm/ranges_remove_copy.h>1990# include <__algorithm/ranges_prev_permutation.h>
1982# include <__algorithm/ranges_remove_copy_if.h>1991# include <__algorithm/ranges_push_heap.h>
1983# include <__algorithm/ranges_remove_if.h>1992# include <__algorithm/ranges_remove.h>
1984# include <__algorithm/ranges_replace.h>1993# include <__algorithm/ranges_remove_copy.h>
1985# include <__algorithm/ranges_replace_copy.h>1994# include <__algorithm/ranges_remove_copy_if.h>
1986# include <__algorithm/ranges_replace_copy_if.h>1995# include <__algorithm/ranges_remove_if.h>
1987# include <__algorithm/ranges_replace_if.h>1996# include <__algorithm/ranges_replace.h>
1988# include <__algorithm/ranges_reverse.h>1997# include <__algorithm/ranges_replace_copy.h>
1989# include <__algorithm/ranges_reverse_copy.h>1998# include <__algorithm/ranges_replace_copy_if.h>
1990# include <__algorithm/ranges_rotate.h>1999# include <__algorithm/ranges_replace_if.h>
1991# include <__algorithm/ranges_rotate_copy.h>2000# include <__algorithm/ranges_reverse.h>
1992# include <__algorithm/ranges_sample.h>2001# include <__algorithm/ranges_reverse_copy.h>
1993# include <__algorithm/ranges_search.h>2002# include <__algorithm/ranges_rotate.h>
1994# include <__algorithm/ranges_search_n.h>2003# include <__algorithm/ranges_rotate_copy.h>
1995# include <__algorithm/ranges_set_difference.h>2004# include <__algorithm/ranges_sample.h>
1996# include <__algorithm/ranges_set_intersection.h>2005# include <__algorithm/ranges_search.h>
1997# include <__algorithm/ranges_set_symmetric_difference.h>2006# include <__algorithm/ranges_search_n.h>
1998# include <__algorithm/ranges_set_union.h>2007# include <__algorithm/ranges_set_difference.h>
1999# include <__algorithm/ranges_shuffle.h>2008# include <__algorithm/ranges_set_intersection.h>
2000# include <__algorithm/ranges_sort.h>2009# include <__algorithm/ranges_set_symmetric_difference.h>
2001# include <__algorithm/ranges_sort_heap.h>2010# include <__algorithm/ranges_set_union.h>
2002# include <__algorithm/ranges_stable_partition.h>2011# include <__algorithm/ranges_shuffle.h>
2003# include <__algorithm/ranges_stable_sort.h>2012# include <__algorithm/ranges_sort.h>
2004# include <__algorithm/ranges_swap_ranges.h>2013# include <__algorithm/ranges_sort_heap.h>
2005# include <__algorithm/ranges_transform.h>2014# include <__algorithm/ranges_stable_partition.h>
2006# include <__algorithm/ranges_unique.h>2015# include <__algorithm/ranges_stable_sort.h>
2007# include <__algorithm/ranges_unique_copy.h>2016# include <__algorithm/ranges_swap_ranges.h>
2008# include <__algorithm/ranges_upper_bound.h>2017# include <__algorithm/ranges_transform.h>
2009# include <__algorithm/shift_left.h>2018# include <__algorithm/ranges_unique.h>
2010# include <__algorithm/shift_right.h>2019# include <__algorithm/ranges_unique_copy.h>
2011#endif2020# include <__algorithm/ranges_upper_bound.h>
20122021# include <__algorithm/shift_left.h>
2013#if _LIBCPP_STD_VER >= 232022# include <__algorithm/shift_right.h>
2014# include <__algorithm/fold.h>2023# endif
2015# include <__algorithm/ranges_contains_subrange.h>2024
2016# include <__algorithm/ranges_ends_with.h>2025# if _LIBCPP_STD_VER >= 23
2017# include <__algorithm/ranges_find_last.h>2026# include <__algorithm/ranges_contains_subrange.h>
2018# include <__algorithm/ranges_starts_with.h>2027# include <__algorithm/ranges_ends_with.h>
2019#endif // _LIBCPP_STD_VER >= 232028# include <__algorithm/ranges_find_last.h>
20202029# include <__algorithm/ranges_fold.h>
2021#include <version>2030# include <__algorithm/ranges_starts_with.h>
2031# endif // _LIBCPP_STD_VER >= 23
2032
2033# include <version>
20222034
2023// standard-mandated includes2035// standard-mandated includes
20242036
2025// [algorithm.syn]2037// [algorithm.syn]
2026#include <initializer_list>2038# include <initializer_list>
20272039
2028#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)2040# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2029# pragma GCC system_header2041# pragma GCC system_header
2030#endif2042# endif
20312043
2032#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 142044# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 14
2033# include <execution>2045# include <execution>
2034#endif2046# endif
20352047
2036#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 202048# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2037# include <atomic>2049# include <atomic>
2038# include <bit>2050# include <bit>
2039# include <concepts>2051# include <concepts>
2040# include <cstdlib>2052# include <cstdlib>
2041# include <cstring>2053# include <cstring>
2042# include <iterator>2054# include <iterator>
2043# include <memory>2055# include <memory>
2044# include <stdexcept>2056# include <stdexcept>
2045# include <type_traits>2057# include <type_traits>
2046# include <utility>2058# include <utility>
2047#endif2059# endif
2060#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
20482061
2049#endif // _LIBCPP_ALGORITHM2062#endif // _LIBCPP_ALGORITHM
lib/libcxx/include/any+77-73
...@@ -80,40 +80,44 @@ namespace std {...@@ -80,40 +80,44 @@ namespace std {
8080
81*/81*/
8282
83#include <__config>83#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
84#include <__memory/allocator.h>84# include <__cxx03/any>
85#include <__memory/allocator_destructor.h>85#else
86#include <__memory/allocator_traits.h>86# include <__config>
87#include <__memory/unique_ptr.h>87# include <__memory/allocator.h>
88#include <__type_traits/add_const.h>88# include <__memory/allocator_destructor.h>
89#include <__type_traits/add_pointer.h>89# include <__memory/allocator_traits.h>
90#include <__type_traits/aligned_storage.h>90# include <__memory/unique_ptr.h>
91#include <__type_traits/conditional.h>91# include <__type_traits/add_cv_quals.h>
92#include <__type_traits/decay.h>92# include <__type_traits/add_pointer.h>
93#include <__type_traits/is_constructible.h>93# include <__type_traits/aligned_storage.h>
94#include <__type_traits/is_function.h>94# include <__type_traits/conditional.h>
95#include <__type_traits/is_nothrow_constructible.h>95# include <__type_traits/decay.h>
96#include <__type_traits/is_reference.h>96# include <__type_traits/enable_if.h>
97#include <__type_traits/is_same.h>97# include <__type_traits/is_constructible.h>
98#include <__type_traits/is_void.h>98# include <__type_traits/is_function.h>
99#include <__type_traits/remove_cv.h>99# include <__type_traits/is_nothrow_constructible.h>
100#include <__type_traits/remove_cvref.h>100# include <__type_traits/is_reference.h>
101#include <__type_traits/remove_reference.h>101# include <__type_traits/is_same.h>
102#include <__utility/forward.h>102# include <__type_traits/is_void.h>
103#include <__utility/in_place.h>103# include <__type_traits/remove_cv.h>
104#include <__utility/move.h>104# include <__type_traits/remove_cvref.h>
105#include <__utility/unreachable.h>105# include <__type_traits/remove_reference.h>
106#include <__verbose_abort>106# include <__utility/forward.h>
107#include <initializer_list>107# include <__utility/in_place.h>
108#include <typeinfo>108# include <__utility/move.h>
109#include <version>109# include <__utility/unreachable.h>
110110# include <__verbose_abort>
111#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)111# include <initializer_list>
112# pragma GCC system_header112# include <typeinfo>
113#endif113# include <version>
114
115# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
116# pragma GCC system_header
117# endif
114118
115_LIBCPP_PUSH_MACROS119_LIBCPP_PUSH_MACROS
116#include <__undef_macros>120# include <__undef_macros>
117121
118namespace std {122namespace std {
119class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast {123class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast {
...@@ -124,14 +128,14 @@ public:...@@ -124,14 +128,14 @@ public:
124128
125_LIBCPP_BEGIN_NAMESPACE_STD129_LIBCPP_BEGIN_NAMESPACE_STD
126130
127#if _LIBCPP_STD_VER >= 17131# if _LIBCPP_STD_VER >= 17
128132
129_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() {133[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() {
130# ifndef _LIBCPP_HAS_NO_EXCEPTIONS134# if _LIBCPP_HAS_EXCEPTIONS
131 throw bad_any_cast();135 throw bad_any_cast();
132# else136# else
133 _LIBCPP_VERBOSE_ABORT("bad_any_cast was thrown in -fno-exceptions mode");137 _LIBCPP_VERBOSE_ABORT("bad_any_cast was thrown in -fno-exceptions mode");
134# endif138# endif
135}139}
136140
137// Forward declarations141// Forward declarations
...@@ -145,11 +149,11 @@ _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any*) _NOEXCEPT;...@@ -145,11 +149,11 @@ _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any*) _NOEXCEPT;
145149
146namespace __any_imp {150namespace __any_imp {
147_LIBCPP_SUPPRESS_DEPRECATED_PUSH151_LIBCPP_SUPPRESS_DEPRECATED_PUSH
148using _Buffer = aligned_storage_t<3 * sizeof(void*), alignof(void*)>;152using _Buffer _LIBCPP_NODEBUG = aligned_storage_t<3 * sizeof(void*), alignof(void*)>;
149_LIBCPP_SUPPRESS_DEPRECATED_POP153_LIBCPP_SUPPRESS_DEPRECATED_POP
150154
151template <class _Tp>155template <class _Tp>
152using _IsSmallObject =156using _IsSmallObject _LIBCPP_NODEBUG =
153 integral_constant<bool,157 integral_constant<bool,
154 sizeof(_Tp) <= sizeof(_Buffer) && alignof(_Buffer) % alignof(_Tp) == 0 &&158 sizeof(_Tp) <= sizeof(_Buffer) && alignof(_Buffer) % alignof(_Tp) == 0 &&
155 is_nothrow_move_constructible<_Tp>::value >;159 is_nothrow_move_constructible<_Tp>::value >;
...@@ -165,8 +169,6 @@ template <class _Tp>...@@ -165,8 +169,6 @@ template <class _Tp>
165struct _LIBCPP_TEMPLATE_VIS __unique_typeinfo {169struct _LIBCPP_TEMPLATE_VIS __unique_typeinfo {
166 static constexpr int __id = 0;170 static constexpr int __id = 0;
167};171};
168template <class _Tp>
169constexpr int __unique_typeinfo<_Tp>::__id;
170172
171template <class _Tp>173template <class _Tp>
172inline _LIBCPP_HIDE_FROM_ABI constexpr const void* __get_fallback_typeid() {174inline _LIBCPP_HIDE_FROM_ABI constexpr const void* __get_fallback_typeid() {
...@@ -175,15 +177,15 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr const void* __get_fallback_typeid() {...@@ -175,15 +177,15 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr const void* __get_fallback_typeid() {
175177
176template <class _Tp>178template <class _Tp>
177inline _LIBCPP_HIDE_FROM_ABI bool __compare_typeid(type_info const* __id, const void* __fallback_id) {179inline _LIBCPP_HIDE_FROM_ABI bool __compare_typeid(type_info const* __id, const void* __fallback_id) {
178# if !defined(_LIBCPP_HAS_NO_RTTI)180# if _LIBCPP_HAS_RTTI
179 if (__id && *__id == typeid(_Tp))181 if (__id && *__id == typeid(_Tp))
180 return true;182 return true;
181# endif183# endif
182 return !__id && __fallback_id == __any_imp::__get_fallback_typeid<_Tp>();184 return !__id && __fallback_id == __any_imp::__get_fallback_typeid<_Tp>();
183}185}
184186
185template <class _Tp>187template <class _Tp>
186using _Handler = conditional_t< _IsSmallObject<_Tp>::value, _SmallHandler<_Tp>, _LargeHandler<_Tp>>;188using _Handler _LIBCPP_NODEBUG = conditional_t< _IsSmallObject<_Tp>::value, _SmallHandler<_Tp>, _LargeHandler<_Tp>>;
187189
188} // namespace __any_imp190} // namespace __any_imp
189191
...@@ -265,7 +267,7 @@ public:...@@ -265,7 +267,7 @@ public:
265 // 6.3.4 any observers267 // 6.3.4 any observers
266 _LIBCPP_HIDE_FROM_ABI bool has_value() const _NOEXCEPT { return __h_ != nullptr; }268 _LIBCPP_HIDE_FROM_ABI bool has_value() const _NOEXCEPT { return __h_ != nullptr; }
267269
268# if !defined(_LIBCPP_HAS_NO_RTTI)270# if _LIBCPP_HAS_RTTI
269 _LIBCPP_HIDE_FROM_ABI const type_info& type() const _NOEXCEPT {271 _LIBCPP_HIDE_FROM_ABI const type_info& type() const _NOEXCEPT {
270 if (__h_) {272 if (__h_) {
271 return *static_cast<type_info const*>(this->__call(_Action::_TypeInfo));273 return *static_cast<type_info const*>(this->__call(_Action::_TypeInfo));
...@@ -273,11 +275,12 @@ public:...@@ -273,11 +275,12 @@ public:
273 return typeid(void);275 return typeid(void);
274 }276 }
275 }277 }
276# endif278# endif
277279
278private:280private:
279 typedef __any_imp::_Action _Action;281 using _Action _LIBCPP_NODEBUG = __any_imp::_Action;
280 using _HandleFuncPtr = void* (*)(_Action, any const*, any*, const type_info*, const void* __fallback_info);282 using _HandleFuncPtr
283 _LIBCPP_NODEBUG = void* (*)(_Action, any const*, any*, const type_info*, const void* __fallback_info);
281284
282 union _Storage {285 union _Storage {
283 _LIBCPP_HIDE_FROM_ABI constexpr _Storage() : __ptr(nullptr) {}286 _LIBCPP_HIDE_FROM_ABI constexpr _Storage() : __ptr(nullptr) {}
...@@ -371,11 +374,11 @@ private:...@@ -371,11 +374,11 @@ private:
371 }374 }
372375
373 _LIBCPP_HIDE_FROM_ABI static void* __type_info() {376 _LIBCPP_HIDE_FROM_ABI static void* __type_info() {
374# if !defined(_LIBCPP_HAS_NO_RTTI)377# if _LIBCPP_HAS_RTTI
375 return const_cast<void*>(static_cast<void const*>(&typeid(_Tp)));378 return const_cast<void*>(static_cast<void const*>(&typeid(_Tp)));
376# else379# else
377 return nullptr;380 return nullptr;
378# endif381# endif
379 }382 }
380};383};
381384
...@@ -443,11 +446,11 @@ private:...@@ -443,11 +446,11 @@ private:
443 }446 }
444447
445 _LIBCPP_HIDE_FROM_ABI static void* __type_info() {448 _LIBCPP_HIDE_FROM_ABI static void* __type_info() {
446# if !defined(_LIBCPP_HAS_NO_RTTI)449# if _LIBCPP_HAS_RTTI
447 return const_cast<void*>(static_cast<void const*>(&typeid(_Tp)));450 return const_cast<void*>(static_cast<void const*>(&typeid(_Tp)));
448# else451# else
449 return nullptr;452 return nullptr;
450# endif453# endif
451 }454 }
452};455};
453456
...@@ -578,37 +581,38 @@ _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any* __any) _NOEXCEPT {...@@ -578,37 +581,38 @@ _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any* __any) _NOEXCEPT {
578 void* __p = __any->__call(581 void* __p = __any->__call(
579 _Action::_Get,582 _Action::_Get,
580 nullptr,583 nullptr,
581# if !defined(_LIBCPP_HAS_NO_RTTI)584# if _LIBCPP_HAS_RTTI
582 &typeid(_ValueType),585 &typeid(_ValueType),
583# else586# else
584 nullptr,587 nullptr,
585# endif588# endif
586 __any_imp::__get_fallback_typeid<_ValueType>());589 __any_imp::__get_fallback_typeid<_ValueType>());
587 return std::__pointer_or_func_cast<_ReturnType>(__p, is_function<_ValueType>{});590 return std::__pointer_or_func_cast<_ReturnType>(__p, is_function<_ValueType>{});
588 }591 }
589 return nullptr;592 return nullptr;
590}593}
591594
592#endif // _LIBCPP_STD_VER >= 17595# endif // _LIBCPP_STD_VER >= 17
593596
594_LIBCPP_END_NAMESPACE_STD597_LIBCPP_END_NAMESPACE_STD
595598
596_LIBCPP_POP_MACROS599_LIBCPP_POP_MACROS
597600
598#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17601# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
599# include <chrono>602# include <chrono>
600#endif603# endif
601604
602#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20605# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
603# include <atomic>606# include <atomic>
604# include <concepts>607# include <concepts>
605# include <cstdlib>608# include <cstdlib>
606# include <iosfwd>609# include <iosfwd>
607# include <iterator>610# include <iterator>
608# include <memory>611# include <memory>
609# include <stdexcept>612# include <stdexcept>
610# include <type_traits>613# include <type_traits>
611# include <variant>614# include <variant>
612#endif615# endif
616#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
613617
614#endif // _LIBCPP_ANY618#endif // _LIBCPP_ANY
lib/libcxx/include/array+158-99
...@@ -19,17 +19,17 @@ template <class T, size_t N >...@@ -19,17 +19,17 @@ template <class T, size_t N >
19struct array19struct array
20{20{
21 // types:21 // types:
22 typedef T & reference;22 using value_type = T;
23 typedef const T & const_reference;23 using pointer = T*;
24 typedef implementation defined iterator;24 using const_pointer = const T*;
25 typedef implementation defined const_iterator;25 using reference = T&;
26 typedef size_t size_type;26 using const_reference = const T&;
27 typedef ptrdiff_t difference_type;27 using size_type = size_t;
28 typedef T value_type;28 using difference_type = ptrdiff_t;
29 typedef T* pointer;29 using iterator = implementation-defined;
30 typedef const T* const_pointer;30 using const_iterator = implementation-defined;
31 typedef std::reverse_iterator<iterator> reverse_iterator;31 using reverse_iterator = std::reverse_iterator<iterator>;
32 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;32 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
3333
34 // No explicit construct/copy/destroy for aggregate type34 // No explicit construct/copy/destroy for aggregate type
35 void fill(const T& u); // constexpr in C++2035 void fill(const T& u); // constexpr in C++20
...@@ -111,78 +111,88 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce...@@ -111,78 +111,88 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
111111
112*/112*/
113113
114#include <__algorithm/equal.h>114#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
115#include <__algorithm/fill_n.h>115# include <__cxx03/array>
116#include <__algorithm/lexicographical_compare.h>116#else
117#include <__algorithm/lexicographical_compare_three_way.h>117# include <__algorithm/equal.h>
118#include <__algorithm/swap_ranges.h>118# include <__algorithm/fill_n.h>
119#include <__assert>119# include <__algorithm/lexicographical_compare.h>
120#include <__config>120# include <__algorithm/lexicographical_compare_three_way.h>
121#include <__fwd/array.h>121# include <__algorithm/swap_ranges.h>
122#include <__iterator/reverse_iterator.h>122# include <__assert>
123#include <__iterator/wrap_iter.h>123# include <__config>
124#include <__tuple/sfinae_helpers.h>124# include <__cstddef/ptrdiff_t.h>
125#include <__type_traits/conditional.h>125# include <__fwd/array.h>
126#include <__type_traits/conjunction.h>126# include <__iterator/reverse_iterator.h>
127#include <__type_traits/is_array.h>127# include <__iterator/static_bounded_iter.h>
128#include <__type_traits/is_const.h>128# include <__iterator/wrap_iter.h>
129#include <__type_traits/is_constructible.h>129# include <__tuple/sfinae_helpers.h>
130#include <__type_traits/is_nothrow_constructible.h>130# include <__type_traits/conditional.h>
131#include <__type_traits/is_same.h>131# include <__type_traits/conjunction.h>
132#include <__type_traits/is_swappable.h>132# include <__type_traits/enable_if.h>
133#include <__type_traits/is_trivially_relocatable.h>133# include <__type_traits/is_array.h>
134#include <__type_traits/remove_cv.h>134# include <__type_traits/is_const.h>
135#include <__utility/empty.h>135# include <__type_traits/is_constructible.h>
136#include <__utility/integer_sequence.h>136# include <__type_traits/is_nothrow_constructible.h>
137#include <__utility/move.h>137# include <__type_traits/is_same.h>
138#include <__utility/unreachable.h>138# include <__type_traits/is_swappable.h>
139#include <stdexcept>139# include <__type_traits/is_trivially_relocatable.h>
140#include <version>140# include <__type_traits/remove_cv.h>
141# include <__utility/empty.h>
142# include <__utility/integer_sequence.h>
143# include <__utility/move.h>
144# include <__utility/unreachable.h>
145# include <stdexcept>
146# include <version>
141147
142// standard-mandated includes148// standard-mandated includes
143149
144// [iterator.range]150// [iterator.range]
145#include <__iterator/access.h>151# include <__iterator/access.h>
146#include <__iterator/data.h>152# include <__iterator/data.h>
147#include <__iterator/empty.h>153# include <__iterator/empty.h>
148#include <__iterator/reverse_access.h>154# include <__iterator/reverse_access.h>
149#include <__iterator/size.h>155# include <__iterator/size.h>
150156
151// [array.syn]157// [array.syn]
152#include <compare>158# include <compare>
153#include <initializer_list>159# include <initializer_list>
154160
155// [tuple.helper]161// [tuple.helper]
156#include <__tuple/tuple_element.h>162# include <__tuple/tuple_element.h>
157#include <__tuple/tuple_size.h>163# include <__tuple/tuple_size.h>
158164
159#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)165# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
160# pragma GCC system_header166# pragma GCC system_header
161#endif167# endif
162168
163_LIBCPP_PUSH_MACROS169_LIBCPP_PUSH_MACROS
164#include <__undef_macros>170# include <__undef_macros>
165171
166_LIBCPP_BEGIN_NAMESPACE_STD172_LIBCPP_BEGIN_NAMESPACE_STD
167173
168template <class _Tp, size_t _Size>174template <class _Tp, size_t _Size>
169struct _LIBCPP_TEMPLATE_VIS array {175struct _LIBCPP_TEMPLATE_VIS array {
170 using __trivially_relocatable = __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>;176 using __trivially_relocatable _LIBCPP_NODEBUG =
177 __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>;
171178
172 // types:179 // types:
173 using __self = array;180 using __self _LIBCPP_NODEBUG = array;
174 using value_type = _Tp;181 using value_type = _Tp;
175 using reference = value_type&;182 using reference = value_type&;
176 using const_reference = const value_type&;183 using const_reference = const value_type&;
177 using pointer = value_type*;184 using pointer = value_type*;
178 using const_pointer = const value_type*;185 using const_pointer = const value_type*;
179#if defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY)186# if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
187 using iterator = __static_bounded_iter<pointer, _Size>;
188 using const_iterator = __static_bounded_iter<const_pointer, _Size>;
189# elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY)
180 using iterator = __wrap_iter<pointer>;190 using iterator = __wrap_iter<pointer>;
181 using const_iterator = __wrap_iter<const_pointer>;191 using const_iterator = __wrap_iter<const_pointer>;
182#else192# else
183 using iterator = pointer;193 using iterator = pointer;
184 using const_iterator = const_pointer;194 using const_iterator = const_pointer;
185#endif195# endif
186 using size_type = size_t;196 using size_type = size_t;
187 using difference_type = ptrdiff_t;197 using difference_type = ptrdiff_t;
188 using reverse_iterator = std::reverse_iterator<iterator>;198 using reverse_iterator = std::reverse_iterator<iterator>;
...@@ -200,13 +210,33 @@ struct _LIBCPP_TEMPLATE_VIS array {...@@ -200,13 +210,33 @@ struct _LIBCPP_TEMPLATE_VIS array {
200 }210 }
201211
202 // iterators:212 // iterators:
203 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT { return iterator(data()); }213 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT {
214# if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
215 return std::__make_static_bounded_iter<_Size>(data(), data());
216# else
217 return iterator(data());
218# endif
219 }
204 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT {220 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT {
221# if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
222 return std::__make_static_bounded_iter<_Size>(data(), data());
223# else
205 return const_iterator(data());224 return const_iterator(data());
225# endif
226 }
227 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT {
228# if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
229 return std::__make_static_bounded_iter<_Size>(data() + _Size, data());
230# else
231 return iterator(data() + _Size);
232# endif
206 }233 }
207 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT { return iterator(data() + _Size); }
208 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT {234 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT {
235# if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
236 return std::__make_static_bounded_iter<_Size>(data() + _Size, data());
237# else
209 return const_iterator(data() + _Size);238 return const_iterator(data() + _Size);
239# endif
210 }240 }
211241
212 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT {242 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT {
...@@ -232,7 +262,7 @@ struct _LIBCPP_TEMPLATE_VIS array {...@@ -232,7 +262,7 @@ struct _LIBCPP_TEMPLATE_VIS array {
232 // capacity:262 // capacity:
233 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return _Size; }263 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return _Size; }
234 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return _Size; }264 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return _Size; }
235 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return _Size == 0; }265 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return _Size == 0; }
236266
237 // element access:267 // element access:
238 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type __n) _NOEXCEPT {268 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type __n) _NOEXCEPT {
...@@ -270,20 +300,28 @@ struct _LIBCPP_TEMPLATE_VIS array {...@@ -270,20 +300,28 @@ struct _LIBCPP_TEMPLATE_VIS array {
270template <class _Tp>300template <class _Tp>
271struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {301struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {
272 // types:302 // types:
273 typedef array __self;303 using __self _LIBCPP_NODEBUG = array;
274 typedef _Tp value_type;304 using value_type = _Tp;
275 typedef value_type& reference;305 using reference = value_type&;
276 typedef const value_type& const_reference;306 using const_reference = const value_type&;
277 typedef value_type* iterator;307 using pointer = value_type*;
278 typedef const value_type* const_iterator;308 using const_pointer = const value_type*;
279 typedef value_type* pointer;309# if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
280 typedef const value_type* const_pointer;310 using iterator = __static_bounded_iter<pointer, 0>;
281 typedef size_t size_type;311 using const_iterator = __static_bounded_iter<const_pointer, 0>;
282 typedef ptrdiff_t difference_type;312# elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY)
283 typedef std::reverse_iterator<iterator> reverse_iterator;313 using iterator = __wrap_iter<pointer>;
284 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;314 using const_iterator = __wrap_iter<const_pointer>;
285315# else
286 typedef __conditional_t<is_const<_Tp>::value, const __empty, __empty> _EmptyType;316 using iterator = pointer;
317 using const_iterator = const_pointer;
318# endif
319 using size_type = size_t;
320 using difference_type = ptrdiff_t;
321 using reverse_iterator = std::reverse_iterator<iterator>;
322 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
323
324 using _EmptyType _LIBCPP_NODEBUG = __conditional_t<is_const<_Tp>::value, const __empty, __empty>;
287325
288 struct _ArrayInStructT {326 struct _ArrayInStructT {
289 _Tp __data_[1];327 _Tp __data_[1];
...@@ -303,13 +341,33 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {...@@ -303,13 +341,33 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {
303 }341 }
304342
305 // iterators:343 // iterators:
306 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT { return iterator(data()); }344 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT {
345# if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
346 return std::__make_static_bounded_iter<0>(data(), data());
347# else
348 return iterator(data());
349# endif
350 }
307 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT {351 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT {
352# if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
353 return std::__make_static_bounded_iter<0>(data(), data());
354# else
308 return const_iterator(data());355 return const_iterator(data());
356# endif
357 }
358 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT {
359# if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
360 return std::__make_static_bounded_iter<0>(data(), data());
361# else
362 return iterator(data());
363# endif
309 }364 }
310 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT { return iterator(data()); }
311 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT {365 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT {
366# if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY)
367 return std::__make_static_bounded_iter<0>(data(), data());
368# else
312 return const_iterator(data());369 return const_iterator(data());
370# endif
313 }371 }
314372
315 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT {373 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT {
...@@ -335,7 +393,7 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {...@@ -335,7 +393,7 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {
335 // capacity:393 // capacity:
336 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return 0; }394 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return 0; }
337 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return 0; }395 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return 0; }
338 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; }396 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; }
339397
340 // element access:398 // element access:
341 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type) _NOEXCEPT {399 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type) _NOEXCEPT {
...@@ -379,10 +437,10 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {...@@ -379,10 +437,10 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {
379 }437 }
380};438};
381439
382#if _LIBCPP_STD_VER >= 17440# if _LIBCPP_STD_VER >= 17
383template <class _Tp, class... _Args, class = enable_if_t<__all<_IsSame<_Tp, _Args>::value...>::value> >441template <class _Tp, class... _Args, class = enable_if_t<__all<_IsSame<_Tp, _Args>::value...>::value> >
384array(_Tp, _Args...) -> array<_Tp, 1 + sizeof...(_Args)>;442array(_Tp, _Args...) -> array<_Tp, 1 + sizeof...(_Args)>;
385#endif443# endif
386444
387template <class _Tp, size_t _Size>445template <class _Tp, size_t _Size>
388inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool446inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
...@@ -390,7 +448,7 @@ operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {...@@ -390,7 +448,7 @@ operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
390 return std::equal(__x.begin(), __x.end(), __y.begin());448 return std::equal(__x.begin(), __x.end(), __y.begin());
391}449}
392450
393#if _LIBCPP_STD_VER <= 17451# if _LIBCPP_STD_VER <= 17
394452
395template <class _Tp, size_t _Size>453template <class _Tp, size_t _Size>
396inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {454inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
...@@ -417,16 +475,15 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const array<_Tp, _Size>& __x, const...@@ -417,16 +475,15 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const array<_Tp, _Size>& __x, const
417 return !(__x < __y);475 return !(__x < __y);
418}476}
419477
420#else // _LIBCPP_STD_VER <= 17478# else // _LIBCPP_STD_VER <= 17
421479
422template <class _Tp, size_t _Size>480template <class _Tp, size_t _Size>
423_LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>481_LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
424operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {482operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
425 return std::lexicographical_compare_three_way(483 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
426 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
427}484}
428485
429#endif // _LIBCPP_STD_VER <= 17486# endif // _LIBCPP_STD_VER <= 17
430487
431template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable_v<_Tp>, int> = 0>488template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable_v<_Tp>, int> = 0>
432inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)489inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
...@@ -440,7 +497,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> > : public integral_con...@@ -440,7 +497,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> > : public integral_con
440template <size_t _Ip, class _Tp, size_t _Size>497template <size_t _Ip, class _Tp, size_t _Size>
441struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> > {498struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> > {
442 static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");499 static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
443 typedef _Tp type;500 using type = _Tp;
444};501};
445502
446template <size_t _Ip, class _Tp, size_t _Size>503template <size_t _Ip, class _Tp, size_t _Size>
...@@ -467,7 +524,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const...@@ -467,7 +524,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const
467 return std::move(__a.__elems_[_Ip]);524 return std::move(__a.__elems_[_Ip]);
468}525}
469526
470#if _LIBCPP_STD_VER >= 20527# if _LIBCPP_STD_VER >= 20
471528
472template <typename _Tp, size_t _Size, size_t... _Index>529template <typename _Tp, size_t _Size, size_t... _Index>
473_LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>530_LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>
...@@ -497,19 +554,21 @@ to_array(_Tp (&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) {...@@ -497,19 +554,21 @@ to_array(_Tp (&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) {
497 return std::__to_array_rvalue_impl(std::move(__arr), make_index_sequence<_Size>());554 return std::__to_array_rvalue_impl(std::move(__arr), make_index_sequence<_Size>());
498}555}
499556
500#endif // _LIBCPP_STD_VER >= 20557# endif // _LIBCPP_STD_VER >= 20
501558
502_LIBCPP_END_NAMESPACE_STD559_LIBCPP_END_NAMESPACE_STD
503560
504_LIBCPP_POP_MACROS561_LIBCPP_POP_MACROS
505562
506#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20563# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
507# include <algorithm>564# include <algorithm>
508# include <concepts>565# include <concepts>
509# include <cstdlib>566# include <cstdlib>
510# include <iterator>567# include <iterator>
511# include <type_traits>568# include <new>
512# include <utility>569# include <type_traits>
513#endif570# include <utility>
571# endif
572#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
514573
515#endif // _LIBCPP_ARRAY574#endif // _LIBCPP_ARRAY
lib/libcxx/include/atomic+96-87
...@@ -101,12 +101,12 @@ struct atomic...@@ -101,12 +101,12 @@ struct atomic
101 bool compare_exchange_strong(T& expc, T desr,101 bool compare_exchange_strong(T& expc, T desr,
102 memory_order m = memory_order_seq_cst) noexcept;102 memory_order m = memory_order_seq_cst) noexcept;
103103
104 void wait(T, memory_order = memory_order::seq_cst) const volatile noexcept;104 void wait(T, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
105 void wait(T, memory_order = memory_order::seq_cst) const noexcept;105 void wait(T, memory_order = memory_order::seq_cst) const noexcept; // since C++20
106 void notify_one() volatile noexcept;106 void notify_one() volatile noexcept; // since C++20
107 void notify_one() noexcept;107 void notify_one() noexcept; // since C++20
108 void notify_all() volatile noexcept;108 void notify_all() volatile noexcept; // since C++20
109 void notify_all() noexcept;109 void notify_all() noexcept; // since C++20
110};110};
111111
112template <>112template <>
...@@ -184,12 +184,12 @@ struct atomic<integral>...@@ -184,12 +184,12 @@ struct atomic<integral>
184 integral operator^=(integral op) volatile noexcept;184 integral operator^=(integral op) volatile noexcept;
185 integral operator^=(integral op) noexcept;185 integral operator^=(integral op) noexcept;
186186
187 void wait(integral, memory_order = memory_order::seq_cst) const volatile noexcept;187 void wait(integral, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
188 void wait(integral, memory_order = memory_order::seq_cst) const noexcept;188 void wait(integral, memory_order = memory_order::seq_cst) const noexcept; // since C++20
189 void notify_one() volatile noexcept;189 void notify_one() volatile noexcept; // since C++20
190 void notify_one() noexcept;190 void notify_one() noexcept; // since C++20
191 void notify_all() volatile noexcept;191 void notify_all() volatile noexcept; // since C++20
192 void notify_all() noexcept;192 void notify_all() noexcept; // since C++20
193};193};
194194
195template <class T>195template <class T>
...@@ -254,12 +254,12 @@ struct atomic<T*>...@@ -254,12 +254,12 @@ struct atomic<T*>
254 T* operator-=(ptrdiff_t op) volatile noexcept;254 T* operator-=(ptrdiff_t op) volatile noexcept;
255 T* operator-=(ptrdiff_t op) noexcept;255 T* operator-=(ptrdiff_t op) noexcept;
256256
257 void wait(T*, memory_order = memory_order::seq_cst) const volatile noexcept;257 void wait(T*, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
258 void wait(T*, memory_order = memory_order::seq_cst) const noexcept;258 void wait(T*, memory_order = memory_order::seq_cst) const noexcept; // since C++20
259 void notify_one() volatile noexcept;259 void notify_one() volatile noexcept; // since C++20
260 void notify_one() noexcept;260 void notify_one() noexcept; // since C++20
261 void notify_all() volatile noexcept;261 void notify_all() volatile noexcept; // since C++20
262 void notify_all() noexcept;262 void notify_all() noexcept; // since C++20
263};263};
264264
265template<>265template<>
...@@ -321,12 +321,12 @@ struct atomic<floating-point-type> { // since C++20...@@ -321,12 +321,12 @@ struct atomic<floating-point-type> { // since C++20
321 floating-point-type operator-=(floating-point-type) volatile noexcept;321 floating-point-type operator-=(floating-point-type) volatile noexcept;
322 floating-point-type operator-=(floating-point-type) noexcept;322 floating-point-type operator-=(floating-point-type) noexcept;
323323
324 void wait(floating-point-type, memory_order = memory_order::seq_cst) const volatile noexcept;324 void wait(floating-point-type, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
325 void wait(floating-point-type, memory_order = memory_order::seq_cst) const noexcept;325 void wait(floating-point-type, memory_order = memory_order::seq_cst) const noexcept; // since C++20
326 void notify_one() volatile noexcept;326 void notify_one() volatile noexcept; // since C++20
327 void notify_one() noexcept;327 void notify_one() noexcept; // since C++20
328 void notify_all() volatile noexcept;328 void notify_all() volatile noexcept; // since C++20
329 void notify_all() noexcept;329 void notify_all() noexcept; // since C++20
330};330};
331331
332// [atomics.nonmembers], non-member functions332// [atomics.nonmembers], non-member functions
...@@ -443,23 +443,23 @@ template<class T>...@@ -443,23 +443,23 @@ template<class T>
443 memory_order) noexcept;443 memory_order) noexcept;
444444
445template<class T>445template<class T>
446 void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type) noexcept;446 void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type) noexcept; // since C++20
447template<class T>447template<class T>
448 void atomic_wait(const atomic<T>*, atomic<T>::value_type) noexcept;448 void atomic_wait(const atomic<T>*, atomic<T>::value_type) noexcept; // since C++20
449template<class T>449template<class T>
450 void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type,450 void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type, // since C++20
451 memory_order) noexcept;451 memory_order) noexcept;
452template<class T>452template<class T>
453 void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type,453 void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type, // since C++20
454 memory_order) noexcept;454 memory_order) noexcept;
455template<class T>455template<class T>
456 void atomic_notify_one(volatile atomic<T>*) noexcept;456 void atomic_notify_one(volatile atomic<T>*) noexcept; // since C++20
457template<class T>457template<class T>
458 void atomic_notify_one(atomic<T>*) noexcept;458 void atomic_notify_one(atomic<T>*) noexcept; // since C++20
459template<class T>459template<class T>
460 void atomic_notify_all(volatile atomic<T>*) noexcept;460 void atomic_notify_all(volatile atomic<T>*) noexcept; // since C++20
461template<class T>461template<class T>
462 void atomic_notify_all(atomic<T>*) noexcept;462 void atomic_notify_all(atomic<T>*) noexcept; // since C++20
463463
464// Atomics for standard typedef types464// Atomics for standard typedef types
465465
...@@ -534,12 +534,12 @@ typedef struct atomic_flag...@@ -534,12 +534,12 @@ typedef struct atomic_flag
534 void clear(memory_order m = memory_order_seq_cst) volatile noexcept;534 void clear(memory_order m = memory_order_seq_cst) volatile noexcept;
535 void clear(memory_order m = memory_order_seq_cst) noexcept;535 void clear(memory_order m = memory_order_seq_cst) noexcept;
536536
537 void wait(bool, memory_order = memory_order::seq_cst) const volatile noexcept;537 void wait(bool, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20
538 void wait(bool, memory_order = memory_order::seq_cst) const noexcept;538 void wait(bool, memory_order = memory_order::seq_cst) const noexcept; // since C++20
539 void notify_one() volatile noexcept;539 void notify_one() volatile noexcept; // since C++20
540 void notify_one() noexcept;540 void notify_one() noexcept; // since C++20
541 void notify_all() volatile noexcept;541 void notify_all() volatile noexcept; // since C++20
542 void notify_all() noexcept;542 void notify_all() noexcept; // since C++20
543} atomic_flag;543} atomic_flag;
544544
545bool atomic_flag_test(volatile atomic_flag* obj) noexcept;545bool atomic_flag_test(volatile atomic_flag* obj) noexcept;
...@@ -557,14 +557,14 @@ void atomic_flag_clear(atomic_flag* obj) noexcept;...@@ -557,14 +557,14 @@ void atomic_flag_clear(atomic_flag* obj) noexcept;
557void atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept;557void atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept;
558void atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept;558void atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept;
559559
560void atomic_wait(const volatile atomic_flag* obj, T old) noexcept;560void atomic_wait(const volatile atomic_flag* obj, T old) noexcept; // since C++20
561void atomic_wait(const atomic_flag* obj, T old) noexcept;561void atomic_wait(const atomic_flag* obj, T old) noexcept; // since C++20
562void atomic_wait_explicit(const volatile atomic_flag* obj, T old, memory_order m) noexcept;562void atomic_wait_explicit(const volatile atomic_flag* obj, T old, memory_order m) noexcept; // since C++20
563void atomic_wait_explicit(const atomic_flag* obj, T old, memory_order m) noexcept;563void atomic_wait_explicit(const atomic_flag* obj, T old, memory_order m) noexcept; // since C++20
564void atomic_one(volatile atomic_flag* obj) noexcept;564void atomic_one(volatile atomic_flag* obj) noexcept; // since C++20
565void atomic_one(atomic_flag* obj) noexcept;565void atomic_one(atomic_flag* obj) noexcept; // since C++20
566void atomic_all(volatile atomic_flag* obj) noexcept;566void atomic_all(volatile atomic_flag* obj) noexcept; // since C++20
567void atomic_all(atomic_flag* obj) noexcept;567void atomic_all(atomic_flag* obj) noexcept; // since C++20
568568
569// fences569// fences
570570
...@@ -587,46 +587,55 @@ template <class T>...@@ -587,46 +587,55 @@ template <class T>
587587
588*/588*/
589589
590#include <__config>590#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
591591# include <__cxx03/atomic>
592#if _LIBCPP_STD_VER < 23 && defined(_LIBCPP_STDATOMIC_H)592#else
593# error <atomic> is incompatible with <stdatomic.h> before C++23. Please compile with -std=c++23.593# include <__config>
594#endif594
595595# if defined(_LIBCPP_STDATOMIC_H) || defined(kill_dependency) || defined(atomic_load)
596#include <__atomic/aliases.h>596# define _LIBCPP_STDATOMIC_H_HAS_DEFINITELY_BEEN_INCLUDED 1
597#include <__atomic/atomic.h>597# else
598#include <__atomic/atomic_base.h>598# define _LIBCPP_STDATOMIC_H_HAS_DEFINITELY_BEEN_INCLUDED 0
599#include <__atomic/atomic_flag.h>599# endif
600#include <__atomic/atomic_init.h>600
601#include <__atomic/atomic_lock_free.h>601# if _LIBCPP_STD_VER < 23 && _LIBCPP_STDATOMIC_H_HAS_DEFINITELY_BEEN_INCLUDED
602#include <__atomic/atomic_sync.h>602# error <atomic> is incompatible with <stdatomic.h> before C++23. Please compile with -std=c++23.
603#include <__atomic/check_memory_order.h>603# endif
604#include <__atomic/contention_t.h>604
605#include <__atomic/cxx_atomic_impl.h>605# include <__atomic/aliases.h>
606#include <__atomic/fence.h>606# include <__atomic/atomic.h>
607#include <__atomic/is_always_lock_free.h>607# include <__atomic/atomic_flag.h>
608#include <__atomic/kill_dependency.h>608# include <__atomic/atomic_init.h>
609#include <__atomic/memory_order.h>609# include <__atomic/atomic_lock_free.h>
610#include <version>610# include <__atomic/atomic_sync.h>
611611# include <__atomic/check_memory_order.h>
612#if _LIBCPP_STD_VER >= 20612# include <__atomic/contention_t.h>
613# include <__atomic/atomic_ref.h>613# include <__atomic/fence.h>
614#endif614# include <__atomic/is_always_lock_free.h>
615615# include <__atomic/kill_dependency.h>
616#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)616# include <__atomic/memory_order.h>
617# pragma GCC system_header617# include <version>
618#endif618
619619# if _LIBCPP_STD_VER >= 20
620#ifdef _LIBCPP_HAS_NO_ATOMIC_HEADER620# include <__atomic/atomic_ref.h>
621# error <atomic> is not implemented621# endif
622#endif622
623623# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
624#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20624# pragma GCC system_header
625# include <cmath>625# endif
626# include <compare>626
627# include <cstdlib>627# if !_LIBCPP_HAS_ATOMIC_HEADER
628# include <cstring>628# error <atomic> is not implemented
629# include <type_traits>629# endif
630#endif630
631# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
632# include <cmath>
633# include <compare>
634# include <cstddef>
635# include <cstdlib>
636# include <cstring>
637# include <type_traits>
638# endif
639#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
631640
632#endif // _LIBCPP_ATOMIC641#endif // _LIBCPP_ATOMIC
lib/libcxx/include/barrier+43-144
...@@ -17,7 +17,7 @@ namespace std...@@ -17,7 +17,7 @@ namespace std
17{17{
1818
19 template<class CompletionFunction = see below>19 template<class CompletionFunction = see below>
20 class barrier20 class barrier // since C++20
21 {21 {
22 public:22 public:
23 using arrival_token = see below;23 using arrival_token = see below;
...@@ -45,30 +45,33 @@ namespace std...@@ -45,30 +45,33 @@ namespace std
4545
46*/46*/
4747
48#include <__config>48#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
4949# include <__cxx03/barrier>
50#if !defined(_LIBCPP_HAS_NO_THREADS)50#else
5151# include <__config>
52# include <__assert>52
53# include <__atomic/atomic_base.h>53# if _LIBCPP_HAS_THREADS
54# include <__atomic/memory_order.h>54
55# include <__memory/unique_ptr.h>55# include <__assert>
56# include <__thread/poll_with_backoff.h>56# include <__atomic/atomic.h>
57# include <__thread/timed_backoff_policy.h>57# include <__atomic/memory_order.h>
58# include <__utility/move.h>58# include <__cstddef/ptrdiff_t.h>
59# include <cstddef>59# include <__memory/unique_ptr.h>
60# include <cstdint>60# include <__thread/poll_with_backoff.h>
61# include <limits>61# include <__thread/timed_backoff_policy.h>
62# include <version>62# include <__utility/move.h>
6363# include <cstdint>
64# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)64# include <limits>
65# pragma GCC system_header65# include <version>
66# endif66
67# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
68# pragma GCC system_header
69# endif
6770
68_LIBCPP_PUSH_MACROS71_LIBCPP_PUSH_MACROS
69# include <__undef_macros>72# include <__undef_macros>
7073
71# if _LIBCPP_STD_VER >= 1474# if _LIBCPP_STD_VER >= 20
7275
73_LIBCPP_BEGIN_NAMESPACE_STD76_LIBCPP_BEGIN_NAMESPACE_STD
7477
...@@ -76,8 +79,6 @@ struct __empty_completion {...@@ -76,8 +79,6 @@ struct __empty_completion {
76 inline _LIBCPP_HIDE_FROM_ABI void operator()() noexcept {}79 inline _LIBCPP_HIDE_FROM_ABI void operator()() noexcept {}
77};80};
7881
79# ifndef _LIBCPP_HAS_NO_TREE_BARRIER
80
81/*82/*
8283
83The default implementation of __barrier_base is a classic tree barrier.84The default implementation of __barrier_base is a classic tree barrier.
...@@ -92,7 +93,7 @@ It looks different from literature pseudocode for two main reasons:...@@ -92,7 +93,7 @@ It looks different from literature pseudocode for two main reasons:
9293
93*/94*/
9495
95using __barrier_phase_t = uint8_t;96using __barrier_phase_t _LIBCPP_NODEBUG = uint8_t;
9697
97class __barrier_algorithm_base;98class __barrier_algorithm_base;
9899
...@@ -109,9 +110,9 @@ template <class _CompletionF>...@@ -109,9 +110,9 @@ template <class _CompletionF>
109class __barrier_base {110class __barrier_base {
110 ptrdiff_t __expected_;111 ptrdiff_t __expected_;
111 unique_ptr<__barrier_algorithm_base, void (*)(__barrier_algorithm_base*)> __base_;112 unique_ptr<__barrier_algorithm_base, void (*)(__barrier_algorithm_base*)> __base_;
112 __atomic_base<ptrdiff_t> __expected_adjustment_;113 atomic<ptrdiff_t> __expected_adjustment_;
113 _CompletionF __completion_;114 _CompletionF __completion_;
114 __atomic_base<__barrier_phase_t> __phase_;115 atomic<__barrier_phase_t> __phase_;
115116
116public:117public:
117 using arrival_token = __barrier_phase_t;118 using arrival_token = __barrier_phase_t;
...@@ -125,7 +126,7 @@ public:...@@ -125,7 +126,7 @@ public:
125 __expected_adjustment_(0),126 __expected_adjustment_(0),
126 __completion_(std::move(__completion)),127 __completion_(std::move(__completion)),
127 __phase_(0) {}128 __phase_(0) {}
128 _LIBCPP_NODISCARD _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update) {129 [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update) {
129 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(130 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
130 __update <= __expected_, "update is greater than the expected count for the current barrier phase");131 __update <= __expected_, "update is greater than the expected count for the current barrier phase");
131132
...@@ -150,111 +151,8 @@ public:...@@ -150,111 +151,8 @@ public:
150 }151 }
151};152};
152153
153# else
154
155/*
156
157The alternative implementation of __barrier_base is a central barrier.
158
159Two versions of this algorithm are provided:
160 1. A fairly straightforward implementation of the litterature for the
161 general case where the completion function is not empty.
162 2. An optimized implementation that exploits 2's complement arithmetic
163 and well-defined overflow in atomic arithmetic, to handle the phase
164 roll-over for free.
165
166*/
167
168template <class _CompletionF>
169class __barrier_base {
170 __atomic_base<ptrdiff_t> __expected;
171 __atomic_base<ptrdiff_t> __arrived;
172 _CompletionF __completion;
173 __atomic_base<bool> __phase;
174
175public:
176 using arrival_token = bool;
177
178 static constexpr ptrdiff_t max() noexcept { return numeric_limits<ptrdiff_t>::max(); }
179
180 _LIBCPP_HIDE_FROM_ABI __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF())
181 : __expected(__expected), __arrived(__expected), __completion(std::move(__completion)), __phase(false) {}
182 [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t update) {
183 auto const __old_phase = __phase.load(memory_order_relaxed);
184 auto const __result = __arrived.fetch_sub(update, memory_order_acq_rel) - update;
185 auto const new_expected = __expected.load(memory_order_relaxed);
186
187 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
188 update <= new_expected, "update is greater than the expected count for the current barrier phase");
189
190 if (0 == __result) {
191 __completion();
192 __arrived.store(new_expected, memory_order_relaxed);
193 __phase.store(!__old_phase, memory_order_release);
194 __phase.notify_all();
195 }
196 return __old_phase;
197 }
198 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(arrival_token&& __old_phase) const {
199 __phase.wait(__old_phase, memory_order_acquire);
200 }
201 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_drop() {
202 __expected.fetch_sub(1, memory_order_relaxed);
203 (void)arrive(1);
204 }
205};
206
207template <>
208class __barrier_base<__empty_completion> {
209 static constexpr uint64_t __expected_unit = 1ull;
210 static constexpr uint64_t __arrived_unit = 1ull << 32;
211 static constexpr uint64_t __expected_mask = __arrived_unit - 1;
212 static constexpr uint64_t __phase_bit = 1ull << 63;
213 static constexpr uint64_t __arrived_mask = (__phase_bit - 1) & ~__expected_mask;
214
215 __atomic_base<uint64_t> __phase_arrived_expected;
216
217 static _LIBCPP_HIDE_FROM_ABI constexpr uint64_t __init(ptrdiff_t __count) _NOEXCEPT {
218 return ((uint64_t(1u << 31) - __count) << 32) | (uint64_t(1u << 31) - __count);
219 }
220
221public:
222 using arrival_token = uint64_t;
223
224 static constexpr ptrdiff_t max() noexcept { return ptrdiff_t(1u << 31) - 1; }
225
226 _LIBCPP_HIDE_FROM_ABI explicit inline __barrier_base(ptrdiff_t __count, __empty_completion = __empty_completion())
227 : __phase_arrived_expected(__init(__count)) {}
228 [[nodiscard]] inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t update) {
229 auto const __inc = __arrived_unit * update;
230 auto const __old = __phase_arrived_expected.fetch_add(__inc, memory_order_acq_rel);
231
232 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
233 update <= __old, "update is greater than the expected count for the current barrier phase");
234
235 if ((__old ^ (__old + __inc)) & __phase_bit) {
236 __phase_arrived_expected.fetch_add((__old & __expected_mask) << 32, memory_order_relaxed);
237 __phase_arrived_expected.notify_all();
238 }
239 return __old & __phase_bit;
240 }
241 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(arrival_token&& __phase) const {
242 auto const __test_fn = [=]() -> bool {
243 uint64_t const __current = __phase_arrived_expected.load(memory_order_acquire);
244 return ((__current & __phase_bit) != __phase);
245 };
246 __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
247 }
248 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_drop() {
249 __phase_arrived_expected.fetch_add(__expected_unit, memory_order_relaxed);
250 (void)arrive(1);
251 }
252};
253
254# endif // !_LIBCPP_HAS_NO_TREE_BARRIER
255
256template <class _CompletionF = __empty_completion>154template <class _CompletionF = __empty_completion>
257class _LIBCPP_DEPRECATED_ATOMIC_SYNC barrier {155class barrier {
258 __barrier_base<_CompletionF> __b_;156 __barrier_base<_CompletionF> __b_;
259157
260public:158public:
...@@ -277,7 +175,7 @@ public:...@@ -277,7 +175,7 @@ public:
277 barrier(barrier const&) = delete;175 barrier(barrier const&) = delete;
278 barrier& operator=(barrier const&) = delete;176 barrier& operator=(barrier const&) = delete;
279177
280 _LIBCPP_NODISCARD _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update = 1) {178 [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update = 1) {
281 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update > 0, "barrier:arrive must be called with a value greater than 0");179 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update > 0, "barrier:arrive must be called with a value greater than 0");
282 return __b_.arrive(__update);180 return __b_.arrive(__update);
283 }181 }
...@@ -290,19 +188,20 @@ public:...@@ -290,19 +188,20 @@ public:
290188
291_LIBCPP_END_NAMESPACE_STD189_LIBCPP_END_NAMESPACE_STD
292190
293# endif // _LIBCPP_STD_VER >= 14191# endif // _LIBCPP_STD_VER >= 20
294192
295_LIBCPP_POP_MACROS193_LIBCPP_POP_MACROS
296194
297#endif // !defined(_LIBCPP_HAS_NO_THREADS)195# endif // _LIBCPP_HAS_THREADS
298196
299#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20197# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
300# include <atomic>198# include <atomic>
301# include <concepts>199# include <concepts>
302# include <iterator>200# include <iterator>
303# include <memory>201# include <memory>
304# include <stdexcept>202# include <stdexcept>
305# include <variant>203# include <variant>
306#endif204# endif
205#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
307206
308#endif //_LIBCPP_BARRIER207#endif // _LIBCPP_BARRIER
lib/libcxx/include/bit+36-36
...@@ -61,41 +61,41 @@ namespace std {...@@ -61,41 +61,41 @@ namespace std {
6161
62*/62*/
6363
64#include <__config>64#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
6565# include <__cxx03/bit>
66#if _LIBCPP_STD_VER >= 2066#else
67# include <__bit/bit_cast.h>67# include <__config>
68# include <__bit/bit_ceil.h>68
69# include <__bit/bit_floor.h>69# if _LIBCPP_STD_VER >= 20
70# include <__bit/bit_log2.h>70# include <__bit/bit_cast.h>
71# include <__bit/bit_width.h>71# include <__bit/bit_ceil.h>
72# include <__bit/countl.h>72# include <__bit/bit_floor.h>
73# include <__bit/countr.h>73# include <__bit/bit_log2.h>
74# include <__bit/endian.h>74# include <__bit/bit_width.h>
75# include <__bit/has_single_bit.h>75# include <__bit/countl.h>
76# include <__bit/popcount.h>76# include <__bit/countr.h>
77# include <__bit/rotate.h>77# include <__bit/endian.h>
78#endif78# include <__bit/has_single_bit.h>
7979# include <__bit/popcount.h>
80#if _LIBCPP_STD_VER >= 2380# include <__bit/rotate.h>
81# include <__bit/byteswap.h>81# endif
82#endif82
8383# if _LIBCPP_STD_VER >= 23
84#include <version>84# include <__bit/byteswap.h>
8585# endif
86#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)86
87# pragma GCC system_header87# include <version>
88#endif88
8989# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
90#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 1790# pragma GCC system_header
91# include <cstdint>91# endif
92#endif92
9393# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
94#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 2094# include <cstdlib>
95# include <cstdlib>95# include <iosfwd>
96# include <iosfwd>96# include <limits>
97# include <limits>97# include <type_traits>
98# include <type_traits>98# endif
99#endif99#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
100100
101#endif // _LIBCPP_BIT101#endif // _LIBCPP_BIT
lib/libcxx/include/bitset+135-125
...@@ -126,32 +126,38 @@ template <size_t N> struct hash<std::bitset<N>>;...@@ -126,32 +126,38 @@ template <size_t N> struct hash<std::bitset<N>>;
126126
127// clang-format on127// clang-format on
128128
129#include <__algorithm/count.h>129#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
130#include <__algorithm/fill.h>130# include <__cxx03/bitset>
131#include <__algorithm/find.h>131#else
132#include <__bit_reference>132# include <__algorithm/count.h>
133#include <__config>133# include <__algorithm/fill.h>
134#include <__functional/hash.h>134# include <__algorithm/fill_n.h>
135#include <__functional/unary_function.h>135# include <__algorithm/find.h>
136#include <__type_traits/is_char_like_type.h>136# include <__assert>
137#include <climits>137# include <__bit_reference>
138#include <cstddef>138# include <__config>
139#include <stdexcept>139# include <__cstddef/ptrdiff_t.h>
140#include <string_view>140# include <__cstddef/size_t.h>
141#include <version>141# include <__functional/hash.h>
142# include <__functional/unary_function.h>
143# include <__type_traits/is_char_like_type.h>
144# include <climits>
145# include <stdexcept>
146# include <string_view>
147# include <version>
142148
143// standard-mandated includes149// standard-mandated includes
144150
145// [bitset.syn]151// [bitset.syn]
146#include <iosfwd>152# include <iosfwd>
147#include <string>153# include <string>
148154
149#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)155# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
150# pragma GCC system_header156# pragma GCC system_header
151#endif157# endif
152158
153_LIBCPP_PUSH_MACROS159_LIBCPP_PUSH_MACROS
154#include <__undef_macros>160# include <__undef_macros>
155161
156_LIBCPP_BEGIN_NAMESPACE_STD162_LIBCPP_BEGIN_NAMESPACE_STD
157163
...@@ -166,9 +172,7 @@ struct __has_storage_type<__bitset<_N_words, _Size> > {...@@ -166,9 +172,7 @@ struct __has_storage_type<__bitset<_N_words, _Size> > {
166template <size_t _N_words, size_t _Size>172template <size_t _N_words, size_t _Size>
167class __bitset {173class __bitset {
168public:174public:
169 typedef ptrdiff_t difference_type;175 typedef size_t __storage_type;
170 typedef size_t size_type;
171 typedef size_type __storage_type;
172176
173protected:177protected:
174 typedef __bitset __self;178 typedef __bitset __self;
...@@ -185,9 +189,9 @@ protected:...@@ -185,9 +189,9 @@ protected:
185 __storage_type __first_[_N_words];189 __storage_type __first_[_N_words];
186190
187 typedef __bit_reference<__bitset> reference;191 typedef __bit_reference<__bitset> reference;
188 typedef __bit_const_reference<__bitset> const_reference;192 typedef __bit_const_reference<__bitset> __const_reference;
189 typedef __bit_iterator<__bitset, false> iterator;193 typedef __bit_iterator<__bitset, false> __iterator;
190 typedef __bit_iterator<__bitset, true> const_iterator;194 typedef __bit_iterator<__bitset, true> __const_iterator;
191195
192 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;196 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
193 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;197 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
...@@ -195,14 +199,14 @@ protected:...@@ -195,14 +199,14 @@ protected:
195 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT {199 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT {
196 return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);200 return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);
197 }201 }
198 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT {202 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __const_reference __make_ref(size_t __pos) const _NOEXCEPT {
199 return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);203 return __const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);
200 }204 }
201 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT {205 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t __pos) _NOEXCEPT {
202 return iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);206 return __iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);
203 }207 }
204 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT {208 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t __pos) const _NOEXCEPT {
205 return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);209 return __const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);
206 }210 }
207211
208 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT;212 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT;
...@@ -222,10 +226,10 @@ protected:...@@ -222,10 +226,10 @@ protected:
222 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT;226 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT;
223227
224private:228private:
225#ifdef _LIBCPP_CXX03_LANG229# ifdef _LIBCPP_CXX03_LANG
226 void __init(unsigned long long __v, false_type) _NOEXCEPT;230 void __init(unsigned long long __v, false_type) _NOEXCEPT;
227 _LIBCPP_HIDE_FROM_ABI void __init(unsigned long long __v, true_type) _NOEXCEPT;231 _LIBCPP_HIDE_FROM_ABI void __init(unsigned long long __v, true_type) _NOEXCEPT;
228#endif // _LIBCPP_CXX03_LANG232# endif // _LIBCPP_CXX03_LANG
229 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(false_type) const;233 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(false_type) const;
230 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(true_type) const;234 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(true_type) const;
231 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(false_type) const;235 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(false_type) const;
...@@ -236,16 +240,16 @@ private:...@@ -236,16 +240,16 @@ private:
236240
237template <size_t _N_words, size_t _Size>241template <size_t _N_words, size_t _Size>
238inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset() _NOEXCEPT242inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset() _NOEXCEPT
239#ifndef _LIBCPP_CXX03_LANG243# ifndef _LIBCPP_CXX03_LANG
240 : __first_{0}244 : __first_{0}
241#endif245# endif
242{246{
243#ifdef _LIBCPP_CXX03_LANG247# ifdef _LIBCPP_CXX03_LANG
244 std::fill_n(__first_, _N_words, __storage_type(0));248 std::fill_n(__first_, _N_words, __storage_type(0));
245#endif249# endif
246}250}
247251
248#ifdef _LIBCPP_CXX03_LANG252# ifdef _LIBCPP_CXX03_LANG
249253
250template <size_t _N_words, size_t _Size>254template <size_t _N_words, size_t _Size>
251void __bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT {255void __bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT {
...@@ -271,54 +275,54 @@ inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned lon...@@ -271,54 +275,54 @@ inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned lon
271 std::fill(__first_ + 1, __first_ + sizeof(__first_) / sizeof(__first_[0]), __storage_type(0));275 std::fill(__first_ + 1, __first_ + sizeof(__first_) / sizeof(__first_[0]), __storage_type(0));
272}276}
273277
274#endif // _LIBCPP_CXX03_LANG278# endif // _LIBCPP_CXX03_LANG
275279
276template <size_t _N_words, size_t _Size>280template <size_t _N_words, size_t _Size>
277inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT281inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
278#ifndef _LIBCPP_CXX03_LANG282# ifndef _LIBCPP_CXX03_LANG
279# if __SIZEOF_SIZE_T__ == 8283# if __SIZEOF_SIZE_T__ == 8
280 : __first_{__v}284 : __first_{__v}
281# elif __SIZEOF_SIZE_T__ == 4285# elif __SIZEOF_SIZE_T__ == 4
282 : __first_{static_cast<__storage_type>(__v),286 : __first_{static_cast<__storage_type>(__v),
283 _Size >= 2 * __bits_per_word287 _Size >= 2 * __bits_per_word
284 ? static_cast<__storage_type>(__v >> __bits_per_word)288 ? static_cast<__storage_type>(__v >> __bits_per_word)
285 : static_cast<__storage_type>((__v >> __bits_per_word) &289 : static_cast<__storage_type>((__v >> __bits_per_word) &
286 (__storage_type(1) << (_Size - __bits_per_word)) - 1)}290 (__storage_type(1) << (_Size - __bits_per_word)) - 1)}
287# else291# else
288# error This constructor has not been ported to this platform292# error This constructor has not been ported to this platform
293# endif
289# endif294# endif
290#endif
291{295{
292#ifdef _LIBCPP_CXX03_LANG296# ifdef _LIBCPP_CXX03_LANG
293 __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>());297 __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>());
294#endif298# endif
295}299}
296300
297template <size_t _N_words, size_t _Size>301template <size_t _N_words, size_t _Size>
298inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void302inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
299__bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT {303__bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT {
300 for (size_type __i = 0; __i < _N_words; ++__i)304 for (size_t __i = 0; __i < _N_words; ++__i)
301 __first_[__i] &= __v.__first_[__i];305 __first_[__i] &= __v.__first_[__i];
302}306}
303307
304template <size_t _N_words, size_t _Size>308template <size_t _N_words, size_t _Size>
305inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void309inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
306__bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT {310__bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT {
307 for (size_type __i = 0; __i < _N_words; ++__i)311 for (size_t __i = 0; __i < _N_words; ++__i)
308 __first_[__i] |= __v.__first_[__i];312 __first_[__i] |= __v.__first_[__i];
309}313}
310314
311template <size_t _N_words, size_t _Size>315template <size_t _N_words, size_t _Size>
312inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void316inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
313__bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT {317__bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT {
314 for (size_type __i = 0; __i < _N_words; ++__i)318 for (size_t __i = 0; __i < _N_words; ++__i)
315 __first_[__i] ^= __v.__first_[__i];319 __first_[__i] ^= __v.__first_[__i];
316}320}
317321
318template <size_t _N_words, size_t _Size>322template <size_t _N_words, size_t _Size>
319_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Size>::flip() _NOEXCEPT {323_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Size>::flip() _NOEXCEPT {
320 // do middle whole words324 // do middle whole words
321 size_type __n = _Size;325 size_t __n = _Size;
322 __storage_pointer __p = __first_;326 __storage_pointer __p = __first_;
323 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)327 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
324 *__p = ~*__p;328 *__p = ~*__p;
...@@ -334,8 +338,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Siz...@@ -334,8 +338,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Siz
334template <size_t _N_words, size_t _Size>338template <size_t _N_words, size_t _Size>
335_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long339_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
336__bitset<_N_words, _Size>::to_ulong(false_type) const {340__bitset<_N_words, _Size>::to_ulong(false_type) const {
337 const_iterator __e = __make_iter(_Size);341 __const_iterator __e = __make_iter(_Size);
338 const_iterator __i = std::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true);342 __const_iterator __i = std::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true);
339 if (__i != __e)343 if (__i != __e)
340 __throw_overflow_error("bitset to_ulong overflow error");344 __throw_overflow_error("bitset to_ulong overflow error");
341345
...@@ -351,8 +355,8 @@ __bitset<_N_words, _Size>::to_ulong(true_type) const {...@@ -351,8 +355,8 @@ __bitset<_N_words, _Size>::to_ulong(true_type) const {
351template <size_t _N_words, size_t _Size>355template <size_t _N_words, size_t _Size>
352_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long356_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
353__bitset<_N_words, _Size>::to_ullong(false_type) const {357__bitset<_N_words, _Size>::to_ullong(false_type) const {
354 const_iterator __e = __make_iter(_Size);358 __const_iterator __e = __make_iter(_Size);
355 const_iterator __i = std::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true);359 __const_iterator __i = std::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true);
356 if (__i != __e)360 if (__i != __e)
357 __throw_overflow_error("bitset to_ullong overflow error");361 __throw_overflow_error("bitset to_ullong overflow error");
358362
...@@ -386,7 +390,7 @@ __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const {...@@ -386,7 +390,7 @@ __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const {
386template <size_t _N_words, size_t _Size>390template <size_t _N_words, size_t _Size>
387_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::all() const _NOEXCEPT {391_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::all() const _NOEXCEPT {
388 // do middle whole words392 // do middle whole words
389 size_type __n = _Size;393 size_t __n = _Size;
390 __const_storage_pointer __p = __first_;394 __const_storage_pointer __p = __first_;
391 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)395 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
392 if (~*__p)396 if (~*__p)
...@@ -403,7 +407,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Siz...@@ -403,7 +407,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Siz
403template <size_t _N_words, size_t _Size>407template <size_t _N_words, size_t _Size>
404_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::any() const _NOEXCEPT {408_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::any() const _NOEXCEPT {
405 // do middle whole words409 // do middle whole words
406 size_type __n = _Size;410 size_t __n = _Size;
407 __const_storage_pointer __p = __first_;411 __const_storage_pointer __p = __first_;
408 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)412 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
409 if (*__p)413 if (*__p)
...@@ -420,7 +424,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Siz...@@ -420,7 +424,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Siz
420template <size_t _N_words, size_t _Size>424template <size_t _N_words, size_t _Size>
421inline size_t __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT {425inline size_t __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT {
422 size_t __h = 0;426 size_t __h = 0;
423 for (size_type __i = 0; __i < _N_words; ++__i)427 for (size_t __i = 0; __i < _N_words; ++__i)
424 __h ^= __first_[__i];428 __h ^= __first_[__i];
425 return __h;429 return __h;
426}430}
...@@ -428,9 +432,7 @@ inline size_t __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT {...@@ -428,9 +432,7 @@ inline size_t __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT {
428template <size_t _Size>432template <size_t _Size>
429class __bitset<1, _Size> {433class __bitset<1, _Size> {
430public:434public:
431 typedef ptrdiff_t difference_type;435 typedef size_t __storage_type;
432 typedef size_t size_type;
433 typedef size_type __storage_type;
434436
435protected:437protected:
436 typedef __bitset __self;438 typedef __bitset __self;
...@@ -447,9 +449,9 @@ protected:...@@ -447,9 +449,9 @@ protected:
447 __storage_type __first_;449 __storage_type __first_;
448450
449 typedef __bit_reference<__bitset> reference;451 typedef __bit_reference<__bitset> reference;
450 typedef __bit_const_reference<__bitset> const_reference;452 typedef __bit_const_reference<__bitset> __const_reference;
451 typedef __bit_iterator<__bitset, false> iterator;453 typedef __bit_iterator<__bitset, false> __iterator;
452 typedef __bit_iterator<__bitset, true> const_iterator;454 typedef __bit_iterator<__bitset, true> __const_iterator;
453455
454 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;456 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
455 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;457 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
...@@ -457,14 +459,14 @@ protected:...@@ -457,14 +459,14 @@ protected:
457 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT {459 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT {
458 return reference(&__first_, __storage_type(1) << __pos);460 return reference(&__first_, __storage_type(1) << __pos);
459 }461 }
460 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT {462 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __const_reference __make_ref(size_t __pos) const _NOEXCEPT {
461 return const_reference(&__first_, __storage_type(1) << __pos);463 return __const_reference(&__first_, __storage_type(1) << __pos);
462 }464 }
463 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT {465 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t __pos) _NOEXCEPT {
464 return iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);466 return __iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);
465 }467 }
466 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT {468 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t __pos) const _NOEXCEPT {
467 return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);469 return __const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);
468 }470 }
469471
470 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT;472 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT;
...@@ -545,9 +547,7 @@ inline size_t __bitset<1, _Size>::__hash_code() const _NOEXCEPT {...@@ -545,9 +547,7 @@ inline size_t __bitset<1, _Size>::__hash_code() const _NOEXCEPT {
545template <>547template <>
546class __bitset<0, 0> {548class __bitset<0, 0> {
547public:549public:
548 typedef ptrdiff_t difference_type;550 typedef size_t __storage_type;
549 typedef size_t size_type;
550 typedef size_type __storage_type;
551551
552protected:552protected:
553 typedef __bitset __self;553 typedef __bitset __self;
...@@ -562,9 +562,9 @@ protected:...@@ -562,9 +562,9 @@ protected:
562 friend struct __bit_array<__bitset>;562 friend struct __bit_array<__bitset>;
563563
564 typedef __bit_reference<__bitset> reference;564 typedef __bit_reference<__bitset> reference;
565 typedef __bit_const_reference<__bitset> const_reference;565 typedef __bit_const_reference<__bitset> __const_reference;
566 typedef __bit_iterator<__bitset, false> iterator;566 typedef __bit_iterator<__bitset, false> __iterator;
567 typedef __bit_iterator<__bitset, true> const_iterator;567 typedef __bit_iterator<__bitset, true> __const_iterator;
568568
569 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;569 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
570 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;570 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;
...@@ -572,14 +572,14 @@ protected:...@@ -572,14 +572,14 @@ protected:
572 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t) _NOEXCEPT {572 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t) _NOEXCEPT {
573 return reference(nullptr, 1);573 return reference(nullptr, 1);
574 }574 }
575 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT {575 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __const_reference __make_ref(size_t) const _NOEXCEPT {
576 return const_reference(nullptr, 1);576 return __const_reference(nullptr, 1);
577 }577 }
578 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t) _NOEXCEPT {578 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t) _NOEXCEPT {
579 return iterator(nullptr, 0);579 return __iterator(nullptr, 0);
580 }580 }
581 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t) const _NOEXCEPT {581 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t) const _NOEXCEPT {
582 return const_iterator(nullptr, 0);582 return __const_iterator(nullptr, 0);
583 }583 }
584584
585 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset&) _NOEXCEPT {}585 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset&) _NOEXCEPT {}
...@@ -611,30 +611,30 @@ class _LIBCPP_TEMPLATE_VIS bitset...@@ -611,30 +611,30 @@ class _LIBCPP_TEMPLATE_VIS bitset
611 : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> {611 : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> {
612public:612public:
613 static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1;613 static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1;
614 typedef __bitset<__n_words, _Size> base;614 typedef __bitset<__n_words, _Size> __base;
615615
616public:616public:
617 typedef typename base::reference reference;617 typedef typename __base::reference reference;
618 typedef typename base::const_reference const_reference;618 typedef typename __base::__const_reference __const_reference;
619619
620 // 23.3.5.1 constructors:620 // 23.3.5.1 constructors:
621 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {}621 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {}
622 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT : base(__v) {}622 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT : __base(__v) {}
623 template <class _CharT, __enable_if_t<_IsCharLikeType<_CharT>::value, int> = 0>623 template <class _CharT, __enable_if_t<_IsCharLikeType<_CharT>::value, int> = 0>
624 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(624 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(
625 const _CharT* __str,625 const _CharT* __str,
626#if _LIBCPP_STD_VER >= 26626# if _LIBCPP_STD_VER >= 26
627 typename basic_string_view<_CharT>::size_type __n = basic_string_view<_CharT>::npos,627 typename basic_string_view<_CharT>::size_type __n = basic_string_view<_CharT>::npos,
628#else628# else
629 typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos,629 typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos,
630#endif630# endif
631 _CharT __zero = _CharT('0'),631 _CharT __zero = _CharT('0'),
632 _CharT __one = _CharT('1')) {632 _CharT __one = _CharT('1')) {
633633
634 size_t __rlen = std::min(__n, char_traits<_CharT>::length(__str));634 size_t __rlen = std::min(__n, char_traits<_CharT>::length(__str));
635 __init_from_string_view(basic_string_view<_CharT>(__str, __rlen), __zero, __one);635 __init_from_string_view(basic_string_view<_CharT>(__str, __rlen), __zero, __one);
636 }636 }
637#if _LIBCPP_STD_VER >= 26637# if _LIBCPP_STD_VER >= 26
638 template <class _CharT, class _Traits>638 template <class _CharT, class _Traits>
639 _LIBCPP_HIDE_FROM_ABI constexpr explicit bitset(639 _LIBCPP_HIDE_FROM_ABI constexpr explicit bitset(
640 basic_string_view<_CharT, _Traits> __str,640 basic_string_view<_CharT, _Traits> __str,
...@@ -648,7 +648,7 @@ public:...@@ -648,7 +648,7 @@ public:
648 size_t __rlen = std::min(__n, __str.size() - __pos);648 size_t __rlen = std::min(__n, __str.size() - __pos);
649 __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one);649 __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one);
650 }650 }
651#endif651# endif
652 template <class _CharT, class _Traits, class _Allocator>652 template <class _CharT, class _Traits, class _Allocator>
653 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(653 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(
654 const basic_string<_CharT, _Traits, _Allocator>& __str,654 const basic_string<_CharT, _Traits, _Allocator>& __str,
...@@ -679,12 +679,21 @@ public:...@@ -679,12 +679,21 @@ public:
679 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& flip(size_t __pos);679 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& flip(size_t __pos);
680680
681 // element access:681 // element access:
682#ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL682# ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
683 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const { return base::__make_ref(__p); }683 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const {
684#else684 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds");
685 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const { return base::__make_ref(__p); }685 return __base::__make_ref(__p);
686#endif686 }
687 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) { return base::__make_ref(__p); }687# else
688 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __const_reference operator[](size_t __p) const {
689 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds");
690 return __base::__make_ref(__p);
691 }
692# endif
693 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) {
694 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds");
695 return __base::__make_ref(__p);
696 }
688 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const;697 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const;
689 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const;698 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const;
690 template <class _CharT, class _Traits, class _Allocator>699 template <class _CharT, class _Traits, class _Allocator>
...@@ -701,9 +710,9 @@ public:...@@ -701,9 +710,9 @@ public:
701 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t count() const _NOEXCEPT;710 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t count() const _NOEXCEPT;
702 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT { return _Size; }711 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT { return _Size; }
703 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const bitset& __rhs) const _NOEXCEPT;712 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const bitset& __rhs) const _NOEXCEPT;
704#if _LIBCPP_STD_VER <= 17713# if _LIBCPP_STD_VER <= 17
705 _LIBCPP_HIDE_FROM_ABI bool operator!=(const bitset& __rhs) const _NOEXCEPT;714 _LIBCPP_HIDE_FROM_ABI bool operator!=(const bitset& __rhs) const _NOEXCEPT;
706#endif715# endif
707 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool test(size_t __pos) const;716 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool test(size_t __pos) const;
708 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;717 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;
709 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;718 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;
...@@ -725,10 +734,10 @@ private:...@@ -725,10 +734,10 @@ private:
725 _CharT __c = __str[__mp - 1 - __i];734 _CharT __c = __str[__mp - 1 - __i];
726 (*this)[__i] = _Traits::eq(__c, __one);735 (*this)[__i] = _Traits::eq(__c, __one);
727 }736 }
728 std::fill(base::__make_iter(__i), base::__make_iter(_Size), false);737 std::fill(__base::__make_iter(__i), __base::__make_iter(_Size), false);
729 }738 }
730739
731 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return base::__hash_code(); }740 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return __base::__hash_code(); }
732741
733 friend struct hash<bitset>;742 friend struct hash<bitset>;
734};743};
...@@ -736,43 +745,43 @@ private:...@@ -736,43 +745,43 @@ private:
736template <size_t _Size>745template <size_t _Size>
737inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&746inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&
738bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT {747bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT {
739 base::operator&=(__rhs);748 __base::operator&=(__rhs);
740 return *this;749 return *this;
741}750}
742751
743template <size_t _Size>752template <size_t _Size>
744inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&753inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&
745bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT {754bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT {
746 base::operator|=(__rhs);755 __base::operator|=(__rhs);
747 return *this;756 return *this;
748}757}
749758
750template <size_t _Size>759template <size_t _Size>
751inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&760inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&
752bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT {761bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT {
753 base::operator^=(__rhs);762 __base::operator^=(__rhs);
754 return *this;763 return *this;
755}764}
756765
757template <size_t _Size>766template <size_t _Size>
758_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT {767_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT {
759 __pos = std::min(__pos, _Size);768 __pos = std::min(__pos, _Size);
760 std::copy_backward(base::__make_iter(0), base::__make_iter(_Size - __pos), base::__make_iter(_Size));769 std::copy_backward(__base::__make_iter(0), __base::__make_iter(_Size - __pos), __base::__make_iter(_Size));
761 std::fill_n(base::__make_iter(0), __pos, false);770 std::fill_n(__base::__make_iter(0), __pos, false);
762 return *this;771 return *this;
763}772}
764773
765template <size_t _Size>774template <size_t _Size>
766_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT {775_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT {
767 __pos = std::min(__pos, _Size);776 __pos = std::min(__pos, _Size);
768 std::copy(base::__make_iter(__pos), base::__make_iter(_Size), base::__make_iter(0));777 std::copy(__base::__make_iter(__pos), __base::__make_iter(_Size), __base::__make_iter(0));
769 std::fill_n(base::__make_iter(_Size - __pos), __pos, false);778 std::fill_n(__base::__make_iter(_Size - __pos), __pos, false);
770 return *this;779 return *this;
771}780}
772781
773template <size_t _Size>782template <size_t _Size>
774inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::set() _NOEXCEPT {783inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::set() _NOEXCEPT {
775 std::fill_n(base::__make_iter(0), _Size, true);784 std::fill_n(__base::__make_iter(0), _Size, true);
776 return *this;785 return *this;
777}786}
778787
...@@ -787,7 +796,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>...@@ -787,7 +796,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>
787796
788template <size_t _Size>797template <size_t _Size>
789inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::reset() _NOEXCEPT {798inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::reset() _NOEXCEPT {
790 std::fill_n(base::__make_iter(0), _Size, false);799 std::fill_n(__base::__make_iter(0), _Size, false);
791 return *this;800 return *this;
792}801}
793802
...@@ -809,7 +818,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> bitset<...@@ -809,7 +818,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> bitset<
809818
810template <size_t _Size>819template <size_t _Size>
811inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::flip() _NOEXCEPT {820inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::flip() _NOEXCEPT {
812 base::flip();821 __base::flip();
813 return *this;822 return *this;
814}823}
815824
...@@ -818,19 +827,19 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>...@@ -818,19 +827,19 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>
818 if (__pos >= _Size)827 if (__pos >= _Size)
819 __throw_out_of_range("bitset flip argument out of range");828 __throw_out_of_range("bitset flip argument out of range");
820829
821 reference __r = base::__make_ref(__pos);830 reference __r = __base::__make_ref(__pos);
822 __r = ~__r;831 __r = ~__r;
823 return *this;832 return *this;
824}833}
825834
826template <size_t _Size>835template <size_t _Size>
827inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long bitset<_Size>::to_ulong() const {836inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long bitset<_Size>::to_ulong() const {
828 return base::to_ulong();837 return __base::to_ulong();
829}838}
830839
831template <size_t _Size>840template <size_t _Size>
832inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long bitset<_Size>::to_ullong() const {841inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long bitset<_Size>::to_ullong() const {
833 return base::to_ullong();842 return __base::to_ullong();
834}843}
835844
836template <size_t _Size>845template <size_t _Size>
...@@ -867,23 +876,23 @@ bitset<_Size>::to_string(char __zero, char __one) const {...@@ -867,23 +876,23 @@ bitset<_Size>::to_string(char __zero, char __one) const {
867876
868template <size_t _Size>877template <size_t _Size>
869inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t bitset<_Size>::count() const _NOEXCEPT {878inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t bitset<_Size>::count() const _NOEXCEPT {
870 return static_cast<size_t>(std::count(base::__make_iter(0), base::__make_iter(_Size), true));879 return static_cast<size_t>(std::count(__base::__make_iter(0), __base::__make_iter(_Size), true));
871}880}
872881
873template <size_t _Size>882template <size_t _Size>
874inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool883inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
875bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT {884bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT {
876 return std::equal(base::__make_iter(0), base::__make_iter(_Size), __rhs.__make_iter(0));885 return std::equal(__base::__make_iter(0), __base::__make_iter(_Size), __rhs.__make_iter(0));
877}886}
878887
879#if _LIBCPP_STD_VER <= 17888# if _LIBCPP_STD_VER <= 17
880889
881template <size_t _Size>890template <size_t _Size>
882inline _LIBCPP_HIDE_FROM_ABI bool bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT {891inline _LIBCPP_HIDE_FROM_ABI bool bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT {
883 return !(*this == __rhs);892 return !(*this == __rhs);
884}893}
885894
886#endif895# endif
887896
888template <size_t _Size>897template <size_t _Size>
889_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(size_t __pos) const {898_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(size_t __pos) const {
...@@ -895,12 +904,12 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(siz...@@ -895,12 +904,12 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(siz
895904
896template <size_t _Size>905template <size_t _Size>
897inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::all() const _NOEXCEPT {906inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::all() const _NOEXCEPT {
898 return base::all();907 return __base::all();
899}908}
900909
901template <size_t _Size>910template <size_t _Size>
902inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::any() const _NOEXCEPT {911inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::any() const _NOEXCEPT {
903 return base::any();912 return __base::any();
904}913}
905914
906template <size_t _Size>915template <size_t _Size>
...@@ -960,10 +969,11 @@ _LIBCPP_END_NAMESPACE_STD...@@ -960,10 +969,11 @@ _LIBCPP_END_NAMESPACE_STD
960969
961_LIBCPP_POP_MACROS970_LIBCPP_POP_MACROS
962971
963#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20972# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
964# include <concepts>973# include <concepts>
965# include <cstdlib>974# include <cstdlib>
966# include <type_traits>975# include <type_traits>
967#endif976# endif
977#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
968978
969#endif // _LIBCPP_BITSET979#endif // _LIBCPP_BITSET
lib/libcxx/include/cassert+13-9
...@@ -16,16 +16,20 @@ Macros:...@@ -16,16 +16,20 @@ Macros:
1616
17*/17*/
1818
19#include <__config>19#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
20# include <__cxx03/cassert>
21#else
22# include <__config>
2023
21// <assert.h> is not provided by libc++24// <assert.h> is not provided by libc++
22#if __has_include(<assert.h>)25# if __has_include(<assert.h>)
23# include <assert.h>26# include <assert.h>
24# ifdef _LIBCPP_ASSERT_H27# ifdef _LIBCPP_ASSERT_H
25# error "If libc++ starts defining <assert.h>, the __has_include check should move to libc++'s <assert.h>"28# error "If libc++ starts defining <assert.h>, the __has_include check should move to libc++'s <assert.h>"
29# endif
26# endif30# endif
27#endif
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
31#endif34# endif
35#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/ccomplex+21-4
...@@ -17,10 +17,27 @@...@@ -17,10 +17,27 @@
1717
18*/18*/
1919
20#include <complex>20#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
21# include <__cxx03/ccomplex>
22#else
23# include <complex>
24
25# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27# endif
28
29# if _LIBCPP_STD_VER >= 20
30
31using __standard_header_ccomplex
32 _LIBCPP_DEPRECATED_("removed in C++20. Include <complex> instead.") _LIBCPP_NODEBUG = void;
33using __use_standard_header_ccomplex _LIBCPP_NODEBUG = __standard_header_ccomplex;
34
35# elif _LIBCPP_STD_VER >= 17
36
37using __standard_header_ccomplex _LIBCPP_DEPRECATED_("Include <complex> instead.") _LIBCPP_NODEBUG = void;
38using __use_standard_header_ccomplex _LIBCPP_NODEBUG = __standard_header_ccomplex;
2139
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)40# endif
23# pragma GCC system_header41#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
24#endif
2542
26#endif // _LIBCPP_CCOMPLEX43#endif // _LIBCPP_CCOMPLEX
lib/libcxx/include/cctype+53-49
...@@ -34,78 +34,81 @@ int toupper(int c);...@@ -34,78 +34,81 @@ int toupper(int c);
34} // std34} // std
35*/35*/
3636
37#include <__config>37#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
38# include <__cxx03/cctype>
39#else
40# include <__config>
3841
39#include <ctype.h>42# include <ctype.h>
4043
41#ifndef _LIBCPP_CTYPE_H44# ifndef _LIBCPP_CTYPE_H
42# error <cctype> tried including <ctype.h> but didn't find libc++'s <ctype.h> header. \45# error <cctype> tried including <ctype.h> but didn't find libc++'s <ctype.h> header. \
43 This usually means that your header search paths are not configured properly. \46 This usually means that your header search paths are not configured properly. \
44 The header search paths should contain the C++ Standard Library headers before \47 The header search paths should contain the C++ Standard Library headers before \
45 any C Standard Library.48 any C Standard Library.
46#endif49# endif
4750
48#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)51# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
49# pragma GCC system_header52# pragma GCC system_header
50#endif53# endif
5154
52_LIBCPP_BEGIN_NAMESPACE_STD55_LIBCPP_BEGIN_NAMESPACE_STD
5356
54#ifdef isalnum57# ifdef isalnum
55# undef isalnum58# undef isalnum
56#endif59# endif
5760
58#ifdef isalpha61# ifdef isalpha
59# undef isalpha62# undef isalpha
60#endif63# endif
6164
62#ifdef isblank65# ifdef isblank
63# undef isblank66# undef isblank
64#endif67# endif
6568
66#ifdef iscntrl69# ifdef iscntrl
67# undef iscntrl70# undef iscntrl
68#endif71# endif
6972
70#ifdef isdigit73# ifdef isdigit
71# undef isdigit74# undef isdigit
72#endif75# endif
7376
74#ifdef isgraph77# ifdef isgraph
75# undef isgraph78# undef isgraph
76#endif79# endif
7780
78#ifdef islower81# ifdef islower
79# undef islower82# undef islower
80#endif83# endif
8184
82#ifdef isprint85# ifdef isprint
83# undef isprint86# undef isprint
84#endif87# endif
8588
86#ifdef ispunct89# ifdef ispunct
87# undef ispunct90# undef ispunct
88#endif91# endif
8992
90#ifdef isspace93# ifdef isspace
91# undef isspace94# undef isspace
92#endif95# endif
9396
94#ifdef isupper97# ifdef isupper
95# undef isupper98# undef isupper
96#endif99# endif
97100
98#ifdef isxdigit101# ifdef isxdigit
99# undef isxdigit102# undef isxdigit
100#endif103# endif
101104
102#ifdef tolower105# ifdef tolower
103# undef tolower106# undef tolower
104#endif107# endif
105108
106#ifdef toupper109# ifdef toupper
107# undef toupper110# undef toupper
108#endif111# endif
109112
110using ::isalnum _LIBCPP_USING_IF_EXISTS;113using ::isalnum _LIBCPP_USING_IF_EXISTS;
111using ::isalpha _LIBCPP_USING_IF_EXISTS;114using ::isalpha _LIBCPP_USING_IF_EXISTS;
...@@ -123,5 +126,6 @@ using ::tolower _LIBCPP_USING_IF_EXISTS;...@@ -123,5 +126,6 @@ using ::tolower _LIBCPP_USING_IF_EXISTS;
123using ::toupper _LIBCPP_USING_IF_EXISTS;126using ::toupper _LIBCPP_USING_IF_EXISTS;
124127
125_LIBCPP_END_NAMESPACE_STD128_LIBCPP_END_NAMESPACE_STD
129#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
126130
127#endif // _LIBCPP_CCTYPE131#endif // _LIBCPP_CCTYPE
lib/libcxx/include/cerrno+11-7
...@@ -22,21 +22,24 @@ Macros:...@@ -22,21 +22,24 @@ Macros:
2222
23*/23*/
2424
25#include <__config>25#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
26# include <__cxx03/cerrno>
27#else
28# include <__config>
2629
27#include <errno.h>30# include <errno.h>
2831
29#ifndef _LIBCPP_ERRNO_H32# ifndef _LIBCPP_ERRNO_H
30# error <cerrno> tried including <errno.h> but didn't find libc++'s <errno.h> header. \33# error <cerrno> tried including <errno.h> but didn't find libc++'s <errno.h> header. \
31 This usually means that your header search paths are not configured properly. \34 This usually means that your header search paths are not configured properly. \
32 The header search paths should contain the C++ Standard Library headers before \35 The header search paths should contain the C++ Standard Library headers before \
33 any C Standard Library, and you are probably using compiler flags that make that \36 any C Standard Library, and you are probably using compiler flags that make that \
34 not be the case.37 not be the case.
35#endif38# endif
3639
37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)40# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
38# pragma GCC system_header41# pragma GCC system_header
39#endif42# endif
4043
41// LWG3869 Deprecate std::errc constants related to UNIX STREAMS44// LWG3869 Deprecate std::errc constants related to UNIX STREAMS
42//45//
...@@ -44,5 +47,6 @@ Macros:...@@ -44,5 +47,6 @@ Macros:
44// deprecated in libc++ in https://github.com/llvm/llvm-project/pull/80542.47// deprecated in libc++ in https://github.com/llvm/llvm-project/pull/80542.
45// Based on the post commit feedback the macro are no longer deprecated.48// Based on the post commit feedback the macro are no longer deprecated.
46// Instead libc++ leaves the deprecation to the provider of errno.h.49// Instead libc++ leaves the deprecation to the provider of errno.h.
50#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
4751
48#endif // _LIBCPP_CERRNO52#endif // _LIBCPP_CERRNO
lib/libcxx/include/cfenv+12-7
...@@ -52,21 +52,24 @@ int feupdateenv(const fenv_t* envp);...@@ -52,21 +52,24 @@ int feupdateenv(const fenv_t* envp);
52} // std52} // std
53*/53*/
5454
55#include <__config>55#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
56# include <__cxx03/cfenv>
57#else
58# include <__config>
5659
57#include <fenv.h>60# include <fenv.h>
5861
59#ifndef _LIBCPP_FENV_H62# ifndef _LIBCPP_FENV_H
60# error <cfenv> tried including <fenv.h> but didn't find libc++'s <fenv.h> header. \63# error <cfenv> tried including <fenv.h> but didn't find libc++'s <fenv.h> header. \
61 This usually means that your header search paths are not configured properly. \64 This usually means that your header search paths are not configured properly. \
62 The header search paths should contain the C++ Standard Library headers before \65 The header search paths should contain the C++ Standard Library headers before \
63 any C Standard Library, and you are probably using compiler flags that make that \66 any C Standard Library, and you are probably using compiler flags that make that \
64 not be the case.67 not be the case.
65#endif68# endif
6669
67#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)70# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
68# pragma GCC system_header71# pragma GCC system_header
69#endif72# endif
7073
71_LIBCPP_BEGIN_NAMESPACE_STD74_LIBCPP_BEGIN_NAMESPACE_STD
7275
...@@ -87,4 +90,6 @@ using ::feupdateenv _LIBCPP_USING_IF_EXISTS;...@@ -87,4 +90,6 @@ using ::feupdateenv _LIBCPP_USING_IF_EXISTS;
8790
88_LIBCPP_END_NAMESPACE_STD91_LIBCPP_END_NAMESPACE_STD
8992
93#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
94
90#endif // _LIBCPP_CFENV95#endif // _LIBCPP_CFENV
lib/libcxx/include/cfloat+11-7
...@@ -69,20 +69,24 @@ Macros:...@@ -69,20 +69,24 @@ Macros:
69 LDBL_TRUE_MIN // C1169 LDBL_TRUE_MIN // C11
70*/70*/
7171
72#include <__config>72#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
73# include <__cxx03/cfloat>
74#else
75# include <__config>
7376
74#include <float.h>77# include <float.h>
7578
76#ifndef _LIBCPP_FLOAT_H79# ifndef _LIBCPP_FLOAT_H
77# error <cfloat> tried including <float.h> but didn't find libc++'s <float.h> header. \80# error <cfloat> tried including <float.h> but didn't find libc++'s <float.h> header. \
78 This usually means that your header search paths are not configured properly. \81 This usually means that your header search paths are not configured properly. \
79 The header search paths should contain the C++ Standard Library headers before \82 The header search paths should contain the C++ Standard Library headers before \
80 any C Standard Library, and you are probably using compiler flags that make that \83 any C Standard Library, and you are probably using compiler flags that make that \
81 not be the case.84 not be the case.
82#endif85# endif
8386
84#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)87# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
85# pragma GCC system_header88# pragma GCC system_header
86#endif89# endif
90#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
8791
88#endif // _LIBCPP_CFLOAT92#endif // _LIBCPP_CFLOAT
lib/libcxx/include/charconv+43-37
...@@ -65,51 +65,57 @@ namespace std {...@@ -65,51 +65,57 @@ namespace std {
65 constexpr from_chars_result from_chars(const char* first, const char* last,65 constexpr from_chars_result from_chars(const char* first, const char* last,
66 see below& value, int base = 10); // constexpr since C++2366 see below& value, int base = 10); // constexpr since C++23
6767
68} // namespace std68 from_chars_result from_chars(const char* first, const char* last,
6969 float& value, chars_format fmt);
70*/
7170
72#include <__config>71 from_chars_result from_chars(const char* first, const char* last,
72 double& value, chars_format fmt);
7373
74#if _LIBCPP_STD_VER >= 1774} // namespace std
75# include <__charconv/chars_format.h>
76# include <__charconv/from_chars_integral.h>
77# include <__charconv/from_chars_result.h>
78# include <__charconv/tables.h>
79# include <__charconv/to_chars.h>
80# include <__charconv/to_chars_base_10.h>
81# include <__charconv/to_chars_floating_point.h>
82# include <__charconv/to_chars_integral.h>
83# include <__charconv/to_chars_result.h>
84# include <__charconv/traits.h>
85#endif // _LIBCPP_STD_VER >= 17
8675
87#include <version>76*/
8877
89#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)78#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
90# pragma GCC system_header79# include <__cxx03/charconv>
91#endif80#else
81# include <__config>
82
83# if _LIBCPP_STD_VER >= 17
84# include <__charconv/chars_format.h>
85# include <__charconv/from_chars_floating_point.h>
86# include <__charconv/from_chars_integral.h>
87# include <__charconv/from_chars_result.h>
88# include <__charconv/tables.h>
89# include <__charconv/to_chars.h>
90# include <__charconv/to_chars_base_10.h>
91# include <__charconv/to_chars_floating_point.h>
92# include <__charconv/to_chars_integral.h>
93# include <__charconv/to_chars_result.h>
94# include <__charconv/traits.h>
95# endif // _LIBCPP_STD_VER >= 17
96
97# include <version>
98
99# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
100# pragma GCC system_header
101# endif
92102
93_LIBCPP_BEGIN_NAMESPACE_STD103_LIBCPP_BEGIN_NAMESPACE_STD
94104
95_LIBCPP_END_NAMESPACE_STD105_LIBCPP_END_NAMESPACE_STD
96106
97#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14107# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
98# include <cerrno>108# include <cmath>
99# include <cstddef>109# include <concepts>
100# include <initializer_list>110# include <cstddef>
101# include <new>111# include <cstdint>
102#endif112# include <cstdlib>
103113# include <cstring>
104#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20114# include <iosfwd>
105# include <cmath>115# include <limits>
106# include <concepts>116# include <new>
107# include <cstdint>117# include <type_traits>
108# include <cstdlib>118# endif
109# include <cstring>119#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
110# include <iosfwd>
111# include <limits>
112# include <type_traits>
113#endif
114120
115#endif // _LIBCPP_CHARCONV121#endif // _LIBCPP_CHARCONV
lib/libcxx/include/chrono+112-71
...@@ -300,6 +300,41 @@ template<class charT, class traits> // C++20...@@ -300,6 +300,41 @@ template<class charT, class traits> // C++20
300 basic_ostream<charT, traits>&300 basic_ostream<charT, traits>&
301 operator<<(basic_ostream<charT, traits>& os, const sys_days& dp);301 operator<<(basic_ostream<charT, traits>& os, const sys_days& dp);
302302
303// [time.clock.utc], class utc_clock
304class utc_clock { // C++20
305public:
306 using rep = a signed arithmetic type;
307 using period = ratio<unspecified, unspecified>;
308 using duration = chrono::duration<rep, period>;
309 using time_point = chrono::time_point<utc_clock>;
310 static constexpr bool is_steady = unspecified;
311
312 static time_point now();
313
314 template<class Duration>
315 static sys_time<common_type_t<Duration, seconds>>
316 to_sys(const utc_time<Duration>& t);
317 template<class Duration>
318 static utc_time<common_type_t<Duration, seconds>>
319 from_sys(const sys_time<Duration>& t);
320};
321
322template<class Duration>
323using utc_time = time_point<utc_clock, Duration>; // C++20
324using utc_seconds = utc_time<seconds>; // C++20
325
326template<class charT, class traits, class Duration> // C++20
327 basic_ostream<charT, traits>&
328 operator<<(basic_ostream<charT, traits>& os, const utc_time<Duration>& t);
329
330struct leap_second_info { // C++20
331 bool is_leap_second;
332 seconds elapsed;
333};
334
335template<class Duration> // C++20
336 leap_second_info get_leap_second_info(const utc_time<Duration>& ut);
337
303class file_clock // C++20338class file_clock // C++20
304{339{
305public:340public:
...@@ -861,6 +896,8 @@ strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y);...@@ -861,6 +896,8 @@ strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y);
861namespace std {896namespace std {
862 template<class Duration, class charT>897 template<class Duration, class charT>
863 struct formatter<chrono::sys_time<Duration>, charT>; // C++20898 struct formatter<chrono::sys_time<Duration>, charT>; // C++20
899 template<class Duration, class charT>
900 struct formatter<chrono::utc_time<Duration>, charT>; // C++20
864 template<class Duration, class charT>901 template<class Duration, class charT>
865 struct formatter<chrono::filetime<Duration>, charT>; // C++20902 struct formatter<chrono::filetime<Duration>, charT>; // C++20
866 template<class Duration, class charT>903 template<class Duration, class charT>
...@@ -939,84 +976,88 @@ constexpr chrono::year operator ""y(unsigned lo...@@ -939,84 +976,88 @@ constexpr chrono::year operator ""y(unsigned lo
939976
940// clang-format on977// clang-format on
941978
942#include <__config>979#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
943980# include <__cxx03/chrono>
944#include <__chrono/duration.h>981#else
945#include <__chrono/file_clock.h>982# include <__config>
946#include <__chrono/high_resolution_clock.h>983
947#include <__chrono/steady_clock.h>984# include <__chrono/duration.h>
948#include <__chrono/system_clock.h>985# include <__chrono/file_clock.h>
949#include <__chrono/time_point.h>986# include <__chrono/high_resolution_clock.h>
950987# include <__chrono/steady_clock.h>
951#if _LIBCPP_STD_VER >= 20988# include <__chrono/system_clock.h>
952# include <__chrono/calendar.h>989# include <__chrono/time_point.h>
953# include <__chrono/day.h>990
954# include <__chrono/exception.h>991# if _LIBCPP_STD_VER >= 20
955# include <__chrono/hh_mm_ss.h>992# include <__chrono/calendar.h>
956# include <__chrono/literals.h>993# include <__chrono/day.h>
957# include <__chrono/local_info.h>994# include <__chrono/exception.h>
958# include <__chrono/month.h>995# include <__chrono/hh_mm_ss.h>
959# include <__chrono/month_weekday.h>996# include <__chrono/literals.h>
960# include <__chrono/monthday.h>997# include <__chrono/local_info.h>
961# include <__chrono/sys_info.h>998# include <__chrono/month.h>
962# include <__chrono/weekday.h>999# include <__chrono/month_weekday.h>
963# include <__chrono/year.h>1000# include <__chrono/monthday.h>
964# include <__chrono/year_month.h>1001# include <__chrono/sys_info.h>
965# include <__chrono/year_month_day.h>1002# include <__chrono/weekday.h>
966# include <__chrono/year_month_weekday.h>1003# include <__chrono/year.h>
9671004# include <__chrono/year_month.h>
968# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)1005# include <__chrono/year_month_day.h>
969# include <__chrono/formatter.h>1006# include <__chrono/year_month_weekday.h>
970# include <__chrono/ostream.h>1007
971# include <__chrono/parser_std_format_spec.h>1008# if _LIBCPP_HAS_LOCALIZATION
972# include <__chrono/statically_widen.h>1009# include <__chrono/formatter.h>
973# endif1010# include <__chrono/ostream.h>
1011# include <__chrono/parser_std_format_spec.h>
1012# include <__chrono/statically_widen.h>
1013# endif
1014
1015# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
1016# include <__chrono/leap_second.h>
1017# include <__chrono/time_zone.h>
1018# include <__chrono/time_zone_link.h>
1019# include <__chrono/tzdb.h>
1020# include <__chrono/tzdb_list.h>
1021# include <__chrono/utc_clock.h>
1022# include <__chrono/zoned_time.h>
1023# endif
9741024
975# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
976 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
977# include <__chrono/leap_second.h>
978# include <__chrono/time_zone.h>
979# include <__chrono/time_zone_link.h>
980# include <__chrono/tzdb.h>
981# include <__chrono/tzdb_list.h>
982# include <__chrono/zoned_time.h>
983# endif1025# endif
9841026
985#endif1027# include <version>
986
987#include <version>
9881028
989// standard-mandated includes1029// standard-mandated includes
9901030
991// [time.syn]1031// [time.syn]
992#include <compare>1032# include <compare>
9931033
994#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)1034# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
995# pragma GCC system_header1035# pragma GCC system_header
996#endif1036# endif
9971037
998#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 171038# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
999# include <cstdint>1039# include <cstdint>
1000# include <stdexcept>1040# include <stdexcept>
1001# include <string_view>1041# include <string_view>
1002# include <vector>1042# endif
1003#endif1043
10041044# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1005#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 201045# include <bit>
1006# include <bit>1046# include <concepts>
1007# include <concepts>1047# include <cstring>
1008# include <cstring>1048# include <forward_list>
1009# include <forward_list>1049# include <string>
1010# include <string>1050# include <tuple>
1011# include <tuple>1051# include <vector>
1012#endif1052# endif
10131053
1014#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 201054# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20
1015# include <charconv>1055# include <charconv>
1016# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)1056# if _LIBCPP_HAS_LOCALIZATION
1017# include <locale>1057# include <locale>
1018# include <ostream>1058# include <ostream>
1059# endif
1019# endif1060# endif
1020#endif1061#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
10211062
1022#endif // _LIBCPP_CHRONO1063#endif // _LIBCPP_CHRONO
lib/libcxx/include/cinttypes+13-8
...@@ -234,26 +234,29 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int...@@ -234,26 +234,29 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
234} // std234} // std
235*/235*/
236236
237#include <__config>237#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
238# include <__cxx03/cinttypes>
239#else
240# include <__config>
238241
239// standard-mandated includes242// standard-mandated includes
240243
241// [cinttypes.syn]244// [cinttypes.syn]
242#include <cstdint>245# include <cstdint>
243246
244#include <inttypes.h>247# include <inttypes.h>
245248
246#ifndef _LIBCPP_INTTYPES_H249# ifndef _LIBCPP_INTTYPES_H
247# error <cinttypes> tried including <inttypes.h> but didn't find libc++'s <inttypes.h> header. \250# error <cinttypes> tried including <inttypes.h> but didn't find libc++'s <inttypes.h> header. \
248 This usually means that your header search paths are not configured properly. \251 This usually means that your header search paths are not configured properly. \
249 The header search paths should contain the C++ Standard Library headers before \252 The header search paths should contain the C++ Standard Library headers before \
250 any C Standard Library, and you are probably using compiler flags that make that \253 any C Standard Library, and you are probably using compiler flags that make that \
251 not be the case.254 not be the case.
252#endif255# endif
253256
254#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)257# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
255# pragma GCC system_header258# pragma GCC system_header
256#endif259# endif
257260
258_LIBCPP_BEGIN_NAMESPACE_STD261_LIBCPP_BEGIN_NAMESPACE_STD
259262
...@@ -267,4 +270,6 @@ using ::wcstoumax _LIBCPP_USING_IF_EXISTS;...@@ -267,4 +270,6 @@ using ::wcstoumax _LIBCPP_USING_IF_EXISTS;
267270
268_LIBCPP_END_NAMESPACE_STD271_LIBCPP_END_NAMESPACE_STD
269272
273#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
274
270#endif // _LIBCPP_CINTTYPES275#endif // _LIBCPP_CINTTYPES
lib/libcxx/include/ciso646+16-4
...@@ -15,10 +15,22 @@...@@ -15,10 +15,22 @@
1515
16*/16*/
1717
18#include <__config>18#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
19# include <__cxx03/ciso646>
20#else
21# include <__config>
1922
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header24# pragma GCC system_header
22#endif25# endif
26
27# if _LIBCPP_STD_VER >= 20
28
29using __standard_header_ciso646
30 _LIBCPP_DEPRECATED_("removed in C++20. Include <version> instead.") _LIBCPP_NODEBUG = void;
31using __use_standard_header_ciso646 _LIBCPP_NODEBUG = __standard_header_ciso646;
32
33# endif
34#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
2335
24#endif // _LIBCPP_CISO64636#endif // _LIBCPP_CISO646
lib/libcxx/include/climits+10-5
...@@ -37,12 +37,17 @@ Macros:...@@ -37,12 +37,17 @@ Macros:
3737
38*/38*/
3939
40#include <__config>40#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
41# include <__cxx03/climits>
42#else
43# include <__config>
4144
42#include <limits.h>45# include <limits.h>
4346
44#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)47# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
45# pragma GCC system_header48# pragma GCC system_header
46#endif49# endif
50
51#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
4752
48#endif // _LIBCPP_CLIMITS53#endif // _LIBCPP_CLIMITS
lib/libcxx/include/clocale+12-13
...@@ -34,21 +34,18 @@ lconv* localeconv();...@@ -34,21 +34,18 @@ lconv* localeconv();
3434
35*/35*/
3636
37#include <__config>37#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
38# include <__cxx03/clocale>
39#else
40# include <__config>
3841
39#include <locale.h>42# if __has_include(<locale.h>)
43# include <locale.h>
44# endif
4045
41#ifndef _LIBCPP_LOCALE_H46# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
42# error <clocale> tried including <locale.h> but didn't find libc++'s <locale.h> header. \47# pragma GCC system_header
43 This usually means that your header search paths are not configured properly. \48# endif
44 The header search paths should contain the C++ Standard Library headers before \
45 any C Standard Library, and you are probably using compiler flags that make that \
46 not be the case.
47#endif
48
49#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
50# pragma GCC system_header
51#endif
5249
53_LIBCPP_BEGIN_NAMESPACE_STD50_LIBCPP_BEGIN_NAMESPACE_STD
5451
...@@ -58,4 +55,6 @@ using ::localeconv _LIBCPP_USING_IF_EXISTS;...@@ -58,4 +55,6 @@ using ::localeconv _LIBCPP_USING_IF_EXISTS;
5855
59_LIBCPP_END_NAMESPACE_STD56_LIBCPP_END_NAMESPACE_STD
6057
58#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
59
61#endif // _LIBCPP_CLOCALE60#endif // _LIBCPP_CLOCALE
lib/libcxx/include/cmath+33-57
...@@ -312,35 +312,38 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept...@@ -312,35 +312,38 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept
312312
313*/313*/
314314
315#include <__config>315#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
316#include <__math/hypot.h>316# include <__cxx03/cmath>
317#include <__type_traits/enable_if.h>317#else
318#include <__type_traits/is_arithmetic.h>318# include <__config>
319#include <__type_traits/is_constant_evaluated.h>319# include <__math/hypot.h>
320#include <__type_traits/is_floating_point.h>320# include <__type_traits/enable_if.h>
321#include <__type_traits/is_same.h>321# include <__type_traits/is_arithmetic.h>
322#include <__type_traits/promote.h>322# include <__type_traits/is_constant_evaluated.h>
323#include <__type_traits/remove_cv.h>323# include <__type_traits/is_floating_point.h>
324#include <limits>324# include <__type_traits/is_same.h>
325#include <version>325# include <__type_traits/promote.h>
326326# include <__type_traits/remove_cv.h>
327#include <__math/special_functions.h>327# include <limits>
328#include <math.h>328# include <version>
329329
330#ifndef _LIBCPP_MATH_H330# include <__math/special_functions.h>
331# include <math.h>
332
333# ifndef _LIBCPP_MATH_H
331# error <cmath> tried including <math.h> but didn't find libc++'s <math.h> header. \334# error <cmath> tried including <math.h> but didn't find libc++'s <math.h> header. \
332 This usually means that your header search paths are not configured properly. \335 This usually means that your header search paths are not configured properly. \
333 The header search paths should contain the C++ Standard Library headers before \336 The header search paths should contain the C++ Standard Library headers before \
334 any C Standard Library, and you are probably using compiler flags that make that \337 any C Standard Library, and you are probably using compiler flags that make that \
335 not be the case.338 not be the case.
336#endif339# endif
337340
338#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)341# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
339# pragma GCC system_header342# pragma GCC system_header
340#endif343# endif
341344
342_LIBCPP_PUSH_MACROS345_LIBCPP_PUSH_MACROS
343#include <__undef_macros>346# include <__undef_macros>
344347
345_LIBCPP_BEGIN_NAMESPACE_STD348_LIBCPP_BEGIN_NAMESPACE_STD
346349
...@@ -554,27 +557,13 @@ using ::scalbnl _LIBCPP_USING_IF_EXISTS;...@@ -554,27 +557,13 @@ using ::scalbnl _LIBCPP_USING_IF_EXISTS;
554using ::tgammal _LIBCPP_USING_IF_EXISTS;557using ::tgammal _LIBCPP_USING_IF_EXISTS;
555using ::truncl _LIBCPP_USING_IF_EXISTS;558using ::truncl _LIBCPP_USING_IF_EXISTS;
556559
557template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>
558_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT {
559#if __has_builtin(__builtin_isnan)
560 return __builtin_isnan(__lcpp_x);
561#else
562 return isnan(__lcpp_x);
563#endif
564}
565
566template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0>
567_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT {
568 return std::isnan(__lcpp_x);
569}
570
571template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>560template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>
572_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT {561_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT {
573#if __has_builtin(__builtin_isinf)562# if __has_builtin(__builtin_isinf)
574 return __builtin_isinf(__lcpp_x);563 return __builtin_isinf(__lcpp_x);
575#else564# else
576 return isinf(__lcpp_x);565 return isinf(__lcpp_x);
577#endif566# endif
578}567}
579568
580template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0>569template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0>
...@@ -582,21 +571,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NO...@@ -582,21 +571,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NO
582 return std::isinf(__lcpp_x);571 return std::isinf(__lcpp_x);
583}572}
584573
585template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>574# if _LIBCPP_STD_VER >= 20
586_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT {
587#if __has_builtin(__builtin_isfinite)
588 return __builtin_isfinite(__lcpp_x);
589#else
590 return isfinite(__lcpp_x);
591#endif
592}
593
594template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0>
595_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT {
596 return __builtin_isfinite(__lcpp_x);
597}
598
599#if _LIBCPP_STD_VER >= 20
600template <typename _Fp>575template <typename _Fp>
601_LIBCPP_HIDE_FROM_ABI constexpr _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {576_LIBCPP_HIDE_FROM_ABI constexpr _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
602 if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))577 if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
...@@ -633,14 +608,15 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr...@@ -633,14 +608,15 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr
633 _IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value));608 _IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value));
634 return std::__lerp((__result_type)__a, (__result_type)__b, (__result_type)__t);609 return std::__lerp((__result_type)__a, (__result_type)__b, (__result_type)__t);
635}610}
636#endif // _LIBCPP_STD_VER >= 20611# endif // _LIBCPP_STD_VER >= 20
637612
638_LIBCPP_END_NAMESPACE_STD613_LIBCPP_END_NAMESPACE_STD
639614
640_LIBCPP_POP_MACROS615_LIBCPP_POP_MACROS
641616
642#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20617# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
643# include <type_traits>618# include <type_traits>
644#endif619# endif
620#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
645621
646#endif // _LIBCPP_CMATH622#endif // _LIBCPP_CMATH
lib/libcxx/include/codecvt+34-30
...@@ -54,15 +54,18 @@ class codecvt_utf8_utf16...@@ -54,15 +54,18 @@ class codecvt_utf8_utf16
5454
55*/55*/
5656
57#include <__config>57#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
58#include <__locale>58# include <__cxx03/codecvt>
59#include <version>59#else
60# include <__config>
61# include <__locale>
62# include <version>
6063
61#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)64# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
62# pragma GCC system_header65# pragma GCC system_header
63#endif66# endif
6467
65#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)68# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
6669
67_LIBCPP_BEGIN_NAMESPACE_STD70_LIBCPP_BEGIN_NAMESPACE_STD
6871
...@@ -73,7 +76,7 @@ enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode { consume_header = 4, generate_hea...@@ -73,7 +76,7 @@ enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode { consume_header = 4, generate_hea
73template <class _Elem>76template <class _Elem>
74class __codecvt_utf8;77class __codecvt_utf8;
7578
76# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS79# if _LIBCPP_HAS_WIDE_CHARACTERS
77template <>80template <>
78class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<wchar_t> : public codecvt<wchar_t, char, mbstate_t> {81class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<wchar_t> : public codecvt<wchar_t, char, mbstate_t> {
79 unsigned long __maxcode_;82 unsigned long __maxcode_;
...@@ -112,7 +115,7 @@ protected:...@@ -112,7 +115,7 @@ protected:
112 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;115 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
113 int do_max_length() const _NOEXCEPT override;116 int do_max_length() const _NOEXCEPT override;
114};117};
115# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS118# endif // _LIBCPP_HAS_WIDE_CHARACTERS
116119
117_LIBCPP_SUPPRESS_DEPRECATED_PUSH120_LIBCPP_SUPPRESS_DEPRECATED_PUSH
118template <>121template <>
...@@ -203,7 +206,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -203,7 +206,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
203template <class _Elem, bool _LittleEndian>206template <class _Elem, bool _LittleEndian>
204class __codecvt_utf16;207class __codecvt_utf16;
205208
206# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS209# if _LIBCPP_HAS_WIDE_CHARACTERS
207template <>210template <>
208class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<wchar_t, false> : public codecvt<wchar_t, char, mbstate_t> {211class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<wchar_t, false> : public codecvt<wchar_t, char, mbstate_t> {
209 unsigned long __maxcode_;212 unsigned long __maxcode_;
...@@ -281,7 +284,7 @@ protected:...@@ -281,7 +284,7 @@ protected:
281 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;284 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
282 int do_max_length() const _NOEXCEPT override;285 int do_max_length() const _NOEXCEPT override;
283};286};
284# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS287# endif // _LIBCPP_HAS_WIDE_CHARACTERS
285288
286_LIBCPP_SUPPRESS_DEPRECATED_PUSH289_LIBCPP_SUPPRESS_DEPRECATED_PUSH
287template <>290template <>
...@@ -448,7 +451,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -448,7 +451,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
448template <class _Elem>451template <class _Elem>
449class __codecvt_utf8_utf16;452class __codecvt_utf8_utf16;
450453
451# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS454# if _LIBCPP_HAS_WIDE_CHARACTERS
452template <>455template <>
453class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<wchar_t> : public codecvt<wchar_t, char, mbstate_t> {456class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<wchar_t> : public codecvt<wchar_t, char, mbstate_t> {
454 unsigned long __maxcode_;457 unsigned long __maxcode_;
...@@ -487,7 +490,7 @@ protected:...@@ -487,7 +490,7 @@ protected:
487 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;490 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
488 int do_max_length() const _NOEXCEPT override;491 int do_max_length() const _NOEXCEPT override;
489};492};
490# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS493# endif // _LIBCPP_HAS_WIDE_CHARACTERS
491494
492_LIBCPP_SUPPRESS_DEPRECATED_PUSH495_LIBCPP_SUPPRESS_DEPRECATED_PUSH
493template <>496template <>
...@@ -576,22 +579,23 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -576,22 +579,23 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
576579
577_LIBCPP_END_NAMESPACE_STD580_LIBCPP_END_NAMESPACE_STD
578581
579#endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)582# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
580583
581#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20584# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
582# include <atomic>585# include <atomic>
583# include <concepts>586# include <concepts>
584# include <cstddef>587# include <cstddef>
585# include <cstdlib>588# include <cstdlib>
586# include <cstring>589# include <cstring>
587# include <initializer_list>590# include <initializer_list>
588# include <iosfwd>591# include <iosfwd>
589# include <limits>592# include <limits>
590# include <mutex>593# include <mutex>
591# include <new>594# include <new>
592# include <stdexcept>595# include <stdexcept>
593# include <type_traits>596# include <type_traits>
594# include <typeinfo>597# include <typeinfo>
595#endif598# endif
599#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
596600
597#endif // _LIBCPP_CODECVT601#endif // _LIBCPP_CODECVT
lib/libcxx/include/compare+33-34
...@@ -140,39 +140,38 @@ namespace std {...@@ -140,39 +140,38 @@ namespace std {
140}140}
141*/141*/
142142
143#include <__config>143#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
144144# include <__cxx03/compare>
145#if _LIBCPP_STD_VER >= 20145#else
146# include <__compare/common_comparison_category.h>146# include <__config>
147# include <__compare/compare_partial_order_fallback.h>147
148# include <__compare/compare_strong_order_fallback.h>148# if _LIBCPP_STD_VER >= 20
149# include <__compare/compare_three_way.h>149# include <__compare/common_comparison_category.h>
150# include <__compare/compare_three_way_result.h>150# include <__compare/compare_partial_order_fallback.h>
151# include <__compare/compare_weak_order_fallback.h>151# include <__compare/compare_strong_order_fallback.h>
152# include <__compare/is_eq.h>152# include <__compare/compare_three_way.h>
153# include <__compare/ordering.h>153# include <__compare/compare_three_way_result.h>
154# include <__compare/partial_order.h>154# include <__compare/compare_weak_order_fallback.h>
155# include <__compare/strong_order.h>155# include <__compare/is_eq.h>
156# include <__compare/synth_three_way.h>156# include <__compare/ordering.h>
157# include <__compare/three_way_comparable.h>157# include <__compare/partial_order.h>
158# include <__compare/weak_order.h>158# include <__compare/strong_order.h>
159#endif // _LIBCPP_STD_VER >= 20159# include <__compare/synth_three_way.h>
160160# include <__compare/three_way_comparable.h>
161#include <version>161# include <__compare/weak_order.h>
162162# endif // _LIBCPP_STD_VER >= 20
163#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)163
164# pragma GCC system_header164# include <version>
165#endif165
166166# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
167#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17167# pragma GCC system_header
168# include <cstddef>168# endif
169# include <cstdint>169
170# include <limits>170# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
171#endif171# include <cmath>
172172# include <cstddef>
173#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20173# include <type_traits>
174# include <cmath>174# endif
175# include <type_traits>175#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
176#endif
177176
178#endif // _LIBCPP_COMPARE177#endif // _LIBCPP_COMPARE
lib/libcxx/include/complex+100-98
...@@ -256,26 +256,29 @@ template<class T> complex<T> tanh (const complex<T>&);...@@ -256,26 +256,29 @@ template<class T> complex<T> tanh (const complex<T>&);
256256
257*/257*/
258258
259#include <__config>259#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
260#include <__fwd/complex.h>260# include <__cxx03/complex>
261#include <__fwd/tuple.h>261#else
262#include <__tuple/tuple_element.h>262# include <__config>
263#include <__tuple/tuple_size.h>263# include <__fwd/complex.h>
264#include <__type_traits/conditional.h>264# include <__fwd/tuple.h>
265#include <__utility/move.h>265# include <__tuple/tuple_element.h>
266#include <cmath>266# include <__tuple/tuple_size.h>
267#include <version>267# include <__type_traits/conditional.h>
268268# include <__utility/move.h>
269#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)269# include <cmath>
270# include <sstream> // for std::basic_ostringstream270# include <version>
271#endif271
272272# if _LIBCPP_HAS_LOCALIZATION
273#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)273# include <sstream> // for std::basic_ostringstream
274# pragma GCC system_header274# endif
275#endif275
276# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
277# pragma GCC system_header
278# endif
276279
277_LIBCPP_PUSH_MACROS280_LIBCPP_PUSH_MACROS
278#include <__undef_macros>281# include <__undef_macros>
279282
280_LIBCPP_BEGIN_NAMESPACE_STD283_LIBCPP_BEGIN_NAMESPACE_STD
281284
...@@ -374,7 +377,7 @@ public:...@@ -374,7 +377,7 @@ public:
374 return *this;377 return *this;
375 }378 }
376379
377#if _LIBCPP_STD_VER >= 26380# if _LIBCPP_STD_VER >= 26
378 template <size_t _Ip, class _Xp>381 template <size_t _Ip, class _Xp>
379 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;382 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;
380383
...@@ -386,7 +389,7 @@ public:...@@ -386,7 +389,7 @@ public:
386389
387 template <size_t _Ip, class _Xp>390 template <size_t _Ip, class _Xp>
388 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;391 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;
389#endif392# endif
390};393};
391394
392template <>395template <>
...@@ -397,18 +400,18 @@ class _LIBCPP_TEMPLATE_VIS complex<long double>;...@@ -397,18 +400,18 @@ class _LIBCPP_TEMPLATE_VIS complex<long double>;
397struct __from_builtin_tag {};400struct __from_builtin_tag {};
398401
399template <class _Tp>402template <class _Tp>
400using __complex_t =403using __complex_t _LIBCPP_NODEBUG =
401 __conditional_t<is_same<_Tp, float>::value,404 __conditional_t<is_same<_Tp, float>::value,
402 _Complex float,405 _Complex float,
403 __conditional_t<is_same<_Tp, double>::value, _Complex double, _Complex long double> >;406 __conditional_t<is_same<_Tp, double>::value, _Complex double, _Complex long double> >;
404407
405template <class _Tp>408template <class _Tp>
406_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __complex_t<_Tp> __make_complex(_Tp __re, _Tp __im) {409_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __complex_t<_Tp> __make_complex(_Tp __re, _Tp __im) {
407#if __has_builtin(__builtin_complex)410# if __has_builtin(__builtin_complex)
408 return __builtin_complex(__re, __im);411 return __builtin_complex(__re, __im);
409#else412# else
410 return __complex_t<_Tp>{__re, __im};413 return __complex_t<_Tp>{__re, __im};
411#endif414# endif
412}415}
413416
414template <>417template <>
...@@ -493,7 +496,7 @@ public:...@@ -493,7 +496,7 @@ public:
493 return *this;496 return *this;
494 }497 }
495498
496#if _LIBCPP_STD_VER >= 26499# if _LIBCPP_STD_VER >= 26
497 template <size_t _Ip, class _Xp>500 template <size_t _Ip, class _Xp>
498 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;501 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;
499502
...@@ -505,7 +508,7 @@ public:...@@ -505,7 +508,7 @@ public:
505508
506 template <size_t _Ip, class _Xp>509 template <size_t _Ip, class _Xp>
507 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;510 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;
508#endif511# endif
509};512};
510513
511template <>514template <>
...@@ -593,7 +596,7 @@ public:...@@ -593,7 +596,7 @@ public:
593 return *this;596 return *this;
594 }597 }
595598
596#if _LIBCPP_STD_VER >= 26599# if _LIBCPP_STD_VER >= 26
597 template <size_t _Ip, class _Xp>600 template <size_t _Ip, class _Xp>
598 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;601 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;
599602
...@@ -605,7 +608,7 @@ public:...@@ -605,7 +608,7 @@ public:
605608
606 template <size_t _Ip, class _Xp>609 template <size_t _Ip, class _Xp>
607 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;610 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;
608#endif611# endif
609};612};
610613
611template <>614template <>
...@@ -694,7 +697,7 @@ public:...@@ -694,7 +697,7 @@ public:
694 return *this;697 return *this;
695 }698 }
696699
697#if _LIBCPP_STD_VER >= 26700# if _LIBCPP_STD_VER >= 26
698 template <size_t _Ip, class _Xp>701 template <size_t _Ip, class _Xp>
699 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;702 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;
700703
...@@ -706,7 +709,7 @@ public:...@@ -706,7 +709,7 @@ public:
706709
707 template <size_t _Ip, class _Xp>710 template <size_t _Ip, class _Xp>
708 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;711 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;
709#endif712# endif
710};713};
711714
712inline _LIBCPP_CONSTEXPR complex<float>::complex(const complex<double>& __c) : __re_(__c.real()), __im_(__c.imag()) {}715inline _LIBCPP_CONSTEXPR complex<float>::complex(const complex<double>& __c) : __re_(__c.real()), __im_(__c.imag()) {}
...@@ -861,7 +864,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator==(const...@@ -861,7 +864,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator==(const
861 return __x.real() == __y && __x.imag() == 0;864 return __x.real() == __y && __x.imag() == 0;
862}865}
863866
864#if _LIBCPP_STD_VER <= 17867# if _LIBCPP_STD_VER <= 17
865868
866template <class _Tp>869template <class _Tp>
867inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator==(const _Tp& __x, const complex<_Tp>& __y) {870inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator==(const _Tp& __x, const complex<_Tp>& __y) {
...@@ -884,7 +887,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator!=(const...@@ -884,7 +887,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator!=(const
884 return !(__x == __y);887 return !(__x == __y);
885}888}
886889
887#endif890# endif
888891
889// 26.3.7 values:892// 26.3.7 values:
890893
...@@ -997,14 +1000,14 @@ conj(_Tp __re) {...@@ -997,14 +1000,14 @@ conj(_Tp __re) {
997template <class _Tp>1000template <class _Tp>
998inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> proj(const complex<_Tp>& __c) {1001inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> proj(const complex<_Tp>& __c) {
999 complex<_Tp> __r = __c;1002 complex<_Tp> __r = __c;
1000 if (std::__constexpr_isinf(__c.real()) || std::__constexpr_isinf(__c.imag()))1003 if (std::isinf(__c.real()) || std::isinf(__c.imag()))
1001 __r = complex<_Tp>(INFINITY, std::copysign(_Tp(0), __c.imag()));1004 __r = complex<_Tp>(INFINITY, std::copysign(_Tp(0), __c.imag()));
1002 return __r;1005 return __r;
1003}1006}
10041007
1005template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>1008template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>
1006inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) {1009inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) {
1007 if (std::__constexpr_isinf(__re))1010 if (std::isinf(__re))
1008 __re = std::abs(__re);1011 __re = std::abs(__re);
1009 return complex<_Tp>(__re);1012 return complex<_Tp>(__re);
1010}1013}
...@@ -1019,23 +1022,23 @@ inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_Co...@@ -1019,23 +1022,23 @@ inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_Co
10191022
1020template <class _Tp>1023template <class _Tp>
1021_LIBCPP_HIDE_FROM_ABI complex<_Tp> polar(const _Tp& __rho, const _Tp& __theta = _Tp()) {1024_LIBCPP_HIDE_FROM_ABI complex<_Tp> polar(const _Tp& __rho, const _Tp& __theta = _Tp()) {
1022 if (std::__constexpr_isnan(__rho) || std::signbit(__rho))1025 if (std::isnan(__rho) || std::signbit(__rho))
1023 return complex<_Tp>(_Tp(NAN), _Tp(NAN));1026 return complex<_Tp>(_Tp(NAN), _Tp(NAN));
1024 if (std::__constexpr_isnan(__theta)) {1027 if (std::isnan(__theta)) {
1025 if (std::__constexpr_isinf(__rho))1028 if (std::isinf(__rho))
1026 return complex<_Tp>(__rho, __theta);1029 return complex<_Tp>(__rho, __theta);
1027 return complex<_Tp>(__theta, __theta);1030 return complex<_Tp>(__theta, __theta);
1028 }1031 }
1029 if (std::__constexpr_isinf(__theta)) {1032 if (std::isinf(__theta)) {
1030 if (std::__constexpr_isinf(__rho))1033 if (std::isinf(__rho))
1031 return complex<_Tp>(__rho, _Tp(NAN));1034 return complex<_Tp>(__rho, _Tp(NAN));
1032 return complex<_Tp>(_Tp(NAN), _Tp(NAN));1035 return complex<_Tp>(_Tp(NAN), _Tp(NAN));
1033 }1036 }
1034 _Tp __x = __rho * std::cos(__theta);1037 _Tp __x = __rho * std::cos(__theta);
1035 if (std::__constexpr_isnan(__x))1038 if (std::isnan(__x))
1036 __x = 0;1039 __x = 0;
1037 _Tp __y = __rho * std::sin(__theta);1040 _Tp __y = __rho * std::sin(__theta);
1038 if (std::__constexpr_isnan(__y))1041 if (std::isnan(__y))
1039 __y = 0;1042 __y = 0;
1040 return complex<_Tp>(__x, __y);1043 return complex<_Tp>(__x, __y);
1041}1044}
...@@ -1058,14 +1061,12 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log10(const complex<_Tp>& __x) {...@@ -1058,14 +1061,12 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log10(const complex<_Tp>& __x) {
10581061
1059template <class _Tp>1062template <class _Tp>
1060_LIBCPP_HIDE_FROM_ABI complex<_Tp> sqrt(const complex<_Tp>& __x) {1063_LIBCPP_HIDE_FROM_ABI complex<_Tp> sqrt(const complex<_Tp>& __x) {
1061 if (std::__constexpr_isinf(__x.imag()))1064 if (std::isinf(__x.imag()))
1062 return complex<_Tp>(_Tp(INFINITY), __x.imag());1065 return complex<_Tp>(_Tp(INFINITY), __x.imag());
1063 if (std::__constexpr_isinf(__x.real())) {1066 if (std::isinf(__x.real())) {
1064 if (__x.real() > _Tp(0))1067 if (__x.real() > _Tp(0))
1065 return complex<_Tp>(1068 return complex<_Tp>(__x.real(), std::isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag()));
1066 __x.real(), std::__constexpr_isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag()));1069 return complex<_Tp>(std::isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag()));
1067 return complex<_Tp>(
1068 std::__constexpr_isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag()));
1069 }1070 }
1070 return std::polar(std::sqrt(std::abs(__x)), std::arg(__x) / _Tp(2));1071 return std::polar(std::sqrt(std::abs(__x)), std::arg(__x) / _Tp(2));
1071}1072}
...@@ -1078,12 +1079,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> exp(const complex<_Tp>& __x) {...@@ -1078,12 +1079,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> exp(const complex<_Tp>& __x) {
1078 if (__i == 0) {1079 if (__i == 0) {
1079 return complex<_Tp>(std::exp(__x.real()), std::copysign(_Tp(0), __x.imag()));1080 return complex<_Tp>(std::exp(__x.real()), std::copysign(_Tp(0), __x.imag()));
1080 }1081 }
1081 if (std::__constexpr_isinf(__x.real())) {1082 if (std::isinf(__x.real())) {
1082 if (__x.real() < _Tp(0)) {1083 if (__x.real() < _Tp(0)) {
1083 if (!std::__constexpr_isfinite(__i))1084 if (!std::isfinite(__i))
1084 __i = _Tp(1);1085 __i = _Tp(1);
1085 } else if (__i == 0 || !std::__constexpr_isfinite(__i)) {1086 } else if (__i == 0 || !std::isfinite(__i)) {
1086 if (std::__constexpr_isinf(__i))1087 if (std::isinf(__i))
1087 __i = _Tp(NAN);1088 __i = _Tp(NAN);
1088 return complex<_Tp>(__x.real(), __i);1089 return complex<_Tp>(__x.real(), __i);
1089 }1090 }
...@@ -1099,20 +1100,20 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> pow(const complex<_Tp>& __x, const com...@@ -1099,20 +1100,20 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> pow(const complex<_Tp>& __x, const com
1099 return std::exp(__y * std::log(__x));1100 return std::exp(__y * std::log(__x));
1100}1101}
11011102
1102template <class _Tp, class _Up>1103template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_floating_point<_Up>::value, int> = 0>
1103inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type>1104inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type>
1104pow(const complex<_Tp>& __x, const complex<_Up>& __y) {1105pow(const complex<_Tp>& __x, const complex<_Up>& __y) {
1105 typedef complex<typename __promote<_Tp, _Up>::type> result_type;1106 typedef complex<typename __promote<_Tp, _Up>::type> result_type;
1106 return std::pow(result_type(__x), result_type(__y));1107 return std::pow(result_type(__x), result_type(__y));
1107}1108}
11081109
1109template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Up>::value, int> = 0>1110template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_arithmetic<_Up>::value, int> = 0>
1110inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const complex<_Tp>& __x, const _Up& __y) {1111inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const complex<_Tp>& __x, const _Up& __y) {
1111 typedef complex<typename __promote<_Tp, _Up>::type> result_type;1112 typedef complex<typename __promote<_Tp, _Up>::type> result_type;
1112 return std::pow(result_type(__x), result_type(__y));1113 return std::pow(result_type(__x), result_type(__y));
1113}1114}
11141115
1115template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value, int> = 0>1116template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_floating_point<_Up>::value, int> = 0>
1116inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const _Tp& __x, const complex<_Up>& __y) {1117inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const _Tp& __x, const complex<_Up>& __y) {
1117 typedef complex<typename __promote<_Tp, _Up>::type> result_type;1118 typedef complex<typename __promote<_Tp, _Up>::type> result_type;
1118 return std::pow(result_type(__x), result_type(__y));1119 return std::pow(result_type(__x), result_type(__y));
...@@ -1130,21 +1131,21 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> __sqr(const complex<_Tp>& __x) {...@@ -1130,21 +1131,21 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> __sqr(const complex<_Tp>& __x) {
1130template <class _Tp>1131template <class _Tp>
1131_LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) {1132_LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) {
1132 const _Tp __pi(atan2(+0., -0.));1133 const _Tp __pi(atan2(+0., -0.));
1133 if (std::__constexpr_isinf(__x.real())) {1134 if (std::isinf(__x.real())) {
1134 if (std::__constexpr_isnan(__x.imag()))1135 if (std::isnan(__x.imag()))
1135 return __x;1136 return __x;
1136 if (std::__constexpr_isinf(__x.imag()))1137 if (std::isinf(__x.imag()))
1137 return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));1138 return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));
1138 return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));1139 return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
1139 }1140 }
1140 if (std::__constexpr_isnan(__x.real())) {1141 if (std::isnan(__x.real())) {
1141 if (std::__constexpr_isinf(__x.imag()))1142 if (std::isinf(__x.imag()))
1142 return complex<_Tp>(__x.imag(), __x.real());1143 return complex<_Tp>(__x.imag(), __x.real());
1143 if (__x.imag() == 0)1144 if (__x.imag() == 0)
1144 return __x;1145 return __x;
1145 return complex<_Tp>(__x.real(), __x.real());1146 return complex<_Tp>(__x.real(), __x.real());
1146 }1147 }
1147 if (std::__constexpr_isinf(__x.imag()))1148 if (std::isinf(__x.imag()))
1148 return complex<_Tp>(std::copysign(__x.imag(), __x.real()), std::copysign(__pi / _Tp(2), __x.imag()));1149 return complex<_Tp>(std::copysign(__x.imag(), __x.real()), std::copysign(__pi / _Tp(2), __x.imag()));
1149 complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) + _Tp(1)));1150 complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) + _Tp(1)));
1150 return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag()));1151 return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag()));
...@@ -1155,10 +1156,10 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) {...@@ -1155,10 +1156,10 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) {
1155template <class _Tp>1156template <class _Tp>
1156_LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) {1157_LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) {
1157 const _Tp __pi(atan2(+0., -0.));1158 const _Tp __pi(atan2(+0., -0.));
1158 if (std::__constexpr_isinf(__x.real())) {1159 if (std::isinf(__x.real())) {
1159 if (std::__constexpr_isnan(__x.imag()))1160 if (std::isnan(__x.imag()))
1160 return complex<_Tp>(std::abs(__x.real()), __x.imag());1161 return complex<_Tp>(std::abs(__x.real()), __x.imag());
1161 if (std::__constexpr_isinf(__x.imag())) {1162 if (std::isinf(__x.imag())) {
1162 if (__x.real() > 0)1163 if (__x.real() > 0)
1163 return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));1164 return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));
1164 else1165 else
...@@ -1168,12 +1169,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) {...@@ -1168,12 +1169,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) {
1168 return complex<_Tp>(-__x.real(), std::copysign(__pi, __x.imag()));1169 return complex<_Tp>(-__x.real(), std::copysign(__pi, __x.imag()));
1169 return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));1170 return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
1170 }1171 }
1171 if (std::__constexpr_isnan(__x.real())) {1172 if (std::isnan(__x.real())) {
1172 if (std::__constexpr_isinf(__x.imag()))1173 if (std::isinf(__x.imag()))
1173 return complex<_Tp>(std::abs(__x.imag()), __x.real());1174 return complex<_Tp>(std::abs(__x.imag()), __x.real());
1174 return complex<_Tp>(__x.real(), __x.real());1175 return complex<_Tp>(__x.real(), __x.real());
1175 }1176 }
1176 if (std::__constexpr_isinf(__x.imag()))1177 if (std::isinf(__x.imag()))
1177 return complex<_Tp>(std::abs(__x.imag()), std::copysign(__pi / _Tp(2), __x.imag()));1178 return complex<_Tp>(std::abs(__x.imag()), std::copysign(__pi / _Tp(2), __x.imag()));
1178 complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1)));1179 complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1)));
1179 return complex<_Tp>(std::copysign(__z.real(), _Tp(0)), std::copysign(__z.imag(), __x.imag()));1180 return complex<_Tp>(std::copysign(__z.real(), _Tp(0)), std::copysign(__z.imag(), __x.imag()));
...@@ -1184,18 +1185,18 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) {...@@ -1184,18 +1185,18 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) {
1184template <class _Tp>1185template <class _Tp>
1185_LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) {1186_LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) {
1186 const _Tp __pi(atan2(+0., -0.));1187 const _Tp __pi(atan2(+0., -0.));
1187 if (std::__constexpr_isinf(__x.imag())) {1188 if (std::isinf(__x.imag())) {
1188 return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag()));1189 return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag()));
1189 }1190 }
1190 if (std::__constexpr_isnan(__x.imag())) {1191 if (std::isnan(__x.imag())) {
1191 if (std::__constexpr_isinf(__x.real()) || __x.real() == 0)1192 if (std::isinf(__x.real()) || __x.real() == 0)
1192 return complex<_Tp>(std::copysign(_Tp(0), __x.real()), __x.imag());1193 return complex<_Tp>(std::copysign(_Tp(0), __x.real()), __x.imag());
1193 return complex<_Tp>(__x.imag(), __x.imag());1194 return complex<_Tp>(__x.imag(), __x.imag());
1194 }1195 }
1195 if (std::__constexpr_isnan(__x.real())) {1196 if (std::isnan(__x.real())) {
1196 return complex<_Tp>(__x.real(), __x.real());1197 return complex<_Tp>(__x.real(), __x.real());
1197 }1198 }
1198 if (std::__constexpr_isinf(__x.real())) {1199 if (std::isinf(__x.real())) {
1199 return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag()));1200 return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag()));
1200 }1201 }
1201 if (std::abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0)) {1202 if (std::abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0)) {
...@@ -1209,11 +1210,11 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) {...@@ -1209,11 +1210,11 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) {
12091210
1210template <class _Tp>1211template <class _Tp>
1211_LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) {1212_LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) {
1212 if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag()))1213 if (std::isinf(__x.real()) && !std::isfinite(__x.imag()))
1213 return complex<_Tp>(__x.real(), _Tp(NAN));1214 return complex<_Tp>(__x.real(), _Tp(NAN));
1214 if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag()))1215 if (__x.real() == 0 && !std::isfinite(__x.imag()))
1215 return complex<_Tp>(__x.real(), _Tp(NAN));1216 return complex<_Tp>(__x.real(), _Tp(NAN));
1216 if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real()))1217 if (__x.imag() == 0 && !std::isfinite(__x.real()))
1217 return __x;1218 return __x;
1218 return complex<_Tp>(std::sinh(__x.real()) * std::cos(__x.imag()), std::cosh(__x.real()) * std::sin(__x.imag()));1219 return complex<_Tp>(std::sinh(__x.real()) * std::cos(__x.imag()), std::cosh(__x.real()) * std::sin(__x.imag()));
1219}1220}
...@@ -1222,13 +1223,13 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) {...@@ -1222,13 +1223,13 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) {
12221223
1223template <class _Tp>1224template <class _Tp>
1224_LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) {1225_LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) {
1225 if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag()))1226 if (std::isinf(__x.real()) && !std::isfinite(__x.imag()))
1226 return complex<_Tp>(std::abs(__x.real()), _Tp(NAN));1227 return complex<_Tp>(std::abs(__x.real()), _Tp(NAN));
1227 if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag()))1228 if (__x.real() == 0 && !std::isfinite(__x.imag()))
1228 return complex<_Tp>(_Tp(NAN), __x.real());1229 return complex<_Tp>(_Tp(NAN), __x.real());
1229 if (__x.real() == 0 && __x.imag() == 0)1230 if (__x.real() == 0 && __x.imag() == 0)
1230 return complex<_Tp>(_Tp(1), __x.imag());1231 return complex<_Tp>(_Tp(1), __x.imag());
1231 if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real()))1232 if (__x.imag() == 0 && !std::isfinite(__x.real()))
1232 return complex<_Tp>(std::abs(__x.real()), __x.imag());1233 return complex<_Tp>(std::abs(__x.real()), __x.imag());
1233 return complex<_Tp>(std::cosh(__x.real()) * std::cos(__x.imag()), std::sinh(__x.real()) * std::sin(__x.imag()));1234 return complex<_Tp>(std::cosh(__x.real()) * std::cos(__x.imag()), std::sinh(__x.real()) * std::sin(__x.imag()));
1234}1235}
...@@ -1237,18 +1238,18 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) {...@@ -1237,18 +1238,18 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) {
12371238
1238template <class _Tp>1239template <class _Tp>
1239_LIBCPP_HIDE_FROM_ABI complex<_Tp> tanh(const complex<_Tp>& __x) {1240_LIBCPP_HIDE_FROM_ABI complex<_Tp> tanh(const complex<_Tp>& __x) {
1240 if (std::__constexpr_isinf(__x.real())) {1241 if (std::isinf(__x.real())) {
1241 if (!std::__constexpr_isfinite(__x.imag()))1242 if (!std::isfinite(__x.imag()))
1242 return complex<_Tp>(std::copysign(_Tp(1), __x.real()), _Tp(0));1243 return complex<_Tp>(std::copysign(_Tp(1), __x.real()), _Tp(0));
1243 return complex<_Tp>(std::copysign(_Tp(1), __x.real()), std::copysign(_Tp(0), std::sin(_Tp(2) * __x.imag())));1244 return complex<_Tp>(std::copysign(_Tp(1), __x.real()), std::copysign(_Tp(0), std::sin(_Tp(2) * __x.imag())));
1244 }1245 }
1245 if (std::__constexpr_isnan(__x.real()) && __x.imag() == 0)1246 if (std::isnan(__x.real()) && __x.imag() == 0)
1246 return __x;1247 return __x;
1247 _Tp __2r(_Tp(2) * __x.real());1248 _Tp __2r(_Tp(2) * __x.real());
1248 _Tp __2i(_Tp(2) * __x.imag());1249 _Tp __2i(_Tp(2) * __x.imag());
1249 _Tp __d(std::cosh(__2r) + std::cos(__2i));1250 _Tp __d(std::cosh(__2r) + std::cos(__2i));
1250 _Tp __2rsh(std::sinh(__2r));1251 _Tp __2rsh(std::sinh(__2r));
1251 if (std::__constexpr_isinf(__2rsh) && std::__constexpr_isinf(__d))1252 if (std::isinf(__2rsh) && std::isinf(__d))
1252 return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1), __2i > _Tp(0) ? _Tp(0) : _Tp(-0.));1253 return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1), __2i > _Tp(0) ? _Tp(0) : _Tp(-0.));
1253 return complex<_Tp>(__2rsh / __d, std::sin(__2i) / __d);1254 return complex<_Tp>(__2rsh / __d, std::sin(__2i) / __d);
1254}1255}
...@@ -1266,10 +1267,10 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asin(const complex<_Tp>& __x) {...@@ -1266,10 +1267,10 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asin(const complex<_Tp>& __x) {
1266template <class _Tp>1267template <class _Tp>
1267_LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) {1268_LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) {
1268 const _Tp __pi(atan2(+0., -0.));1269 const _Tp __pi(atan2(+0., -0.));
1269 if (std::__constexpr_isinf(__x.real())) {1270 if (std::isinf(__x.real())) {
1270 if (std::__constexpr_isnan(__x.imag()))1271 if (std::isnan(__x.imag()))
1271 return complex<_Tp>(__x.imag(), __x.real());1272 return complex<_Tp>(__x.imag(), __x.real());
1272 if (std::__constexpr_isinf(__x.imag())) {1273 if (std::isinf(__x.imag())) {
1273 if (__x.real() < _Tp(0))1274 if (__x.real() < _Tp(0))
1274 return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());1275 return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
1275 return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag());1276 return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag());
...@@ -1278,12 +1279,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) {...@@ -1278,12 +1279,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) {
1278 return complex<_Tp>(__pi, std::signbit(__x.imag()) ? -__x.real() : __x.real());1279 return complex<_Tp>(__pi, std::signbit(__x.imag()) ? -__x.real() : __x.real());
1279 return complex<_Tp>(_Tp(0), std::signbit(__x.imag()) ? __x.real() : -__x.real());1280 return complex<_Tp>(_Tp(0), std::signbit(__x.imag()) ? __x.real() : -__x.real());
1280 }1281 }
1281 if (std::__constexpr_isnan(__x.real())) {1282 if (std::isnan(__x.real())) {
1282 if (std::__constexpr_isinf(__x.imag()))1283 if (std::isinf(__x.imag()))
1283 return complex<_Tp>(__x.real(), -__x.imag());1284 return complex<_Tp>(__x.real(), -__x.imag());
1284 return complex<_Tp>(__x.real(), __x.real());1285 return complex<_Tp>(__x.real(), __x.real());
1285 }1286 }
1286 if (std::__constexpr_isinf(__x.imag()))1287 if (std::isinf(__x.imag()))
1287 return complex<_Tp>(__pi / _Tp(2), -__x.imag());1288 return complex<_Tp>(__pi / _Tp(2), -__x.imag());
1288 if (__x.real() == 0 && (__x.imag() == 0 || std::isnan(__x.imag())))1289 if (__x.real() == 0 && (__x.imag() == 0 || std::isnan(__x.imag())))
1289 return complex<_Tp>(__pi / _Tp(2), -__x.imag());1290 return complex<_Tp>(__pi / _Tp(2), -__x.imag());
...@@ -1324,7 +1325,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> tan(const complex<_Tp>& __x) {...@@ -1324,7 +1325,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> tan(const complex<_Tp>& __x) {
1324 return complex<_Tp>(__z.imag(), -__z.real());1325 return complex<_Tp>(__z.imag(), -__z.real());
1325}1326}
13261327
1327#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)1328# if _LIBCPP_HAS_LOCALIZATION
1328template <class _Tp, class _CharT, class _Traits>1329template <class _Tp, class _CharT, class _Traits>
1329_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&1330_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
1330operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) {1331operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) {
...@@ -1381,9 +1382,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) {...@@ -1381,9 +1382,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) {
1381 __s << '(' << __x.real() << ',' << __x.imag() << ')';1382 __s << '(' << __x.real() << ',' << __x.imag() << ')';
1382 return __os << __s.str();1383 return __os << __s.str();
1383}1384}
1384#endif // !_LIBCPP_HAS_NO_LOCALIZATION1385# endif // _LIBCPP_HAS_LOCALIZATION
13851386
1386#if _LIBCPP_STD_VER >= 261387# if _LIBCPP_STD_VER >= 26
13871388
1388// [complex.tuple], tuple interface1389// [complex.tuple], tuple interface
13891390
...@@ -1436,9 +1437,9 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&& __z) noexce...@@ -1436,9 +1437,9 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&& __z) noexce
1436 }1437 }
1437}1438}
14381439
1439#endif // _LIBCPP_STD_VER >= 261440# endif // _LIBCPP_STD_VER >= 26
14401441
1441#if _LIBCPP_STD_VER >= 141442# if _LIBCPP_STD_VER >= 14
1442// Literal suffix for complex number literals [complex.literals]1443// Literal suffix for complex number literals [complex.literals]
1443inline namespace literals {1444inline namespace literals {
1444inline namespace complex_literals {1445inline namespace complex_literals {
...@@ -1465,16 +1466,17 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(unsigned long...@@ -1465,16 +1466,17 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(unsigned long
1465}1466}
1466} // namespace complex_literals1467} // namespace complex_literals
1467} // namespace literals1468} // namespace literals
1468#endif1469# endif
14691470
1470_LIBCPP_END_NAMESPACE_STD1471_LIBCPP_END_NAMESPACE_STD
14711472
1472_LIBCPP_POP_MACROS1473_LIBCPP_POP_MACROS
14731474
1474#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 201475# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1475# include <iosfwd>1476# include <iosfwd>
1476# include <stdexcept>1477# include <stdexcept>
1477# include <type_traits>1478# include <type_traits>
1478#endif1479# endif
1480#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
14791481
1480#endif // _LIBCPP_COMPLEX1482#endif // _LIBCPP_COMPLEX
lib/libcxx/include/complex.h+15-11
...@@ -17,16 +17,20 @@...@@ -17,16 +17,20 @@
1717
18*/18*/
1919
20#include <__config>20#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
2121# include <__cxx03/complex.h>
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#else
23# pragma GCC system_header23# include <__config>
24#endif24
2525# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26#ifdef __cplusplus26# pragma GCC system_header
27# include <ccomplex>27# endif
28#elif __has_include_next(<complex.h>)28
29# include_next <complex.h>29# ifdef __cplusplus
30#endif30# include <complex>
31# elif __has_include_next(<complex.h>)
32# include_next <complex.h>
33# endif
34#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
3135
32#endif // _LIBCPP_COMPLEX_H36#endif // _LIBCPP_COMPLEX_H
lib/libcxx/include/concepts+41-40
...@@ -129,45 +129,46 @@ namespace std {...@@ -129,45 +129,46 @@ namespace std {
129129
130*/130*/
131131
132#include <__config>132#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
133133# include <__cxx03/concepts>
134#if _LIBCPP_STD_VER >= 20134#else
135# include <__concepts/arithmetic.h>135# include <__config>
136# include <__concepts/assignable.h>136
137# include <__concepts/boolean_testable.h>137# if _LIBCPP_STD_VER >= 20
138# include <__concepts/class_or_enum.h>138# include <__concepts/arithmetic.h>
139# include <__concepts/common_reference_with.h>139# include <__concepts/assignable.h>
140# include <__concepts/common_with.h>140# include <__concepts/boolean_testable.h>
141# include <__concepts/constructible.h>141# include <__concepts/class_or_enum.h>
142# include <__concepts/convertible_to.h>142# include <__concepts/common_reference_with.h>
143# include <__concepts/copyable.h>143# include <__concepts/common_with.h>
144# include <__concepts/derived_from.h>144# include <__concepts/constructible.h>
145# include <__concepts/destructible.h>145# include <__concepts/convertible_to.h>
146# include <__concepts/different_from.h>146# include <__concepts/copyable.h>
147# include <__concepts/equality_comparable.h>147# include <__concepts/derived_from.h>
148# include <__concepts/invocable.h>148# include <__concepts/destructible.h>
149# include <__concepts/movable.h>149# include <__concepts/different_from.h>
150# include <__concepts/predicate.h>150# include <__concepts/equality_comparable.h>
151# include <__concepts/regular.h>151# include <__concepts/invocable.h>
152# include <__concepts/relation.h>152# include <__concepts/movable.h>
153# include <__concepts/same_as.h>153# include <__concepts/predicate.h>
154# include <__concepts/semiregular.h>154# include <__concepts/regular.h>
155# include <__concepts/swappable.h>155# include <__concepts/relation.h>
156# include <__concepts/totally_ordered.h>156# include <__concepts/same_as.h>
157#endif // _LIBCPP_STD_VER >= 20157# include <__concepts/semiregular.h>
158158# include <__concepts/swappable.h>
159#include <version>159# include <__concepts/totally_ordered.h>
160160# endif // _LIBCPP_STD_VER >= 20
161#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17161
162# include <cstddef>162# include <version>
163#endif163
164164# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
165#if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)165# include <cstddef>
166# include <type_traits>166# include <type_traits>
167#endif167# endif
168168
169#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)169# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
170# pragma GCC system_header170# pragma GCC system_header
171#endif171# endif
172#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
172173
173#endif // _LIBCPP_CONCEPTS174#endif // _LIBCPP_CONCEPTS
lib/libcxx/include/condition_variable+43-39
...@@ -118,29 +118,32 @@ public:...@@ -118,29 +118,32 @@ public:
118118
119*/119*/
120120
121#include <__chrono/duration.h>121#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
122#include <__chrono/steady_clock.h>122# include <__cxx03/condition_variable>
123#include <__chrono/time_point.h>123#else
124#include <__condition_variable/condition_variable.h>124# include <__chrono/duration.h>
125#include <__config>125# include <__chrono/steady_clock.h>
126#include <__memory/shared_ptr.h>126# include <__chrono/time_point.h>
127#include <__mutex/lock_guard.h>127# include <__condition_variable/condition_variable.h>
128#include <__mutex/mutex.h>128# include <__config>
129#include <__mutex/tag_types.h>129# include <__memory/shared_ptr.h>
130#include <__mutex/unique_lock.h>130# include <__mutex/lock_guard.h>
131#include <__stop_token/stop_callback.h>131# include <__mutex/mutex.h>
132#include <__stop_token/stop_token.h>132# include <__mutex/tag_types.h>
133#include <__utility/move.h>133# include <__mutex/unique_lock.h>
134#include <version>134# include <__stop_token/stop_callback.h>
135135# include <__stop_token/stop_token.h>
136#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)136# include <__utility/move.h>
137# pragma GCC system_header137# include <version>
138#endif138
139# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
140# pragma GCC system_header
141# endif
139142
140_LIBCPP_PUSH_MACROS143_LIBCPP_PUSH_MACROS
141#include <__undef_macros>144# include <__undef_macros>
142145
143#ifndef _LIBCPP_HAS_NO_THREADS146# if _LIBCPP_HAS_THREADS
144147
145_LIBCPP_BEGIN_NAMESPACE_STD148_LIBCPP_BEGIN_NAMESPACE_STD
146149
...@@ -173,7 +176,7 @@ public:...@@ -173,7 +176,7 @@ public:
173 template <class _Lock, class _Rep, class _Period, class _Predicate>176 template <class _Lock, class _Rep, class _Period, class _Predicate>
174 bool _LIBCPP_HIDE_FROM_ABI wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred);177 bool _LIBCPP_HIDE_FROM_ABI wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred);
175178
176# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN)179# if _LIBCPP_STD_VER >= 20
177180
178 template <class _Lock, class _Predicate>181 template <class _Lock, class _Predicate>
179 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool wait(_Lock& __lock, stop_token __stoken, _Predicate __pred);182 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool wait(_Lock& __lock, stop_token __stoken, _Predicate __pred);
...@@ -186,7 +189,7 @@ public:...@@ -186,7 +189,7 @@ public:
186 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool189 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool
187 wait_for(_Lock& __lock, stop_token __stoken, const chrono::duration<_Rep, _Period>& __rel_time, _Predicate __pred);190 wait_for(_Lock& __lock, stop_token __stoken, const chrono::duration<_Rep, _Period>& __rel_time, _Predicate __pred);
188191
189# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN)192# endif // _LIBCPP_STD_VER >= 20
190};193};
191194
192inline condition_variable_any::condition_variable_any() : __mut_(make_shared<mutex>()) {}195inline condition_variable_any::condition_variable_any() : __mut_(make_shared<mutex>()) {}
...@@ -260,7 +263,7 @@ condition_variable_any::wait_for(_Lock& __lock, const chrono::duration<_Rep, _Pe...@@ -260,7 +263,7 @@ condition_variable_any::wait_for(_Lock& __lock, const chrono::duration<_Rep, _Pe
260 return wait_until(__lock, chrono::steady_clock::now() + __d, std::move(__pred));263 return wait_until(__lock, chrono::steady_clock::now() + __d, std::move(__pred));
261}264}
262265
263# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN)266# if _LIBCPP_STD_VER >= 20
264267
265template <class _Lock, class _Predicate>268template <class _Lock, class _Predicate>
266bool condition_variable_any::wait(_Lock& __user_lock, stop_token __stoken, _Predicate __pred) {269bool condition_variable_any::wait(_Lock& __user_lock, stop_token __stoken, _Predicate __pred) {
...@@ -341,29 +344,30 @@ bool condition_variable_any::wait_for(...@@ -341,29 +344,30 @@ bool condition_variable_any::wait_for(
341 return wait_until(__lock, std::move(__stoken), chrono::steady_clock::now() + __rel_time, std::move(__pred));344 return wait_until(__lock, std::move(__stoken), chrono::steady_clock::now() + __rel_time, std::move(__pred));
342}345}
343346
344# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN)347# endif // _LIBCPP_STD_VER >= 20
345348
346_LIBCPP_EXPORTED_FROM_ABI void notify_all_at_thread_exit(condition_variable&, unique_lock<mutex>);349_LIBCPP_EXPORTED_FROM_ABI void notify_all_at_thread_exit(condition_variable&, unique_lock<mutex>);
347350
348_LIBCPP_END_NAMESPACE_STD351_LIBCPP_END_NAMESPACE_STD
349352
350#endif // !_LIBCPP_HAS_NO_THREADS353# endif // _LIBCPP_HAS_THREADS
351354
352_LIBCPP_POP_MACROS355_LIBCPP_POP_MACROS
353356
354#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20357# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
355# include <atomic>358# include <atomic>
356# include <concepts>359# include <concepts>
357# include <cstdint>360# include <cstdint>
358# include <cstdlib>361# include <cstdlib>
359# include <cstring>362# include <cstring>
360# include <initializer_list>363# include <initializer_list>
361# include <iosfwd>364# include <iosfwd>
362# include <new>365# include <new>
363# include <stdexcept>366# include <stdexcept>
364# include <system_error>367# include <system_error>
365# include <type_traits>368# include <type_traits>
366# include <typeinfo>369# include <typeinfo>
367#endif370# endif
371#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
368372
369#endif // _LIBCPP_CONDITION_VARIABLE373#endif // _LIBCPP_CONDITION_VARIABLE
lib/libcxx/include/coroutine+22-17
...@@ -38,30 +38,35 @@ struct suspend_always;...@@ -38,30 +38,35 @@ struct suspend_always;
3838
39 */39 */
4040
41#include <__config>41#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
42# include <__cxx03/coroutine>
43#else
44# include <__config>
4245
43#if _LIBCPP_STD_VER >= 2046# if _LIBCPP_STD_VER >= 20
44# include <__coroutine/coroutine_handle.h>47# include <__coroutine/coroutine_handle.h>
45# include <__coroutine/coroutine_traits.h>48# include <__coroutine/coroutine_traits.h>
46# include <__coroutine/noop_coroutine_handle.h>49# include <__coroutine/noop_coroutine_handle.h>
47# include <__coroutine/trivial_awaitables.h>50# include <__coroutine/trivial_awaitables.h>
48#endif // _LIBCPP_STD_VER >= 2051# endif // _LIBCPP_STD_VER >= 20
4952
50#include <version>53# include <version>
5154
52// standard-mandated includes55// standard-mandated includes
5356
54// [coroutine.syn]57// [coroutine.syn]
55#include <compare>58# include <compare>
5659
57#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER60# ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
58# pragma GCC system_header61# pragma GCC system_header
59#endif62# endif
6063
61#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 2064# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
62# include <iosfwd>65# include <cstddef>
63# include <limits>66# include <iosfwd>
64# include <type_traits>67# include <limits>
65#endif68# include <type_traits>
69# endif
70#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
6671
67#endif // _LIBCPP_COROUTINE72#endif // _LIBCPP_COROUTINE
lib/libcxx/include/csetjmp+14-9
...@@ -30,19 +30,22 @@ void longjmp(jmp_buf env, int val);...@@ -30,19 +30,22 @@ void longjmp(jmp_buf env, int val);
3030
31*/31*/
3232
33#include <__config>33#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
34# include <__cxx03/csetjmp>
35#else
36# include <__config>
3437
35// <setjmp.h> is not provided by libc++38// <setjmp.h> is not provided by libc++
36#if __has_include(<setjmp.h>)39# if __has_include(<setjmp.h>)
37# include <setjmp.h>40# include <setjmp.h>
38# ifdef _LIBCPP_SETJMP_H41# ifdef _LIBCPP_SETJMP_H
39# error "If libc++ starts defining <setjmp.h>, the __has_include check should move to libc++'s <setjmp.h>"42# error "If libc++ starts defining <setjmp.h>, the __has_include check should move to libc++'s <setjmp.h>"
43# endif
40# endif44# endif
41#endif
4245
43#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)46# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
44# pragma GCC system_header47# pragma GCC system_header
45#endif48# endif
4649
47_LIBCPP_BEGIN_NAMESPACE_STD50_LIBCPP_BEGIN_NAMESPACE_STD
4851
...@@ -51,4 +54,6 @@ using ::longjmp _LIBCPP_USING_IF_EXISTS;...@@ -51,4 +54,6 @@ using ::longjmp _LIBCPP_USING_IF_EXISTS;
5154
52_LIBCPP_END_NAMESPACE_STD55_LIBCPP_END_NAMESPACE_STD
5356
57#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
58
54#endif // _LIBCPP_CSETJMP59#endif // _LIBCPP_CSETJMP
lib/libcxx/include/csignal+14-9
...@@ -39,19 +39,22 @@ int raise(int sig);...@@ -39,19 +39,22 @@ int raise(int sig);
3939
40*/40*/
4141
42#include <__config>42#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
43# include <__cxx03/csignal>
44#else
45# include <__config>
4346
44// <signal.h> is not provided by libc++47// <signal.h> is not provided by libc++
45#if __has_include(<signal.h>)48# if __has_include(<signal.h>)
46# include <signal.h>49# include <signal.h>
47# ifdef _LIBCPP_SIGNAL_H50# ifdef _LIBCPP_SIGNAL_H
48# error "If libc++ starts defining <signal.h>, the __has_include check should move to libc++'s <signal.h>"51# error "If libc++ starts defining <signal.h>, the __has_include check should move to libc++'s <signal.h>"
52# endif
49# endif53# endif
50#endif
5154
52#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)55# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
53# pragma GCC system_header56# pragma GCC system_header
54#endif57# endif
5558
56_LIBCPP_BEGIN_NAMESPACE_STD59_LIBCPP_BEGIN_NAMESPACE_STD
5760
...@@ -61,4 +64,6 @@ using ::raise _LIBCPP_USING_IF_EXISTS;...@@ -61,4 +64,6 @@ using ::raise _LIBCPP_USING_IF_EXISTS;
6164
62_LIBCPP_END_NAMESPACE_STD65_LIBCPP_END_NAMESPACE_STD
6366
67#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
68
64#endif // _LIBCPP_CSIGNAL69#endif // _LIBCPP_CSIGNAL
lib/libcxx/include/cstdalign created+59
...@@ -0,0 +1,59 @@
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_CSTDALIGN
11#define _LIBCPP_CSTDALIGN
12
13/*
14 cstdalign synopsis
15
16Macros:
17
18 __alignas_is_defined
19 __alignof_is_defined
20
21*/
22
23#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
24# include <__cxx03/__config>
25#else
26# include <__config>
27
28// <stdalign.h> is not provided by libc++
29# if __has_include(<stdalign.h>)
30# include <stdalign.h>
31# ifdef _LIBCPP_STDALIGN_H
32# error "If libc++ starts defining <stdalign.h>, the __has_include check should move to libc++'s <stdalign.h>"
33# endif
34# endif
35
36# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
37# pragma GCC system_header
38# endif
39
40# undef __alignas_is_defined
41# define __alignas_is_defined 1
42
43# undef __alignof_is_defined
44# define __alignof_is_defined 1
45
46# if _LIBCPP_STD_VER >= 20
47
48using __standard_header_cstdalign _LIBCPP_DEPRECATED_("removed in C++20.") _LIBCPP_NODEBUG = void;
49using __use_standard_header_cstdalign _LIBCPP_NODEBUG = __standard_header_cstdalign;
50
51# elif _LIBCPP_STD_VER >= 17
52
53using __standard_header_cstdalign _LIBCPP_DEPRECATED _LIBCPP_NODEBUG = void;
54using __use_standard_header_cstdalign _LIBCPP_NODEBUG = __standard_header_cstdalign;
55
56# endif
57#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
58
59#endif // _LIBCPP_CSTDALIGN
lib/libcxx/include/cstdarg+14-9
...@@ -31,19 +31,22 @@ Types:...@@ -31,19 +31,22 @@ Types:
3131
32*/32*/
3333
34#include <__config>34#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
35# include <__cxx03/cstdarg>
36#else
37# include <__config>
3538
36// <stdarg.h> is not provided by libc++39// <stdarg.h> is not provided by libc++
37#if __has_include(<stdarg.h>)40# if __has_include(<stdarg.h>)
38# include <stdarg.h>41# include <stdarg.h>
39# ifdef _LIBCPP_STDARG_H42# ifdef _LIBCPP_STDARG_H
40# error "If libc++ starts defining <stdarg.h>, the __has_include check should move to libc++'s <stdarg.h>"43# error "If libc++ starts defining <stdarg.h>, the __has_include check should move to libc++'s <stdarg.h>"
44# endif
41# endif45# endif
42#endif
4346
44#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)47# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
45# pragma GCC system_header48# pragma GCC system_header
46#endif49# endif
4750
48_LIBCPP_BEGIN_NAMESPACE_STD51_LIBCPP_BEGIN_NAMESPACE_STD
4952
...@@ -51,4 +54,6 @@ using ::va_list _LIBCPP_USING_IF_EXISTS;...@@ -51,4 +54,6 @@ using ::va_list _LIBCPP_USING_IF_EXISTS;
5154
52_LIBCPP_END_NAMESPACE_STD55_LIBCPP_END_NAMESPACE_STD
5356
57#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
58
54#endif // _LIBCPP_CSTDARG59#endif // _LIBCPP_CSTDARG
lib/libcxx/include/cstdbool+22-6
...@@ -19,13 +19,29 @@ Macros:...@@ -19,13 +19,29 @@ Macros:
1919
20*/20*/
2121
22#include <__config>22#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
23# include <__cxx03/cstdbool>
24#else
25# include <__config>
2326
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header28# pragma GCC system_header
26#endif29# endif
2730
28#undef __bool_true_false_are_defined31# undef __bool_true_false_are_defined
29#define __bool_true_false_are_defined 132# define __bool_true_false_are_defined 1
33
34# if _LIBCPP_STD_VER >= 20
35
36using __standard_header_cstdbool _LIBCPP_DEPRECATED_("removed in C++20.") _LIBCPP_NODEBUG = void;
37using __use_standard_header_cstdbool _LIBCPP_NODEBUG = __standard_header_cstdbool;
38
39# elif _LIBCPP_STD_VER >= 17
40
41using __standard_header_cstdbool _LIBCPP_DEPRECATED _LIBCPP_NODEBUG = void;
42using __use_standard_header_cstdbool _LIBCPP_NODEBUG = __standard_header_cstdbool;
43
44# endif
45#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
3046
31#endif // _LIBCPP_CSTDBOOL47#endif // _LIBCPP_CSTDBOOL
lib/libcxx/include/cstddef+19-89
...@@ -33,101 +33,31 @@ Types:...@@ -33,101 +33,31 @@ Types:
3333
34*/34*/
3535
36#include <__config>36#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
37#include <__type_traits/enable_if.h>37# include <__cxx03/cstddef>
38#include <__type_traits/integral_constant.h>38#else
39#include <__type_traits/is_integral.h>39# include <__config>
40#include <version>40# include <version>
4141
42#include <stddef.h>42# include <stddef.h>
4343
44#ifndef _LIBCPP_STDDEF_H44# ifndef _LIBCPP_STDDEF_H
45# error <cstddef> tried including <stddef.h> but didn't find libc++'s <stddef.h> header. \45# error <cstddef> tried including <stddef.h> but didn't find libc++'s <stddef.h> header. \
46 This usually means that your header search paths are not configured properly. \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 \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 \48 any C Standard Library, and you are probably using compiler flags that make that \
49 not be the case.49 not be the case.
50#endif50# endif
5151
52#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)52# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
53# pragma GCC system_header53# pragma GCC system_header
54#endif54# endif
5555
56_LIBCPP_BEGIN_NAMESPACE_STD56# include <__cstddef/byte.h>
5757# include <__cstddef/max_align_t.h>
58using ::nullptr_t;58# include <__cstddef/nullptr_t.h>
59using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;59# include <__cstddef/ptrdiff_t.h>
60using ::size_t _LIBCPP_USING_IF_EXISTS;60# include <__cstddef/size_t.h>
6161#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
62#if !defined(_LIBCPP_CXX03_LANG)
63using ::max_align_t _LIBCPP_USING_IF_EXISTS;
64#endif
65
66_LIBCPP_END_NAMESPACE_STD
67
68#if _LIBCPP_STD_VER >= 17
69namespace std // purposefully not versioned
70{
71enum class byte : unsigned char {};
72
73_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept {
74 return static_cast<byte>(
75 static_cast<unsigned char>(static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)));
76}
77
78_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept {
79 return __lhs = __lhs | __rhs;
80}
81
82_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator&(byte __lhs, byte __rhs) noexcept {
83 return static_cast<byte>(
84 static_cast<unsigned char>(static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)));
85}
86
87_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept {
88 return __lhs = __lhs & __rhs;
89}
90
91_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^(byte __lhs, byte __rhs) noexcept {
92 return static_cast<byte>(
93 static_cast<unsigned char>(static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)));
94}
95
96_LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept {
97 return __lhs = __lhs ^ __rhs;
98}
99
100_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~(byte __b) noexcept {
101 return static_cast<byte>(static_cast<unsigned char>(~static_cast<unsigned int>(__b)));
102}
103
104template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
105_LIBCPP_HIDE_FROM_ABI constexpr byte& operator<<=(byte& __lhs, _Integer __shift) noexcept {
106 return __lhs = __lhs << __shift;
107}
108
109template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
110_LIBCPP_HIDE_FROM_ABI constexpr byte operator<<(byte __lhs, _Integer __shift) noexcept {
111 return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift));
112}
113
114template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
115_LIBCPP_HIDE_FROM_ABI constexpr byte& operator>>=(byte& __lhs, _Integer __shift) noexcept {
116 return __lhs = __lhs >> __shift;
117}
118
119template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
120_LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) noexcept {
121 return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift));
122}
123
124template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
125[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept {
126 return static_cast<_Integer>(__b);
127}
128
129} // namespace std
130
131#endif
13262
133#endif // _LIBCPP_CSTDDEF63#endif // _LIBCPP_CSTDDEF
lib/libcxx/include/cstdint+12-13
...@@ -140,21 +140,18 @@ Types:...@@ -140,21 +140,18 @@ Types:
140} // std140} // std
141*/141*/
142142
143#include <__config>143#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
144# include <__cxx03/cstdint>
145#else
146# include <__config>
144147
145#include <stdint.h>148# if __has_include(<stdint.h>)
149# include <stdint.h>
150# endif
146151
147#ifndef _LIBCPP_STDINT_H152# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
148# error <cstdint> tried including <stdint.h> but didn't find libc++'s <stdint.h> header. \153# pragma GCC system_header
149 This usually means that your header search paths are not configured properly. \154# endif
150 The header search paths should contain the C++ Standard Library headers before \
151 any C Standard Library, and you are probably using compiler flags that make that \
152 not be the case.
153#endif
154
155#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
156# pragma GCC system_header
157#endif
158155
159_LIBCPP_BEGIN_NAMESPACE_STD156_LIBCPP_BEGIN_NAMESPACE_STD
160157
...@@ -196,4 +193,6 @@ using ::uintmax_t _LIBCPP_USING_IF_EXISTS;...@@ -196,4 +193,6 @@ using ::uintmax_t _LIBCPP_USING_IF_EXISTS;
196193
197_LIBCPP_END_NAMESPACE_STD194_LIBCPP_END_NAMESPACE_STD
198195
196#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
197
199#endif // _LIBCPP_CSTDINT198#endif // _LIBCPP_CSTDINT
lib/libcxx/include/cstdio+15-10
...@@ -95,27 +95,30 @@ void perror(const char* s);...@@ -95,27 +95,30 @@ void perror(const char* s);
95} // std95} // std
96*/96*/
9797
98#include <__config>98#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
99# include <__cxx03/cstdio>
100#else
101# include <__config>
102# include <__cstddef/size_t.h>
99103
100#include <stdio.h>104# include <stdio.h>
101105
102#ifndef _LIBCPP_STDIO_H106# ifndef _LIBCPP_STDIO_H
103# error <cstdio> tried including <stdio.h> but didn't find libc++'s <stdio.h> header. \107# error <cstdio> tried including <stdio.h> but didn't find libc++'s <stdio.h> header. \
104 This usually means that your header search paths are not configured properly. \108 This usually means that your header search paths are not configured properly. \
105 The header search paths should contain the C++ Standard Library headers before \109 The header search paths should contain the C++ Standard Library headers before \
106 any C Standard Library, and you are probably using compiler flags that make that \110 any C Standard Library, and you are probably using compiler flags that make that \
107 not be the case.111 not be the case.
108#endif112# endif
109113
110#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)114# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
111# pragma GCC system_header115# pragma GCC system_header
112#endif116# endif
113117
114_LIBCPP_BEGIN_NAMESPACE_STD118_LIBCPP_BEGIN_NAMESPACE_STD
115119
116using ::FILE _LIBCPP_USING_IF_EXISTS;120using ::FILE _LIBCPP_USING_IF_EXISTS;
117using ::fpos_t _LIBCPP_USING_IF_EXISTS;121using ::fpos_t _LIBCPP_USING_IF_EXISTS;
118using ::size_t _LIBCPP_USING_IF_EXISTS;
119122
120using ::fclose _LIBCPP_USING_IF_EXISTS;123using ::fclose _LIBCPP_USING_IF_EXISTS;
121using ::fflush _LIBCPP_USING_IF_EXISTS;124using ::fflush _LIBCPP_USING_IF_EXISTS;
...@@ -158,9 +161,9 @@ using ::tmpfile _LIBCPP_USING_IF_EXISTS;...@@ -158,9 +161,9 @@ using ::tmpfile _LIBCPP_USING_IF_EXISTS;
158using ::tmpnam _LIBCPP_USING_IF_EXISTS;161using ::tmpnam _LIBCPP_USING_IF_EXISTS;
159162
160using ::getchar _LIBCPP_USING_IF_EXISTS;163using ::getchar _LIBCPP_USING_IF_EXISTS;
161#if _LIBCPP_STD_VER <= 11164# if _LIBCPP_STD_VER <= 11
162using ::gets _LIBCPP_USING_IF_EXISTS;165using ::gets _LIBCPP_USING_IF_EXISTS;
163#endif166# endif
164using ::scanf _LIBCPP_USING_IF_EXISTS;167using ::scanf _LIBCPP_USING_IF_EXISTS;
165using ::vscanf _LIBCPP_USING_IF_EXISTS;168using ::vscanf _LIBCPP_USING_IF_EXISTS;
166169
...@@ -171,4 +174,6 @@ using ::vprintf _LIBCPP_USING_IF_EXISTS;...@@ -171,4 +174,6 @@ using ::vprintf _LIBCPP_USING_IF_EXISTS;
171174
172_LIBCPP_END_NAMESPACE_STD175_LIBCPP_END_NAMESPACE_STD
173176
177#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
178
174#endif // _LIBCPP_CSTDIO179#endif // _LIBCPP_CSTDIO
lib/libcxx/include/cstdlib+19-14
...@@ -81,25 +81,28 @@ void *aligned_alloc(size_t alignment, size_t size); // C11...@@ -81,25 +81,28 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
8181
82*/82*/
8383
84#include <__config>84#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
85# include <__cxx03/cstdlib>
86#else
87# include <__config>
88# include <__cstddef/size_t.h>
8589
86#include <stdlib.h>90# include <stdlib.h>
8791
88#ifndef _LIBCPP_STDLIB_H92# ifndef _LIBCPP_STDLIB_H
89# error <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header. \93# error <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header. \
90 This usually means that your header search paths are not configured properly. \94 This usually means that your header search paths are not configured properly. \
91 The header search paths should contain the C++ Standard Library headers before \95 The header search paths should contain the C++ Standard Library headers before \
92 any C Standard Library, and you are probably using compiler flags that make that \96 any C Standard Library, and you are probably using compiler flags that make that \
93 not be the case.97 not be the case.
94#endif98# endif
9599
96#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)100# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
97# pragma GCC system_header101# pragma GCC system_header
98#endif102# endif
99103
100_LIBCPP_BEGIN_NAMESPACE_STD104_LIBCPP_BEGIN_NAMESPACE_STD
101105
102using ::size_t _LIBCPP_USING_IF_EXISTS;
103using ::div_t _LIBCPP_USING_IF_EXISTS;106using ::div_t _LIBCPP_USING_IF_EXISTS;
104using ::ldiv_t _LIBCPP_USING_IF_EXISTS;107using ::ldiv_t _LIBCPP_USING_IF_EXISTS;
105using ::lldiv_t _LIBCPP_USING_IF_EXISTS;108using ::lldiv_t _LIBCPP_USING_IF_EXISTS;
...@@ -135,20 +138,22 @@ using ::div _LIBCPP_USING_IF_EXISTS;...@@ -135,20 +138,22 @@ using ::div _LIBCPP_USING_IF_EXISTS;
135using ::ldiv _LIBCPP_USING_IF_EXISTS;138using ::ldiv _LIBCPP_USING_IF_EXISTS;
136using ::lldiv _LIBCPP_USING_IF_EXISTS;139using ::lldiv _LIBCPP_USING_IF_EXISTS;
137using ::mblen _LIBCPP_USING_IF_EXISTS;140using ::mblen _LIBCPP_USING_IF_EXISTS;
138#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS141# if _LIBCPP_HAS_WIDE_CHARACTERS
139using ::mbtowc _LIBCPP_USING_IF_EXISTS;142using ::mbtowc _LIBCPP_USING_IF_EXISTS;
140using ::wctomb _LIBCPP_USING_IF_EXISTS;143using ::wctomb _LIBCPP_USING_IF_EXISTS;
141using ::mbstowcs _LIBCPP_USING_IF_EXISTS;144using ::mbstowcs _LIBCPP_USING_IF_EXISTS;
142using ::wcstombs _LIBCPP_USING_IF_EXISTS;145using ::wcstombs _LIBCPP_USING_IF_EXISTS;
143#endif146# endif
144#if !defined(_LIBCPP_CXX03_LANG)147# if !defined(_LIBCPP_CXX03_LANG)
145using ::at_quick_exit _LIBCPP_USING_IF_EXISTS;148using ::at_quick_exit _LIBCPP_USING_IF_EXISTS;
146using ::quick_exit _LIBCPP_USING_IF_EXISTS;149using ::quick_exit _LIBCPP_USING_IF_EXISTS;
147#endif150# endif
148#if _LIBCPP_STD_VER >= 17151# if _LIBCPP_STD_VER >= 17
149using ::aligned_alloc _LIBCPP_USING_IF_EXISTS;152using ::aligned_alloc _LIBCPP_USING_IF_EXISTS;
150#endif153# endif
151154
152_LIBCPP_END_NAMESPACE_STD155_LIBCPP_END_NAMESPACE_STD
153156
157#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
158
154#endif // _LIBCPP_CSTDLIB159#endif // _LIBCPP_CSTDLIB
lib/libcxx/include/cstring+14-9
...@@ -56,26 +56,29 @@ size_t strlen(const char* s);...@@ -56,26 +56,29 @@ size_t strlen(const char* s);
5656
57*/57*/
5858
59#include <__config>59#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
60#include <__type_traits/is_constant_evaluated.h>60# include <__cxx03/cstring>
61#else
62# include <__config>
63# include <__cstddef/size_t.h>
64# include <__type_traits/is_constant_evaluated.h>
6165
62#include <string.h>66# include <string.h>
6367
64#ifndef _LIBCPP_STRING_H68# ifndef _LIBCPP_STRING_H
65# error <cstring> tried including <string.h> but didn't find libc++'s <string.h> header. \69# error <cstring> tried including <string.h> but didn't find libc++'s <string.h> header. \
66 This usually means that your header search paths are not configured properly. \70 This usually means that your header search paths are not configured properly. \
67 The header search paths should contain the C++ Standard Library headers before \71 The header search paths should contain the C++ Standard Library headers before \
68 any C Standard Library, and you are probably using compiler flags that make that \72 any C Standard Library, and you are probably using compiler flags that make that \
69 not be the case.73 not be the case.
70#endif74# endif
7175
72#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)76# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
73# pragma GCC system_header77# pragma GCC system_header
74#endif78# endif
7579
76_LIBCPP_BEGIN_NAMESPACE_STD80_LIBCPP_BEGIN_NAMESPACE_STD
7781
78using ::size_t _LIBCPP_USING_IF_EXISTS;
79using ::memcpy _LIBCPP_USING_IF_EXISTS;82using ::memcpy _LIBCPP_USING_IF_EXISTS;
80using ::memmove _LIBCPP_USING_IF_EXISTS;83using ::memmove _LIBCPP_USING_IF_EXISTS;
81using ::strcpy _LIBCPP_USING_IF_EXISTS;84using ::strcpy _LIBCPP_USING_IF_EXISTS;
...@@ -101,4 +104,6 @@ using ::strlen _LIBCPP_USING_IF_EXISTS;...@@ -101,4 +104,6 @@ using ::strlen _LIBCPP_USING_IF_EXISTS;
101104
102_LIBCPP_END_NAMESPACE_STD105_LIBCPP_END_NAMESPACE_STD
103106
107#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
108
104#endif // _LIBCPP_CSTRING109#endif // _LIBCPP_CSTRING
lib/libcxx/include/ctgmath+23-5
...@@ -18,11 +18,29 @@...@@ -18,11 +18,29 @@
1818
19*/19*/
2020
21#include <ccomplex>21#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
22#include <cmath>22# include <__cxx03/ctgmath>
23#else
24# include <cmath>
25# include <complex>
26
27# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29# endif
30
31# if _LIBCPP_STD_VER >= 20
32
33using __standard_header_ctgmath
34 _LIBCPP_DEPRECATED_("removed in C++20. Include <cmath> and <complex> instead.") _LIBCPP_NODEBUG = void;
35using __use_standard_header_ctgmath _LIBCPP_NODEBUG = __standard_header_ctgmath;
36
37# elif _LIBCPP_STD_VER >= 17
38
39using __standard_header_ctgmath _LIBCPP_DEPRECATED_("Include <cmath> and <complex> instead.") _LIBCPP_NODEBUG = void;
40using __use_standard_header_ctgmath _LIBCPP_NODEBUG = __standard_header_ctgmath;
41
42# endif
2343
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)44#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
25# pragma GCC system_header
26#endif
2745
28#endif // _LIBCPP_CTGMATH46#endif // _LIBCPP_CTGMATH
lib/libcxx/include/ctime+19-14
...@@ -45,29 +45,32 @@ int timespec_get( struct timespec *ts, int base); // C++17...@@ -45,29 +45,32 @@ int timespec_get( struct timespec *ts, int base); // C++17
4545
46*/46*/
4747
48#include <__config>48#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
49# include <__cxx03/ctime>
50#else
51# include <__config>
52# include <__cstddef/size_t.h>
4953
50// <time.h> is not provided by libc++54// <time.h> is not provided by libc++
51#if __has_include(<time.h>)55# if __has_include(<time.h>)
52# include <time.h>56# include <time.h>
53# ifdef _LIBCPP_TIME_H57# ifdef _LIBCPP_TIME_H
54# error "If libc++ starts defining <time.h>, the __has_include check should move to libc++'s <time.h>"58# error "If libc++ starts defining <time.h>, the __has_include check should move to libc++'s <time.h>"
59# endif
55# endif60# endif
56#endif
5761
58#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)62# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
59# pragma GCC system_header63# pragma GCC system_header
60#endif64# endif
6165
62_LIBCPP_BEGIN_NAMESPACE_STD66_LIBCPP_BEGIN_NAMESPACE_STD
6367
64using ::clock_t _LIBCPP_USING_IF_EXISTS;68using ::clock_t _LIBCPP_USING_IF_EXISTS;
65using ::size_t _LIBCPP_USING_IF_EXISTS;
66using ::time_t _LIBCPP_USING_IF_EXISTS;69using ::time_t _LIBCPP_USING_IF_EXISTS;
67using ::tm _LIBCPP_USING_IF_EXISTS;70using ::tm _LIBCPP_USING_IF_EXISTS;
68#if _LIBCPP_STD_VER >= 1771# if _LIBCPP_STD_VER >= 17
69using ::timespec _LIBCPP_USING_IF_EXISTS;72using ::timespec _LIBCPP_USING_IF_EXISTS;
70#endif73# endif
71using ::clock _LIBCPP_USING_IF_EXISTS;74using ::clock _LIBCPP_USING_IF_EXISTS;
72using ::difftime _LIBCPP_USING_IF_EXISTS;75using ::difftime _LIBCPP_USING_IF_EXISTS;
73using ::mktime _LIBCPP_USING_IF_EXISTS;76using ::mktime _LIBCPP_USING_IF_EXISTS;
...@@ -77,10 +80,12 @@ using ::ctime _LIBCPP_USING_IF_EXISTS;...@@ -77,10 +80,12 @@ using ::ctime _LIBCPP_USING_IF_EXISTS;
77using ::gmtime _LIBCPP_USING_IF_EXISTS;80using ::gmtime _LIBCPP_USING_IF_EXISTS;
78using ::localtime _LIBCPP_USING_IF_EXISTS;81using ::localtime _LIBCPP_USING_IF_EXISTS;
79using ::strftime _LIBCPP_USING_IF_EXISTS;82using ::strftime _LIBCPP_USING_IF_EXISTS;
80#if _LIBCPP_STD_VER >= 1783# if _LIBCPP_STD_VER >= 17
81using ::timespec_get _LIBCPP_USING_IF_EXISTS;84using ::timespec_get _LIBCPP_USING_IF_EXISTS;
82#endif85# endif
8386
84_LIBCPP_END_NAMESPACE_STD87_LIBCPP_END_NAMESPACE_STD
8588
89#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
90
86#endif // _LIBCPP_CTIME91#endif // _LIBCPP_CTIME
lib/libcxx/include/ctype.h+32-28
...@@ -29,33 +29,37 @@ int tolower(int c);...@@ -29,33 +29,37 @@ int tolower(int c);
29int toupper(int c);29int toupper(int c);
30*/30*/
3131
32#include <__config>32#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
3333# include <__cxx03/ctype.h>
34#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)34#else
35# pragma GCC system_header35# include <__config>
36#endif36
3737# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
38#if __has_include_next(<ctype.h>)38# pragma GCC system_header
39# include_next <ctype.h>39# endif
40#endif40
4141# if __has_include_next(<ctype.h>)
42#ifdef __cplusplus42# include_next <ctype.h>
4343# endif
44# undef isalnum44
45# undef isalpha45# ifdef __cplusplus
46# undef isblank46
47# undef iscntrl47# undef isalnum
48# undef isdigit48# undef isalpha
49# undef isgraph49# undef isblank
50# undef islower50# undef iscntrl
51# undef isprint51# undef isdigit
52# undef ispunct52# undef isgraph
53# undef isspace53# undef islower
54# undef isupper54# undef isprint
55# undef isxdigit55# undef ispunct
56# undef tolower56# undef isspace
57# undef toupper57# undef isupper
5858# undef isxdigit
59#endif59# undef tolower
60# undef toupper
61
62# endif
63#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
6064
61#endif // _LIBCPP_CTYPE_H65#endif // _LIBCPP_CTYPE_H
lib/libcxx/include/cuchar+17-12
...@@ -36,40 +36,45 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);...@@ -36,40 +36,45 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
3636
37*/37*/
3838
39#include <__config>39#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
40# include <__cxx03/cuchar>
41#else
42# include <__config>
43# include <__cstddef/size_t.h>
4044
41#include <uchar.h>45# include <uchar.h>
4246
43#ifndef _LIBCPP_UCHAR_H47# ifndef _LIBCPP_UCHAR_H
44# error <cuchar> tried including <uchar.h> but didn't find libc++'s <uchar.h> header. \48# error <cuchar> tried including <uchar.h> but didn't find libc++'s <uchar.h> header. \
45 This usually means that your header search paths are not configured properly. \49 This usually means that your header search paths are not configured properly. \
46 The header search paths should contain the C++ Standard Library headers before \50 The header search paths should contain the C++ Standard Library headers before \
47 any C Standard Library, and you are probably using compiler flags that make that \51 any C Standard Library, and you are probably using compiler flags that make that \
48 not be the case.52 not be the case.
49#endif53# endif
5054
51#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)55# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
52# pragma GCC system_header56# pragma GCC system_header
53#endif57# endif
5458
55_LIBCPP_BEGIN_NAMESPACE_STD59_LIBCPP_BEGIN_NAMESPACE_STD
5660
57#if !defined(_LIBCPP_CXX03_LANG)61# if !defined(_LIBCPP_CXX03_LANG)
5862
59using ::mbstate_t _LIBCPP_USING_IF_EXISTS;63using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
60using ::size_t _LIBCPP_USING_IF_EXISTS;
6164
62# if !defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8)65# if _LIBCPP_HAS_C8RTOMB_MBRTOC8
63using ::mbrtoc8 _LIBCPP_USING_IF_EXISTS;66using ::mbrtoc8 _LIBCPP_USING_IF_EXISTS;
64using ::c8rtomb _LIBCPP_USING_IF_EXISTS;67using ::c8rtomb _LIBCPP_USING_IF_EXISTS;
65# endif68# endif
66using ::mbrtoc16 _LIBCPP_USING_IF_EXISTS;69using ::mbrtoc16 _LIBCPP_USING_IF_EXISTS;
67using ::c16rtomb _LIBCPP_USING_IF_EXISTS;70using ::c16rtomb _LIBCPP_USING_IF_EXISTS;
68using ::mbrtoc32 _LIBCPP_USING_IF_EXISTS;71using ::mbrtoc32 _LIBCPP_USING_IF_EXISTS;
69using ::c32rtomb _LIBCPP_USING_IF_EXISTS;72using ::c32rtomb _LIBCPP_USING_IF_EXISTS;
7073
71#endif // _LIBCPP_CXX03_LANG74# endif // _LIBCPP_CXX03_LANG
7275
73_LIBCPP_END_NAMESPACE_STD76_LIBCPP_END_NAMESPACE_STD
7477
78#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
79
75#endif // _LIBCPP_CUCHAR80#endif // _LIBCPP_CUCHAR
lib/libcxx/include/cwchar+31-27
...@@ -102,32 +102,35 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,...@@ -102,32 +102,35 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
102102
103*/103*/
104104
105#include <__config>105#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
106#include <__type_traits/copy_cv.h>106# include <__cxx03/cwchar>
107#include <__type_traits/is_constant_evaluated.h>107#else
108#include <__type_traits/is_equality_comparable.h>108# include <__config>
109#include <__type_traits/is_same.h>109# include <__cstddef/size_t.h>
110#include <__type_traits/remove_cv.h>110# include <__type_traits/copy_cv.h>
111#include <cwctype>111# include <__type_traits/is_constant_evaluated.h>
112# include <__type_traits/is_equality_comparable.h>
113# include <__type_traits/is_same.h>
114# include <__type_traits/remove_cv.h>
115# include <cwctype>
112116
113#include <wchar.h>117# include <wchar.h>
114118
115#ifndef _LIBCPP_WCHAR_H119# ifndef _LIBCPP_WCHAR_H
116# error <cwchar> tried including <wchar.h> but didn't find libc++'s <wchar.h> header. \120# error <cwchar> tried including <wchar.h> but didn't find libc++'s <wchar.h> header. \
117 This usually means that your header search paths are not configured properly. \121 This usually means that your header search paths are not configured properly. \
118 The header search paths should contain the C++ Standard Library headers before \122 The header search paths should contain the C++ Standard Library headers before \
119 any C Standard Library, and you are probably using compiler flags that make that \123 any C Standard Library, and you are probably using compiler flags that make that \
120 not be the case.124 not be the case.
121#endif125# endif
122126
123#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)127# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
124# pragma GCC system_header128# pragma GCC system_header
125#endif129# endif
126130
127_LIBCPP_BEGIN_NAMESPACE_STD131_LIBCPP_BEGIN_NAMESPACE_STD
128132
129using ::mbstate_t _LIBCPP_USING_IF_EXISTS;133using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
130using ::size_t _LIBCPP_USING_IF_EXISTS;
131using ::tm _LIBCPP_USING_IF_EXISTS;134using ::tm _LIBCPP_USING_IF_EXISTS;
132using ::wint_t _LIBCPP_USING_IF_EXISTS;135using ::wint_t _LIBCPP_USING_IF_EXISTS;
133using ::FILE _LIBCPP_USING_IF_EXISTS;136using ::FILE _LIBCPP_USING_IF_EXISTS;
...@@ -194,9 +197,9 @@ using ::vwprintf _LIBCPP_USING_IF_EXISTS;...@@ -194,9 +197,9 @@ using ::vwprintf _LIBCPP_USING_IF_EXISTS;
194using ::wprintf _LIBCPP_USING_IF_EXISTS;197using ::wprintf _LIBCPP_USING_IF_EXISTS;
195198
196inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_wcslen(const wchar_t* __str) {199inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_wcslen(const wchar_t* __str) {
197#if __has_builtin(__builtin_wcslen)200# if __has_builtin(__builtin_wcslen)
198 return __builtin_wcslen(__str);201 return __builtin_wcslen(__str);
199#else202# else
200 if (!__libcpp_is_constant_evaluated())203 if (!__libcpp_is_constant_evaluated())
201 return std::wcslen(__str);204 return std::wcslen(__str);
202205
...@@ -204,14 +207,14 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_wc...@@ -204,14 +207,14 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_wc
204 for (; *__str != L'\0'; ++__str)207 for (; *__str != L'\0'; ++__str)
205 ++__len;208 ++__len;
206 return __len;209 return __len;
207#endif210# endif
208}211}
209212
210inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int213inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
211__constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count) {214__constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count) {
212#if __has_builtin(__builtin_wmemcmp)215# if __has_builtin(__builtin_wmemcmp)
213 return __builtin_wmemcmp(__lhs, __rhs, __count);216 return __builtin_wmemcmp(__lhs, __rhs, __count);
214#else217# else
215 if (!__libcpp_is_constant_evaluated())218 if (!__libcpp_is_constant_evaluated())
216 return std::wmemcmp(__lhs, __rhs, __count);219 return std::wmemcmp(__lhs, __rhs, __count);
217220
...@@ -222,7 +225,7 @@ __constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count)...@@ -222,7 +225,7 @@ __constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count)
222 return 1;225 return 1;
223 }226 }
224 return 0;227 return 0;
225#endif228# endif
226}229}
227230
228template <class _Tp, class _Up>231template <class _Tp, class _Up>
...@@ -231,18 +234,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp...@@ -231,18 +234,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp
231 __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value,234 __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value,
232 "Calling wmemchr on non-trivially equality comparable types is unsafe.");235 "Calling wmemchr on non-trivially equality comparable types is unsafe.");
233236
234#if __has_builtin(__builtin_wmemchr)237# if __has_builtin(__builtin_wmemchr)
235 if (!__libcpp_is_constant_evaluated()) {238 if (!__libcpp_is_constant_evaluated()) {
236 wchar_t __value_buffer = 0;239 wchar_t __value_buffer = 0;
237 __builtin_memcpy(&__value_buffer, &__value, sizeof(wchar_t));240 __builtin_memcpy(&__value_buffer, &__value, sizeof(wchar_t));
238 return reinterpret_cast<_Tp*>(241 return reinterpret_cast<_Tp*>(
239 __builtin_wmemchr(reinterpret_cast<__copy_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count));242 __builtin_wmemchr(reinterpret_cast<__copy_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count));
240 }243 }
241# if _LIBCPP_STD_VER >= 17244# if _LIBCPP_STD_VER >= 17
242 else if constexpr (is_same_v<remove_cv_t<_Tp>, wchar_t>)245 else if constexpr (is_same_v<remove_cv_t<_Tp>, wchar_t>)
243 return __builtin_wmemchr(__str, __value, __count);246 return __builtin_wmemchr(__str, __value, __count);
244# endif247# endif
245#endif // __has_builtin(__builtin_wmemchr)248# endif // __has_builtin(__builtin_wmemchr)
246249
247 for (; __count; --__count) {250 for (; __count; --__count) {
248 if (*__str == __value)251 if (*__str == __value)
...@@ -254,8 +257,9 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp...@@ -254,8 +257,9 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp
254257
255_LIBCPP_END_NAMESPACE_STD258_LIBCPP_END_NAMESPACE_STD
256259
257#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20260# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
258# include <cstddef>261# include <cstddef>
259#endif262# endif
263#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
260264
261#endif // _LIBCPP_CWCHAR265#endif // _LIBCPP_CWCHAR
lib/libcxx/include/cwctype+15-10
...@@ -49,26 +49,29 @@ wctrans_t wctrans(const char* property);...@@ -49,26 +49,29 @@ wctrans_t wctrans(const char* property);
4949
50*/50*/
5151
52#include <__config>52#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
53#include <cctype>53# include <__cxx03/cwctype>
54#else
55# include <__config>
56# include <cctype>
5457
55#include <wctype.h>58# include <wctype.h>
5659
57#ifndef _LIBCPP_WCTYPE_H60# ifndef _LIBCPP_WCTYPE_H
58# error <cwctype> tried including <wctype.h> but didn't find libc++'s <wctype.h> header. \61# error <cwctype> tried including <wctype.h> but didn't find libc++'s <wctype.h> header. \
59 This usually means that your header search paths are not configured properly. \62 This usually means that your header search paths are not configured properly. \
60 The header search paths should contain the C++ Standard Library headers before \63 The header search paths should contain the C++ Standard Library headers before \
61 any C Standard Library, and you are probably using compiler flags that make that \64 any C Standard Library, and you are probably using compiler flags that make that \
62 not be the case.65 not be the case.
63#endif66# endif
6467
65#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)68# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
66# pragma GCC system_header69# pragma GCC system_header
67#endif70# endif
6871
69_LIBCPP_BEGIN_NAMESPACE_STD72_LIBCPP_BEGIN_NAMESPACE_STD
7073
71#if defined(_LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H)74# if defined(_LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H)
72using ::wint_t _LIBCPP_USING_IF_EXISTS;75using ::wint_t _LIBCPP_USING_IF_EXISTS;
73using ::wctrans_t _LIBCPP_USING_IF_EXISTS;76using ::wctrans_t _LIBCPP_USING_IF_EXISTS;
74using ::wctype_t _LIBCPP_USING_IF_EXISTS;77using ::wctype_t _LIBCPP_USING_IF_EXISTS;
...@@ -90,8 +93,10 @@ using ::towlower _LIBCPP_USING_IF_EXISTS;...@@ -90,8 +93,10 @@ using ::towlower _LIBCPP_USING_IF_EXISTS;
90using ::towupper _LIBCPP_USING_IF_EXISTS;93using ::towupper _LIBCPP_USING_IF_EXISTS;
91using ::towctrans _LIBCPP_USING_IF_EXISTS;94using ::towctrans _LIBCPP_USING_IF_EXISTS;
92using ::wctrans _LIBCPP_USING_IF_EXISTS;95using ::wctrans _LIBCPP_USING_IF_EXISTS;
93#endif // _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H96# endif // _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H
9497
95_LIBCPP_END_NAMESPACE_STD98_LIBCPP_END_NAMESPACE_STD
9699
100#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
101
97#endif // _LIBCPP_CWCTYPE102#endif // _LIBCPP_CWCTYPE
lib/libcxx/include/deque+267-233
...@@ -177,72 +177,90 @@ template <class T, class Allocator, class Predicate>...@@ -177,72 +177,90 @@ template <class T, class Allocator, class Predicate>
177177
178*/178*/
179179
180#include <__algorithm/copy.h>180#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
181#include <__algorithm/copy_backward.h>181# include <__cxx03/deque>
182#include <__algorithm/copy_n.h>182#else
183#include <__algorithm/equal.h>183# include <__algorithm/copy.h>
184#include <__algorithm/fill_n.h>184# include <__algorithm/copy_backward.h>
185#include <__algorithm/lexicographical_compare.h>185# include <__algorithm/copy_n.h>
186#include <__algorithm/lexicographical_compare_three_way.h>186# include <__algorithm/equal.h>
187#include <__algorithm/min.h>187# include <__algorithm/fill_n.h>
188#include <__algorithm/remove.h>188# include <__algorithm/lexicographical_compare.h>
189#include <__algorithm/remove_if.h>189# include <__algorithm/lexicographical_compare_three_way.h>
190#include <__algorithm/unwrap_iter.h>190# include <__algorithm/max.h>
191#include <__assert>191# include <__algorithm/min.h>
192#include <__config>192# include <__algorithm/move.h>
193#include <__debug_utils/sanitizers.h>193# include <__algorithm/move_backward.h>
194#include <__format/enable_insertable.h>194# include <__algorithm/remove.h>
195#include <__fwd/deque.h>195# include <__algorithm/remove_if.h>
196#include <__iterator/distance.h>196# include <__algorithm/unwrap_iter.h>
197#include <__iterator/iterator_traits.h>197# include <__assert>
198#include <__iterator/next.h>198# include <__config>
199#include <__iterator/prev.h>199# include <__debug_utils/sanitizers.h>
200#include <__iterator/reverse_iterator.h>200# include <__format/enable_insertable.h>
201#include <__iterator/segmented_iterator.h>201# include <__fwd/deque.h>
202#include <__memory/addressof.h>202# include <__iterator/distance.h>
203#include <__memory/allocator_destructor.h>203# include <__iterator/iterator_traits.h>
204#include <__memory/pointer_traits.h>204# include <__iterator/move_iterator.h>
205#include <__memory/temp_value.h>205# include <__iterator/next.h>
206#include <__memory/unique_ptr.h>206# include <__iterator/prev.h>
207#include <__memory_resource/polymorphic_allocator.h>207# include <__iterator/reverse_iterator.h>
208#include <__ranges/access.h>208# include <__iterator/segmented_iterator.h>
209#include <__ranges/concepts.h>209# include <__memory/addressof.h>
210#include <__ranges/container_compatible_range.h>210# include <__memory/allocator.h>
211#include <__ranges/from_range.h>211# include <__memory/allocator_destructor.h>
212#include <__ranges/size.h>212# include <__memory/allocator_traits.h>
213#include <__split_buffer>213# include <__memory/compressed_pair.h>
214#include <__type_traits/is_allocator.h>214# include <__memory/pointer_traits.h>
215#include <__type_traits/is_convertible.h>215# include <__memory/swap_allocator.h>
216#include <__type_traits/is_same.h>216# include <__memory/temp_value.h>
217#include <__type_traits/is_swappable.h>217# include <__memory/unique_ptr.h>
218#include <__type_traits/type_identity.h>218# include <__memory_resource/polymorphic_allocator.h>
219#include <__utility/forward.h>219# include <__ranges/access.h>
220#include <__utility/move.h>220# include <__ranges/concepts.h>
221#include <__utility/pair.h>221# include <__ranges/container_compatible_range.h>
222#include <__utility/swap.h>222# include <__ranges/from_range.h>
223#include <limits>223# include <__ranges/size.h>
224#include <stdexcept>224# include <__split_buffer>
225#include <version>225# include <__type_traits/conditional.h>
226# include <__type_traits/container_traits.h>
227# include <__type_traits/disjunction.h>
228# include <__type_traits/enable_if.h>
229# include <__type_traits/is_allocator.h>
230# include <__type_traits/is_convertible.h>
231# include <__type_traits/is_nothrow_assignable.h>
232# include <__type_traits/is_nothrow_constructible.h>
233# include <__type_traits/is_same.h>
234# include <__type_traits/is_swappable.h>
235# include <__type_traits/is_trivially_relocatable.h>
236# include <__type_traits/type_identity.h>
237# include <__utility/forward.h>
238# include <__utility/move.h>
239# include <__utility/pair.h>
240# include <__utility/swap.h>
241# include <limits>
242# include <stdexcept>
243# include <version>
226244
227// standard-mandated includes245// standard-mandated includes
228246
229// [iterator.range]247// [iterator.range]
230#include <__iterator/access.h>248# include <__iterator/access.h>
231#include <__iterator/data.h>249# include <__iterator/data.h>
232#include <__iterator/empty.h>250# include <__iterator/empty.h>
233#include <__iterator/reverse_access.h>251# include <__iterator/reverse_access.h>
234#include <__iterator/size.h>252# include <__iterator/size.h>
235253
236// [deque.syn]254// [deque.syn]
237#include <compare>255# include <compare>
238#include <initializer_list>256# include <initializer_list>
239257
240#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)258# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
241# pragma GCC system_header259# pragma GCC system_header
242#endif260# endif
243261
244_LIBCPP_PUSH_MACROS262_LIBCPP_PUSH_MACROS
245#include <__undef_macros>263# include <__undef_macros>
246264
247_LIBCPP_BEGIN_NAMESPACE_STD265_LIBCPP_BEGIN_NAMESPACE_STD
248266
...@@ -257,13 +275,13 @@ template <class _ValueType,...@@ -257,13 +275,13 @@ template <class _ValueType,
257 class _MapPointer,275 class _MapPointer,
258 class _DiffType,276 class _DiffType,
259 _DiffType _BS =277 _DiffType _BS =
260#ifdef _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE278# ifdef _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
261 // Keep template parameter to avoid changing all template declarations thoughout279 // Keep template parameter to avoid changing all template declarations thoughout
262 // this file.280 // this file.
263 0281 0
264#else282# else
265 __deque_block_size<_ValueType, _DiffType>::value283 __deque_block_size<_ValueType, _DiffType>::value
266#endif284# endif
267 >285 >
268class _LIBCPP_TEMPLATE_VIS __deque_iterator {286class _LIBCPP_TEMPLATE_VIS __deque_iterator {
269 typedef _MapPointer __map_iterator;287 typedef _MapPointer __map_iterator;
...@@ -284,10 +302,10 @@ public:...@@ -284,10 +302,10 @@ public:
284 typedef _Reference reference;302 typedef _Reference reference;
285303
286 _LIBCPP_HIDE_FROM_ABI __deque_iterator() _NOEXCEPT304 _LIBCPP_HIDE_FROM_ABI __deque_iterator() _NOEXCEPT
287#if _LIBCPP_STD_VER >= 14305# if _LIBCPP_STD_VER >= 14
288 : __m_iter_(nullptr),306 : __m_iter_(nullptr),
289 __ptr_(nullptr)307 __ptr_(nullptr)
290#endif308# endif
291 {309 {
292 }310 }
293311
...@@ -376,13 +394,10 @@ public:...@@ -376,13 +394,10 @@ public:
376 return __x.__ptr_ == __y.__ptr_;394 return __x.__ptr_ == __y.__ptr_;
377 }395 }
378396
379#if _LIBCPP_STD_VER <= 17397# if _LIBCPP_STD_VER <= 17
380 _LIBCPP_HIDE_FROM_ABI friend bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y) {398 _LIBCPP_HIDE_FROM_ABI friend bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y) {
381 return !(__x == __y);399 return !(__x == __y);
382 }400 }
383#endif
384
385 // TODO(mordante) disable these overloads in the LLVM 20 release.
386 _LIBCPP_HIDE_FROM_ABI friend bool operator<(const __deque_iterator& __x, const __deque_iterator& __y) {401 _LIBCPP_HIDE_FROM_ABI friend bool operator<(const __deque_iterator& __x, const __deque_iterator& __y) {
387 return __x.__m_iter_ < __y.__m_iter_ || (__x.__m_iter_ == __y.__m_iter_ && __x.__ptr_ < __y.__ptr_);402 return __x.__m_iter_ < __y.__m_iter_ || (__x.__m_iter_ == __y.__m_iter_ && __x.__ptr_ < __y.__ptr_);
388 }403 }
...@@ -399,7 +414,8 @@ public:...@@ -399,7 +414,8 @@ public:
399 return !(__x < __y);414 return !(__x < __y);
400 }415 }
401416
402#if _LIBCPP_STD_VER >= 20417# else
418
403 _LIBCPP_HIDE_FROM_ABI friend strong_ordering operator<=>(const __deque_iterator& __x, const __deque_iterator& __y) {419 _LIBCPP_HIDE_FROM_ABI friend strong_ordering operator<=>(const __deque_iterator& __x, const __deque_iterator& __y) {
404 if (__x.__m_iter_ < __y.__m_iter_)420 if (__x.__m_iter_ < __y.__m_iter_)
405 return strong_ordering::less;421 return strong_ordering::less;
...@@ -420,7 +436,7 @@ public:...@@ -420,7 +436,7 @@ public:
420436
421 return strong_ordering::greater;437 return strong_ordering::greater;
422 }438 }
423#endif // _LIBCPP_STD_VER >= 20439# endif // _LIBCPP_STD_VER >= 20
424440
425private:441private:
426 _LIBCPP_HIDE_FROM_ABI explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT442 _LIBCPP_HIDE_FROM_ABI explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT
...@@ -440,12 +456,13 @@ template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,...@@ -440,12 +456,13 @@ template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
440struct __segmented_iterator_traits<456struct __segmented_iterator_traits<
441 __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize> > {457 __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize> > {
442private:458private:
443 using _Iterator = __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize>;459 using _Iterator _LIBCPP_NODEBUG =
460 __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize>;
444461
445public:462public:
446 using __is_segmented_iterator = true_type;463 using __is_segmented_iterator _LIBCPP_NODEBUG = true_type;
447 using __segment_iterator = _MapPointer;464 using __segment_iterator _LIBCPP_NODEBUG = _MapPointer;
448 using __local_iterator = _Pointer;465 using __local_iterator _LIBCPP_NODEBUG = _Pointer;
449466
450 static _LIBCPP_HIDE_FROM_ABI __segment_iterator __segment(_Iterator __iter) { return __iter.__m_iter_; }467 static _LIBCPP_HIDE_FROM_ABI __segment_iterator __segment(_Iterator __iter) { return __iter.__m_iter_; }
451 static _LIBCPP_HIDE_FROM_ABI __local_iterator __local(_Iterator __iter) { return __iter.__ptr_; }468 static _LIBCPP_HIDE_FROM_ABI __local_iterator __local(_Iterator __iter) { return __iter.__ptr_; }
...@@ -475,8 +492,8 @@ public:...@@ -475,8 +492,8 @@ public:
475492
476 using value_type = _Tp;493 using value_type = _Tp;
477494
478 using allocator_type = _Allocator;495 using allocator_type = _Allocator;
479 using __alloc_traits = allocator_traits<allocator_type>;496 using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>;
480 static_assert(__check_valid_allocator<allocator_type>::value, "");497 static_assert(__check_valid_allocator<allocator_type>::value, "");
481 static_assert(is_same<typename allocator_type::value_type, value_type>::value,498 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
482 "Allocator::value_type must be same type as value_type");499 "Allocator::value_type must be same type as value_type");
...@@ -487,13 +504,13 @@ public:...@@ -487,13 +504,13 @@ public:
487 using pointer = typename __alloc_traits::pointer;504 using pointer = typename __alloc_traits::pointer;
488 using const_pointer = typename __alloc_traits::const_pointer;505 using const_pointer = typename __alloc_traits::const_pointer;
489506
490 using __pointer_allocator = __rebind_alloc<__alloc_traits, pointer>;507 using __pointer_allocator _LIBCPP_NODEBUG = __rebind_alloc<__alloc_traits, pointer>;
491 using __const_pointer_allocator = __rebind_alloc<__alloc_traits, const_pointer>;508 using __const_pointer_allocator _LIBCPP_NODEBUG = __rebind_alloc<__alloc_traits, const_pointer>;
492 using __map = __split_buffer<pointer, __pointer_allocator>;509 using __map _LIBCPP_NODEBUG = __split_buffer<pointer, __pointer_allocator>;
493 using __map_alloc_traits = allocator_traits<__pointer_allocator>;510 using __map_alloc_traits _LIBCPP_NODEBUG = allocator_traits<__pointer_allocator>;
494 using __map_pointer = typename __map_alloc_traits::pointer;511 using __map_pointer _LIBCPP_NODEBUG = typename __map_alloc_traits::pointer;
495 using __map_const_pointer = typename allocator_traits<__const_pointer_allocator>::const_pointer;512 using __map_const_pointer _LIBCPP_NODEBUG = typename allocator_traits<__const_pointer_allocator>::const_pointer;
496 using __map_const_iterator = typename __map::const_iterator;513 using __map_const_iterator _LIBCPP_NODEBUG = typename __map::const_iterator;
497514
498 using reference = value_type&;515 using reference = value_type&;
499 using const_reference = const value_type&;516 using const_reference = const value_type&;
...@@ -509,7 +526,7 @@ public:...@@ -509,7 +526,7 @@ public:
509 // - size_type: is always trivially relocatable, since it is required to be an integral type526 // - size_type: is always trivially relocatable, since it is required to be an integral type
510 // - allocator_type: may not be trivially relocatable, so it's checked527 // - allocator_type: may not be trivially relocatable, so it's checked
511 // None of these are referencing the `deque` itself, so if all of them are trivially relocatable, `deque` is too.528 // None of these are referencing the `deque` itself, so if all of them are trivially relocatable, `deque` is too.
512 using __trivially_relocatable = __conditional_t<529 using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<
513 __libcpp_is_trivially_relocatable<__map>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,530 __libcpp_is_trivially_relocatable<__map>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
514 deque,531 deque,
515 void>;532 void>;
...@@ -584,12 +601,12 @@ private:...@@ -584,12 +601,12 @@ private:
584601
585 __map __map_;602 __map __map_;
586 size_type __start_;603 size_type __start_;
587 __compressed_pair<size_type, allocator_type> __size_;604 _LIBCPP_COMPRESSED_PAIR(size_type, __size_, allocator_type, __alloc_);
588605
589public:606public:
590 // construct/copy/destroy:607 // construct/copy/destroy:
591 _LIBCPP_HIDE_FROM_ABI deque() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)608 _LIBCPP_HIDE_FROM_ABI deque() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
592 : __start_(0), __size_(0, __default_init_tag()) {609 : __start_(0), __size_(0) {
593 __annotate_new(0);610 __annotate_new(0);
594 }611 }
595612
...@@ -603,19 +620,19 @@ public:...@@ -603,19 +620,19 @@ public:
603 }620 }
604621
605 _LIBCPP_HIDE_FROM_ABI explicit deque(const allocator_type& __a)622 _LIBCPP_HIDE_FROM_ABI explicit deque(const allocator_type& __a)
606 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {623 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) {
607 __annotate_new(0);624 __annotate_new(0);
608 }625 }
609626
610 explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n);627 explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n);
611#if _LIBCPP_STD_VER >= 14628# if _LIBCPP_STD_VER >= 14
612 explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const _Allocator& __a);629 explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const _Allocator& __a);
613#endif630# endif
614 _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v);631 _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v);
615632
616 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>633 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>
617 _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v, const allocator_type& __a)634 _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v, const allocator_type& __a)
618 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {635 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) {
619 __annotate_new(0);636 __annotate_new(0);
620 if (__n > 0)637 if (__n > 0)
621 __append(__n, __v);638 __append(__n, __v);
...@@ -626,10 +643,10 @@ public:...@@ -626,10 +643,10 @@ public:
626 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>643 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
627 _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l, const allocator_type& __a);644 _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l, const allocator_type& __a);
628645
629#if _LIBCPP_STD_VER >= 23646# if _LIBCPP_STD_VER >= 23
630 template <_ContainerCompatibleRange<_Tp> _Range>647 template <_ContainerCompatibleRange<_Tp> _Range>
631 _LIBCPP_HIDE_FROM_ABI deque(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())648 _LIBCPP_HIDE_FROM_ABI deque(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())
632 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {649 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) {
633 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {650 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
634 __append_with_size(ranges::begin(__range), ranges::distance(__range));651 __append_with_size(ranges::begin(__range), ranges::distance(__range));
635652
...@@ -639,14 +656,14 @@ public:...@@ -639,14 +656,14 @@ public:
639 }656 }
640 }657 }
641 }658 }
642#endif659# endif
643660
644 _LIBCPP_HIDE_FROM_ABI deque(const deque& __c);661 _LIBCPP_HIDE_FROM_ABI deque(const deque& __c);
645 _LIBCPP_HIDE_FROM_ABI deque(const deque& __c, const __type_identity_t<allocator_type>& __a);662 _LIBCPP_HIDE_FROM_ABI deque(const deque& __c, const __type_identity_t<allocator_type>& __a);
646663
647 _LIBCPP_HIDE_FROM_ABI deque& operator=(const deque& __c);664 _LIBCPP_HIDE_FROM_ABI deque& operator=(const deque& __c);
648665
649#ifndef _LIBCPP_CXX03_LANG666# ifndef _LIBCPP_CXX03_LANG
650 _LIBCPP_HIDE_FROM_ABI deque(initializer_list<value_type> __il);667 _LIBCPP_HIDE_FROM_ABI deque(initializer_list<value_type> __il);
651 _LIBCPP_HIDE_FROM_ABI deque(initializer_list<value_type> __il, const allocator_type& __a);668 _LIBCPP_HIDE_FROM_ABI deque(initializer_list<value_type> __il, const allocator_type& __a);
652669
...@@ -662,7 +679,7 @@ public:...@@ -662,7 +679,7 @@ public:
662 is_nothrow_move_assignable<allocator_type>::value);679 is_nothrow_move_assignable<allocator_type>::value);
663680
664 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); }681 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); }
665#endif // _LIBCPP_CXX03_LANG682# endif // _LIBCPP_CXX03_LANG
666683
667 template <class _InputIter,684 template <class _InputIter,
668 __enable_if_t<__has_input_iterator_category<_InputIter>::value &&685 __enable_if_t<__has_input_iterator_category<_InputIter>::value &&
...@@ -672,7 +689,7 @@ public:...@@ -672,7 +689,7 @@ public:
672 template <class _RAIter, __enable_if_t<__has_random_access_iterator_category<_RAIter>::value, int> = 0>689 template <class _RAIter, __enable_if_t<__has_random_access_iterator_category<_RAIter>::value, int> = 0>
673 _LIBCPP_HIDE_FROM_ABI void assign(_RAIter __f, _RAIter __l);690 _LIBCPP_HIDE_FROM_ABI void assign(_RAIter __f, _RAIter __l);
674691
675#if _LIBCPP_STD_VER >= 23692# if _LIBCPP_STD_VER >= 23
676 template <_ContainerCompatibleRange<_Tp> _Range>693 template <_ContainerCompatibleRange<_Tp> _Range>
677 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) {694 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) {
678 if constexpr (ranges::random_access_range<_Range>) {695 if constexpr (ranges::random_access_range<_Range>) {
...@@ -687,13 +704,13 @@ public:...@@ -687,13 +704,13 @@ public:
687 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));704 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));
688 }705 }
689 }706 }
690#endif707# endif
691708
692 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v);709 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v);
693710
694 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT;711 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT;
695 _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __size_.second(); }712 _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __alloc_; }
696 _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __size_.second(); }713 _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __alloc_; }
697714
698 // iterators:715 // iterators:
699716
...@@ -732,8 +749,8 @@ public:...@@ -732,8 +749,8 @@ public:
732 // capacity:749 // capacity:
733 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size(); }750 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size(); }
734751
735 _LIBCPP_HIDE_FROM_ABI size_type& __size() _NOEXCEPT { return __size_.first(); }752 _LIBCPP_HIDE_FROM_ABI size_type& __size() _NOEXCEPT { return __size_; }
736 _LIBCPP_HIDE_FROM_ABI const size_type& __size() const _NOEXCEPT { return __size_.first(); }753 _LIBCPP_HIDE_FROM_ABI const size_type& __size() const _NOEXCEPT { return __size_; }
737754
738 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {755 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
739 return std::min<size_type>(__alloc_traits::max_size(__alloc()), numeric_limits<difference_type>::max());756 return std::min<size_type>(__alloc_traits::max_size(__alloc()), numeric_limits<difference_type>::max());
...@@ -741,7 +758,7 @@ public:...@@ -741,7 +758,7 @@ public:
741 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);758 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);
742 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v);759 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v);
743 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;760 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
744 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; }761 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; }
745762
746 // element access:763 // element access:
747 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __i) _NOEXCEPT;764 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __i) _NOEXCEPT;
...@@ -756,25 +773,25 @@ public:...@@ -756,25 +773,25 @@ public:
756 // 23.2.2.3 modifiers:773 // 23.2.2.3 modifiers:
757 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v);774 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v);
758 _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __v);775 _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __v);
759#ifndef _LIBCPP_CXX03_LANG776# ifndef _LIBCPP_CXX03_LANG
760# if _LIBCPP_STD_VER >= 17777# if _LIBCPP_STD_VER >= 17
761 template <class... _Args>778 template <class... _Args>
762 _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);779 _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);
763 template <class... _Args>780 template <class... _Args>
764 _LIBCPP_HIDE_FROM_ABI reference emplace_back(_Args&&... __args);781 _LIBCPP_HIDE_FROM_ABI reference emplace_back(_Args&&... __args);
765# else782# else
766 template <class... _Args>783 template <class... _Args>
767 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);784 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);
768 template <class... _Args>785 template <class... _Args>
769 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args);786 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args);
770# endif787# endif
771 template <class... _Args>788 template <class... _Args>
772 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args);789 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args);
773790
774 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v);791 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v);
775 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __v);792 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __v);
776793
777# if _LIBCPP_STD_VER >= 23794# if _LIBCPP_STD_VER >= 23
778 template <_ContainerCompatibleRange<_Tp> _Range>795 template <_ContainerCompatibleRange<_Tp> _Range>
779 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) {796 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) {
780 insert_range(begin(), std::forward<_Range>(__range));797 insert_range(begin(), std::forward<_Range>(__range));
...@@ -784,14 +801,14 @@ public:...@@ -784,14 +801,14 @@ public:
784 _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) {801 _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) {
785 insert_range(end(), std::forward<_Range>(__range));802 insert_range(end(), std::forward<_Range>(__range));
786 }803 }
787# endif804# endif
788805
789 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v);806 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v);
790807
791 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list<value_type> __il) {808 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list<value_type> __il) {
792 return insert(__p, __il.begin(), __il.end());809 return insert(__p, __il.begin(), __il.end());
793 }810 }
794#endif // _LIBCPP_CXX03_LANG811# endif // _LIBCPP_CXX03_LANG
795 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v);812 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v);
796 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __v);813 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __v);
797 template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> = 0>814 template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> = 0>
...@@ -802,7 +819,7 @@ public:...@@ -802,7 +819,7 @@ public:
802 template <class _BiIter, __enable_if_t<__has_bidirectional_iterator_category<_BiIter>::value, int> = 0>819 template <class _BiIter, __enable_if_t<__has_bidirectional_iterator_category<_BiIter>::value, int> = 0>
803 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _BiIter __f, _BiIter __l);820 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _BiIter __f, _BiIter __l);
804821
805#if _LIBCPP_STD_VER >= 23822# if _LIBCPP_STD_VER >= 23
806 template <_ContainerCompatibleRange<_Tp> _Range>823 template <_ContainerCompatibleRange<_Tp> _Range>
807 _LIBCPP_HIDE_FROM_ABI iterator insert_range(const_iterator __position, _Range&& __range) {824 _LIBCPP_HIDE_FROM_ABI iterator insert_range(const_iterator __position, _Range&& __range) {
808 if constexpr (ranges::bidirectional_range<_Range>) {825 if constexpr (ranges::bidirectional_range<_Range>) {
...@@ -817,7 +834,7 @@ public:...@@ -817,7 +834,7 @@ public:
817 return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));834 return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));
818 }835 }
819 }836 }
820#endif837# endif
821838
822 _LIBCPP_HIDE_FROM_ABI void pop_front();839 _LIBCPP_HIDE_FROM_ABI void pop_front();
823 _LIBCPP_HIDE_FROM_ABI void pop_back();840 _LIBCPP_HIDE_FROM_ABI void pop_back();
...@@ -825,11 +842,11 @@ public:...@@ -825,11 +842,11 @@ public:
825 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l);842 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l);
826843
827 _LIBCPP_HIDE_FROM_ABI void swap(deque& __c)844 _LIBCPP_HIDE_FROM_ABI void swap(deque& __c)
828#if _LIBCPP_STD_VER >= 14845# if _LIBCPP_STD_VER >= 14
829 _NOEXCEPT;846 _NOEXCEPT;
830#else847# else
831 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);848 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
832#endif849# endif
833 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;850 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
834851
835 _LIBCPP_HIDE_FROM_ABI bool __invariants() const {852 _LIBCPP_HIDE_FROM_ABI bool __invariants() const {
...@@ -907,7 +924,7 @@ private:...@@ -907,7 +924,7 @@ private:
907 (void)__end;924 (void)__end;
908 (void)__annotation_type;925 (void)__annotation_type;
909 (void)__place;926 (void)__place;
910#ifndef _LIBCPP_HAS_NO_ASAN927# if _LIBCPP_HAS_ASAN
911 // __beg - index of the first item to annotate928 // __beg - index of the first item to annotate
912 // __end - index behind the last item to annotate (so last item + 1)929 // __end - index behind the last item to annotate (so last item + 1)
913 // __annotation_type - __asan_unposion or __asan_poison930 // __annotation_type - __asan_unposion or __asan_poison
...@@ -1000,23 +1017,23 @@ private:...@@ -1000,23 +1017,23 @@ private:
1000 std::__annotate_double_ended_contiguous_container<_Allocator>(1017 std::__annotate_double_ended_contiguous_container<_Allocator>(
1001 __mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end);1018 __mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end);
1002 }1019 }
1003#endif // !_LIBCPP_HAS_NO_ASAN1020# endif // _LIBCPP_HAS_ASAN
1004 }1021 }
10051022
1006 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {1023 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {
1007 (void)__current_size;1024 (void)__current_size;
1008#ifndef _LIBCPP_HAS_NO_ASAN1025# if _LIBCPP_HAS_ASAN
1009 if (__current_size == 0)1026 if (__current_size == 0)
1010 __annotate_from_to(0, __map_.size() * __block_size, __asan_poison, __asan_back_moved);1027 __annotate_from_to(0, __map_.size() * __block_size, __asan_poison, __asan_back_moved);
1011 else {1028 else {
1012 __annotate_from_to(0, __start_, __asan_poison, __asan_front_moved);1029 __annotate_from_to(0, __start_, __asan_poison, __asan_front_moved);
1013 __annotate_from_to(__start_ + __current_size, __map_.size() * __block_size, __asan_poison, __asan_back_moved);1030 __annotate_from_to(__start_ + __current_size, __map_.size() * __block_size, __asan_poison, __asan_back_moved);
1014 }1031 }
1015#endif1032# endif // _LIBCPP_HAS_ASAN
1016 }1033 }
10171034
1018 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {1035 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {
1019#ifndef _LIBCPP_HAS_NO_ASAN1036# if _LIBCPP_HAS_ASAN
1020 if (empty()) {1037 if (empty()) {
1021 for (size_t __i = 0; __i < __map_.size(); ++__i) {1038 for (size_t __i = 0; __i < __map_.size(); ++__i) {
1022 __annotate_whole_block(__i, __asan_unposion);1039 __annotate_whole_block(__i, __asan_unposion);
...@@ -1025,37 +1042,37 @@ private:...@@ -1025,37 +1042,37 @@ private:
1025 __annotate_from_to(0, __start_, __asan_unposion, __asan_front_moved);1042 __annotate_from_to(0, __start_, __asan_unposion, __asan_front_moved);
1026 __annotate_from_to(__start_ + size(), __map_.size() * __block_size, __asan_unposion, __asan_back_moved);1043 __annotate_from_to(__start_ + size(), __map_.size() * __block_size, __asan_unposion, __asan_back_moved);
1027 }1044 }
1028#endif1045# endif // _LIBCPP_HAS_ASAN
1029 }1046 }
10301047
1031 _LIBCPP_HIDE_FROM_ABI void __annotate_increase_front(size_type __n) const _NOEXCEPT {1048 _LIBCPP_HIDE_FROM_ABI void __annotate_increase_front(size_type __n) const _NOEXCEPT {
1032 (void)__n;1049 (void)__n;
1033#ifndef _LIBCPP_HAS_NO_ASAN1050# if _LIBCPP_HAS_ASAN
1034 __annotate_from_to(__start_ - __n, __start_, __asan_unposion, __asan_front_moved);1051 __annotate_from_to(__start_ - __n, __start_, __asan_unposion, __asan_front_moved);
1035#endif1052# endif
1036 }1053 }
10371054
1038 _LIBCPP_HIDE_FROM_ABI void __annotate_increase_back(size_type __n) const _NOEXCEPT {1055 _LIBCPP_HIDE_FROM_ABI void __annotate_increase_back(size_type __n) const _NOEXCEPT {
1039 (void)__n;1056 (void)__n;
1040#ifndef _LIBCPP_HAS_NO_ASAN1057# if _LIBCPP_HAS_ASAN
1041 __annotate_from_to(__start_ + size(), __start_ + size() + __n, __asan_unposion, __asan_back_moved);1058 __annotate_from_to(__start_ + size(), __start_ + size() + __n, __asan_unposion, __asan_back_moved);
1042#endif1059# endif
1043 }1060 }
10441061
1045 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_front(size_type __old_size, size_type __old_start) const _NOEXCEPT {1062 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_front(size_type __old_size, size_type __old_start) const _NOEXCEPT {
1046 (void)__old_size;1063 (void)__old_size;
1047 (void)__old_start;1064 (void)__old_start;
1048#ifndef _LIBCPP_HAS_NO_ASAN1065# if _LIBCPP_HAS_ASAN
1049 __annotate_from_to(__old_start, __old_start + (__old_size - size()), __asan_poison, __asan_front_moved);1066 __annotate_from_to(__old_start, __old_start + (__old_size - size()), __asan_poison, __asan_front_moved);
1050#endif1067# endif
1051 }1068 }
10521069
1053 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_back(size_type __old_size, size_type __old_start) const _NOEXCEPT {1070 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_back(size_type __old_size, size_type __old_start) const _NOEXCEPT {
1054 (void)__old_size;1071 (void)__old_size;
1055 (void)__old_start;1072 (void)__old_start;
1056#ifndef _LIBCPP_HAS_NO_ASAN1073# if _LIBCPP_HAS_ASAN
1057 __annotate_from_to(__old_start + size(), __old_start + __old_size, __asan_poison, __asan_back_moved);1074 __annotate_from_to(__old_start + size(), __old_start + __old_size, __asan_poison, __asan_back_moved);
1058#endif1075# endif
1059 }1076 }
10601077
1061 _LIBCPP_HIDE_FROM_ABI void __annotate_poison_block(const void* __beginning, const void* __end) const _NOEXCEPT {1078 _LIBCPP_HIDE_FROM_ABI void __annotate_poison_block(const void* __beginning, const void* __end) const _NOEXCEPT {
...@@ -1066,7 +1083,7 @@ private:...@@ -1066,7 +1083,7 @@ private:
1066 __annotate_whole_block(size_t __block_index, __asan_annotation_type __annotation_type) const _NOEXCEPT {1083 __annotate_whole_block(size_t __block_index, __asan_annotation_type __annotation_type) const _NOEXCEPT {
1067 (void)__block_index;1084 (void)__block_index;
1068 (void)__annotation_type;1085 (void)__annotation_type;
1069#ifndef _LIBCPP_HAS_NO_ASAN1086# if _LIBCPP_HAS_ASAN
1070 __map_const_iterator __block_it = __map_.begin() + __block_index;1087 __map_const_iterator __block_it = __map_.begin() + __block_index;
1071 const void* __block_start = std::__to_address(*__block_it);1088 const void* __block_start = std::__to_address(*__block_it);
1072 const void* __block_end = std::__to_address(*__block_it + __block_size);1089 const void* __block_end = std::__to_address(*__block_it + __block_size);
...@@ -1077,9 +1094,9 @@ private:...@@ -1077,9 +1094,9 @@ private:
1077 std::__annotate_double_ended_contiguous_container<_Allocator>(1094 std::__annotate_double_ended_contiguous_container<_Allocator>(
1078 __block_start, __block_end, __block_start, __block_start, __block_start, __block_end);1095 __block_start, __block_end, __block_start, __block_start, __block_start, __block_end);
1079 }1096 }
1080#endif1097# endif
1081 }1098 }
1082#if !defined(_LIBCPP_HAS_NO_ASAN)1099# if _LIBCPP_HAS_ASAN
10831100
1084public:1101public:
1085 _LIBCPP_HIDE_FROM_ABI bool __verify_asan_annotations() const _NOEXCEPT {1102 _LIBCPP_HIDE_FROM_ABI bool __verify_asan_annotations() const _NOEXCEPT {
...@@ -1141,7 +1158,7 @@ public:...@@ -1141,7 +1158,7 @@ public:
1141 }1158 }
11421159
1143private:1160private:
1144#endif // _LIBCPP_VERIFY_ASAN_DEQUE_ANNOTATIONS1161# endif // _LIBCPP_HAS_ASAN
1145 _LIBCPP_HIDE_FROM_ABI bool __maybe_remove_front_spare(bool __keep_one = true) {1162 _LIBCPP_HIDE_FROM_ABI bool __maybe_remove_front_spare(bool __keep_one = true) {
1146 if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) {1163 if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) {
1147 __annotate_whole_block(0, __asan_unposion);1164 __annotate_whole_block(0, __asan_unposion);
...@@ -1216,8 +1233,8 @@ private:...@@ -1216,8 +1233,8 @@ private:
1216 clear();1233 clear();
1217 shrink_to_fit();1234 shrink_to_fit();
1218 }1235 }
1219 __alloc() = __c.__alloc();1236 __alloc() = __c.__alloc();
1220 __map_.__alloc() = __c.__map_.__alloc();1237 __map_.__alloc_ = __c.__map_.__alloc_;
1221 }1238 }
12221239
1223 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const deque&, false_type) {}1240 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const deque&, false_type) {}
...@@ -1231,7 +1248,7 @@ template <class _Tp, class _Alloc>...@@ -1231,7 +1248,7 @@ template <class _Tp, class _Alloc>
1231_LIBCPP_CONSTEXPR const typename allocator_traits<_Alloc>::difference_type deque<_Tp, _Alloc>::__block_size =1248_LIBCPP_CONSTEXPR const typename allocator_traits<_Alloc>::difference_type deque<_Tp, _Alloc>::__block_size =
1232 __deque_block_size<value_type, difference_type>::value;1249 __deque_block_size<value_type, difference_type>::value;
12331250
1234#if _LIBCPP_STD_VER >= 171251# if _LIBCPP_STD_VER >= 17
1235template <class _InputIterator,1252template <class _InputIterator,
1236 class _Alloc = allocator<__iter_value_type<_InputIterator>>,1253 class _Alloc = allocator<__iter_value_type<_InputIterator>>,
1237 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,1254 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
...@@ -1243,34 +1260,34 @@ template <class _InputIterator,...@@ -1243,34 +1260,34 @@ template <class _InputIterator,
1243 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,1260 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1244 class = enable_if_t<__is_allocator<_Alloc>::value> >1261 class = enable_if_t<__is_allocator<_Alloc>::value> >
1245deque(_InputIterator, _InputIterator, _Alloc) -> deque<__iter_value_type<_InputIterator>, _Alloc>;1262deque(_InputIterator, _InputIterator, _Alloc) -> deque<__iter_value_type<_InputIterator>, _Alloc>;
1246#endif1263# endif
12471264
1248#if _LIBCPP_STD_VER >= 231265# if _LIBCPP_STD_VER >= 23
1249template <ranges::input_range _Range,1266template <ranges::input_range _Range,
1250 class _Alloc = allocator<ranges::range_value_t<_Range>>,1267 class _Alloc = allocator<ranges::range_value_t<_Range>>,
1251 class = enable_if_t<__is_allocator<_Alloc>::value> >1268 class = enable_if_t<__is_allocator<_Alloc>::value> >
1252deque(from_range_t, _Range&&, _Alloc = _Alloc()) -> deque<ranges::range_value_t<_Range>, _Alloc>;1269deque(from_range_t, _Range&&, _Alloc = _Alloc()) -> deque<ranges::range_value_t<_Range>, _Alloc>;
1253#endif1270# endif
12541271
1255template <class _Tp, class _Allocator>1272template <class _Tp, class _Allocator>
1256deque<_Tp, _Allocator>::deque(size_type __n) : __start_(0), __size_(0, __default_init_tag()) {1273deque<_Tp, _Allocator>::deque(size_type __n) : __start_(0), __size_(0) {
1257 __annotate_new(0);1274 __annotate_new(0);
1258 if (__n > 0)1275 if (__n > 0)
1259 __append(__n);1276 __append(__n);
1260}1277}
12611278
1262#if _LIBCPP_STD_VER >= 141279# if _LIBCPP_STD_VER >= 14
1263template <class _Tp, class _Allocator>1280template <class _Tp, class _Allocator>
1264deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)1281deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
1265 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {1282 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) {
1266 __annotate_new(0);1283 __annotate_new(0);
1267 if (__n > 0)1284 if (__n > 0)
1268 __append(__n);1285 __append(__n);
1269}1286}
1270#endif1287# endif
12711288
1272template <class _Tp, class _Allocator>1289template <class _Tp, class _Allocator>
1273deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) : __start_(0), __size_(0, __default_init_tag()) {1290deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) : __start_(0), __size_(0) {
1274 __annotate_new(0);1291 __annotate_new(0);
1275 if (__n > 0)1292 if (__n > 0)
1276 __append(__n, __v);1293 __append(__n, __v);
...@@ -1278,7 +1295,7 @@ deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) : __start_(0...@@ -1278,7 +1295,7 @@ deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) : __start_(0
12781295
1279template <class _Tp, class _Allocator>1296template <class _Tp, class _Allocator>
1280template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >1297template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
1281deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l) : __start_(0), __size_(0, __default_init_tag()) {1298deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l) : __start_(0), __size_(0) {
1282 __annotate_new(0);1299 __annotate_new(0);
1283 __append(__f, __l);1300 __append(__f, __l);
1284}1301}
...@@ -1286,7 +1303,7 @@ deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l) : __start_(0), __s...@@ -1286,7 +1303,7 @@ deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l) : __start_(0), __s
1286template <class _Tp, class _Allocator>1303template <class _Tp, class _Allocator>
1287template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >1304template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
1288deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a)1305deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a)
1289 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {1306 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) {
1290 __annotate_new(0);1307 __annotate_new(0);
1291 __append(__f, __l);1308 __append(__f, __l);
1292}1309}
...@@ -1295,14 +1312,15 @@ template <class _Tp, class _Allocator>...@@ -1295,14 +1312,15 @@ template <class _Tp, class _Allocator>
1295deque<_Tp, _Allocator>::deque(const deque& __c)1312deque<_Tp, _Allocator>::deque(const deque& __c)
1296 : __map_(__pointer_allocator(__alloc_traits::select_on_container_copy_construction(__c.__alloc()))),1313 : __map_(__pointer_allocator(__alloc_traits::select_on_container_copy_construction(__c.__alloc()))),
1297 __start_(0),1314 __start_(0),
1298 __size_(0, __map_.__alloc()) {1315 __size_(0),
1316 __alloc_(__map_.__alloc_) {
1299 __annotate_new(0);1317 __annotate_new(0);
1300 __append(__c.begin(), __c.end());1318 __append(__c.begin(), __c.end());
1301}1319}
13021320
1303template <class _Tp, class _Allocator>1321template <class _Tp, class _Allocator>
1304deque<_Tp, _Allocator>::deque(const deque& __c, const __type_identity_t<allocator_type>& __a)1322deque<_Tp, _Allocator>::deque(const deque& __c, const __type_identity_t<allocator_type>& __a)
1305 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {1323 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) {
1306 __annotate_new(0);1324 __annotate_new(0);
1307 __append(__c.begin(), __c.end());1325 __append(__c.begin(), __c.end());
1308}1326}
...@@ -1316,24 +1334,27 @@ deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(const deque& __c) {...@@ -1316,24 +1334,27 @@ deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(const deque& __c) {
1316 return *this;1334 return *this;
1317}1335}
13181336
1319#ifndef _LIBCPP_CXX03_LANG1337# ifndef _LIBCPP_CXX03_LANG
13201338
1321template <class _Tp, class _Allocator>1339template <class _Tp, class _Allocator>
1322deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il) : __start_(0), __size_(0, __default_init_tag()) {1340deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il) : __start_(0), __size_(0) {
1323 __annotate_new(0);1341 __annotate_new(0);
1324 __append(__il.begin(), __il.end());1342 __append(__il.begin(), __il.end());
1325}1343}
13261344
1327template <class _Tp, class _Allocator>1345template <class _Tp, class _Allocator>
1328deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator_type& __a)1346deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator_type& __a)
1329 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {1347 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) {
1330 __annotate_new(0);1348 __annotate_new(0);
1331 __append(__il.begin(), __il.end());1349 __append(__il.begin(), __il.end());
1332}1350}
13331351
1334template <class _Tp, class _Allocator>1352template <class _Tp, class _Allocator>
1335inline deque<_Tp, _Allocator>::deque(deque&& __c) noexcept(is_nothrow_move_constructible<allocator_type>::value)1353inline deque<_Tp, _Allocator>::deque(deque&& __c) noexcept(is_nothrow_move_constructible<allocator_type>::value)
1336 : __map_(std::move(__c.__map_)), __start_(std::move(__c.__start_)), __size_(std::move(__c.__size_)) {1354 : __map_(std::move(__c.__map_)),
1355 __start_(std::move(__c.__start_)),
1356 __size_(std::move(__c.__size_)),
1357 __alloc_(std::move(__c.__alloc_)) {
1337 __c.__start_ = 0;1358 __c.__start_ = 0;
1338 __c.__size() = 0;1359 __c.__size() = 0;
1339}1360}
...@@ -1342,7 +1363,8 @@ template <class _Tp, class _Allocator>...@@ -1342,7 +1363,8 @@ template <class _Tp, class _Allocator>
1342inline deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<allocator_type>& __a)1363inline deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<allocator_type>& __a)
1343 : __map_(std::move(__c.__map_), __pointer_allocator(__a)),1364 : __map_(std::move(__c.__map_), __pointer_allocator(__a)),
1344 __start_(std::move(__c.__start_)),1365 __start_(std::move(__c.__start_)),
1345 __size_(std::move(__c.__size()), __a) {1366 __size_(std::move(__c.__size_)),
1367 __alloc_(__a) {
1346 if (__a == __c.__alloc()) {1368 if (__a == __c.__alloc()) {
1347 __c.__start_ = 0;1369 __c.__start_ = 0;
1348 __c.__size() = 0;1370 __c.__size() = 0;
...@@ -1380,7 +1402,7 @@ void deque<_Tp, _Allocator>::__move_assign(deque& __c,...@@ -1380,7 +1402,7 @@ void deque<_Tp, _Allocator>::__move_assign(deque& __c,
1380 __move_assign(__c);1402 __move_assign(__c);
1381}1403}
13821404
1383#endif // _LIBCPP_CXX03_LANG1405# endif // _LIBCPP_CXX03_LANG
13841406
1385template <class _Tp, class _Allocator>1407template <class _Tp, class _Allocator>
1386template <class _InputIter,1408template <class _InputIter,
...@@ -1568,7 +1590,7 @@ void deque<_Tp, _Allocator>::push_front(const value_type& __v) {...@@ -1568,7 +1590,7 @@ void deque<_Tp, _Allocator>::push_front(const value_type& __v) {
1568 ++__size();1590 ++__size();
1569}1591}
15701592
1571#ifndef _LIBCPP_CXX03_LANG1593# ifndef _LIBCPP_CXX03_LANG
1572template <class _Tp, class _Allocator>1594template <class _Tp, class _Allocator>
1573void deque<_Tp, _Allocator>::push_back(value_type&& __v) {1595void deque<_Tp, _Allocator>::push_back(value_type&& __v) {
1574 allocator_type& __a = __alloc();1596 allocator_type& __a = __alloc();
...@@ -1582,11 +1604,11 @@ void deque<_Tp, _Allocator>::push_back(value_type&& __v) {...@@ -1582,11 +1604,11 @@ void deque<_Tp, _Allocator>::push_back(value_type&& __v) {
15821604
1583template <class _Tp, class _Allocator>1605template <class _Tp, class _Allocator>
1584template <class... _Args>1606template <class... _Args>
1585# if _LIBCPP_STD_VER >= 171607# if _LIBCPP_STD_VER >= 17
1586typename deque<_Tp, _Allocator>::reference1608typename deque<_Tp, _Allocator>::reference
1587# else1609# else
1588void1610void
1589# endif1611# endif
1590deque<_Tp, _Allocator>::emplace_back(_Args&&... __args) {1612deque<_Tp, _Allocator>::emplace_back(_Args&&... __args) {
1591 allocator_type& __a = __alloc();1613 allocator_type& __a = __alloc();
1592 if (__back_spare() == 0)1614 if (__back_spare() == 0)
...@@ -1595,9 +1617,9 @@ deque<_Tp, _Allocator>::emplace_back(_Args&&... __args) {...@@ -1595,9 +1617,9 @@ deque<_Tp, _Allocator>::emplace_back(_Args&&... __args) {
1595 __annotate_increase_back(1);1617 __annotate_increase_back(1);
1596 __alloc_traits::construct(__a, std::addressof(*end()), std::forward<_Args>(__args)...);1618 __alloc_traits::construct(__a, std::addressof(*end()), std::forward<_Args>(__args)...);
1597 ++__size();1619 ++__size();
1598# if _LIBCPP_STD_VER >= 171620# if _LIBCPP_STD_VER >= 17
1599 return *--end();1621 return *--end();
1600# endif1622# endif
1601}1623}
16021624
1603template <class _Tp, class _Allocator>1625template <class _Tp, class _Allocator>
...@@ -1614,11 +1636,11 @@ void deque<_Tp, _Allocator>::push_front(value_type&& __v) {...@@ -1614,11 +1636,11 @@ void deque<_Tp, _Allocator>::push_front(value_type&& __v) {
16141636
1615template <class _Tp, class _Allocator>1637template <class _Tp, class _Allocator>
1616template <class... _Args>1638template <class... _Args>
1617# if _LIBCPP_STD_VER >= 171639# if _LIBCPP_STD_VER >= 17
1618typename deque<_Tp, _Allocator>::reference1640typename deque<_Tp, _Allocator>::reference
1619# else1641# else
1620void1642void
1621# endif1643# endif
1622deque<_Tp, _Allocator>::emplace_front(_Args&&... __args) {1644deque<_Tp, _Allocator>::emplace_front(_Args&&... __args) {
1623 allocator_type& __a = __alloc();1645 allocator_type& __a = __alloc();
1624 if (__front_spare() == 0)1646 if (__front_spare() == 0)
...@@ -1628,9 +1650,9 @@ deque<_Tp, _Allocator>::emplace_front(_Args&&... __args) {...@@ -1628,9 +1650,9 @@ deque<_Tp, _Allocator>::emplace_front(_Args&&... __args) {
1628 __alloc_traits::construct(__a, std::addressof(*--begin()), std::forward<_Args>(__args)...);1650 __alloc_traits::construct(__a, std::addressof(*--begin()), std::forward<_Args>(__args)...);
1629 --__start_;1651 --__start_;
1630 ++__size();1652 ++__size();
1631# if _LIBCPP_STD_VER >= 171653# if _LIBCPP_STD_VER >= 17
1632 return *begin();1654 return *begin();
1633# endif1655# endif
1634}1656}
16351657
1636template <class _Tp, class _Allocator>1658template <class _Tp, class _Allocator>
...@@ -1728,7 +1750,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::emplace(const_...@@ -1728,7 +1750,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::emplace(const_
1728 return begin() + __pos;1750 return begin() + __pos;
1729}1751}
17301752
1731#endif // _LIBCPP_CXX03_LANG1753# endif // _LIBCPP_CXX03_LANG
17321754
1733template <class _Tp, class _Allocator>1755template <class _Tp, class _Allocator>
1734typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v) {1756typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v) {
...@@ -1951,11 +1973,11 @@ template <class _Tp, class _Allocator>...@@ -1951,11 +1973,11 @@ template <class _Tp, class _Allocator>
1951template <class _InputIterator, class _Sentinel>1973template <class _InputIterator, class _Sentinel>
1952_LIBCPP_HIDE_FROM_ABI void deque<_Tp, _Allocator>::__append_with_sentinel(_InputIterator __f, _Sentinel __l) {1974_LIBCPP_HIDE_FROM_ABI void deque<_Tp, _Allocator>::__append_with_sentinel(_InputIterator __f, _Sentinel __l) {
1953 for (; __f != __l; ++__f)1975 for (; __f != __l; ++__f)
1954#ifdef _LIBCPP_CXX03_LANG1976# ifdef _LIBCPP_CXX03_LANG
1955 push_back(*__f);1977 push_back(*__f);
1956#else1978# else
1957 emplace_back(*__f);1979 emplace_back(*__f);
1958#endif1980# endif
1959}1981}
19601982
1961template <class _Tp, class _Allocator>1983template <class _Tp, class _Allocator>
...@@ -2023,39 +2045,39 @@ void deque<_Tp, _Allocator>::__add_front_capacity() {...@@ -2023,39 +2045,39 @@ void deque<_Tp, _Allocator>::__add_front_capacity() {
2023 __start_ += __block_size;2045 __start_ += __block_size;
2024 pointer __pt = __map_.back();2046 pointer __pt = __map_.back();
2025 __map_.pop_back();2047 __map_.pop_back();
2026 __map_.push_front(__pt);2048 __map_.emplace_front(__pt);
2027 }2049 }
2028 // Else if __map_.size() < __map_.capacity() then we need to allocate 1 buffer2050 // Else if __map_.size() < __map_.capacity() then we need to allocate 1 buffer
2029 else if (__map_.size() < __map_.capacity()) { // we can put the new buffer into the map, but don't shift things around2051 else if (__map_.size() < __map_.capacity()) { // we can put the new buffer into the map, but don't shift things around
2030 // until all buffers are allocated. If we throw, we don't need to fix2052 // until all buffers are allocated. If we throw, we don't need to fix
2031 // anything up (any added buffers are undetectible)2053 // anything up (any added buffers are undetectible)
2032 if (__map_.__front_spare() > 0)2054 if (__map_.__front_spare() > 0)
2033 __map_.push_front(__alloc_traits::allocate(__a, __block_size));2055 __map_.emplace_front(__alloc_traits::allocate(__a, __block_size));
2034 else {2056 else {
2035 __map_.push_back(__alloc_traits::allocate(__a, __block_size));2057 __map_.emplace_back(__alloc_traits::allocate(__a, __block_size));
2036 // Done allocating, reorder capacity2058 // Done allocating, reorder capacity
2037 pointer __pt = __map_.back();2059 pointer __pt = __map_.back();
2038 __map_.pop_back();2060 __map_.pop_back();
2039 __map_.push_front(__pt);2061 __map_.emplace_front(__pt);
2040 }2062 }
2041 __start_ = __map_.size() == 1 ? __block_size / 2 : __start_ + __block_size;2063 __start_ = __map_.size() == 1 ? __block_size / 2 : __start_ + __block_size;
2042 }2064 }
2043 // Else need to allocate 1 buffer, *and* we need to reallocate __map_.2065 // Else need to allocate 1 buffer, *and* we need to reallocate __map_.
2044 else {2066 else {
2045 __split_buffer<pointer, __pointer_allocator&> __buf(2067 __split_buffer<pointer, __pointer_allocator&> __buf(
2046 std::max<size_type>(2 * __map_.capacity(), 1), 0, __map_.__alloc());2068 std::max<size_type>(2 * __map_.capacity(), 1), 0, __map_.__alloc_);
20472069
2048 typedef __allocator_destructor<_Allocator> _Dp;2070 typedef __allocator_destructor<_Allocator> _Dp;
2049 unique_ptr<pointer, _Dp> __hold(__alloc_traits::allocate(__a, __block_size), _Dp(__a, __block_size));2071 unique_ptr<pointer, _Dp> __hold(__alloc_traits::allocate(__a, __block_size), _Dp(__a, __block_size));
2050 __buf.push_back(__hold.get());2072 __buf.emplace_back(__hold.get());
2051 __hold.release();2073 __hold.release();
20522074
2053 for (__map_pointer __i = __map_.begin(); __i != __map_.end(); ++__i)2075 for (__map_pointer __i = __map_.begin(); __i != __map_.end(); ++__i)
2054 __buf.push_back(*__i);2076 __buf.emplace_back(*__i);
2055 std::swap(__map_.__first_, __buf.__first_);2077 std::swap(__map_.__first_, __buf.__first_);
2056 std::swap(__map_.__begin_, __buf.__begin_);2078 std::swap(__map_.__begin_, __buf.__begin_);
2057 std::swap(__map_.__end_, __buf.__end_);2079 std::swap(__map_.__end_, __buf.__end_);
2058 std::swap(__map_.__end_cap(), __buf.__end_cap());2080 std::swap(__map_.__cap_, __buf.__cap_);
2059 __start_ = __map_.size() == 1 ? __block_size / 2 : __start_ + __block_size;2081 __start_ = __map_.size() == 1 ? __block_size / 2 : __start_ + __block_size;
2060 }2082 }
2061 __annotate_whole_block(0, __asan_poison);2083 __annotate_whole_block(0, __asan_poison);
...@@ -2077,7 +2099,7 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) {...@@ -2077,7 +2099,7 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) {
2077 for (; __back_capacity > 0; --__back_capacity) {2099 for (; __back_capacity > 0; --__back_capacity) {
2078 pointer __pt = __map_.back();2100 pointer __pt = __map_.back();
2079 __map_.pop_back();2101 __map_.pop_back();
2080 __map_.push_front(__pt);2102 __map_.emplace_front(__pt);
2081 }2103 }
2082 }2104 }
2083 // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers2105 // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
...@@ -2088,17 +2110,17 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) {...@@ -2088,17 +2110,17 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) {
2088 for (; __nb > 0; --__nb, __start_ += __block_size - (__map_.size() == 1)) {2110 for (; __nb > 0; --__nb, __start_ += __block_size - (__map_.size() == 1)) {
2089 if (__map_.__front_spare() == 0)2111 if (__map_.__front_spare() == 0)
2090 break;2112 break;
2091 __map_.push_front(__alloc_traits::allocate(__a, __block_size));2113 __map_.emplace_front(__alloc_traits::allocate(__a, __block_size));
2092 __annotate_whole_block(0, __asan_poison);2114 __annotate_whole_block(0, __asan_poison);
2093 }2115 }
2094 for (; __nb > 0; --__nb, ++__back_capacity)2116 for (; __nb > 0; --__nb, ++__back_capacity)
2095 __map_.push_back(__alloc_traits::allocate(__a, __block_size));2117 __map_.emplace_back(__alloc_traits::allocate(__a, __block_size));
2096 // Done allocating, reorder capacity2118 // Done allocating, reorder capacity
2097 __start_ += __back_capacity * __block_size;2119 __start_ += __back_capacity * __block_size;
2098 for (; __back_capacity > 0; --__back_capacity) {2120 for (; __back_capacity > 0; --__back_capacity) {
2099 pointer __pt = __map_.back();2121 pointer __pt = __map_.back();
2100 __map_.pop_back();2122 __map_.pop_back();
2101 __map_.push_front(__pt);2123 __map_.emplace_front(__pt);
2102 __annotate_whole_block(0, __asan_poison);2124 __annotate_whole_block(0, __asan_poison);
2103 }2125 }
2104 }2126 }
...@@ -2106,33 +2128,33 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) {...@@ -2106,33 +2128,33 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) {
2106 else {2128 else {
2107 size_type __ds = (__nb + __back_capacity) * __block_size - __map_.empty();2129 size_type __ds = (__nb + __back_capacity) * __block_size - __map_.empty();
2108 __split_buffer<pointer, __pointer_allocator&> __buf(2130 __split_buffer<pointer, __pointer_allocator&> __buf(
2109 std::max<size_type>(2 * __map_.capacity(), __nb + __map_.size()), 0, __map_.__alloc());2131 std::max<size_type>(2 * __map_.capacity(), __nb + __map_.size()), 0, __map_.__alloc_);
2110#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2132# if _LIBCPP_HAS_EXCEPTIONS
2111 try {2133 try {
2112#endif // _LIBCPP_HAS_NO_EXCEPTIONS2134# endif // _LIBCPP_HAS_EXCEPTIONS
2113 for (; __nb > 0; --__nb) {2135 for (; __nb > 0; --__nb) {
2114 __buf.push_back(__alloc_traits::allocate(__a, __block_size));2136 __buf.emplace_back(__alloc_traits::allocate(__a, __block_size));
2115 // ASan: this is empty container, we have to poison whole block2137 // ASan: this is empty container, we have to poison whole block
2116 __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size));2138 __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size));
2117 }2139 }
2118#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2140# if _LIBCPP_HAS_EXCEPTIONS
2119 } catch (...) {2141 } catch (...) {
2120 __annotate_delete();2142 __annotate_delete();
2121 for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i)2143 for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i)
2122 __alloc_traits::deallocate(__a, *__i, __block_size);2144 __alloc_traits::deallocate(__a, *__i, __block_size);
2123 throw;2145 throw;
2124 }2146 }
2125#endif // _LIBCPP_HAS_NO_EXCEPTIONS2147# endif // _LIBCPP_HAS_EXCEPTIONS
2126 for (; __back_capacity > 0; --__back_capacity) {2148 for (; __back_capacity > 0; --__back_capacity) {
2127 __buf.push_back(__map_.back());2149 __buf.emplace_back(__map_.back());
2128 __map_.pop_back();2150 __map_.pop_back();
2129 }2151 }
2130 for (__map_pointer __i = __map_.begin(); __i != __map_.end(); ++__i)2152 for (__map_pointer __i = __map_.begin(); __i != __map_.end(); ++__i)
2131 __buf.push_back(*__i);2153 __buf.emplace_back(*__i);
2132 std::swap(__map_.__first_, __buf.__first_);2154 std::swap(__map_.__first_, __buf.__first_);
2133 std::swap(__map_.__begin_, __buf.__begin_);2155 std::swap(__map_.__begin_, __buf.__begin_);
2134 std::swap(__map_.__end_, __buf.__end_);2156 std::swap(__map_.__end_, __buf.__end_);
2135 std::swap(__map_.__end_cap(), __buf.__end_cap());2157 std::swap(__map_.__cap_, __buf.__cap_);
2136 __start_ += __ds;2158 __start_ += __ds;
2137 }2159 }
2138}2160}
...@@ -2146,39 +2168,39 @@ void deque<_Tp, _Allocator>::__add_back_capacity() {...@@ -2146,39 +2168,39 @@ void deque<_Tp, _Allocator>::__add_back_capacity() {
2146 __start_ -= __block_size;2168 __start_ -= __block_size;
2147 pointer __pt = __map_.front();2169 pointer __pt = __map_.front();
2148 __map_.pop_front();2170 __map_.pop_front();
2149 __map_.push_back(__pt);2171 __map_.emplace_back(__pt);
2150 }2172 }
2151 // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers2173 // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
2152 else if (__map_.size() < __map_.capacity()) { // we can put the new buffer into the map, but don't shift things around2174 else if (__map_.size() < __map_.capacity()) { // we can put the new buffer into the map, but don't shift things around
2153 // until it is allocated. If we throw, we don't need to fix2175 // until it is allocated. If we throw, we don't need to fix
2154 // anything up (any added buffers are undetectible)2176 // anything up (any added buffers are undetectible)
2155 if (__map_.__back_spare() != 0)2177 if (__map_.__back_spare() != 0)
2156 __map_.push_back(__alloc_traits::allocate(__a, __block_size));2178 __map_.emplace_back(__alloc_traits::allocate(__a, __block_size));
2157 else {2179 else {
2158 __map_.push_front(__alloc_traits::allocate(__a, __block_size));2180 __map_.emplace_front(__alloc_traits::allocate(__a, __block_size));
2159 // Done allocating, reorder capacity2181 // Done allocating, reorder capacity
2160 pointer __pt = __map_.front();2182 pointer __pt = __map_.front();
2161 __map_.pop_front();2183 __map_.pop_front();
2162 __map_.push_back(__pt);2184 __map_.emplace_back(__pt);
2163 }2185 }
2164 __annotate_whole_block(__map_.size() - 1, __asan_poison);2186 __annotate_whole_block(__map_.size() - 1, __asan_poison);
2165 }2187 }
2166 // Else need to allocate 1 buffer, *and* we need to reallocate __map_.2188 // Else need to allocate 1 buffer, *and* we need to reallocate __map_.
2167 else {2189 else {
2168 __split_buffer<pointer, __pointer_allocator&> __buf(2190 __split_buffer<pointer, __pointer_allocator&> __buf(
2169 std::max<size_type>(2 * __map_.capacity(), 1), __map_.size(), __map_.__alloc());2191 std::max<size_type>(2 * __map_.capacity(), 1), __map_.size(), __map_.__alloc_);
21702192
2171 typedef __allocator_destructor<_Allocator> _Dp;2193 typedef __allocator_destructor<_Allocator> _Dp;
2172 unique_ptr<pointer, _Dp> __hold(__alloc_traits::allocate(__a, __block_size), _Dp(__a, __block_size));2194 unique_ptr<pointer, _Dp> __hold(__alloc_traits::allocate(__a, __block_size), _Dp(__a, __block_size));
2173 __buf.push_back(__hold.get());2195 __buf.emplace_back(__hold.get());
2174 __hold.release();2196 __hold.release();
21752197
2176 for (__map_pointer __i = __map_.end(); __i != __map_.begin();)2198 for (__map_pointer __i = __map_.end(); __i != __map_.begin();)
2177 __buf.push_front(*--__i);2199 __buf.emplace_front(*--__i);
2178 std::swap(__map_.__first_, __buf.__first_);2200 std::swap(__map_.__first_, __buf.__first_);
2179 std::swap(__map_.__begin_, __buf.__begin_);2201 std::swap(__map_.__begin_, __buf.__begin_);
2180 std::swap(__map_.__end_, __buf.__end_);2202 std::swap(__map_.__end_, __buf.__end_);
2181 std::swap(__map_.__end_cap(), __buf.__end_cap());2203 std::swap(__map_.__cap_, __buf.__cap_);
2182 __annotate_whole_block(__map_.size() - 1, __asan_poison);2204 __annotate_whole_block(__map_.size() - 1, __asan_poison);
2183 }2205 }
2184}2206}
...@@ -2199,7 +2221,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {...@@ -2199,7 +2221,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {
2199 for (; __front_capacity > 0; --__front_capacity) {2221 for (; __front_capacity > 0; --__front_capacity) {
2200 pointer __pt = __map_.front();2222 pointer __pt = __map_.front();
2201 __map_.pop_front();2223 __map_.pop_front();
2202 __map_.push_back(__pt);2224 __map_.emplace_back(__pt);
2203 }2225 }
2204 }2226 }
2205 // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers2227 // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
...@@ -2210,11 +2232,11 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {...@@ -2210,11 +2232,11 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {
2210 for (; __nb > 0; --__nb) {2232 for (; __nb > 0; --__nb) {
2211 if (__map_.__back_spare() == 0)2233 if (__map_.__back_spare() == 0)
2212 break;2234 break;
2213 __map_.push_back(__alloc_traits::allocate(__a, __block_size));2235 __map_.emplace_back(__alloc_traits::allocate(__a, __block_size));
2214 __annotate_whole_block(__map_.size() - 1, __asan_poison);2236 __annotate_whole_block(__map_.size() - 1, __asan_poison);
2215 }2237 }
2216 for (; __nb > 0; --__nb, ++__front_capacity, __start_ += __block_size - (__map_.size() == 1)) {2238 for (; __nb > 0; --__nb, ++__front_capacity, __start_ += __block_size - (__map_.size() == 1)) {
2217 __map_.push_front(__alloc_traits::allocate(__a, __block_size));2239 __map_.emplace_front(__alloc_traits::allocate(__a, __block_size));
2218 __annotate_whole_block(0, __asan_poison);2240 __annotate_whole_block(0, __asan_poison);
2219 }2241 }
2220 // Done allocating, reorder capacity2242 // Done allocating, reorder capacity
...@@ -2222,7 +2244,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {...@@ -2222,7 +2244,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {
2222 for (; __front_capacity > 0; --__front_capacity) {2244 for (; __front_capacity > 0; --__front_capacity) {
2223 pointer __pt = __map_.front();2245 pointer __pt = __map_.front();
2224 __map_.pop_front();2246 __map_.pop_front();
2225 __map_.push_back(__pt);2247 __map_.emplace_back(__pt);
2226 }2248 }
2227 }2249 }
2228 // Else need to allocate __nb buffers, *and* we need to reallocate __map_.2250 // Else need to allocate __nb buffers, *and* we need to reallocate __map_.
...@@ -2231,33 +2253,33 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {...@@ -2231,33 +2253,33 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {
2231 __split_buffer<pointer, __pointer_allocator&> __buf(2253 __split_buffer<pointer, __pointer_allocator&> __buf(
2232 std::max<size_type>(2 * __map_.capacity(), __nb + __map_.size()),2254 std::max<size_type>(2 * __map_.capacity(), __nb + __map_.size()),
2233 __map_.size() - __front_capacity,2255 __map_.size() - __front_capacity,
2234 __map_.__alloc());2256 __map_.__alloc_);
2235#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2257# if _LIBCPP_HAS_EXCEPTIONS
2236 try {2258 try {
2237#endif // _LIBCPP_HAS_NO_EXCEPTIONS2259# endif // _LIBCPP_HAS_EXCEPTIONS
2238 for (; __nb > 0; --__nb) {2260 for (; __nb > 0; --__nb) {
2239 __buf.push_back(__alloc_traits::allocate(__a, __block_size));2261 __buf.emplace_back(__alloc_traits::allocate(__a, __block_size));
2240 // ASan: this is an empty container, we have to poison the whole block2262 // ASan: this is an empty container, we have to poison the whole block
2241 __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size));2263 __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size));
2242 }2264 }
2243#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2265# if _LIBCPP_HAS_EXCEPTIONS
2244 } catch (...) {2266 } catch (...) {
2245 __annotate_delete();2267 __annotate_delete();
2246 for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i)2268 for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i)
2247 __alloc_traits::deallocate(__a, *__i, __block_size);2269 __alloc_traits::deallocate(__a, *__i, __block_size);
2248 throw;2270 throw;
2249 }2271 }
2250#endif // _LIBCPP_HAS_NO_EXCEPTIONS2272# endif // _LIBCPP_HAS_EXCEPTIONS
2251 for (; __front_capacity > 0; --__front_capacity) {2273 for (; __front_capacity > 0; --__front_capacity) {
2252 __buf.push_back(__map_.front());2274 __buf.emplace_back(__map_.front());
2253 __map_.pop_front();2275 __map_.pop_front();
2254 }2276 }
2255 for (__map_pointer __i = __map_.end(); __i != __map_.begin();)2277 for (__map_pointer __i = __map_.end(); __i != __map_.begin();)
2256 __buf.push_front(*--__i);2278 __buf.emplace_front(*--__i);
2257 std::swap(__map_.__first_, __buf.__first_);2279 std::swap(__map_.__first_, __buf.__first_);
2258 std::swap(__map_.__begin_, __buf.__begin_);2280 std::swap(__map_.__begin_, __buf.__begin_);
2259 std::swap(__map_.__end_, __buf.__end_);2281 std::swap(__map_.__end_, __buf.__end_);
2260 std::swap(__map_.__end_cap(), __buf.__end_cap());2282 std::swap(__map_.__cap_, __buf.__cap_);
2261 __start_ -= __ds;2283 __start_ -= __ds;
2262 }2284 }
2263}2285}
...@@ -2413,7 +2435,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_it...@@ -2413,7 +2435,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_it
2413 difference_type __pos = __f - __b;2435 difference_type __pos = __f - __b;
2414 iterator __p = __b + __pos;2436 iterator __p = __b + __pos;
2415 allocator_type& __a = __alloc();2437 allocator_type& __a = __alloc();
2416 if (static_cast<size_t>(__pos) <= (size() - 1) / 2) { // erase from front2438 if (static_cast<size_type>(__pos) <= (size() - 1) / 2) { // erase from front
2417 std::move_backward(__b, __p, std::next(__p));2439 std::move_backward(__b, __p, std::next(__p));
2418 __alloc_traits::destroy(__a, std::addressof(*__b));2440 __alloc_traits::destroy(__a, std::addressof(*__b));
2419 --__size();2441 --__size();
...@@ -2441,7 +2463,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_it...@@ -2441,7 +2463,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_it
2441 iterator __p = __b + __pos;2463 iterator __p = __b + __pos;
2442 if (__n > 0) {2464 if (__n > 0) {
2443 allocator_type& __a = __alloc();2465 allocator_type& __a = __alloc();
2444 if (static_cast<size_t>(__pos) <= (size() - __n) / 2) { // erase from front2466 if (static_cast<size_type>(__pos) <= (size() - __n) / 2) { // erase from front
2445 iterator __i = std::move_backward(__b, __p, __p + __n);2467 iterator __i = std::move_backward(__b, __p, __p + __n);
2446 for (; __b != __i; ++__b)2468 for (; __b != __i; ++__b)
2447 __alloc_traits::destroy(__a, std::addressof(*__b));2469 __alloc_traits::destroy(__a, std::addressof(*__b));
...@@ -2484,11 +2506,11 @@ void deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f) {...@@ -2484,11 +2506,11 @@ void deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f) {
24842506
2485template <class _Tp, class _Allocator>2507template <class _Tp, class _Allocator>
2486inline void deque<_Tp, _Allocator>::swap(deque& __c)2508inline void deque<_Tp, _Allocator>::swap(deque& __c)
2487#if _LIBCPP_STD_VER >= 142509# if _LIBCPP_STD_VER >= 14
2488 _NOEXCEPT2510 _NOEXCEPT
2489#else2511# else
2490 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)2512 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
2491#endif2513# endif
2492{2514{
2493 __map_.swap(__c.__map_);2515 __map_.swap(__c.__map_);
2494 std::swap(__start_, __c.__start_);2516 std::swap(__start_, __c.__start_);
...@@ -2524,7 +2546,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const deque<_Tp, _Allocator>& __x,...@@ -2524,7 +2546,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const deque<_Tp, _Allocator>& __x,
2524 return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());2546 return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
2525}2547}
25262548
2527#if _LIBCPP_STD_VER <= 172549# if _LIBCPP_STD_VER <= 17
25282550
2529template <class _Tp, class _Allocator>2551template <class _Tp, class _Allocator>
2530inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) {2552inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) {
...@@ -2551,7 +2573,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const deque<_Tp, _Allocator>& __x,...@@ -2551,7 +2573,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const deque<_Tp, _Allocator>& __x,
2551 return !(__y < __x);2573 return !(__y < __x);
2552}2574}
25532575
2554#else // _LIBCPP_STD_VER <= 172576# else // _LIBCPP_STD_VER <= 17
25552577
2556template <class _Tp, class _Allocator>2578template <class _Tp, class _Allocator>
2557_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>2579_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
...@@ -2559,7 +2581,7 @@ operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y...@@ -2559,7 +2581,7 @@ operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y
2559 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);2581 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
2560}2582}
25612583
2562#endif // _LIBCPP_STD_VER <= 172584# endif // _LIBCPP_STD_VER <= 17
25632585
2564template <class _Tp, class _Allocator>2586template <class _Tp, class _Allocator>
2565inline _LIBCPP_HIDE_FROM_ABI void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)2587inline _LIBCPP_HIDE_FROM_ABI void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)
...@@ -2567,7 +2589,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _...@@ -2567,7 +2589,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _
2567 __x.swap(__y);2589 __x.swap(__y);
2568}2590}
25692591
2570#if _LIBCPP_STD_VER >= 202592# if _LIBCPP_STD_VER >= 20
2571template <class _Tp, class _Allocator, class _Up>2593template <class _Tp, class _Allocator, class _Up>
2572inline _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::size_type2594inline _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::size_type
2573erase(deque<_Tp, _Allocator>& __c, const _Up& __v) {2595erase(deque<_Tp, _Allocator>& __c, const _Up& __v) {
...@@ -2586,36 +2608,48 @@ erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) {...@@ -2586,36 +2608,48 @@ erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) {
25862608
2587template <>2609template <>
2588inline constexpr bool __format::__enable_insertable<std::deque<char>> = true;2610inline constexpr bool __format::__enable_insertable<std::deque<char>> = true;
2589# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2611# if _LIBCPP_HAS_WIDE_CHARACTERS
2590template <>2612template <>
2591inline constexpr bool __format::__enable_insertable<std::deque<wchar_t>> = true;2613inline constexpr bool __format::__enable_insertable<std::deque<wchar_t>> = true;
2592# endif2614# endif
2615
2616# endif // _LIBCPP_STD_VER >= 20
25932617
2594#endif // _LIBCPP_STD_VER >= 202618template <class _Tp, class _Allocator>
2619struct __container_traits<deque<_Tp, _Allocator> > {
2620 // http://eel.is/c++draft/deque.modifiers#3
2621 // If an exception is thrown other than by the copy constructor, move constructor, assignment operator, or move
2622 // assignment operator of T, there are no effects. If an exception is thrown while inserting a single element at
2623 // either end, there are no effects. Otherwise, if an exception is thrown by the move constructor of a
2624 // non-Cpp17CopyInsertable T, the effects are unspecified.
2625 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
2626 _Or<is_nothrow_move_constructible<_Tp>, __is_cpp17_copy_insertable<_Allocator> >::value;
2627};
25952628
2596_LIBCPP_END_NAMESPACE_STD2629_LIBCPP_END_NAMESPACE_STD
25972630
2598#if _LIBCPP_STD_VER >= 172631# if _LIBCPP_STD_VER >= 17
2599_LIBCPP_BEGIN_NAMESPACE_STD2632_LIBCPP_BEGIN_NAMESPACE_STD
2600namespace pmr {2633namespace pmr {
2601template <class _ValueT>2634template <class _ValueT>
2602using deque _LIBCPP_AVAILABILITY_PMR = std::deque<_ValueT, polymorphic_allocator<_ValueT>>;2635using deque _LIBCPP_AVAILABILITY_PMR = std::deque<_ValueT, polymorphic_allocator<_ValueT>>;
2603} // namespace pmr2636} // namespace pmr
2604_LIBCPP_END_NAMESPACE_STD2637_LIBCPP_END_NAMESPACE_STD
2605#endif2638# endif
26062639
2607_LIBCPP_POP_MACROS2640_LIBCPP_POP_MACROS
26082641
2609#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 202642# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2610# include <algorithm>2643# include <algorithm>
2611# include <atomic>2644# include <atomic>
2612# include <concepts>2645# include <concepts>
2613# include <cstdlib>2646# include <cstdlib>
2614# include <functional>2647# include <functional>
2615# include <iosfwd>2648# include <iosfwd>
2616# include <iterator>2649# include <iterator>
2617# include <type_traits>2650# include <type_traits>
2618# include <typeinfo>2651# include <typeinfo>
2619#endif2652# endif
2653#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
26202654
2621#endif // _LIBCPP_DEQUE2655#endif // _LIBCPP_DEQUE
lib/libcxx/include/errno.h+272-268
...@@ -22,378 +22,382 @@ Macros:...@@ -22,378 +22,382 @@ Macros:
2222
23*/23*/
2424
25#include <__config>25#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
26# include <__cxx03/errno.h>
27#else
28# include <__config>
2629
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header31# pragma GCC system_header
29#endif32# endif
3033
31#if __has_include_next(<errno.h>)34# if __has_include_next(<errno.h>)
32# include_next <errno.h>35# include_next <errno.h>
33#endif36# endif
3437
35#ifdef __cplusplus38# ifdef __cplusplus
3639
37# if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)40# if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
3841
39# ifdef ELAST42# ifdef ELAST
4043
41static const int __elast1 = ELAST + 1;44static const int __elast1 = ELAST + 1;
42static const int __elast2 = ELAST + 2;45static const int __elast2 = ELAST + 2;
4346
44# else47# else
4548
46static const int __elast1 = 104;49static const int __elast1 = 104;
47static const int __elast2 = 105;50static const int __elast2 = 105;
4851
49# endif52# endif
5053
51# ifdef ENOTRECOVERABLE54# ifdef ENOTRECOVERABLE
5255
53# define EOWNERDEAD __elast156# define EOWNERDEAD __elast1
5457
55# ifdef ELAST58# ifdef ELAST
56# undef ELAST59# undef ELAST
57# define ELAST EOWNERDEAD60# define ELAST EOWNERDEAD
58# endif61# endif
5962
60# elif defined(EOWNERDEAD)63# elif defined(EOWNERDEAD)
6164
62# define ENOTRECOVERABLE __elast165# define ENOTRECOVERABLE __elast1
63# ifdef ELAST66# ifdef ELAST
64# undef ELAST67# undef ELAST
65# define ELAST ENOTRECOVERABLE68# define ELAST ENOTRECOVERABLE
66# endif69# endif
6770
68# else // defined(EOWNERDEAD)71# else // defined(EOWNERDEAD)
6972
70# define EOWNERDEAD __elast173# define EOWNERDEAD __elast1
71# define ENOTRECOVERABLE __elast274# define ENOTRECOVERABLE __elast2
72# ifdef ELAST75# ifdef ELAST
73# undef ELAST76# undef ELAST
74# define ELAST ENOTRECOVERABLE77# define ELAST ENOTRECOVERABLE
75# endif78# endif
7679
77# endif // defined(EOWNERDEAD)80# endif // defined(EOWNERDEAD)
7881
79# endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)82# endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
8083
81// supply errno values likely to be missing, particularly on Windows84// supply errno values likely to be missing, particularly on Windows
8285
83# ifndef EAFNOSUPPORT86# ifndef EAFNOSUPPORT
84# define EAFNOSUPPORT 990187# define EAFNOSUPPORT 9901
85# endif88# endif
8689
87# ifndef EADDRINUSE90# ifndef EADDRINUSE
88# define EADDRINUSE 990291# define EADDRINUSE 9902
89# endif92# endif
9093
91# ifndef EADDRNOTAVAIL94# ifndef EADDRNOTAVAIL
92# define EADDRNOTAVAIL 990395# define EADDRNOTAVAIL 9903
93# endif96# endif
9497
95# ifndef EISCONN98# ifndef EISCONN
96# define EISCONN 990499# define EISCONN 9904
97# endif100# endif
98101
99# ifndef EBADMSG102# ifndef EBADMSG
100# define EBADMSG 9905103# define EBADMSG 9905
101# endif104# endif
102105
103# ifndef ECONNABORTED106# ifndef ECONNABORTED
104# define ECONNABORTED 9906107# define ECONNABORTED 9906
105# endif108# endif
106109
107# ifndef EALREADY110# ifndef EALREADY
108# define EALREADY 9907111# define EALREADY 9907
109# endif112# endif
110113
111# ifndef ECONNREFUSED114# ifndef ECONNREFUSED
112# define ECONNREFUSED 9908115# define ECONNREFUSED 9908
113# endif116# endif
114117
115# ifndef ECONNRESET118# ifndef ECONNRESET
116# define ECONNRESET 9909119# define ECONNRESET 9909
117# endif120# endif
118121
119# ifndef EDESTADDRREQ122# ifndef EDESTADDRREQ
120# define EDESTADDRREQ 9910123# define EDESTADDRREQ 9910
121# endif124# endif
122125
123# ifndef EHOSTUNREACH126# ifndef EHOSTUNREACH
124# define EHOSTUNREACH 9911127# define EHOSTUNREACH 9911
125# endif128# endif
126129
127# ifndef EIDRM130# ifndef EIDRM
128# define EIDRM 9912131# define EIDRM 9912
129# endif132# endif
130133
131# ifndef EMSGSIZE134# ifndef EMSGSIZE
132# define EMSGSIZE 9913135# define EMSGSIZE 9913
133# endif136# endif
134137
135# ifndef ENETDOWN138# ifndef ENETDOWN
136# define ENETDOWN 9914139# define ENETDOWN 9914
137# endif140# endif
138141
139# ifndef ENETRESET142# ifndef ENETRESET
140# define ENETRESET 9915143# define ENETRESET 9915
141# endif144# endif
142145
143# ifndef ENETUNREACH146# ifndef ENETUNREACH
144# define ENETUNREACH 9916147# define ENETUNREACH 9916
145# endif148# endif
146149
147# ifndef ENOBUFS150# ifndef ENOBUFS
148# define ENOBUFS 9917151# define ENOBUFS 9917
149# endif152# endif
150153
151# ifndef ENOLINK154# ifndef ENOLINK
152# define ENOLINK 9918155# define ENOLINK 9918
153# endif156# endif
154157
155# ifndef ENODATA158# ifndef ENODATA
156# define ENODATA 9919159# define ENODATA 9919
157# endif160# endif
158161
159# ifndef ENOMSG162# ifndef ENOMSG
160# define ENOMSG 9920163# define ENOMSG 9920
161# endif164# endif
162165
163# ifndef ENOPROTOOPT166# ifndef ENOPROTOOPT
164# define ENOPROTOOPT 9921167# define ENOPROTOOPT 9921
165# endif168# endif
166169
167# ifndef ENOSR170# ifndef ENOSR
168# define ENOSR 9922171# define ENOSR 9922
169# endif172# endif
170173
171# ifndef ENOTSOCK174# ifndef ENOTSOCK
172# define ENOTSOCK 9923175# define ENOTSOCK 9923
173# endif176# endif
174177
175# ifndef ENOSTR178# ifndef ENOSTR
176# define ENOSTR 9924179# define ENOSTR 9924
177# endif180# endif
178181
179# ifndef ENOTCONN182# ifndef ENOTCONN
180# define ENOTCONN 9925183# define ENOTCONN 9925
181# endif184# endif
182185
183# ifndef ENOTSUP186# ifndef ENOTSUP
184# define ENOTSUP 9926187# define ENOTSUP 9926
185# endif188# endif
186189
187# ifndef ECANCELED190# ifndef ECANCELED
188# define ECANCELED 9927191# define ECANCELED 9927
189# endif192# endif
190193
191# ifndef EINPROGRESS194# ifndef EINPROGRESS
192# define EINPROGRESS 9928195# define EINPROGRESS 9928
193# endif196# endif
194197
195# ifndef EOPNOTSUPP198# ifndef EOPNOTSUPP
196# define EOPNOTSUPP 9929199# define EOPNOTSUPP 9929
197# endif200# endif
198201
199# ifndef EWOULDBLOCK202# ifndef EWOULDBLOCK
200# define EWOULDBLOCK 9930203# define EWOULDBLOCK 9930
201# endif204# endif
202205
203# ifndef EOWNERDEAD206# ifndef EOWNERDEAD
204# define EOWNERDEAD 9931207# define EOWNERDEAD 9931
205# endif208# endif
206209
207# ifndef EPROTO210# ifndef EPROTO
208# define EPROTO 9932211# define EPROTO 9932
209# endif212# endif
210213
211# ifndef EPROTONOSUPPORT214# ifndef EPROTONOSUPPORT
212# define EPROTONOSUPPORT 9933215# define EPROTONOSUPPORT 9933
213# endif216# endif
214217
215# ifndef ENOTRECOVERABLE218# ifndef ENOTRECOVERABLE
216# define ENOTRECOVERABLE 9934219# define ENOTRECOVERABLE 9934
217# endif220# endif
218221
219# ifndef ETIME222# ifndef ETIME
220# define ETIME 9935223# define ETIME 9935
221# endif224# endif
222225
223# ifndef ETXTBSY226# ifndef ETXTBSY
224# define ETXTBSY 9936227# define ETXTBSY 9936
225# endif228# endif
226229
227# ifndef ETIMEDOUT230# ifndef ETIMEDOUT
228# define ETIMEDOUT 9938231# define ETIMEDOUT 9938
229# endif232# endif
230233
231# ifndef ELOOP234# ifndef ELOOP
232# define ELOOP 9939235# define ELOOP 9939
233# endif236# endif
234237
235# ifndef EOVERFLOW238# ifndef EOVERFLOW
236# define EOVERFLOW 9940239# define EOVERFLOW 9940
237# endif240# endif
238241
239# ifndef EPROTOTYPE242# ifndef EPROTOTYPE
240# define EPROTOTYPE 9941243# define EPROTOTYPE 9941
241# endif244# endif
242245
243# ifndef ENOSYS246# ifndef ENOSYS
244# define ENOSYS 9942247# define ENOSYS 9942
245# endif248# endif
246249
247# ifndef EINVAL250# ifndef EINVAL
248# define EINVAL 9943251# define EINVAL 9943
249# endif252# endif
250253
251# ifndef ERANGE254# ifndef ERANGE
252# define ERANGE 9944255# define ERANGE 9944
253# endif256# endif
254257
255# ifndef EILSEQ258# ifndef EILSEQ
256# define EILSEQ 9945259# define EILSEQ 9945
257# endif260# endif
258261
259// Windows Mobile doesn't appear to define these:262// Windows Mobile doesn't appear to define these:
260263
261# ifndef E2BIG264# ifndef E2BIG
262# define E2BIG 9946265# define E2BIG 9946
263# endif266# endif
264267
265# ifndef EDOM268# ifndef EDOM
266# define EDOM 9947269# define EDOM 9947
267# endif270# endif
268271
269# ifndef EFAULT272# ifndef EFAULT
270# define EFAULT 9948273# define EFAULT 9948
271# endif274# endif
272275
273# ifndef EBADF276# ifndef EBADF
274# define EBADF 9949277# define EBADF 9949
275# endif278# endif
276279
277# ifndef EPIPE280# ifndef EPIPE
278# define EPIPE 9950281# define EPIPE 9950
279# endif282# endif
280283
281# ifndef EXDEV284# ifndef EXDEV
282# define EXDEV 9951285# define EXDEV 9951
283# endif286# endif
284287
285# ifndef EBUSY288# ifndef EBUSY
286# define EBUSY 9952289# define EBUSY 9952
287# endif290# endif
288291
289# ifndef ENOTEMPTY292# ifndef ENOTEMPTY
290# define ENOTEMPTY 9953293# define ENOTEMPTY 9953
291# endif294# endif
292295
293# ifndef ENOEXEC296# ifndef ENOEXEC
294# define ENOEXEC 9954297# define ENOEXEC 9954
295# endif298# endif
296299
297# ifndef EEXIST300# ifndef EEXIST
298# define EEXIST 9955301# define EEXIST 9955
299# endif302# endif
300303
301# ifndef EFBIG304# ifndef EFBIG
302# define EFBIG 9956305# define EFBIG 9956
303# endif306# endif
304307
305# ifndef ENAMETOOLONG308# ifndef ENAMETOOLONG
306# define ENAMETOOLONG 9957309# define ENAMETOOLONG 9957
307# endif310# endif
308311
309# ifndef ENOTTY312# ifndef ENOTTY
310# define ENOTTY 9958313# define ENOTTY 9958
311# endif314# endif
312315
313# ifndef EINTR316# ifndef EINTR
314# define EINTR 9959317# define EINTR 9959
315# endif318# endif
316319
317# ifndef ESPIPE320# ifndef ESPIPE
318# define ESPIPE 9960321# define ESPIPE 9960
319# endif322# endif
320323
321# ifndef EIO324# ifndef EIO
322# define EIO 9961325# define EIO 9961
323# endif326# endif
324327
325# ifndef EISDIR328# ifndef EISDIR
326# define EISDIR 9962329# define EISDIR 9962
327# endif330# endif
328331
329# ifndef ECHILD332# ifndef ECHILD
330# define ECHILD 9963333# define ECHILD 9963
331# endif334# endif
332335
333# ifndef ENOLCK336# ifndef ENOLCK
334# define ENOLCK 9964337# define ENOLCK 9964
335# endif338# endif
336339
337# ifndef ENOSPC340# ifndef ENOSPC
338# define ENOSPC 9965341# define ENOSPC 9965
339# endif342# endif
340343
341# ifndef ENXIO344# ifndef ENXIO
342# define ENXIO 9966345# define ENXIO 9966
343# endif346# endif
344347
345# ifndef ENODEV348# ifndef ENODEV
346# define ENODEV 9967349# define ENODEV 9967
347# endif350# endif
348351
349# ifndef ENOENT352# ifndef ENOENT
350# define ENOENT 9968353# define ENOENT 9968
351# endif354# endif
352355
353# ifndef ESRCH356# ifndef ESRCH
354# define ESRCH 9969357# define ESRCH 9969
355# endif358# endif
356359
357# ifndef ENOTDIR360# ifndef ENOTDIR
358# define ENOTDIR 9970361# define ENOTDIR 9970
359# endif362# endif
360363
361# ifndef ENOMEM364# ifndef ENOMEM
362# define ENOMEM 9971365# define ENOMEM 9971
363# endif366# endif
364367
365# ifndef EPERM368# ifndef EPERM
366# define EPERM 9972369# define EPERM 9972
367# endif370# endif
368371
369# ifndef EACCES372# ifndef EACCES
370# define EACCES 9973373# define EACCES 9973
371# endif374# endif
372375
373# ifndef EROFS376# ifndef EROFS
374# define EROFS 9974377# define EROFS 9974
375# endif378# endif
376379
377# ifndef EDEADLK380# ifndef EDEADLK
378# define EDEADLK 9975381# define EDEADLK 9975
379# endif382# endif
380383
381# ifndef EAGAIN384# ifndef EAGAIN
382# define EAGAIN 9976385# define EAGAIN 9976
383# endif386# endif
384387
385# ifndef ENFILE388# ifndef ENFILE
386# define ENFILE 9977389# define ENFILE 9977
387# endif390# endif
388391
389# ifndef EMFILE392# ifndef EMFILE
390# define EMFILE 9978393# define EMFILE 9978
391# endif394# endif
392395
393# ifndef EMLINK396# ifndef EMLINK
394# define EMLINK 9979397# define EMLINK 9979
395# endif398# endif
396399
397#endif // __cplusplus400# endif // __cplusplus
401#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
398402
399#endif // _LIBCPP_ERRNO_H403#endif // _LIBCPP_ERRNO_H
lib/libcxx/include/exception+23-17
...@@ -47,7 +47,7 @@ terminate_handler set_terminate(terminate_handler f ) noexcept;...@@ -47,7 +47,7 @@ terminate_handler set_terminate(terminate_handler f ) noexcept;
47terminate_handler get_terminate() noexcept;47terminate_handler get_terminate() noexcept;
48[[noreturn]] void terminate() noexcept;48[[noreturn]] void terminate() noexcept;
4949
50bool uncaught_exception() noexcept;50bool uncaught_exception() noexcept; // deprecated in C++17, removed in C++20
51int uncaught_exceptions() noexcept; // C++1751int uncaught_exceptions() noexcept; // C++17
5252
53typedef unspecified exception_ptr;53typedef unspecified exception_ptr;
...@@ -76,21 +76,27 @@ template <class E> void rethrow_if_nested(const E& e);...@@ -76,21 +76,27 @@ template <class E> void rethrow_if_nested(const E& e);
7676
77*/77*/
7878
79#include <__config>79#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
80#include <__exception/exception.h>80# include <__cxx03/exception>
81#include <__exception/exception_ptr.h>81#else
82#include <__exception/nested_exception.h>82# include <__config>
83#include <__exception/operations.h>83# include <__exception/exception.h>
84#include <__exception/terminate.h>84# include <__exception/exception_ptr.h>
85#include <version>85# include <__exception/nested_exception.h>
8686# include <__exception/operations.h>
87#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)87# include <__exception/terminate.h>
88# pragma GCC system_header88# include <version>
89#endif89
9090# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
91#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 2091# pragma GCC system_header
92# include <cstdlib>92# endif
93# include <type_traits>93
94#endif94# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
95# include <cstddef>
96# include <cstdlib>
97# include <new>
98# include <type_traits>
99# endif
100#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
95101
96#endif // _LIBCPP_EXCEPTION102#endif // _LIBCPP_EXCEPTION
lib/libcxx/include/execution+33-19
...@@ -32,17 +32,20 @@ namespace std {...@@ -32,17 +32,20 @@ namespace std {
32}32}
33*/33*/
3434
35#include <__config>35#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
36#include <__type_traits/is_execution_policy.h>36# include <__cxx03/execution>
37#include <__type_traits/is_same.h>37#else
38#include <__type_traits/remove_cvref.h>38# include <__config>
39#include <version>39# include <__type_traits/is_execution_policy.h>
4040# include <__type_traits/is_same.h>
41#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)41# include <__type_traits/remove_cvref.h>
42# pragma GCC system_header42# include <version>
43#endif43
44# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
45# pragma GCC system_header
46# endif
4447
45#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 1748# if _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
4649
47_LIBCPP_BEGIN_NAMESPACE_STD50_LIBCPP_BEGIN_NAMESPACE_STD
4851
...@@ -79,7 +82,7 @@ struct __unsequenced_policy {...@@ -79,7 +82,7 @@ struct __unsequenced_policy {
7982
80constexpr __unsequenced_policy __unseq{__disable_user_instantiations_tag{}};83constexpr __unsequenced_policy __unseq{__disable_user_instantiations_tag{}};
8184
82# if _LIBCPP_STD_VER >= 2085# if _LIBCPP_STD_VER >= 20
8386
84struct unsequenced_policy {87struct unsequenced_policy {
85 _LIBCPP_HIDE_FROM_ABI constexpr explicit unsequenced_policy(__disable_user_instantiations_tag) {}88 _LIBCPP_HIDE_FROM_ABI constexpr explicit unsequenced_policy(__disable_user_instantiations_tag) {}
...@@ -89,10 +92,14 @@ struct unsequenced_policy {...@@ -89,10 +92,14 @@ struct unsequenced_policy {
8992
90inline constexpr unsequenced_policy unseq{__disable_user_instantiations_tag{}};93inline constexpr unsequenced_policy unseq{__disable_user_instantiations_tag{}};
9194
92# endif // _LIBCPP_STD_VER >= 2095# endif // _LIBCPP_STD_VER >= 20
9396
94} // namespace execution97} // namespace execution
9598
99_LIBCPP_DIAGNOSTIC_PUSH
100# if __has_warning("-Winvalid-specialization")
101_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
102# endif
96template <>103template <>
97inline constexpr bool is_execution_policy_v<execution::sequenced_policy> = true;104inline constexpr bool is_execution_policy_v<execution::sequenced_policy> = true;
98105
...@@ -104,6 +111,7 @@ inline constexpr bool is_execution_policy_v<execution::parallel_unsequenced_poli...@@ -104,6 +111,7 @@ inline constexpr bool is_execution_policy_v<execution::parallel_unsequenced_poli
104111
105template <>112template <>
106inline constexpr bool is_execution_policy_v<execution::__unsequenced_policy> = true;113inline constexpr bool is_execution_policy_v<execution::__unsequenced_policy> = true;
114_LIBCPP_DIAGNOSTIC_POP
107115
108template <>116template <>
109inline constexpr bool __is_parallel_execution_policy_impl<execution::parallel_policy> = true;117inline constexpr bool __is_parallel_execution_policy_impl<execution::parallel_policy> = true;
...@@ -117,17 +125,22 @@ inline constexpr bool __is_unsequenced_execution_policy_impl<execution::__unsequ...@@ -117,17 +125,22 @@ inline constexpr bool __is_unsequenced_execution_policy_impl<execution::__unsequ
117template <>125template <>
118inline constexpr bool __is_unsequenced_execution_policy_impl<execution::parallel_unsequenced_policy> = true;126inline constexpr bool __is_unsequenced_execution_policy_impl<execution::parallel_unsequenced_policy> = true;
119127
120# if _LIBCPP_STD_VER >= 20128# if _LIBCPP_STD_VER >= 20
129_LIBCPP_DIAGNOSTIC_PUSH
130# if __has_warning("-Winvalid-specialization")
131_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
132# endif
121template <>133template <>
122inline constexpr bool is_execution_policy_v<execution::unsequenced_policy> = true;134inline constexpr bool is_execution_policy_v<execution::unsequenced_policy> = true;
135_LIBCPP_DIAGNOSTIC_POP
123136
124template <>137template <>
125inline constexpr bool __is_unsequenced_execution_policy_impl<execution::unsequenced_policy> = true;138inline constexpr bool __is_unsequenced_execution_policy_impl<execution::unsequenced_policy> = true;
126139
127# endif140# endif
128141
129template <class _Tp>142template <class _Tp>
130struct is_execution_policy : bool_constant<is_execution_policy_v<_Tp>> {};143struct _LIBCPP_NO_SPECIALIZATIONS is_execution_policy : bool_constant<is_execution_policy_v<_Tp>> {};
131144
132template <class _ExecutionPolicy>145template <class _ExecutionPolicy>
133_LIBCPP_HIDE_FROM_ABI auto __remove_parallel_policy(const _ExecutionPolicy&) {146_LIBCPP_HIDE_FROM_ABI auto __remove_parallel_policy(const _ExecutionPolicy&) {
...@@ -140,10 +153,11 @@ _LIBCPP_HIDE_FROM_ABI auto __remove_parallel_policy(const _ExecutionPolicy&) {...@@ -140,10 +153,11 @@ _LIBCPP_HIDE_FROM_ABI auto __remove_parallel_policy(const _ExecutionPolicy&) {
140153
141_LIBCPP_END_NAMESPACE_STD154_LIBCPP_END_NAMESPACE_STD
142155
143#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17156# endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
144157
145#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20158# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
146# include <cstddef>159# include <cstddef>
147#endif160# endif
161#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
148162
149#endif // _LIBCPP_EXECUTION163#endif // _LIBCPP_EXECUTION
lib/libcxx/include/expected+18-20
...@@ -38,25 +38,23 @@ namespace std {...@@ -38,25 +38,23 @@ namespace std {
3838
39*/39*/
4040
41#include <__config>41#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
4242# include <__cxx03/expected>
43#if _LIBCPP_STD_VER >= 2343#else
44# include <__expected/bad_expected_access.h>44# include <__config>
45# include <__expected/expected.h>45
46# include <__expected/unexpect.h>46# if _LIBCPP_STD_VER >= 23
47# include <__expected/unexpected.h>47# include <__expected/bad_expected_access.h>
48#endif48# include <__expected/expected.h>
4949# include <__expected/unexpect.h>
50#include <version>50# include <__expected/unexpected.h>
5151# endif
52#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)52
53# pragma GCC system_header53# include <version>
54#endif54
5555# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
56#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 2056# pragma GCC system_header
57# include <cstddef>57# endif
58# include <initializer_list>58#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
59# include <new>
60#endif
6159
62#endif // _LIBCPP_EXPECTED60#endif // _LIBCPP_EXPECTED
lib/libcxx/include/experimental/__config deleted-45
...@@ -1,45 +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_EXPERIMENTAL_CONFIG
11#define _LIBCPP_EXPERIMENTAL_CONFIG
12
13#include <__config>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL \
20 namespace std { \
21 namespace experimental {
22#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL \
23 } \
24 }
25
26#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {
27#define _LIBCPP_END_NAMESPACE_LFTS \
28 } \
29 } \
30 }
31
32#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 {
33#define _LIBCPP_END_NAMESPACE_LFTS_V2 \
34 } \
35 } \
36 }
37
38// TODO: support more targets
39#if defined(__AVX__)
40# define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32
41#else
42# define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16
43#endif
44
45#endif
lib/libcxx/include/experimental/__simd/aligned_tag.h+2-2
...@@ -10,10 +10,10 @@...@@ -10,10 +10,10 @@
10#ifndef _LIBCPP_EXPERIMENTAL___SIMD_ALIGNED_TAG_H10#ifndef _LIBCPP_EXPERIMENTAL___SIMD_ALIGNED_TAG_H
11#define _LIBCPP_EXPERIMENTAL___SIMD_ALIGNED_TAG_H11#define _LIBCPP_EXPERIMENTAL___SIMD_ALIGNED_TAG_H
1212
13#include <__config>
14#include <__cstddef/size_t.h>
13#include <__memory/assume_aligned.h>15#include <__memory/assume_aligned.h>
14#include <__type_traits/remove_const.h>16#include <__type_traits/remove_const.h>
15#include <cstddef>
16#include <experimental/__config>
17#include <experimental/__simd/traits.h>17#include <experimental/__simd/traits.h>
1818
19#if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)19#if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)
lib/libcxx/include/experimental/__simd/declaration.h+9-2
...@@ -10,11 +10,18 @@...@@ -10,11 +10,18 @@
10#ifndef _LIBCPP_EXPERIMENTAL___SIMD_DECLARATION_H10#ifndef _LIBCPP_EXPERIMENTAL___SIMD_DECLARATION_H
11#define _LIBCPP_EXPERIMENTAL___SIMD_DECLARATION_H11#define _LIBCPP_EXPERIMENTAL___SIMD_DECLARATION_H
1212
13#include <cstddef>13#include <__config>
14#include <experimental/__config>14#include <__cstddef/size_t.h>
1515
16#if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)16#if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)
1717
18// TODO: support more targets
19# if defined(__AVX__)
20# define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32
21# else
22# define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16
23# endif
24
18_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL25_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
19inline namespace parallelism_v2 {26inline namespace parallelism_v2 {
20namespace simd_abi {27namespace simd_abi {
lib/libcxx/include/experimental/__simd/reference.h+89-2
...@@ -10,12 +10,14 @@...@@ -10,12 +10,14 @@
10#ifndef _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H10#ifndef _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H
11#define _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H11#define _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H
1212
13#include <__config>
14#include <__cstddef/size_t.h>
15#include <__type_traits/enable_if.h>
13#include <__type_traits/is_assignable.h>16#include <__type_traits/is_assignable.h>
14#include <__type_traits/is_same.h>17#include <__type_traits/is_same.h>
18#include <__utility/declval.h>
15#include <__utility/forward.h>19#include <__utility/forward.h>
16#include <__utility/move.h>20#include <__utility/move.h>
17#include <cstddef>
18#include <experimental/__config>
19#include <experimental/__simd/utility.h>21#include <experimental/__simd/utility.h>
2022
21_LIBCPP_PUSH_MACROS23_LIBCPP_PUSH_MACROS
...@@ -71,6 +73,91 @@ public:...@@ -71,6 +73,91 @@ public:
7173
72 template <class _Tp1, class _Storage1, class _Vp1>74 template <class _Tp1, class _Storage1, class _Vp1>
73 friend void swap(__simd_reference<_Tp1, _Storage1, _Vp1>&& __a, _Vp1& __b) noexcept;75 friend void swap(__simd_reference<_Tp1, _Storage1, _Vp1>&& __a, _Vp1& __b) noexcept;
76
77 template <class _Up, class = decltype(std::declval<value_type&>() += std::declval<_Up>())>
78 _LIBCPP_HIDE_FROM_ABI __simd_reference operator+=(_Up&& __v) && noexcept {
79 __set(__get() + static_cast<value_type>(std::forward<_Up>(__v)));
80 return {__s_, __idx_};
81 }
82
83 template <class _Up, class = decltype(std::declval<value_type&>() -= std::declval<_Up>())>
84 _LIBCPP_HIDE_FROM_ABI __simd_reference operator-=(_Up&& __v) && noexcept {
85 __set(__get() - static_cast<value_type>(std::forward<_Up>(__v)));
86 return {__s_, __idx_};
87 }
88
89 template <class _Up, class = decltype(std::declval<value_type&>() *= std::declval<_Up>())>
90 _LIBCPP_HIDE_FROM_ABI __simd_reference operator*=(_Up&& __v) && noexcept {
91 __set(__get() * static_cast<value_type>(std::forward<_Up>(__v)));
92 return {__s_, __idx_};
93 }
94
95 template <class _Up, class = decltype(std::declval<value_type&>() /= std::declval<_Up>())>
96 _LIBCPP_HIDE_FROM_ABI __simd_reference operator/=(_Up&& __v) && noexcept {
97 __set(__get() / static_cast<value_type>(std::forward<_Up>(__v)));
98 return {__s_, __idx_};
99 }
100
101 template <class _Up, class = decltype(std::declval<value_type&>() %= std::declval<_Up>())>
102 _LIBCPP_HIDE_FROM_ABI __simd_reference operator%=(_Up&& __v) && noexcept {
103 __set(__get() % static_cast<value_type>(std::forward<_Up>(__v)));
104 return {__s_, __idx_};
105 }
106
107 template <class _Up, class = decltype(std::declval<value_type&>() &= std::declval<_Up>())>
108 _LIBCPP_HIDE_FROM_ABI __simd_reference operator&=(_Up&& __v) && noexcept {
109 __set(__get() & static_cast<value_type>(std::forward<_Up>(__v)));
110 return {__s_, __idx_};
111 }
112
113 template <class _Up, class = decltype(std::declval<value_type&>() |= std::declval<_Up>())>
114 _LIBCPP_HIDE_FROM_ABI __simd_reference operator|=(_Up&& __v) && noexcept {
115 __set(__get() | static_cast<value_type>(std::forward<_Up>(__v)));
116 return {__s_, __idx_};
117 }
118
119 template <class _Up, class = decltype(std::declval<value_type&>() ^= std::declval<_Up>())>
120 _LIBCPP_HIDE_FROM_ABI __simd_reference operator^=(_Up&& __v) && noexcept {
121 __set(__get() ^ static_cast<value_type>(std::forward<_Up>(__v)));
122 return {__s_, __idx_};
123 }
124
125 template <class _Up, class = decltype(std::declval<value_type&>() <<= std::declval<_Up>())>
126 _LIBCPP_HIDE_FROM_ABI __simd_reference operator<<=(_Up&& __v) && noexcept {
127 __set(__get() << static_cast<value_type>(std::forward<_Up>(__v)));
128 return {__s_, __idx_};
129 }
130
131 template <class _Up, class = decltype(std::declval<value_type&>() >>= std::declval<_Up>())>
132 _LIBCPP_HIDE_FROM_ABI __simd_reference operator>>=(_Up&& __v) && noexcept {
133 __set(__get() >> static_cast<value_type>(std::forward<_Up>(__v)));
134 return {__s_, __idx_};
135 }
136
137 // Note: All legal vectorizable types support operator++/--.
138 // There doesn't seem to be a way to trigger the constraint.
139 // Therefore, no SFINAE check is added here.
140 __simd_reference _LIBCPP_HIDE_FROM_ABI operator++() && noexcept {
141 __set(__get() + 1);
142 return {__s_, __idx_};
143 }
144
145 value_type _LIBCPP_HIDE_FROM_ABI operator++(int) && noexcept {
146 auto __r = __get();
147 __set(__get() + 1);
148 return __r;
149 }
150
151 __simd_reference _LIBCPP_HIDE_FROM_ABI operator--() && noexcept {
152 __set(__get() - 1);
153 return {__s_, __idx_};
154 }
155
156 value_type _LIBCPP_HIDE_FROM_ABI operator--(int) && noexcept {
157 auto __r = __get();
158 __set(__get() - 1);
159 return __r;
160 }
74};161};
75162
76template <class _Tp, class _Storage, class _Vp>163template <class _Tp, class _Storage, class _Vp>
lib/libcxx/include/experimental/__simd/scalar.h+20-5
...@@ -11,8 +11,9 @@...@@ -11,8 +11,9 @@
11#define _LIBCPP_EXPERIMENTAL___SIMD_SCALAR_H11#define _LIBCPP_EXPERIMENTAL___SIMD_SCALAR_H
1212
13#include <__assert>13#include <__assert>
14#include <cstddef>14#include <__config>
15#include <experimental/__config>15#include <__cstddef/size_t.h>
16#include <__type_traits/integral_constant.h>
16#include <experimental/__simd/declaration.h>17#include <experimental/__simd/declaration.h>
17#include <experimental/__simd/traits.h>18#include <experimental/__simd/traits.h>
1819
...@@ -48,8 +49,8 @@ struct __mask_storage<_Tp, simd_abi::__scalar> : __simd_storage<bool, simd_abi::...@@ -48,8 +49,8 @@ struct __mask_storage<_Tp, simd_abi::__scalar> : __simd_storage<bool, simd_abi::
4849
49template <class _Tp>50template <class _Tp>
50struct __simd_operations<_Tp, simd_abi::__scalar> {51struct __simd_operations<_Tp, simd_abi::__scalar> {
51 using _SimdStorage = __simd_storage<_Tp, simd_abi::__scalar>;52 using _SimdStorage _LIBCPP_NODEBUG = __simd_storage<_Tp, simd_abi::__scalar>;
52 using _MaskStorage = __mask_storage<_Tp, simd_abi::__scalar>;53 using _MaskStorage _LIBCPP_NODEBUG = __mask_storage<_Tp, simd_abi::__scalar>;
5354
54 static _LIBCPP_HIDE_FROM_ABI _SimdStorage __broadcast(_Tp __v) noexcept { return {__v}; }55 static _LIBCPP_HIDE_FROM_ABI _SimdStorage __broadcast(_Tp __v) noexcept { return {__v}; }
5556
...@@ -67,11 +68,25 @@ struct __simd_operations<_Tp, simd_abi::__scalar> {...@@ -67,11 +68,25 @@ struct __simd_operations<_Tp, simd_abi::__scalar> {
67 static _LIBCPP_HIDE_FROM_ABI void __store(_SimdStorage __s, _Up* __mem) noexcept {68 static _LIBCPP_HIDE_FROM_ABI void __store(_SimdStorage __s, _Up* __mem) noexcept {
68 *__mem = static_cast<_Up>(__s.__data);69 *__mem = static_cast<_Up>(__s.__data);
69 }70 }
71
72 static _LIBCPP_HIDE_FROM_ABI void __increment(_SimdStorage& __s) noexcept { ++__s.__data; }
73
74 static _LIBCPP_HIDE_FROM_ABI void __decrement(_SimdStorage& __s) noexcept { --__s.__data; }
75
76 static _LIBCPP_HIDE_FROM_ABI _MaskStorage __negate(_SimdStorage __s) noexcept { return {!__s.__data}; }
77
78 static _LIBCPP_HIDE_FROM_ABI _SimdStorage __bitwise_not(_SimdStorage __s) noexcept {
79 return {static_cast<_Tp>(~__s.__data)};
80 }
81
82 static _LIBCPP_HIDE_FROM_ABI _SimdStorage __unary_minus(_SimdStorage __s) noexcept {
83 return {static_cast<_Tp>(-__s.__data)};
84 }
70};85};
7186
72template <class _Tp>87template <class _Tp>
73struct __mask_operations<_Tp, simd_abi::__scalar> {88struct __mask_operations<_Tp, simd_abi::__scalar> {
74 using _MaskStorage = __mask_storage<_Tp, simd_abi::__scalar>;89 using _MaskStorage _LIBCPP_NODEBUG = __mask_storage<_Tp, simd_abi::__scalar>;
7590
76 static _LIBCPP_HIDE_FROM_ABI _MaskStorage __broadcast(bool __v) noexcept { return {__v}; }91 static _LIBCPP_HIDE_FROM_ABI _MaskStorage __broadcast(bool __v) noexcept { return {__v}; }
7792
lib/libcxx/include/experimental/__simd/simd.h+58-5
...@@ -10,11 +10,13 @@...@@ -10,11 +10,13 @@
10#ifndef _LIBCPP_EXPERIMENTAL___SIMD_SIMD_H10#ifndef _LIBCPP_EXPERIMENTAL___SIMD_SIMD_H
11#define _LIBCPP_EXPERIMENTAL___SIMD_SIMD_H11#define _LIBCPP_EXPERIMENTAL___SIMD_SIMD_H
1212
13#include <__config>
14#include <__cstddef/size_t.h>
15#include <__type_traits/enable_if.h>
16#include <__type_traits/is_integral.h>
13#include <__type_traits/is_same.h>17#include <__type_traits/is_same.h>
14#include <__type_traits/remove_cvref.h>18#include <__type_traits/remove_cvref.h>
15#include <__utility/forward.h>19#include <__utility/forward.h>
16#include <cstddef>
17#include <experimental/__config>
18#include <experimental/__simd/declaration.h>20#include <experimental/__simd/declaration.h>
19#include <experimental/__simd/reference.h>21#include <experimental/__simd/reference.h>
20#include <experimental/__simd/traits.h>22#include <experimental/__simd/traits.h>
...@@ -25,15 +27,29 @@...@@ -25,15 +27,29 @@
25_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL27_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
26inline namespace parallelism_v2 {28inline namespace parallelism_v2 {
2729
30template <class _Simd, class _Impl, bool>
31class __simd_int_operators {};
32
33template <class _Simd, class _Impl>
34class __simd_int_operators<_Simd, _Impl, true> {
35public:
36 // unary operators for integral _Tp
37 _LIBCPP_HIDE_FROM_ABI _Simd operator~() const noexcept {
38 return _Simd(_Impl::__bitwise_not((*static_cast<const _Simd*>(this)).__s_), _Simd::__storage_tag);
39 }
40};
41
28// class template simd [simd.class]42// class template simd [simd.class]
29// TODO: implement simd class43// TODO: implement simd class
30template <class _Tp, class _Abi>44template <class _Tp, class _Abi>
31class simd {45class simd : public __simd_int_operators<simd<_Tp, _Abi>, __simd_operations<_Tp, _Abi>, is_integral_v<_Tp>> {
32 using _Impl = __simd_operations<_Tp, _Abi>;46 using _Impl _LIBCPP_NODEBUG = __simd_operations<_Tp, _Abi>;
33 using _Storage = typename _Impl::_SimdStorage;47 using _Storage _LIBCPP_NODEBUG = typename _Impl::_SimdStorage;
3448
35 _Storage __s_;49 _Storage __s_;
3650
51 friend class __simd_int_operators<simd, _Impl, true>;
52
37public:53public:
38 using value_type = _Tp;54 using value_type = _Tp;
39 using reference = __simd_reference<_Tp, _Storage, value_type>;55 using reference = __simd_reference<_Tp, _Storage, value_type>;
...@@ -44,6 +60,12 @@ public:...@@ -44,6 +60,12 @@ public:
4460
45 _LIBCPP_HIDE_FROM_ABI simd() noexcept = default;61 _LIBCPP_HIDE_FROM_ABI simd() noexcept = default;
4662
63 // explicit conversion from and to implementation-defined types
64 struct __storage_tag_t {};
65 static constexpr __storage_tag_t __storage_tag{};
66 explicit _LIBCPP_HIDE_FROM_ABI operator _Storage() const { return __s_; }
67 explicit _LIBCPP_HIDE_FROM_ABI simd(const _Storage& __s, __storage_tag_t) : __s_(__s) {}
68
47 // broadcast constructor69 // broadcast constructor
48 template <class _Up, enable_if_t<__can_broadcast_v<value_type, __remove_cvref_t<_Up>>, int> = 0>70 template <class _Up, enable_if_t<__can_broadcast_v<value_type, __remove_cvref_t<_Up>>, int> = 0>
49 _LIBCPP_HIDE_FROM_ABI simd(_Up&& __v) noexcept : __s_(_Impl::__broadcast(static_cast<value_type>(__v))) {}71 _LIBCPP_HIDE_FROM_ABI simd(_Up&& __v) noexcept : __s_(_Impl::__broadcast(static_cast<value_type>(__v))) {}
...@@ -84,6 +106,37 @@ public:...@@ -84,6 +106,37 @@ public:
84 // scalar access [simd.subscr]106 // scalar access [simd.subscr]
85 _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __i) noexcept { return reference(__s_, __i); }107 _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __i) noexcept { return reference(__s_, __i); }
86 _LIBCPP_HIDE_FROM_ABI value_type operator[](size_t __i) const noexcept { return __s_.__get(__i); }108 _LIBCPP_HIDE_FROM_ABI value_type operator[](size_t __i) const noexcept { return __s_.__get(__i); }
109
110 // simd unary operators
111 _LIBCPP_HIDE_FROM_ABI simd& operator++() noexcept {
112 _Impl::__increment(__s_);
113 return *this;
114 }
115
116 _LIBCPP_HIDE_FROM_ABI simd operator++(int) noexcept {
117 simd __r = *this;
118 _Impl::__increment(__s_);
119 return __r;
120 }
121
122 _LIBCPP_HIDE_FROM_ABI simd& operator--() noexcept {
123 _Impl::__decrement(__s_);
124 return *this;
125 }
126
127 _LIBCPP_HIDE_FROM_ABI simd operator--(int) noexcept {
128 simd __r = *this;
129 _Impl::__decrement(__s_);
130 return __r;
131 }
132
133 _LIBCPP_HIDE_FROM_ABI mask_type operator!() const noexcept {
134 return mask_type(_Impl::__negate(__s_), mask_type::__storage_tag);
135 }
136
137 _LIBCPP_HIDE_FROM_ABI simd operator+() const noexcept { return *this; }
138
139 _LIBCPP_HIDE_FROM_ABI simd operator-() const noexcept { return simd(_Impl::__unary_minus(__s_), __storage_tag); }
87};140};
88141
89template <class _Tp, class _Abi>142template <class _Tp, class _Abi>
lib/libcxx/include/experimental/__simd/simd_mask.h+11-4
...@@ -10,9 +10,10 @@...@@ -10,9 +10,10 @@
10#ifndef _LIBCPP_EXPERIMENTAL___SIMD_SIMD_MASK_H10#ifndef _LIBCPP_EXPERIMENTAL___SIMD_SIMD_MASK_H
11#define _LIBCPP_EXPERIMENTAL___SIMD_SIMD_MASK_H11#define _LIBCPP_EXPERIMENTAL___SIMD_SIMD_MASK_H
1212
13#include <__config>
14#include <__cstddef/size_t.h>
15#include <__type_traits/enable_if.h>
13#include <__type_traits/is_same.h>16#include <__type_traits/is_same.h>
14#include <cstddef>
15#include <experimental/__config>
16#include <experimental/__simd/declaration.h>17#include <experimental/__simd/declaration.h>
17#include <experimental/__simd/reference.h>18#include <experimental/__simd/reference.h>
18#include <experimental/__simd/traits.h>19#include <experimental/__simd/traits.h>
...@@ -26,8 +27,8 @@ inline namespace parallelism_v2 {...@@ -26,8 +27,8 @@ inline namespace parallelism_v2 {
26// TODO: implement simd_mask class27// TODO: implement simd_mask class
27template <class _Tp, class _Abi>28template <class _Tp, class _Abi>
28class simd_mask {29class simd_mask {
29 using _Impl = __mask_operations<_Tp, _Abi>;30 using _Impl _LIBCPP_NODEBUG = __mask_operations<_Tp, _Abi>;
30 using _Storage = typename _Impl::_MaskStorage;31 using _Storage _LIBCPP_NODEBUG = typename _Impl::_MaskStorage;
3132
32 _Storage __s_;33 _Storage __s_;
3334
...@@ -41,6 +42,12 @@ public:...@@ -41,6 +42,12 @@ public:
4142
42 _LIBCPP_HIDE_FROM_ABI simd_mask() noexcept = default;43 _LIBCPP_HIDE_FROM_ABI simd_mask() noexcept = default;
4344
45 // explicit conversion from and to implementation-defined types
46 struct __storage_tag_t {};
47 static constexpr __storage_tag_t __storage_tag{};
48 explicit _LIBCPP_HIDE_FROM_ABI operator _Storage() const { return __s_; }
49 explicit _LIBCPP_HIDE_FROM_ABI simd_mask(const _Storage& __s, __storage_tag_t) : __s_(__s) {}
50
44 // broadcast constructor51 // broadcast constructor
45 _LIBCPP_HIDE_FROM_ABI explicit simd_mask(value_type __v) noexcept : __s_(_Impl::__broadcast(__v)) {}52 _LIBCPP_HIDE_FROM_ABI explicit simd_mask(value_type __v) noexcept : __s_(_Impl::__broadcast(__v)) {}
4653
lib/libcxx/include/experimental/__simd/traits.h+2-2
...@@ -11,10 +11,10 @@...@@ -11,10 +11,10 @@
11#define _LIBCPP_EXPERIMENTAL___SIMD_TRAITS_H11#define _LIBCPP_EXPERIMENTAL___SIMD_TRAITS_H
1212
13#include <__bit/bit_ceil.h>13#include <__bit/bit_ceil.h>
14#include <__config>
15#include <__cstddef/size_t.h>
14#include <__type_traits/integral_constant.h>16#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_same.h>17#include <__type_traits/is_same.h>
16#include <cstddef>
17#include <experimental/__config>
18#include <experimental/__simd/declaration.h>18#include <experimental/__simd/declaration.h>
19#include <experimental/__simd/utility.h>19#include <experimental/__simd/utility.h>
2020
lib/libcxx/include/experimental/__simd/utility.h+3-3
...@@ -10,6 +10,8 @@...@@ -10,6 +10,8 @@
10#ifndef _LIBCPP_EXPERIMENTAL___SIMD_UTILITY_H10#ifndef _LIBCPP_EXPERIMENTAL___SIMD_UTILITY_H
11#define _LIBCPP_EXPERIMENTAL___SIMD_UTILITY_H11#define _LIBCPP_EXPERIMENTAL___SIMD_UTILITY_H
1212
13#include <__config>
14#include <__cstddef/size_t.h>
13#include <__type_traits/is_arithmetic.h>15#include <__type_traits/is_arithmetic.h>
14#include <__type_traits/is_const.h>16#include <__type_traits/is_const.h>
15#include <__type_traits/is_constant_evaluated.h>17#include <__type_traits/is_constant_evaluated.h>
...@@ -20,9 +22,7 @@...@@ -20,9 +22,7 @@
20#include <__type_traits/void_t.h>22#include <__type_traits/void_t.h>
21#include <__utility/declval.h>23#include <__utility/declval.h>
22#include <__utility/integer_sequence.h>24#include <__utility/integer_sequence.h>
23#include <cstddef>
24#include <cstdint>25#include <cstdint>
25#include <experimental/__config>
26#include <limits>26#include <limits>
2727
28_LIBCPP_PUSH_MACROS28_LIBCPP_PUSH_MACROS
...@@ -47,7 +47,7 @@ _LIBCPP_HIDE_FROM_ABI auto __choose_mask_type() {...@@ -47,7 +47,7 @@ _LIBCPP_HIDE_FROM_ABI auto __choose_mask_type() {
47 } else if constexpr (sizeof(_Tp) == 8) {47 } else if constexpr (sizeof(_Tp) == 8) {
48 return uint64_t{};48 return uint64_t{};
49 }49 }
50# ifndef _LIBCPP_HAS_NO_INT12850# if _LIBCPP_HAS_INT128
51 else if constexpr (sizeof(_Tp) == 16) {51 else if constexpr (sizeof(_Tp) == 16) {
52 return __uint128_t{};52 return __uint128_t{};
53 }53 }
lib/libcxx/include/experimental/__simd/vec_ext.h+18-7
...@@ -12,10 +12,11 @@...@@ -12,10 +12,11 @@
1212
13#include <__assert>13#include <__assert>
14#include <__bit/bit_ceil.h>14#include <__bit/bit_ceil.h>
15#include <__config>
16#include <__cstddef/size_t.h>
17#include <__type_traits/integral_constant.h>
15#include <__utility/forward.h>18#include <__utility/forward.h>
16#include <__utility/integer_sequence.h>19#include <__utility/integer_sequence.h>
17#include <cstddef>
18#include <experimental/__config>
19#include <experimental/__simd/declaration.h>20#include <experimental/__simd/declaration.h>
20#include <experimental/__simd/traits.h>21#include <experimental/__simd/traits.h>
21#include <experimental/__simd/utility.h>22#include <experimental/__simd/utility.h>
...@@ -39,11 +40,11 @@ struct __simd_storage<_Tp, simd_abi::__vec_ext<_Np>> {...@@ -39,11 +40,11 @@ struct __simd_storage<_Tp, simd_abi::__vec_ext<_Np>> {
39 _Tp __data __attribute__((__vector_size__(std::__bit_ceil((sizeof(_Tp) * _Np)))));40 _Tp __data __attribute__((__vector_size__(std::__bit_ceil((sizeof(_Tp) * _Np)))));
4041
41 _LIBCPP_HIDE_FROM_ABI _Tp __get(size_t __idx) const noexcept {42 _LIBCPP_HIDE_FROM_ABI _Tp __get(size_t __idx) const noexcept {
42 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx >= 0 && __idx < _Np, "Index is out of bounds");43 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx < _Np, "Index is out of bounds");
43 return __data[__idx];44 return __data[__idx];
44 }45 }
45 _LIBCPP_HIDE_FROM_ABI void __set(size_t __idx, _Tp __v) noexcept {46 _LIBCPP_HIDE_FROM_ABI void __set(size_t __idx, _Tp __v) noexcept {
46 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx >= 0 && __idx < _Np, "Index is out of bounds");47 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx < _Np, "Index is out of bounds");
47 __data[__idx] = __v;48 __data[__idx] = __v;
48 }49 }
49};50};
...@@ -54,8 +55,8 @@ struct __mask_storage<_Tp, simd_abi::__vec_ext<_Np>>...@@ -54,8 +55,8 @@ struct __mask_storage<_Tp, simd_abi::__vec_ext<_Np>>
5455
55template <class _Tp, int _Np>56template <class _Tp, int _Np>
56struct __simd_operations<_Tp, simd_abi::__vec_ext<_Np>> {57struct __simd_operations<_Tp, simd_abi::__vec_ext<_Np>> {
57 using _SimdStorage = __simd_storage<_Tp, simd_abi::__vec_ext<_Np>>;58 using _SimdStorage _LIBCPP_NODEBUG = __simd_storage<_Tp, simd_abi::__vec_ext<_Np>>;
58 using _MaskStorage = __mask_storage<_Tp, simd_abi::__vec_ext<_Np>>;59 using _MaskStorage _LIBCPP_NODEBUG = __mask_storage<_Tp, simd_abi::__vec_ext<_Np>>;
5960
60 static _LIBCPP_HIDE_FROM_ABI _SimdStorage __broadcast(_Tp __v) noexcept {61 static _LIBCPP_HIDE_FROM_ABI _SimdStorage __broadcast(_Tp __v) noexcept {
61 _SimdStorage __result;62 _SimdStorage __result;
...@@ -86,11 +87,21 @@ struct __simd_operations<_Tp, simd_abi::__vec_ext<_Np>> {...@@ -86,11 +87,21 @@ struct __simd_operations<_Tp, simd_abi::__vec_ext<_Np>> {
86 for (size_t __i = 0; __i < _Np; __i++)87 for (size_t __i = 0; __i < _Np; __i++)
87 __mem[__i] = static_cast<_Up>(__s.__data[__i]);88 __mem[__i] = static_cast<_Up>(__s.__data[__i]);
88 }89 }
90
91 static _LIBCPP_HIDE_FROM_ABI void __increment(_SimdStorage& __s) noexcept { __s.__data = __s.__data + 1; }
92
93 static _LIBCPP_HIDE_FROM_ABI void __decrement(_SimdStorage& __s) noexcept { __s.__data = __s.__data - 1; }
94
95 static _LIBCPP_HIDE_FROM_ABI _MaskStorage __negate(_SimdStorage __s) noexcept { return {!__s.__data}; }
96
97 static _LIBCPP_HIDE_FROM_ABI _SimdStorage __bitwise_not(_SimdStorage __s) noexcept { return {~__s.__data}; }
98
99 static _LIBCPP_HIDE_FROM_ABI _SimdStorage __unary_minus(_SimdStorage __s) noexcept { return {-__s.__data}; }
89};100};
90101
91template <class _Tp, int _Np>102template <class _Tp, int _Np>
92struct __mask_operations<_Tp, simd_abi::__vec_ext<_Np>> {103struct __mask_operations<_Tp, simd_abi::__vec_ext<_Np>> {
93 using _MaskStorage = __mask_storage<_Tp, simd_abi::__vec_ext<_Np>>;104 using _MaskStorage _LIBCPP_NODEBUG = __mask_storage<_Tp, simd_abi::__vec_ext<_Np>>;
94105
95 static _LIBCPP_HIDE_FROM_ABI _MaskStorage __broadcast(bool __v) noexcept {106 static _LIBCPP_HIDE_FROM_ABI _MaskStorage __broadcast(bool __v) noexcept {
96 _MaskStorage __result;107 _MaskStorage __result;
lib/libcxx/include/experimental/iterator+24-17
...@@ -52,21 +52,26 @@ namespace std {...@@ -52,21 +52,26 @@ namespace std {
5252
53*/53*/
5454
55#include <__memory/addressof.h>55#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
56#include <__type_traits/decay.h>56# include <__cxx03/experimental/iterator>
57#include <__utility/forward.h>57#else
58#include <__utility/move.h>58# include <__config>
59#include <experimental/__config>59# include <__memory/addressof.h>
60#include <iterator>60# include <__ostream/basic_ostream.h>
6161# include <__string/char_traits.h>
62#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)62# include <__type_traits/decay.h>
63# pragma GCC system_header63# include <__utility/forward.h>
64#endif64# include <__utility/move.h>
65# include <iterator>
66
67# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
68# pragma GCC system_header
69# endif
6570
66_LIBCPP_PUSH_MACROS71_LIBCPP_PUSH_MACROS
67#include <__undef_macros>72# include <__undef_macros>
6873
69#if _LIBCPP_STD_VER >= 1474# if _LIBCPP_STD_VER >= 14
7075
71_LIBCPP_BEGIN_NAMESPACE_LFTS76_LIBCPP_BEGIN_NAMESPACE_LFTS
7277
...@@ -115,13 +120,15 @@ make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim&& __d) {...@@ -115,13 +120,15 @@ make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim&& __d) {
115120
116_LIBCPP_END_NAMESPACE_LFTS121_LIBCPP_END_NAMESPACE_LFTS
117122
118#endif // _LIBCPP_STD_VER >= 14123# endif // _LIBCPP_STD_VER >= 14
119124
120_LIBCPP_POP_MACROS125_LIBCPP_POP_MACROS
121126
122#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20127# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
123# include <iosfwd>128# include <cstddef>
124# include <type_traits>129# include <iosfwd>
125#endif130# include <type_traits>
131# endif
132#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
126133
127#endif // _LIBCPP_EXPERIMENTAL_ITERATOR134#endif // _LIBCPP_EXPERIMENTAL_ITERATOR
lib/libcxx/include/experimental/memory+30-23
...@@ -49,25 +49,30 @@ public:...@@ -49,25 +49,30 @@ public:
49}49}
50*/50*/
5151
52#include <__functional/hash.h>52#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
53#include <__functional/operations.h>53# include <__cxx03/experimental/memory>
54#include <__type_traits/add_lvalue_reference.h>54#else
55#include <__type_traits/add_pointer.h>55# include <__config>
56#include <__type_traits/common_type.h>56# include <__cstddef/nullptr_t.h>
57#include <__type_traits/enable_if.h>57# include <__cstddef/size_t.h>
58#include <__type_traits/is_convertible.h>58# include <__functional/hash.h>
59#include <cstddef>59# include <__functional/operations.h>
60#include <experimental/__config>60# include <__type_traits/add_lvalue_reference.h>
6161# include <__type_traits/add_pointer.h>
62#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)62# include <__type_traits/common_type.h>
63# pragma GCC system_header63# include <__type_traits/enable_if.h>
64#endif64# include <__type_traits/is_convertible.h>
6565# include <version>
66#ifdef _LIBCPP_ENABLE_EXPERIMENTAL66
67# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
68# pragma GCC system_header
69# endif
70
71# ifdef _LIBCPP_ENABLE_EXPERIMENTAL
6772
68_LIBCPP_BEGIN_NAMESPACE_LFTS_V273_LIBCPP_BEGIN_NAMESPACE_LFTS_V2
6974
70# if _LIBCPP_STD_VER >= 1775# if _LIBCPP_STD_VER >= 17
7176
72template <class _Wp>77template <class _Wp>
73class observer_ptr {78class observer_ptr {
...@@ -170,7 +175,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator>=(observer_ptr<_W1> __a, observer_ptr<_W2> _...@@ -170,7 +175,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator>=(observer_ptr<_W1> __a, observer_ptr<_W2> _
170 return !(__a < __b);175 return !(__a < __b);
171}176}
172177
173# endif // _LIBCPP_STD_VER >= 17178# endif // _LIBCPP_STD_VER >= 17
174179
175_LIBCPP_END_NAMESPACE_LFTS_V2180_LIBCPP_END_NAMESPACE_LFTS_V2
176181
...@@ -178,21 +183,23 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -178,21 +183,23 @@ _LIBCPP_BEGIN_NAMESPACE_STD
178183
179// hash184// hash
180185
181# if _LIBCPP_STD_VER >= 17186# if _LIBCPP_STD_VER >= 17
182template <class _Tp>187template <class _Tp>
183struct hash<experimental::observer_ptr<_Tp>> {188struct hash<experimental::observer_ptr<_Tp>> {
184 _LIBCPP_HIDE_FROM_ABI size_t operator()(const experimental::observer_ptr<_Tp>& __ptr) const noexcept {189 _LIBCPP_HIDE_FROM_ABI size_t operator()(const experimental::observer_ptr<_Tp>& __ptr) const noexcept {
185 return hash<_Tp*>()(__ptr.get());190 return hash<_Tp*>()(__ptr.get());
186 }191 }
187};192};
188# endif // _LIBCPP_STD_VER >= 17193# endif // _LIBCPP_STD_VER >= 17
189194
190_LIBCPP_END_NAMESPACE_STD195_LIBCPP_END_NAMESPACE_STD
191196
192#endif // _LIBCPP_ENABLE_EXPERIMENTAL197# endif // _LIBCPP_ENABLE_EXPERIMENTAL
193198
194#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20199# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
195# include <limits>200# include <cstddef>
196#endif201# include <limits>
202# endif
203#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
197204
198#endif /* _LIBCPP_EXPERIMENTAL_MEMORY */205#endif /* _LIBCPP_EXPERIMENTAL_MEMORY */
lib/libcxx/include/experimental/propagate_const+39-32
...@@ -107,37 +107,42 @@...@@ -107,37 +107,42 @@
107107
108*/108*/
109109
110#include <__functional/operations.h>110#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
111#include <__fwd/functional.h>111# include <__cxx03/experimental/propagate_const>
112#include <__type_traits/conditional.h>112#else
113#include <__type_traits/decay.h>113# include <__config>
114#include <__type_traits/enable_if.h>114# include <__cstddef/nullptr_t.h>
115#include <__type_traits/is_array.h>115# include <__cstddef/size_t.h>
116#include <__type_traits/is_constructible.h>116# include <__functional/operations.h>
117#include <__type_traits/is_convertible.h>117# include <__fwd/functional.h>
118#include <__type_traits/is_function.h>118# include <__type_traits/conditional.h>
119#include <__type_traits/is_pointer.h>119# include <__type_traits/decay.h>
120#include <__type_traits/is_reference.h>120# include <__type_traits/enable_if.h>
121#include <__type_traits/is_same.h>121# include <__type_traits/is_array.h>
122#include <__type_traits/is_swappable.h>122# include <__type_traits/is_constructible.h>
123#include <__type_traits/remove_cv.h>123# include <__type_traits/is_convertible.h>
124#include <__type_traits/remove_pointer.h>124# include <__type_traits/is_function.h>
125#include <__type_traits/remove_reference.h>125# include <__type_traits/is_pointer.h>
126#include <__utility/declval.h>126# include <__type_traits/is_reference.h>
127#include <__utility/forward.h>127# include <__type_traits/is_same.h>
128#include <__utility/move.h>128# include <__type_traits/is_swappable.h>
129#include <__utility/swap.h>129# include <__type_traits/remove_cv.h>
130#include <cstddef>130# include <__type_traits/remove_pointer.h>
131#include <experimental/__config>131# include <__type_traits/remove_reference.h>
132132# include <__utility/declval.h>
133#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)133# include <__utility/forward.h>
134# pragma GCC system_header134# include <__utility/move.h>
135#endif135# include <__utility/swap.h>
136# include <version>
137
138# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
139# pragma GCC system_header
140# endif
136141
137_LIBCPP_PUSH_MACROS142_LIBCPP_PUSH_MACROS
138#include <__undef_macros>143# include <__undef_macros>
139144
140#if _LIBCPP_STD_VER >= 14145# if _LIBCPP_STD_VER >= 14
141146
142_LIBCPP_BEGIN_NAMESPACE_LFTS_V2147_LIBCPP_BEGIN_NAMESPACE_LFTS_V2
143148
...@@ -479,12 +484,14 @@ struct greater_equal<experimental::propagate_const<_Tp>> {...@@ -479,12 +484,14 @@ struct greater_equal<experimental::propagate_const<_Tp>> {
479484
480_LIBCPP_END_NAMESPACE_STD485_LIBCPP_END_NAMESPACE_STD
481486
482#endif // _LIBCPP_STD_VER >= 14487# endif // _LIBCPP_STD_VER >= 14
483488
484_LIBCPP_POP_MACROS489_LIBCPP_POP_MACROS
485490
486#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20491# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
487# include <type_traits>492# include <cstddef>
488#endif493# include <type_traits>
494# endif
495#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
489496
490#endif // _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST497#endif // _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST
lib/libcxx/include/experimental/simd+17-9
...@@ -75,14 +75,22 @@ inline namespace parallelism_v2 {...@@ -75,14 +75,22 @@ inline namespace parallelism_v2 {
75# pragma GCC system_header75# pragma GCC system_header
76#endif76#endif
7777
78#include <experimental/__config>78#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
79#include <experimental/__simd/aligned_tag.h>79# include <__cxx03/experimental/simd>
80#include <experimental/__simd/declaration.h>80#else
81#include <experimental/__simd/reference.h>81# include <__config>
82#include <experimental/__simd/scalar.h>82# include <experimental/__simd/aligned_tag.h>
83#include <experimental/__simd/simd.h>83# include <experimental/__simd/declaration.h>
84#include <experimental/__simd/simd_mask.h>84# include <experimental/__simd/reference.h>
85#include <experimental/__simd/traits.h>85# include <experimental/__simd/scalar.h>
86#include <experimental/__simd/vec_ext.h>86# include <experimental/__simd/simd.h>
87# include <experimental/__simd/simd_mask.h>
88# include <experimental/__simd/traits.h>
89# include <experimental/__simd/vec_ext.h>
90
91# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
92# include <cstddef>
93# endif
94#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
8795
88#endif /* _LIBCPP_EXPERIMENTAL_SIMD */96#endif /* _LIBCPP_EXPERIMENTAL_SIMD */
lib/libcxx/include/experimental/type_traits+16-8
...@@ -68,16 +68,19 @@ inline namespace fundamentals_v1 {...@@ -68,16 +68,19 @@ inline namespace fundamentals_v1 {
6868
69 */69 */
7070
71#include <experimental/__config>71#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
72# include <__cxx03/experimental/type_traits>
73#else
74# include <__config>
7275
73#if _LIBCPP_STD_VER >= 1476# if _LIBCPP_STD_VER >= 14
7477
75# include <initializer_list>78# include <initializer_list>
76# include <type_traits>79# include <type_traits>
7780
78# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)81# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
79# pragma GCC system_header82# pragma GCC system_header
80# endif83# endif
8184
82_LIBCPP_BEGIN_NAMESPACE_LFTS85_LIBCPP_BEGIN_NAMESPACE_LFTS
8386
...@@ -148,6 +151,11 @@ constexpr bool is_detected_convertible_v = is_detected_convertible<_To, _Op, _Ar...@@ -148,6 +151,11 @@ constexpr bool is_detected_convertible_v = is_detected_convertible<_To, _Op, _Ar
148151
149_LIBCPP_END_NAMESPACE_LFTS152_LIBCPP_END_NAMESPACE_LFTS
150153
151#endif /* _LIBCPP_STD_VER >= 14 */154# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
155# include <cstddef>
156# endif
157
158# endif /* _LIBCPP_STD_VER >= 14 */
159#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
152160
153#endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */161#endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */
lib/libcxx/include/experimental/utility+13-5
...@@ -30,12 +30,15 @@ inline namespace fundamentals_v1 {...@@ -30,12 +30,15 @@ inline namespace fundamentals_v1 {
3030
31 */31 */
3232
33#include <experimental/__config>33#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
34#include <utility>34# include <__cxx03/experimental/utility>
35#else
36# include <__config>
37# include <utility>
3538
36#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)39# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
37# pragma GCC system_header40# pragma GCC system_header
38#endif41# endif
3942
40_LIBCPP_BEGIN_NAMESPACE_LFTS43_LIBCPP_BEGIN_NAMESPACE_LFTS
4144
...@@ -43,4 +46,9 @@ struct _LIBCPP_TEMPLATE_VIS erased_type {};...@@ -43,4 +46,9 @@ struct _LIBCPP_TEMPLATE_VIS erased_type {};
4346
44_LIBCPP_END_NAMESPACE_LFTS47_LIBCPP_END_NAMESPACE_LFTS
4548
49# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
50# include <cstddef>
51# endif
52#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
53
46#endif /* _LIBCPP_EXPERIMENTAL_UTILITY */54#endif /* _LIBCPP_EXPERIMENTAL_UTILITY */
lib/libcxx/include/ext/hash_map+26-22
...@@ -201,23 +201,26 @@ template <class Key, class T, class Hash, class Pred, class Alloc>...@@ -201,23 +201,26 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
201201
202*/202*/
203203
204#include <__config>204#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
205#include <__hash_table>205# include <__cxx03/ext/hash_map>
206#include <algorithm>206#else
207#include <ext/__hash>207# include <__config>
208#include <functional>208# include <__hash_table>
209209# include <algorithm>
210#if defined(__DEPRECATED) && __DEPRECATED210# include <ext/__hash>
211# if defined(_LIBCPP_WARNING)211# include <functional>
212
213# if defined(__DEPRECATED) && __DEPRECATED
214# if defined(_LIBCPP_WARNING)
212_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>")
213# else216# else
214# warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>217# warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>
218# endif
215# endif219# endif
216#endif
217220
218#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)221# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
219# pragma GCC system_header222# pragma GCC system_header
220#endif223# endif
221224
222namespace __gnu_cxx {225namespace __gnu_cxx {
223226
...@@ -312,17 +315,17 @@ public:...@@ -312,17 +315,17 @@ public:
312 _LIBCPP_HIDE_FROM_ABI explicit __hash_map_node_destructor(allocator_type& __na)315 _LIBCPP_HIDE_FROM_ABI explicit __hash_map_node_destructor(allocator_type& __na)
313 : __na_(__na), __first_constructed(false), __second_constructed(false) {}316 : __na_(__na), __first_constructed(false), __second_constructed(false) {}
314317
315#ifndef _LIBCPP_CXX03_LANG318# ifndef _LIBCPP_CXX03_LANG
316 _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(std::__hash_node_destructor<allocator_type>&& __x)319 _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(std::__hash_node_destructor<allocator_type>&& __x)
317 : __na_(__x.__na_), __first_constructed(__x.__value_constructed), __second_constructed(__x.__value_constructed) {320 : __na_(__x.__na_), __first_constructed(__x.__value_constructed), __second_constructed(__x.__value_constructed) {
318 __x.__value_constructed = false;321 __x.__value_constructed = false;
319 }322 }
320#else // _LIBCPP_CXX03_LANG323# else // _LIBCPP_CXX03_LANG
321 _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(const std::__hash_node_destructor<allocator_type>& __x)324 _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(const std::__hash_node_destructor<allocator_type>& __x)
322 : __na_(__x.__na_), __first_constructed(__x.__value_constructed), __second_constructed(__x.__value_constructed) {325 : __na_(__x.__na_), __first_constructed(__x.__value_constructed), __second_constructed(__x.__value_constructed) {
323 const_cast<bool&>(__x.__value_constructed) = false;326 const_cast<bool&>(__x.__value_constructed) = false;
324 }327 }
325#endif // _LIBCPP_CXX03_LANG328# endif // _LIBCPP_CXX03_LANG
326329
327 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) {330 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) {
328 if (__second_constructed)331 if (__second_constructed)
...@@ -863,10 +866,11 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const hash_multimap<_Key, _Tp, _Has...@@ -863,10 +866,11 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const hash_multimap<_Key, _Tp, _Has
863866
864} // namespace __gnu_cxx867} // namespace __gnu_cxx
865868
866#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20869# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
867# include <concepts>870# include <concepts>
868# include <iterator>871# include <iterator>
869# include <type_traits>872# include <type_traits>
870#endif873# endif
874#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
871875
872#endif // _LIBCPP_HASH_MAP876#endif // _LIBCPP_HASH_MAP
lib/libcxx/include/ext/hash_set+23-19
...@@ -192,23 +192,26 @@ template <class Value, class Hash, class Pred, class Alloc>...@@ -192,23 +192,26 @@ template <class Value, class Hash, class Pred, class Alloc>
192192
193*/193*/
194194
195#include <__config>195#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
196#include <__hash_table>196# include <__cxx03/ext/hash_set>
197#include <algorithm>197#else
198#include <ext/__hash>198# include <__config>
199#include <functional>199# include <__hash_table>
200200# include <algorithm>
201#if defined(__DEPRECATED) && __DEPRECATED201# include <ext/__hash>
202# if defined(_LIBCPP_WARNING)202# include <functional>
203
204# if defined(__DEPRECATED) && __DEPRECATED
205# if defined(_LIBCPP_WARNING)
203_LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>")206_LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>")
204# else207# else
205# warning Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>208# warning Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>
209# endif
206# endif210# endif
207#endif
208211
209#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)212# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
210# pragma GCC system_header213# pragma GCC system_header
211#endif214# endif
212215
213namespace __gnu_cxx {216namespace __gnu_cxx {
214217
...@@ -575,10 +578,11 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const hash_multiset<_Value, _Hash,...@@ -575,10 +578,11 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const hash_multiset<_Value, _Hash,
575578
576} // namespace __gnu_cxx579} // namespace __gnu_cxx
577580
578#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20581# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
579# include <concepts>582# include <concepts>
580# include <iterator>583# include <iterator>
581# include <type_traits>584# include <type_traits>
582#endif585# endif
586#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
583587
584#endif // _LIBCPP_HASH_SET588#endif // _LIBCPP_HASH_SET
lib/libcxx/include/fenv.h+46-42
...@@ -49,66 +49,70 @@ int feupdateenv(const fenv_t* envp);...@@ -49,66 +49,70 @@ int feupdateenv(const fenv_t* envp);
4949
50*/50*/
5151
52#include <__config>52#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
53# include <__cxx03/fenv.h>
54#else
55# include <__config>
5356
54#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)57# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
55# pragma GCC system_header58# pragma GCC system_header
56#endif59# endif
5760
58#if __has_include_next(<fenv.h>)61# if __has_include_next(<fenv.h>)
59# include_next <fenv.h>62# include_next <fenv.h>
60#endif63# endif
6164
62#ifdef __cplusplus65# ifdef __cplusplus
6366
64extern "C++" {67extern "C++" {
6568
66# ifdef feclearexcept69# ifdef feclearexcept
67# undef feclearexcept70# undef feclearexcept
68# endif71# endif
6972
70# ifdef fegetexceptflag73# ifdef fegetexceptflag
71# undef fegetexceptflag74# undef fegetexceptflag
72# endif75# endif
7376
74# ifdef feraiseexcept77# ifdef feraiseexcept
75# undef feraiseexcept78# undef feraiseexcept
76# endif79# endif
7780
78# ifdef fesetexceptflag81# ifdef fesetexceptflag
79# undef fesetexceptflag82# undef fesetexceptflag
80# endif83# endif
8184
82# ifdef fetestexcept85# ifdef fetestexcept
83# undef fetestexcept86# undef fetestexcept
84# endif87# endif
8588
86# ifdef fegetround89# ifdef fegetround
87# undef fegetround90# undef fegetround
88# endif91# endif
8992
90# ifdef fesetround93# ifdef fesetround
91# undef fesetround94# undef fesetround
92# endif95# endif
9396
94# ifdef fegetenv97# ifdef fegetenv
95# undef fegetenv98# undef fegetenv
96# endif99# endif
97100
98# ifdef feholdexcept101# ifdef feholdexcept
99# undef feholdexcept102# undef feholdexcept
100# endif103# endif
101104
102# ifdef fesetenv105# ifdef fesetenv
103# undef fesetenv106# undef fesetenv
104# endif107# endif
105108
106# ifdef feupdateenv109# ifdef feupdateenv
107# undef feupdateenv110# undef feupdateenv
108# endif111# endif
109112
110} // extern "C++"113} // extern "C++"
111114
112#endif // defined(__cplusplus)115# endif // defined(__cplusplus)
116#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
113117
114#endif // _LIBCPP_FENV_H118#endif // _LIBCPP_FENV_H
lib/libcxx/include/filesystem+40-36
...@@ -533,45 +533,49 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct...@@ -533,45 +533,49 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
533533
534*/534*/
535535
536#include <__config>536#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
537537# include <__cxx03/filesystem>
538#if _LIBCPP_STD_VER >= 17538#else
539# include <__filesystem/copy_options.h>539# include <__config>
540# include <__filesystem/directory_entry.h>540
541# include <__filesystem/directory_iterator.h>541# if _LIBCPP_STD_VER >= 17
542# include <__filesystem/directory_options.h>542# include <__filesystem/copy_options.h>
543# include <__filesystem/file_status.h>543# include <__filesystem/directory_entry.h>
544# include <__filesystem/file_time_type.h>544# include <__filesystem/directory_iterator.h>
545# include <__filesystem/file_type.h>545# include <__filesystem/directory_options.h>
546# include <__filesystem/filesystem_error.h>546# include <__filesystem/file_status.h>
547# include <__filesystem/operations.h>547# include <__filesystem/file_time_type.h>
548# include <__filesystem/path.h>548# include <__filesystem/file_type.h>
549# include <__filesystem/path_iterator.h>549# include <__filesystem/filesystem_error.h>
550# include <__filesystem/perm_options.h>550# include <__filesystem/operations.h>
551# include <__filesystem/perms.h>551# include <__filesystem/path.h>
552# include <__filesystem/recursive_directory_iterator.h>552# include <__filesystem/path_iterator.h>
553# include <__filesystem/space_info.h>553# include <__filesystem/perm_options.h>
554# include <__filesystem/u8path.h>554# include <__filesystem/perms.h>
555#endif555# include <__filesystem/recursive_directory_iterator.h>
556556# include <__filesystem/space_info.h>
557#include <version>557# include <__filesystem/u8path.h>
558# endif
559
560# include <version>
558561
559// standard-mandated includes562// standard-mandated includes
560563
561// [fs.filesystem.syn]564// [fs.filesystem.syn]
562#include <compare>565# include <compare>
563566
564#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)567# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
565# pragma GCC system_header568# pragma GCC system_header
566#endif569# endif
567570
568#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20571# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
569# include <concepts>572# include <concepts>
570# include <cstdlib>573# include <cstdlib>
571# include <cstring>574# include <cstring>
572# include <iosfwd>575# include <iosfwd>
573# include <new>576# include <new>
574# include <system_error>577# include <system_error>
575#endif578# endif
579#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
576580
577#endif // _LIBCPP_FILESYSTEM581#endif // _LIBCPP_FILESYSTEM
lib/libcxx/include/flat_map created+83
...@@ -0,0 +1,83 @@
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_FLAT_MAP
11#define _LIBCPP_FLAT_MAP
12
13/*
14 Header <flat_map> synopsis
15
16#include <compare> // see [compare.syn]
17#include <initializer_list> // see [initializer.list.syn]
18
19namespace std {
20 // [flat.map], class template flat_map
21 template<class Key, class T, class Compare = less<Key>,
22 class KeyContainer = vector<Key>, class MappedContainer = vector<T>>
23 class flat_map;
24
25 struct sorted_unique_t { explicit sorted_unique_t() = default; };
26 inline constexpr sorted_unique_t sorted_unique{};
27
28 template<class Key, class T, class Compare, class KeyContainer, class MappedContainer,
29 class Allocator>
30 struct uses_allocator<flat_map<Key, T, Compare, KeyContainer, MappedContainer>,
31 Allocator>;
32
33 // [flat.map.erasure], erasure for flat_map
34 template<class Key, class T, class Compare, class KeyContainer, class MappedContainer,
35 class Predicate>
36 typename flat_map<Key, T, Compare, KeyContainer, MappedContainer>::size_type
37 erase_if(flat_map<Key, T, Compare, KeyContainer, MappedContainer>& c, Predicate pred);
38
39 // [flat.multimap], class template flat_multimap
40 template<class Key, class T, class Compare = less<Key>,
41 class KeyContainer = vector<Key>, class MappedContainer = vector<T>>
42 class flat_multimap;
43
44 struct sorted_equivalent_t { explicit sorted_equivalent_t() = default; };
45 inline constexpr sorted_equivalent_t sorted_equivalent{};
46
47 template<class Key, class T, class Compare, class KeyContainer, class MappedContainer,
48 class Allocator>
49 struct uses_allocator<flat_multimap<Key, T, Compare, KeyContainer, MappedContainer>,
50 Allocator>;
51
52 // [flat.multimap.erasure], erasure for flat_multimap
53 template<class Key, class T, class Compare, class KeyContainer, class MappedContainer,
54 class Predicate>
55 typename flat_multimap<Key, T, Compare, KeyContainer, MappedContainer>::size_type
56 erase_if(flat_multimap<Key, T, Compare, KeyContainer, MappedContainer>& c, Predicate pred);
57*/
58
59#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
60# include <__cxx03/__config>
61#else
62# include <__config>
63
64# if _LIBCPP_STD_VER >= 23
65# include <__flat_map/flat_map.h>
66# include <__flat_map/flat_multimap.h>
67# include <__flat_map/sorted_equivalent.h>
68# include <__flat_map/sorted_unique.h>
69# endif
70
71// for feature-test macros
72# include <version>
73
74// standard required includes
75# include <compare>
76# include <initializer_list>
77
78# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
79# pragma GCC system_header
80# endif
81#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
82
83#endif // _LIBCPP_FLAT_MAP
lib/libcxx/include/float.h+19-15
...@@ -70,26 +70,30 @@ Macros:...@@ -70,26 +70,30 @@ Macros:
7070
71*/71*/
7272
73#include <__config>73#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
74# include <__cxx03/float.h>
75#else
76# include <__config>
7477
75#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)78# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
76# pragma GCC system_header79# pragma GCC system_header
77#endif80# endif
7881
79#if __has_include_next(<float.h>)82# if __has_include_next(<float.h>)
80# include_next <float.h>83# include_next <float.h>
81#endif84# endif
8285
83#ifdef __cplusplus86# ifdef __cplusplus
8487
85# ifndef FLT_EVAL_METHOD88# ifndef FLT_EVAL_METHOD
86# define FLT_EVAL_METHOD __FLT_EVAL_METHOD__89# define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
87# endif90# endif
8891
89# ifndef DECIMAL_DIG92# ifndef DECIMAL_DIG
90# define DECIMAL_DIG __DECIMAL_DIG__93# define DECIMAL_DIG __DECIMAL_DIG__
91# endif94# endif
9295
93#endif // __cplusplus96# endif // __cplusplus
97#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
9498
95#endif // _LIBCPP_FLOAT_H99#endif // _LIBCPP_FLOAT_H
lib/libcxx/include/format+77-70
...@@ -126,6 +126,9 @@ namespace std {...@@ -126,6 +126,9 @@ namespace std {
126 // [format.formatter], formatter126 // [format.formatter], formatter
127 template<class T, class charT = char> struct formatter;127 template<class T, class charT = char> struct formatter;
128128
129 template<class T>
130 constexpr bool enable_nonlocking_formatter_optimization = false; // since C++23
131
129 // [format.parse.ctx], class template basic_format_parse_context132 // [format.parse.ctx], class template basic_format_parse_context
130 template<class charT> class basic_format_parse_context;133 template<class charT> class basic_format_parse_context;
131 using format_parse_context = basic_format_parse_context<char>;134 using format_parse_context = basic_format_parse_context<char>;
...@@ -133,7 +136,7 @@ namespace std {...@@ -133,7 +136,7 @@ namespace std {
133136
134 // [format.range], formatting of ranges137 // [format.range], formatting of ranges
135 // [format.range.fmtkind], variable template format_kind138 // [format.range.fmtkind], variable template format_kind
136 enum class range_format { // since C++23139 enum class range_format { // since C++23
137 disabled,140 disabled,
138 map,141 map,
139 set,142 set,
...@@ -143,20 +146,20 @@ namespace std {...@@ -143,20 +146,20 @@ namespace std {
143 };146 };
144147
145 template<class R>148 template<class R>
146 constexpr unspecified format_kind = unspecified; // since C++23149 constexpr unspecified format_kind = unspecified; // since C++23
147150
148 template<ranges::input_range R>151 template<ranges::input_range R>
149 requires same_as<R, remove_cvref_t<R>>152 requires same_as<R, remove_cvref_t<R>>
150 constexpr range_format format_kind<R> = see below; // since C++23153 constexpr range_format format_kind<R> = see below; // since C++23
151154
152 // [format.range.formatter], class template range_formatter155 // [format.range.formatter], class template range_formatter
153 template<class T, class charT = char>156 template<class T, class charT = char>
154 requires same_as<remove_cvref_t<T>, T> && formattable<T, charT>157 requires same_as<remove_cvref_t<T>, T> && formattable<T, charT>
155 class range_formatter; // since C++23158 class range_formatter; // since C++23
156159
157 // [format.range.fmtdef], class template range-default-formatter160 // [format.range.fmtdef], class template range-default-formatter
158 template<range_format K, ranges::input_range R, class charT>161 template<range_format K, ranges::input_range R, class charT>
159 struct range-default-formatter; // exposition only, since C++23162 struct range-default-formatter; // exposition only, since C++23
160163
161 // [format.range.fmtmap], [format.range.fmtset], [format.range.fmtstr],164 // [format.range.fmtmap], [format.range.fmtset], [format.range.fmtstr],
162 // specializations for maps, sets, and strings165 // specializations for maps, sets, and strings
...@@ -173,7 +176,7 @@ namespace std {...@@ -173,7 +176,7 @@ namespace std {
173 see below visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg); // Deprecated in C++26176 see below visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg); // Deprecated in C++26
174177
175 // [format.arg.store], class template format-arg-store178 // [format.arg.store], class template format-arg-store
176 template<class Context, class... Args> struct format-arg-store; // exposition only179 template<class Context, class... Args> struct format-arg-store; // exposition only
177180
178 template<class Context = format_context, class... Args>181 template<class Context = format_context, class... Args>
179 format-arg-store<Context, Args...>182 format-arg-store<Context, Args...>
...@@ -188,70 +191,74 @@ namespace std {...@@ -188,70 +191,74 @@ namespace std {
188191
189*/192*/
190193
191#include <__config>194#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
192195# include <__cxx03/format>
193#if _LIBCPP_STD_VER >= 20196#else
194# include <__format/buffer.h>197# include <__config>
195# include <__format/concepts.h>198
196# include <__format/container_adaptor.h>199# if _LIBCPP_STD_VER >= 20
197# include <__format/enable_insertable.h>200# include <__format/buffer.h>
198# include <__format/escaped_output_table.h>201# include <__format/concepts.h>
199# include <__format/extended_grapheme_cluster_table.h>202# include <__format/container_adaptor.h>
200# include <__format/format_arg.h>203# include <__format/enable_insertable.h>
201# include <__format/format_arg_store.h>204# include <__format/escaped_output_table.h>
202# include <__format/format_args.h>205# include <__format/extended_grapheme_cluster_table.h>
203# include <__format/format_context.h>206# include <__format/format_arg.h>
204# include <__format/format_error.h>207# include <__format/format_arg_store.h>
205# include <__format/format_functions.h>208# include <__format/format_args.h>
206# include <__format/format_parse_context.h>209# include <__format/format_context.h>
207# include <__format/format_string.h>210# include <__format/format_error.h>
208# include <__format/format_to_n_result.h>211# include <__format/format_functions.h>
209# include <__format/formatter.h>212# include <__format/format_parse_context.h>
210# include <__format/formatter_bool.h>213# include <__format/format_string.h>
211# include <__format/formatter_char.h>214# include <__format/format_to_n_result.h>
212# include <__format/formatter_floating_point.h>215# include <__format/formatter.h>
213# include <__format/formatter_integer.h>216# include <__format/formatter_bool.h>
214# include <__format/formatter_pointer.h>217# include <__format/formatter_char.h>
215# include <__format/formatter_string.h>218# include <__format/formatter_floating_point.h>
216# include <__format/formatter_tuple.h>219# include <__format/formatter_integer.h>
217# include <__format/parser_std_format_spec.h>220# include <__format/formatter_pointer.h>
218# include <__format/range_default_formatter.h>221# include <__format/formatter_string.h>
219# include <__format/range_formatter.h>222# include <__format/formatter_tuple.h>
220# include <__format/unicode.h>223# include <__format/parser_std_format_spec.h>
221# include <__fwd/format.h>224# include <__format/range_default_formatter.h>
222#endif225# include <__format/range_formatter.h>
223226# include <__format/unicode.h>
224#include <version>227# include <__fwd/format.h>
225228# endif
226#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)229
227# pragma GCC system_header230# include <version>
228#endif231
229232# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
230#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20233# pragma GCC system_header
231# include <array>234# endif
232# include <cctype>235
233# include <cerrno>236# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
234# include <clocale>237# include <array>
235# include <cmath>238# include <cctype>
236# include <cstddef>239# include <cerrno>
237# include <cstdint>240# include <clocale>
238# include <cstdlib>241# include <cmath>
239# include <cstring>242# include <cstddef>
240# include <initializer_list>243# include <cstdint>
241# include <limits>244# include <cstdlib>
242# include <locale>245# include <cstring>
243# include <new>246# include <initializer_list>
244# include <optional>247# include <limits>
245# include <queue>248# include <locale>
246# include <stack>249# include <new>
247# include <stdexcept>250# include <optional>
248# include <string>251# include <queue>
249# include <string_view>252# include <stack>
250# include <tuple>253# include <stdexcept>
251254# include <string>
252# if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)255# include <string_view>
253# include <cwchar>256# include <tuple>
257
258# if _LIBCPP_HAS_WIDE_CHARACTERS
259# include <cwchar>
260# endif
254# endif261# endif
255#endif262#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
256263
257#endif // _LIBCPP_FORMAT264#endif // _LIBCPP_FORMAT
lib/libcxx/include/forward_list+255-229
...@@ -195,62 +195,70 @@ template <class T, class Allocator, class Predicate>...@@ -195,62 +195,70 @@ template <class T, class Allocator, class Predicate>
195195
196*/196*/
197197
198#include <__algorithm/comp.h>198#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
199#include <__algorithm/lexicographical_compare.h>199# include <__cxx03/forward_list>
200#include <__algorithm/lexicographical_compare_three_way.h>200#else
201#include <__algorithm/min.h>201# include <__algorithm/comp.h>
202#include <__config>202# include <__algorithm/lexicographical_compare.h>
203#include <__iterator/distance.h>203# include <__algorithm/lexicographical_compare_three_way.h>
204#include <__iterator/iterator_traits.h>204# include <__algorithm/min.h>
205#include <__iterator/move_iterator.h>205# include <__assert>
206#include <__iterator/next.h>206# include <__config>
207#include <__memory/addressof.h>207# include <__cstddef/nullptr_t.h>
208#include <__memory/allocation_guard.h>208# include <__iterator/distance.h>
209#include <__memory/allocator.h>209# include <__iterator/iterator_traits.h>
210#include <__memory/allocator_traits.h>210# include <__iterator/move_iterator.h>
211#include <__memory/compressed_pair.h>211# include <__iterator/next.h>
212#include <__memory/construct_at.h>212# include <__memory/addressof.h>
213#include <__memory/pointer_traits.h>213# include <__memory/allocation_guard.h>
214#include <__memory/swap_allocator.h>214# include <__memory/allocator.h>
215#include <__memory_resource/polymorphic_allocator.h>215# include <__memory/allocator_traits.h>
216#include <__ranges/access.h>216# include <__memory/compressed_pair.h>
217#include <__ranges/concepts.h>217# include <__memory/construct_at.h>
218#include <__ranges/container_compatible_range.h>218# include <__memory/pointer_traits.h>
219#include <__ranges/from_range.h>219# include <__memory/swap_allocator.h>
220#include <__type_traits/conditional.h>220# include <__memory_resource/polymorphic_allocator.h>
221#include <__type_traits/is_allocator.h>221# include <__new/launder.h>
222#include <__type_traits/is_const.h>222# include <__ranges/access.h>
223#include <__type_traits/is_nothrow_assignable.h>223# include <__ranges/concepts.h>
224#include <__type_traits/is_nothrow_constructible.h>224# include <__ranges/container_compatible_range.h>
225#include <__type_traits/is_pointer.h>225# include <__ranges/from_range.h>
226#include <__type_traits/is_same.h>226# include <__type_traits/conditional.h>
227#include <__type_traits/is_swappable.h>227# include <__type_traits/container_traits.h>
228#include <__type_traits/type_identity.h>228# include <__type_traits/enable_if.h>
229#include <__utility/forward.h>229# include <__type_traits/is_allocator.h>
230#include <__utility/move.h>230# include <__type_traits/is_const.h>
231#include <limits>231# include <__type_traits/is_nothrow_assignable.h>
232#include <new> // __launder232# include <__type_traits/is_nothrow_constructible.h>
233#include <version>233# include <__type_traits/is_pointer.h>
234# include <__type_traits/is_same.h>
235# include <__type_traits/is_swappable.h>
236# include <__type_traits/type_identity.h>
237# include <__utility/forward.h>
238# include <__utility/move.h>
239# include <__utility/swap.h>
240# include <limits>
241# include <version>
234242
235// standard-mandated includes243// standard-mandated includes
236244
237// [iterator.range]245// [iterator.range]
238#include <__iterator/access.h>246# include <__iterator/access.h>
239#include <__iterator/data.h>247# include <__iterator/data.h>
240#include <__iterator/empty.h>248# include <__iterator/empty.h>
241#include <__iterator/reverse_access.h>249# include <__iterator/reverse_access.h>
242#include <__iterator/size.h>250# include <__iterator/size.h>
243251
244// [forward.list.syn]252// [forward.list.syn]
245#include <compare>253# include <compare>
246#include <initializer_list>254# include <initializer_list>
247255
248#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)256# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
249# pragma GCC system_header257# pragma GCC system_header
250#endif258# endif
251259
252_LIBCPP_PUSH_MACROS260_LIBCPP_PUSH_MACROS
253#include <__undef_macros>261# include <__undef_macros>
254262
255_LIBCPP_BEGIN_NAMESPACE_STD263_LIBCPP_BEGIN_NAMESPACE_STD
256264
...@@ -276,18 +284,20 @@ struct __forward_node_traits {...@@ -276,18 +284,20 @@ struct __forward_node_traits {
276 typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer;284 typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer;
277 typedef __rebind_pointer_t<_NodePtr, void> __void_pointer;285 typedef __rebind_pointer_t<_NodePtr, void> __void_pointer;
278286
279#if defined(_LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB)287// TODO(LLVM 22): Remove this check
280 typedef __begin_node_pointer __iter_node_pointer;288# ifndef _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
281#else289 static_assert(sizeof(__begin_node_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__begin_node_pointer) ==
282 typedef __conditional_t<is_pointer<__void_pointer>::value, __begin_node_pointer, __node_pointer> __iter_node_pointer;290 _LIBCPP_ALIGNOF(__node_pointer),
283#endif291 "It looks like you are using std::forward_list with a fancy pointer type that thas a different "
284292 "representation depending on whether it points to a forward_list base pointer or a forward_list node "
285 typedef __conditional_t<is_same<__iter_node_pointer, __node_pointer>::value, __begin_node_pointer, __node_pointer>293 "pointer (both of which are implementation details of the standard library). This means that your ABI "
286 __non_iter_node_pointer;294 "is being broken between LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define "
295 "the _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic.");
296# endif
287297
288 _LIBCPP_HIDE_FROM_ABI static __iter_node_pointer __as_iter_node(__iter_node_pointer __p) { return __p; }298 _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__begin_node_pointer __p) { return __p; }
289 _LIBCPP_HIDE_FROM_ABI static __iter_node_pointer __as_iter_node(__non_iter_node_pointer __p) {299 _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__node_pointer __p) {
290 return static_cast<__iter_node_pointer>(static_cast<__void_pointer>(__p));300 return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__p));
291 }301 }
292};302};
293303
...@@ -307,7 +317,8 @@ struct __forward_begin_node {...@@ -307,7 +317,8 @@ struct __forward_begin_node {
307};317};
308318
309template <class _Tp, class _VoidPtr>319template <class _Tp, class _VoidPtr>
310using __begin_node_of = __forward_begin_node<__rebind_pointer_t<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> > >;320using __begin_node_of _LIBCPP_NODEBUG =
321 __forward_begin_node<__rebind_pointer_t<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> > >;
311322
312template <class _Tp, class _VoidPtr>323template <class _Tp, class _VoidPtr>
313struct __forward_list_node : public __begin_node_of<_Tp, _VoidPtr> {324struct __forward_list_node : public __begin_node_of<_Tp, _VoidPtr> {
...@@ -317,7 +328,7 @@ struct __forward_list_node : public __begin_node_of<_Tp, _VoidPtr> {...@@ -317,7 +328,7 @@ struct __forward_list_node : public __begin_node_of<_Tp, _VoidPtr> {
317328
318 // We allow starting the lifetime of nodes without initializing the value held by the node,329 // We allow starting the lifetime of nodes without initializing the value held by the node,
319 // since that is handled by the list itself in order to be allocator-aware.330 // since that is handled by the list itself in order to be allocator-aware.
320#ifndef _LIBCPP_CXX03_LANG331# ifndef _LIBCPP_CXX03_LANG
321332
322private:333private:
323 union {334 union {
...@@ -326,14 +337,14 @@ private:...@@ -326,14 +337,14 @@ private:
326337
327public:338public:
328 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }339 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }
329#else340# else
330341
331private:342private:
332 _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)];343 _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)];
333344
334public:345public:
335 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); }346 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); }
336#endif347# endif
337348
338 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_node(_NodePtr __next) : _Base(__next) {}349 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_node(_NodePtr __next) : _Base(__next) {}
339 _LIBCPP_HIDE_FROM_ABI ~__forward_list_node() {}350 _LIBCPP_HIDE_FROM_ABI ~__forward_list_node() {}
...@@ -349,10 +360,9 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_iterator {...@@ -349,10 +360,9 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_iterator {
349 typedef __forward_node_traits<_NodePtr> __traits;360 typedef __forward_node_traits<_NodePtr> __traits;
350 typedef typename __traits::__node_pointer __node_pointer;361 typedef typename __traits::__node_pointer __node_pointer;
351 typedef typename __traits::__begin_node_pointer __begin_node_pointer;362 typedef typename __traits::__begin_node_pointer __begin_node_pointer;
352 typedef typename __traits::__iter_node_pointer __iter_node_pointer;
353 typedef typename __traits::__void_pointer __void_pointer;363 typedef typename __traits::__void_pointer __void_pointer;
354364
355 __iter_node_pointer __ptr_;365 __begin_node_pointer __ptr_;
356366
357 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const {367 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const {
358 return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_));368 return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_));
...@@ -415,10 +425,9 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator {...@@ -415,10 +425,9 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator {
415 typedef typename __traits::__node_type __node_type;425 typedef typename __traits::__node_type __node_type;
416 typedef typename __traits::__node_pointer __node_pointer;426 typedef typename __traits::__node_pointer __node_pointer;
417 typedef typename __traits::__begin_node_pointer __begin_node_pointer;427 typedef typename __traits::__begin_node_pointer __begin_node_pointer;
418 typedef typename __traits::__iter_node_pointer __iter_node_pointer;
419 typedef typename __traits::__void_pointer __void_pointer;428 typedef typename __traits::__void_pointer __void_pointer;
420429
421 __iter_node_pointer __ptr_;430 __begin_node_pointer __ptr_;
422431
423 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const {432 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const {
424 return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_));433 return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_));
...@@ -490,34 +499,31 @@ protected:...@@ -490,34 +499,31 @@ protected:
490 typedef __rebind_alloc<allocator_traits<allocator_type>, __begin_node> __begin_node_allocator;499 typedef __rebind_alloc<allocator_traits<allocator_type>, __begin_node> __begin_node_allocator;
491 typedef typename allocator_traits<__begin_node_allocator>::pointer __begin_node_pointer;500 typedef typename allocator_traits<__begin_node_allocator>::pointer __begin_node_pointer;
492501
493 __compressed_pair<__begin_node, __node_allocator> __before_begin_;502 _LIBCPP_COMPRESSED_PAIR(__begin_node, __before_begin_, __node_allocator, __alloc_);
494503
495 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() _NOEXCEPT {504 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() _NOEXCEPT {
496 return pointer_traits<__begin_node_pointer>::pointer_to(__before_begin_.first());505 return pointer_traits<__begin_node_pointer>::pointer_to(__before_begin_);
497 }506 }
498 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() const _NOEXCEPT {507 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() const _NOEXCEPT {
499 return pointer_traits<__begin_node_pointer>::pointer_to(const_cast<__begin_node&>(__before_begin_.first()));508 return pointer_traits<__begin_node_pointer>::pointer_to(const_cast<__begin_node&>(__before_begin_));
500 }509 }
501510
502 _LIBCPP_HIDE_FROM_ABI __node_allocator& __alloc() _NOEXCEPT { return __before_begin_.second(); }
503 _LIBCPP_HIDE_FROM_ABI const __node_allocator& __alloc() const _NOEXCEPT { return __before_begin_.second(); }
504
505 typedef __forward_list_iterator<__node_pointer> iterator;511 typedef __forward_list_iterator<__node_pointer> iterator;
506 typedef __forward_list_const_iterator<__node_pointer> const_iterator;512 typedef __forward_list_const_iterator<__node_pointer> const_iterator;
507513
508 _LIBCPP_HIDE_FROM_ABI __forward_list_base() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)514 _LIBCPP_HIDE_FROM_ABI __forward_list_base() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
509 : __before_begin_(__begin_node(), __default_init_tag()) {}515 : __before_begin_(__begin_node()) {}
510 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const allocator_type& __a)516 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const allocator_type& __a)
511 : __before_begin_(__begin_node(), __node_allocator(__a)) {}517 : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) {}
512 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const __node_allocator& __a)518 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const __node_allocator& __a)
513 : __before_begin_(__begin_node(), __a) {}519 : __before_begin_(__begin_node()), __alloc_(__a) {}
514520
515public:521public:
516#ifndef _LIBCPP_CXX03_LANG522# ifndef _LIBCPP_CXX03_LANG
517 _LIBCPP_HIDE_FROM_ABI523 _LIBCPP_HIDE_FROM_ABI
518 __forward_list_base(__forward_list_base&& __x) noexcept(is_nothrow_move_constructible<__node_allocator>::value);524 __forward_list_base(__forward_list_base&& __x) noexcept(is_nothrow_move_constructible<__node_allocator>::value);
519 _LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x, const allocator_type& __a);525 _LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x, const allocator_type& __a);
520#endif // _LIBCPP_CXX03_LANG526# endif // _LIBCPP_CXX03_LANG
521527
522 __forward_list_base(const __forward_list_base&) = delete;528 __forward_list_base(const __forward_list_base&) = delete;
523 __forward_list_base& operator=(const __forward_list_base&) = delete;529 __forward_list_base& operator=(const __forward_list_base&) = delete;
...@@ -537,8 +543,7 @@ protected:...@@ -537,8 +543,7 @@ protected:
537543
538 template <class... _Args>544 template <class... _Args>
539 _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__node_pointer __next, _Args&&... __args) {545 _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__node_pointer __next, _Args&&... __args) {
540 __node_allocator& __a = __alloc();546 __allocation_guard<__node_allocator> __guard(__alloc_, 1);
541 __allocation_guard<__node_allocator> __guard(__a, 1);
542 // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value547 // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value
543 // held inside the node, since we need to use the allocator's construct() method for that.548 // held inside the node, since we need to use the allocator's construct() method for that.
544 //549 //
...@@ -548,26 +553,25 @@ protected:...@@ -548,26 +553,25 @@ protected:
548 std::__construct_at(std::addressof(*__guard.__get()), __next);553 std::__construct_at(std::addressof(*__guard.__get()), __next);
549554
550 // Now construct the value_type using the allocator's construct() method.555 // Now construct the value_type using the allocator's construct() method.
551 __node_traits::construct(__a, std::addressof(__guard.__get()->__get_value()), std::forward<_Args>(__args)...);556 __node_traits::construct(__alloc_, std::addressof(__guard.__get()->__get_value()), std::forward<_Args>(__args)...);
552 return __guard.__release_ptr();557 return __guard.__release_ptr();
553 }558 }
554559
555 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {560 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {
556 // For the same reason as above, we use the allocator's destroy() method for the value_type,561 // For the same reason as above, we use the allocator's destroy() method for the value_type,
557 // but not for the node itself.562 // but not for the node itself.
558 __node_allocator& __a = __alloc();563 __node_traits::destroy(__alloc_, std::addressof(__node->__get_value()));
559 __node_traits::destroy(__a, std::addressof(__node->__get_value()));
560 std::__destroy_at(std::addressof(*__node));564 std::__destroy_at(std::addressof(*__node));
561 __node_traits::deallocate(__a, __node, 1);565 __node_traits::deallocate(__alloc_, __node, 1);
562 }566 }
563567
564public:568public:
565 _LIBCPP_HIDE_FROM_ABI void swap(__forward_list_base& __x)569 _LIBCPP_HIDE_FROM_ABI void swap(__forward_list_base& __x)
566#if _LIBCPP_STD_VER >= 14570# if _LIBCPP_STD_VER >= 14
567 _NOEXCEPT;571 _NOEXCEPT;
568#else572# else
569 _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>);573 _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>);
570#endif574# endif
571575
572protected:576protected:
573 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;577 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
...@@ -575,37 +579,37 @@ protected:...@@ -575,37 +579,37 @@ protected:
575private:579private:
576 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base&, false_type) {}580 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base&, false_type) {}
577 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base& __x, true_type) {581 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base& __x, true_type) {
578 if (__alloc() != __x.__alloc())582 if (__alloc_ != __x.__alloc_)
579 clear();583 clear();
580 __alloc() = __x.__alloc();584 __alloc_ = __x.__alloc_;
581 }585 }
582586
583 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base&, false_type) _NOEXCEPT {}587 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base&, false_type) _NOEXCEPT {}
584 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base& __x, true_type)588 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base& __x, true_type)
585 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {589 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {
586 __alloc() = std::move(__x.__alloc());590 __alloc_ = std::move(__x.__alloc_);
587 }591 }
588};592};
589593
590#ifndef _LIBCPP_CXX03_LANG594# ifndef _LIBCPP_CXX03_LANG
591595
592template <class _Tp, class _Alloc>596template <class _Tp, class _Alloc>
593inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x) noexcept(597inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x) noexcept(
594 is_nothrow_move_constructible<__node_allocator>::value)598 is_nothrow_move_constructible<__node_allocator>::value)
595 : __before_begin_(std::move(__x.__before_begin_)) {599 : __before_begin_(std::move(__x.__before_begin_)), __alloc_(std::move(__x.__alloc_)) {
596 __x.__before_begin()->__next_ = nullptr;600 __x.__before_begin()->__next_ = nullptr;
597}601}
598602
599template <class _Tp, class _Alloc>603template <class _Tp, class _Alloc>
600inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x, const allocator_type& __a)604inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x, const allocator_type& __a)
601 : __before_begin_(__begin_node(), __node_allocator(__a)) {605 : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) {
602 if (__alloc() == __x.__alloc()) {606 if (__alloc_ == __x.__alloc_) {
603 __before_begin()->__next_ = __x.__before_begin()->__next_;607 __before_begin()->__next_ = __x.__before_begin()->__next_;
604 __x.__before_begin()->__next_ = nullptr;608 __x.__before_begin()->__next_ = nullptr;
605 }609 }
606}610}
607611
608#endif // _LIBCPP_CXX03_LANG612# endif // _LIBCPP_CXX03_LANG
609613
610template <class _Tp, class _Alloc>614template <class _Tp, class _Alloc>
611__forward_list_base<_Tp, _Alloc>::~__forward_list_base() {615__forward_list_base<_Tp, _Alloc>::~__forward_list_base() {
...@@ -614,14 +618,13 @@ __forward_list_base<_Tp, _Alloc>::~__forward_list_base() {...@@ -614,14 +618,13 @@ __forward_list_base<_Tp, _Alloc>::~__forward_list_base() {
614618
615template <class _Tp, class _Alloc>619template <class _Tp, class _Alloc>
616inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)620inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
617#if _LIBCPP_STD_VER >= 14621# if _LIBCPP_STD_VER >= 14
618 _NOEXCEPT622 _NOEXCEPT
619#else623# else
620 _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)624 _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)
621#endif625# endif
622{626{
623 std::__swap_allocator(627 std::__swap_allocator(__alloc_, __x.__alloc_);
624 __alloc(), __x.__alloc(), integral_constant<bool, __node_traits::propagate_on_container_swap::value>());
625 using std::swap;628 using std::swap;
626 swap(__before_begin()->__next_, __x.__before_begin()->__next_);629 swap(__before_begin()->__next_, __x.__before_begin()->__next_);
627}630}
...@@ -638,12 +641,12 @@ void __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT {...@@ -638,12 +641,12 @@ void __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT {
638641
639template <class _Tp, class _Alloc /*= allocator<_Tp>*/>642template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
640class _LIBCPP_TEMPLATE_VIS forward_list : private __forward_list_base<_Tp, _Alloc> {643class _LIBCPP_TEMPLATE_VIS forward_list : private __forward_list_base<_Tp, _Alloc> {
641 typedef __forward_list_base<_Tp, _Alloc> base;644 typedef __forward_list_base<_Tp, _Alloc> __base;
642 typedef typename base::__node_allocator __node_allocator;645 typedef typename __base::__node_allocator __node_allocator;
643 typedef typename base::__node_type __node_type;646 typedef typename __base::__node_type __node_type;
644 typedef typename base::__node_traits __node_traits;647 typedef typename __base::__node_traits __node_traits;
645 typedef typename base::__node_pointer __node_pointer;648 typedef typename __base::__node_pointer __node_pointer;
646 typedef typename base::__begin_node_pointer __begin_node_pointer;649 typedef typename __base::__begin_node_pointer __begin_node_pointer;
647650
648public:651public:
649 typedef _Tp value_type;652 typedef _Tp value_type;
...@@ -664,25 +667,25 @@ public:...@@ -664,25 +667,25 @@ public:
664 typedef typename allocator_traits<allocator_type>::size_type size_type;667 typedef typename allocator_traits<allocator_type>::size_type size_type;
665 typedef typename allocator_traits<allocator_type>::difference_type difference_type;668 typedef typename allocator_traits<allocator_type>::difference_type difference_type;
666669
667 typedef typename base::iterator iterator;670 typedef typename __base::iterator iterator;
668 typedef typename base::const_iterator const_iterator;671 typedef typename __base::const_iterator const_iterator;
669#if _LIBCPP_STD_VER >= 20672# if _LIBCPP_STD_VER >= 20
670 typedef size_type __remove_return_type;673 typedef size_type __remove_return_type;
671#else674# else
672 typedef void __remove_return_type;675 typedef void __remove_return_type;
673#endif676# endif
674677
675 _LIBCPP_HIDE_FROM_ABI forward_list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {678 _LIBCPP_HIDE_FROM_ABI forward_list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {
676 } // = default;679 } // = default;
677 _LIBCPP_HIDE_FROM_ABI explicit forward_list(const allocator_type& __a);680 _LIBCPP_HIDE_FROM_ABI explicit forward_list(const allocator_type& __a);
678 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n);681 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n);
679#if _LIBCPP_STD_VER >= 14682# if _LIBCPP_STD_VER >= 14
680 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n, const allocator_type& __a);683 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n, const allocator_type& __a);
681#endif684# endif
682 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v);685 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v);
683686
684 template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0>687 template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
685 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v, const allocator_type& __a) : base(__a) {688 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v, const allocator_type& __a) : __base(__a) {
686 insert_after(cbefore_begin(), __n, __v);689 insert_after(cbefore_begin(), __n, __v);
687 }690 }
688691
...@@ -692,22 +695,22 @@ public:...@@ -692,22 +695,22 @@ public:
692 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>695 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
693 _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a);696 _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a);
694697
695#if _LIBCPP_STD_VER >= 23698# if _LIBCPP_STD_VER >= 23
696 template <_ContainerCompatibleRange<_Tp> _Range>699 template <_ContainerCompatibleRange<_Tp> _Range>
697 _LIBCPP_HIDE_FROM_ABI forward_list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())700 _LIBCPP_HIDE_FROM_ABI forward_list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())
698 : base(__a) {701 : __base(__a) {
699 prepend_range(std::forward<_Range>(__range));702 prepend_range(std::forward<_Range>(__range));
700 }703 }
701#endif704# endif
702705
703 _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x);706 _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x);
704 _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a);707 _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a);
705708
706 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(const forward_list& __x);709 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(const forward_list& __x);
707710
708#ifndef _LIBCPP_CXX03_LANG711# ifndef _LIBCPP_CXX03_LANG
709 _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x) noexcept(is_nothrow_move_constructible<base>::value)712 _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x) noexcept(is_nothrow_move_constructible<__base>::value)
710 : base(std::move(__x)) {}713 : __base(std::move(__x)) {}
711 _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a);714 _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a);
712715
713 _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il);716 _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il);
...@@ -720,74 +723,82 @@ public:...@@ -720,74 +723,82 @@ public:
720 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(initializer_list<value_type> __il);723 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(initializer_list<value_type> __il);
721724
722 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il);725 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il);
723#endif // _LIBCPP_CXX03_LANG726# endif // _LIBCPP_CXX03_LANG
724727
725 // ~forward_list() = default;728 // ~forward_list() = default;
726729
727 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>730 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
728 void _LIBCPP_HIDE_FROM_ABI assign(_InputIterator __f, _InputIterator __l);731 void _LIBCPP_HIDE_FROM_ABI assign(_InputIterator __f, _InputIterator __l);
729732
730#if _LIBCPP_STD_VER >= 23733# if _LIBCPP_STD_VER >= 23
731 template <_ContainerCompatibleRange<_Tp> _Range>734 template <_ContainerCompatibleRange<_Tp> _Range>
732 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) {735 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) {
733 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));736 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));
734 }737 }
735#endif738# endif
736739
737 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v);740 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v);
738741
739 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(base::__alloc()); }742 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(this->__alloc_); }
740743
741 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(base::__before_begin()->__next_); }744 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__base::__before_begin()->__next_); }
742 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {745 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {
743 return const_iterator(base::__before_begin()->__next_);746 return const_iterator(__base::__before_begin()->__next_);
744 }747 }
745 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(nullptr); }748 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(nullptr); }
746 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(nullptr); }749 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(nullptr); }
747750
748 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT {751 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT {
749 return const_iterator(base::__before_begin()->__next_);752 return const_iterator(__base::__before_begin()->__next_);
750 }753 }
751 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return const_iterator(nullptr); }754 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return const_iterator(nullptr); }
752755
753 _LIBCPP_HIDE_FROM_ABI iterator before_begin() _NOEXCEPT { return iterator(base::__before_begin()); }756 _LIBCPP_HIDE_FROM_ABI iterator before_begin() _NOEXCEPT { return iterator(__base::__before_begin()); }
754 _LIBCPP_HIDE_FROM_ABI const_iterator before_begin() const _NOEXCEPT { return const_iterator(base::__before_begin()); }757 _LIBCPP_HIDE_FROM_ABI const_iterator before_begin() const _NOEXCEPT {
758 return const_iterator(__base::__before_begin());
759 }
755 _LIBCPP_HIDE_FROM_ABI const_iterator cbefore_begin() const _NOEXCEPT {760 _LIBCPP_HIDE_FROM_ABI const_iterator cbefore_begin() const _NOEXCEPT {
756 return const_iterator(base::__before_begin());761 return const_iterator(__base::__before_begin());
757 }762 }
758763
759 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {764 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {
760 return base::__before_begin()->__next_ == nullptr;765 return __base::__before_begin()->__next_ == nullptr;
761 }766 }
762 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {767 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
763 return std::min<size_type>(__node_traits::max_size(base::__alloc()), numeric_limits<difference_type>::max());768 return std::min<size_type>(__node_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max());
764 }769 }
765770
766 _LIBCPP_HIDE_FROM_ABI reference front() { return base::__before_begin()->__next_->__get_value(); }771 _LIBCPP_HIDE_FROM_ABI reference front() {
767 _LIBCPP_HIDE_FROM_ABI const_reference front() const { return base::__before_begin()->__next_->__get_value(); }772 _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list");
773 return __base::__before_begin()->__next_->__get_value();
774 }
775 _LIBCPP_HIDE_FROM_ABI const_reference front() const {
776 _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list");
777 return __base::__before_begin()->__next_->__get_value();
778 }
768779
769#ifndef _LIBCPP_CXX03_LANG780# ifndef _LIBCPP_CXX03_LANG
770# if _LIBCPP_STD_VER >= 17781# if _LIBCPP_STD_VER >= 17
771 template <class... _Args>782 template <class... _Args>
772 _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);783 _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);
773# else784# else
774 template <class... _Args>785 template <class... _Args>
775 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);786 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);
776# endif787# endif
777 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v);788 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v);
778#endif // _LIBCPP_CXX03_LANG789# endif // _LIBCPP_CXX03_LANG
779 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v);790 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v);
780791
781#if _LIBCPP_STD_VER >= 23792# if _LIBCPP_STD_VER >= 23
782 template <_ContainerCompatibleRange<_Tp> _Range>793 template <_ContainerCompatibleRange<_Tp> _Range>
783 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) {794 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) {
784 insert_range_after(cbefore_begin(), std::forward<_Range>(__range));795 insert_range_after(cbefore_begin(), std::forward<_Range>(__range));
785 }796 }
786#endif797# endif
787798
788 _LIBCPP_HIDE_FROM_ABI void pop_front();799 _LIBCPP_HIDE_FROM_ABI void pop_front();
789800
790#ifndef _LIBCPP_CXX03_LANG801# ifndef _LIBCPP_CXX03_LANG
791 template <class... _Args>802 template <class... _Args>
792 _LIBCPP_HIDE_FROM_ABI iterator emplace_after(const_iterator __p, _Args&&... __args);803 _LIBCPP_HIDE_FROM_ABI iterator emplace_after(const_iterator __p, _Args&&... __args);
793804
...@@ -795,18 +806,18 @@ public:...@@ -795,18 +806,18 @@ public:
795 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, initializer_list<value_type> __il) {806 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, initializer_list<value_type> __il) {
796 return insert_after(__p, __il.begin(), __il.end());807 return insert_after(__p, __il.begin(), __il.end());
797 }808 }
798#endif // _LIBCPP_CXX03_LANG809# endif // _LIBCPP_CXX03_LANG
799 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, const value_type& __v);810 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, const value_type& __v);
800 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, size_type __n, const value_type& __v);811 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, size_type __n, const value_type& __v);
801 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>812 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
802 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l);813 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l);
803814
804#if _LIBCPP_STD_VER >= 23815# if _LIBCPP_STD_VER >= 23
805 template <_ContainerCompatibleRange<_Tp> _Range>816 template <_ContainerCompatibleRange<_Tp> _Range>
806 _LIBCPP_HIDE_FROM_ABI iterator insert_range_after(const_iterator __position, _Range&& __range) {817 _LIBCPP_HIDE_FROM_ABI iterator insert_range_after(const_iterator __position, _Range&& __range) {
807 return __insert_after_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));818 return __insert_after_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));
808 }819 }
809#endif820# endif
810821
811 template <class _InputIterator, class _Sentinel>822 template <class _InputIterator, class _Sentinel>
812 _LIBCPP_HIDE_FROM_ABI iterator __insert_after_with_sentinel(const_iterator __p, _InputIterator __f, _Sentinel __l);823 _LIBCPP_HIDE_FROM_ABI iterator __insert_after_with_sentinel(const_iterator __p, _InputIterator __f, _Sentinel __l);
...@@ -815,18 +826,18 @@ public:...@@ -815,18 +826,18 @@ public:
815 _LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __f, const_iterator __l);826 _LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __f, const_iterator __l);
816827
817 _LIBCPP_HIDE_FROM_ABI void swap(forward_list& __x)828 _LIBCPP_HIDE_FROM_ABI void swap(forward_list& __x)
818#if _LIBCPP_STD_VER >= 14829# if _LIBCPP_STD_VER >= 14
819 _NOEXCEPT830 _NOEXCEPT
820#else831# else
821 _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)832 _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)
822#endif833# endif
823 {834 {
824 base::swap(__x);835 __base::swap(__x);
825 }836 }
826837
827 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);838 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);
828 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v);839 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v);
829 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { base::clear(); }840 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); }
830841
831 _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list&& __x);842 _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list&& __x);
832 _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list&& __x, const_iterator __i);843 _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list&& __x, const_iterator __i);
...@@ -842,13 +853,13 @@ public:...@@ -842,13 +853,13 @@ public:
842 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); }853 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); }
843 template <class _BinaryPredicate>854 template <class _BinaryPredicate>
844 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPredicate __binary_pred);855 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPredicate __binary_pred);
845#ifndef _LIBCPP_CXX03_LANG856# ifndef _LIBCPP_CXX03_LANG
846 _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x) { merge(__x, __less<>()); }857 _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x) { merge(__x, __less<>()); }
847 template <class _Compare>858 template <class _Compare>
848 _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x, _Compare __comp) {859 _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x, _Compare __comp) {
849 merge(__x, std::move(__comp));860 merge(__x, std::move(__comp));
850 }861 }
851#endif // _LIBCPP_CXX03_LANG862# endif // _LIBCPP_CXX03_LANG
852 _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x) { merge(__x, __less<>()); }863 _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x) { merge(__x, __less<>()); }
853 template <class _Compare>864 template <class _Compare>
854 _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x, _Compare __comp);865 _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x, _Compare __comp);
...@@ -858,11 +869,11 @@ public:...@@ -858,11 +869,11 @@ public:
858 _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT;869 _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT;
859870
860private:871private:
861#ifndef _LIBCPP_CXX03_LANG872# ifndef _LIBCPP_CXX03_LANG
862 _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, true_type)873 _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, true_type)
863 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);874 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
864 _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, false_type);875 _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, false_type);
865#endif // _LIBCPP_CXX03_LANG876# endif // _LIBCPP_CXX03_LANG
866877
867 template <class _Iter, class _Sent>878 template <class _Iter, class _Sent>
868 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iter __f, _Sent __l);879 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iter __f, _Sent __l);
...@@ -875,7 +886,7 @@ private:...@@ -875,7 +886,7 @@ private:
875 static _LIBCPP_HIDDEN __node_pointer __sort(__node_pointer __f, difference_type __sz, _Compare& __comp);886 static _LIBCPP_HIDDEN __node_pointer __sort(__node_pointer __f, difference_type __sz, _Compare& __comp);
876};887};
877888
878#if _LIBCPP_STD_VER >= 17889# if _LIBCPP_STD_VER >= 17
879template <class _InputIterator,890template <class _InputIterator,
880 class _Alloc = allocator<__iter_value_type<_InputIterator>>,891 class _Alloc = allocator<__iter_value_type<_InputIterator>>,
881 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,892 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
...@@ -887,37 +898,37 @@ template <class _InputIterator,...@@ -887,37 +898,37 @@ template <class _InputIterator,
887 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,898 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
888 class = enable_if_t<__is_allocator<_Alloc>::value> >899 class = enable_if_t<__is_allocator<_Alloc>::value> >
889forward_list(_InputIterator, _InputIterator, _Alloc) -> forward_list<__iter_value_type<_InputIterator>, _Alloc>;900forward_list(_InputIterator, _InputIterator, _Alloc) -> forward_list<__iter_value_type<_InputIterator>, _Alloc>;
890#endif901# endif
891902
892#if _LIBCPP_STD_VER >= 23903# if _LIBCPP_STD_VER >= 23
893template <ranges::input_range _Range,904template <ranges::input_range _Range,
894 class _Alloc = allocator<ranges::range_value_t<_Range>>,905 class _Alloc = allocator<ranges::range_value_t<_Range>>,
895 class = enable_if_t<__is_allocator<_Alloc>::value> >906 class = enable_if_t<__is_allocator<_Alloc>::value> >
896forward_list(from_range_t, _Range&&, _Alloc = _Alloc()) -> forward_list<ranges::range_value_t<_Range>, _Alloc>;907forward_list(from_range_t, _Range&&, _Alloc = _Alloc()) -> forward_list<ranges::range_value_t<_Range>, _Alloc>;
897#endif908# endif
898909
899template <class _Tp, class _Alloc>910template <class _Tp, class _Alloc>
900inline forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a) : base(__a) {}911inline forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a) : __base(__a) {}
901912
902template <class _Tp, class _Alloc>913template <class _Tp, class _Alloc>
903forward_list<_Tp, _Alloc>::forward_list(size_type __n) {914forward_list<_Tp, _Alloc>::forward_list(size_type __n) {
904 if (__n > 0) {915 if (__n > 0) {
905 for (__begin_node_pointer __p = base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) {916 for (__begin_node_pointer __p = __base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) {
906 __p->__next_ = this->__create_node(/* next = */ nullptr);917 __p->__next_ = this->__create_node(/* next = */ nullptr);
907 }918 }
908 }919 }
909}920}
910921
911#if _LIBCPP_STD_VER >= 14922# if _LIBCPP_STD_VER >= 14
912template <class _Tp, class _Alloc>923template <class _Tp, class _Alloc>
913forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __base_alloc) : base(__base_alloc) {924forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __base_alloc) : __base(__base_alloc) {
914 if (__n > 0) {925 if (__n > 0) {
915 for (__begin_node_pointer __p = base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) {926 for (__begin_node_pointer __p = __base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) {
916 __p->__next_ = this->__create_node(/* next = */ nullptr);927 __p->__next_ = this->__create_node(/* next = */ nullptr);
917 }928 }
918 }929 }
919}930}
920#endif931# endif
921932
922template <class _Tp, class _Alloc>933template <class _Tp, class _Alloc>
923forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) {934forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) {
...@@ -932,36 +943,37 @@ forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l)...@@ -932,36 +943,37 @@ forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l)
932943
933template <class _Tp, class _Alloc>944template <class _Tp, class _Alloc>
934template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >945template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >
935forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a) : base(__a) {946forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
947 : __base(__a) {
936 insert_after(cbefore_begin(), __f, __l);948 insert_after(cbefore_begin(), __f, __l);
937}949}
938950
939template <class _Tp, class _Alloc>951template <class _Tp, class _Alloc>
940forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x)952forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x)
941 : base(__node_traits::select_on_container_copy_construction(__x.__alloc())) {953 : __base(__node_traits::select_on_container_copy_construction(__x.__alloc_)) {
942 insert_after(cbefore_begin(), __x.begin(), __x.end());954 insert_after(cbefore_begin(), __x.begin(), __x.end());
943}955}
944956
945template <class _Tp, class _Alloc>957template <class _Tp, class _Alloc>
946forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a)958forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a)
947 : base(__a) {959 : __base(__a) {
948 insert_after(cbefore_begin(), __x.begin(), __x.end());960 insert_after(cbefore_begin(), __x.begin(), __x.end());
949}961}
950962
951template <class _Tp, class _Alloc>963template <class _Tp, class _Alloc>
952forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_list& __x) {964forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_list& __x) {
953 if (this != std::addressof(__x)) {965 if (this != std::addressof(__x)) {
954 base::__copy_assign_alloc(__x);966 __base::__copy_assign_alloc(__x);
955 assign(__x.begin(), __x.end());967 assign(__x.begin(), __x.end());
956 }968 }
957 return *this;969 return *this;
958}970}
959971
960#ifndef _LIBCPP_CXX03_LANG972# ifndef _LIBCPP_CXX03_LANG
961template <class _Tp, class _Alloc>973template <class _Tp, class _Alloc>
962forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a)974forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a)
963 : base(std::move(__x), __a) {975 : __base(std::move(__x), __a) {
964 if (base::__alloc() != __x.__alloc()) {976 if (this->__alloc_ != __x.__alloc_) {
965 typedef move_iterator<iterator> _Ip;977 typedef move_iterator<iterator> _Ip;
966 insert_after(cbefore_begin(), _Ip(__x.begin()), _Ip(__x.end()));978 insert_after(cbefore_begin(), _Ip(__x.begin()), _Ip(__x.end()));
967 }979 }
...@@ -973,7 +985,7 @@ forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il) {...@@ -973,7 +985,7 @@ forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il) {
973}985}
974986
975template <class _Tp, class _Alloc>987template <class _Tp, class _Alloc>
976forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il, const allocator_type& __a) : base(__a) {988forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il, const allocator_type& __a) : __base(__a) {
977 insert_after(cbefore_begin(), __il.begin(), __il.end());989 insert_after(cbefore_begin(), __il.begin(), __il.end());
978}990}
979991
...@@ -981,14 +993,14 @@ template <class _Tp, class _Alloc>...@@ -981,14 +993,14 @@ template <class _Tp, class _Alloc>
981void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type)993void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type)
982 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {994 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
983 clear();995 clear();
984 base::__move_assign_alloc(__x);996 __base::__move_assign_alloc(__x);
985 base::__before_begin()->__next_ = __x.__before_begin()->__next_;997 __base::__before_begin()->__next_ = __x.__before_begin()->__next_;
986 __x.__before_begin()->__next_ = nullptr;998 __x.__before_begin()->__next_ = nullptr;
987}999}
9881000
989template <class _Tp, class _Alloc>1001template <class _Tp, class _Alloc>
990void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type) {1002void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type) {
991 if (base::__alloc() == __x.__alloc())1003 if (this->__alloc_ == __x.__alloc_)
992 __move_assign(__x, true_type());1004 __move_assign(__x, true_type());
993 else {1005 else {
994 typedef move_iterator<iterator> _Ip;1006 typedef move_iterator<iterator> _Ip;
...@@ -1009,7 +1021,7 @@ inline forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(initializ...@@ -1009,7 +1021,7 @@ inline forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(initializ
1009 return *this;1021 return *this;
1010}1022}
10111023
1012#endif // _LIBCPP_CXX03_LANG1024# endif // _LIBCPP_CXX03_LANG
10131025
1014template <class _Tp, class _Alloc>1026template <class _Tp, class _Alloc>
1015template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >1027template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >
...@@ -1044,7 +1056,7 @@ void forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v) {...@@ -1044,7 +1056,7 @@ void forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v) {
1044 erase_after(__i, __e);1056 erase_after(__i, __e);
1045}1057}
10461058
1047#ifndef _LIBCPP_CXX03_LANG1059# ifndef _LIBCPP_CXX03_LANG
10481060
1049template <class _Tp, class _Alloc>1061template <class _Tp, class _Alloc>
1050inline void forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il) {1062inline void forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il) {
...@@ -1053,39 +1065,41 @@ inline void forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il)...@@ -1053,39 +1065,41 @@ inline void forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il)
10531065
1054template <class _Tp, class _Alloc>1066template <class _Tp, class _Alloc>
1055template <class... _Args>1067template <class... _Args>
1056# if _LIBCPP_STD_VER >= 171068# if _LIBCPP_STD_VER >= 17
1057typename forward_list<_Tp, _Alloc>::reference1069typename forward_list<_Tp, _Alloc>::reference
1058# else1070# else
1059void1071void
1060# endif1072# endif
1061forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {1073forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {
1062 base::__before_begin()->__next_ =1074 __base::__before_begin()->__next_ =
1063 this->__create_node(/* next = */ base::__before_begin()->__next_, std::forward<_Args>(__args)...);1075 this->__create_node(/* next = */ __base::__before_begin()->__next_, std::forward<_Args>(__args)...);
1064# if _LIBCPP_STD_VER >= 171076# if _LIBCPP_STD_VER >= 17
1065 return base::__before_begin()->__next_->__get_value();1077 return __base::__before_begin()->__next_->__get_value();
1066# endif1078# endif
1067}1079}
10681080
1069template <class _Tp, class _Alloc>1081template <class _Tp, class _Alloc>
1070void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) {1082void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) {
1071 base::__before_begin()->__next_ = this->__create_node(/* next = */ base::__before_begin()->__next_, std::move(__v));1083 __base::__before_begin()->__next_ =
1084 this->__create_node(/* next = */ __base::__before_begin()->__next_, std::move(__v));
1072}1085}
10731086
1074#endif // _LIBCPP_CXX03_LANG1087# endif // _LIBCPP_CXX03_LANG
10751088
1076template <class _Tp, class _Alloc>1089template <class _Tp, class _Alloc>
1077void forward_list<_Tp, _Alloc>::push_front(const value_type& __v) {1090void forward_list<_Tp, _Alloc>::push_front(const value_type& __v) {
1078 base::__before_begin()->__next_ = this->__create_node(/* next = */ base::__before_begin()->__next_, __v);1091 __base::__before_begin()->__next_ = this->__create_node(/* next = */ __base::__before_begin()->__next_, __v);
1079}1092}
10801093
1081template <class _Tp, class _Alloc>1094template <class _Tp, class _Alloc>
1082void forward_list<_Tp, _Alloc>::pop_front() {1095void forward_list<_Tp, _Alloc>::pop_front() {
1083 __node_pointer __p = base::__before_begin()->__next_;1096 _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::pop_front called on an empty list");
1084 base::__before_begin()->__next_ = __p->__next_;1097 __node_pointer __p = __base::__before_begin()->__next_;
1098 __base::__before_begin()->__next_ = __p->__next_;
1085 this->__delete_node(__p);1099 this->__delete_node(__p);
1086}1100}
10871101
1088#ifndef _LIBCPP_CXX03_LANG1102# ifndef _LIBCPP_CXX03_LANG
10891103
1090template <class _Tp, class _Alloc>1104template <class _Tp, class _Alloc>
1091template <class... _Args>1105template <class... _Args>
...@@ -1104,7 +1118,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) {...@@ -1104,7 +1118,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) {
1104 return iterator(__r->__next_);1118 return iterator(__r->__next_);
1105}1119}
11061120
1107#endif // _LIBCPP_CXX03_LANG1121# endif // _LIBCPP_CXX03_LANG
11081122
1109template <class _Tp, class _Alloc>1123template <class _Tp, class _Alloc>
1110typename forward_list<_Tp, _Alloc>::iterator1124typename forward_list<_Tp, _Alloc>::iterator
...@@ -1121,13 +1135,13 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const...@@ -1121,13 +1135,13 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const
1121 if (__n > 0) {1135 if (__n > 0) {
1122 __node_pointer __first = this->__create_node(/* next = */ nullptr, __v);1136 __node_pointer __first = this->__create_node(/* next = */ nullptr, __v);
1123 __node_pointer __last = __first;1137 __node_pointer __last = __first;
1124#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1138# if _LIBCPP_HAS_EXCEPTIONS
1125 try {1139 try {
1126#endif // _LIBCPP_HAS_NO_EXCEPTIONS1140# endif // _LIBCPP_HAS_EXCEPTIONS
1127 for (--__n; __n != 0; --__n, __last = __last->__next_) {1141 for (--__n; __n != 0; --__n, __last = __last->__next_) {
1128 __last->__next_ = this->__create_node(/* next = */ nullptr, __v);1142 __last->__next_ = this->__create_node(/* next = */ nullptr, __v);
1129 }1143 }
1130#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1144# if _LIBCPP_HAS_EXCEPTIONS
1131 } catch (...) {1145 } catch (...) {
1132 while (__first != nullptr) {1146 while (__first != nullptr) {
1133 __node_pointer __next = __first->__next_;1147 __node_pointer __next = __first->__next_;
...@@ -1136,7 +1150,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const...@@ -1136,7 +1150,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const
1136 }1150 }
1137 throw;1151 throw;
1138 }1152 }
1139#endif // _LIBCPP_HAS_NO_EXCEPTIONS1153# endif // _LIBCPP_HAS_EXCEPTIONS
1140 __last->__next_ = __r->__next_;1154 __last->__next_ = __r->__next_;
1141 __r->__next_ = __first;1155 __r->__next_ = __first;
1142 __r = static_cast<__begin_node_pointer>(__last);1156 __r = static_cast<__begin_node_pointer>(__last);
...@@ -1161,13 +1175,13 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp...@@ -1161,13 +1175,13 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp
1161 __node_pointer __first = this->__create_node(/* next = */ nullptr, *__f);1175 __node_pointer __first = this->__create_node(/* next = */ nullptr, *__f);
1162 __node_pointer __last = __first;1176 __node_pointer __last = __first;
11631177
1164#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1178# if _LIBCPP_HAS_EXCEPTIONS
1165 try {1179 try {
1166#endif // _LIBCPP_HAS_NO_EXCEPTIONS1180# endif // _LIBCPP_HAS_EXCEPTIONS
1167 for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_))) {1181 for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_))) {
1168 __last->__next_ = this->__create_node(/* next = */ nullptr, *__f);1182 __last->__next_ = this->__create_node(/* next = */ nullptr, *__f);
1169 }1183 }
1170#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1184# if _LIBCPP_HAS_EXCEPTIONS
1171 } catch (...) {1185 } catch (...) {
1172 while (__first != nullptr) {1186 while (__first != nullptr) {
1173 __node_pointer __next = __first->__next_;1187 __node_pointer __next = __first->__next_;
...@@ -1176,7 +1190,7 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp...@@ -1176,7 +1190,7 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp
1176 }1190 }
1177 throw;1191 throw;
1178 }1192 }
1179#endif // _LIBCPP_HAS_NO_EXCEPTIONS1193# endif // _LIBCPP_HAS_EXCEPTIONS
11801194
1181 __last->__next_ = __r->__next_;1195 __last->__next_ = __r->__next_;
1182 __r->__next_ = __first;1196 __r->__next_ = __first;
...@@ -1378,8 +1392,9 @@ template <class _Tp, class _Alloc>...@@ -1378,8 +1392,9 @@ template <class _Tp, class _Alloc>
1378template <class _Compare>1392template <class _Compare>
1379void forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) {1393void forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) {
1380 if (this != std::addressof(__x)) {1394 if (this != std::addressof(__x)) {
1381 base::__before_begin()->__next_ = __merge(base::__before_begin()->__next_, __x.__before_begin()->__next_, __comp);1395 __base::__before_begin()->__next_ =
1382 __x.__before_begin()->__next_ = nullptr;1396 __merge(__base::__before_begin()->__next_, __x.__before_begin()->__next_, __comp);
1397 __x.__before_begin()->__next_ = nullptr;
1383 }1398 }
1384}1399}
13851400
...@@ -1423,7 +1438,7 @@ forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, _Co...@@ -1423,7 +1438,7 @@ forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, _Co
1423template <class _Tp, class _Alloc>1438template <class _Tp, class _Alloc>
1424template <class _Compare>1439template <class _Compare>
1425inline void forward_list<_Tp, _Alloc>::sort(_Compare __comp) {1440inline void forward_list<_Tp, _Alloc>::sort(_Compare __comp) {
1426 base::__before_begin()->__next_ = __sort(base::__before_begin()->__next_, std::distance(begin(), end()), __comp);1441 __base::__before_begin()->__next_ = __sort(__base::__before_begin()->__next_, std::distance(begin(), end()), __comp);
1427}1442}
14281443
1429template <class _Tp, class _Alloc>1444template <class _Tp, class _Alloc>
...@@ -1453,7 +1468,7 @@ forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz, _Co...@@ -1453,7 +1468,7 @@ forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz, _Co
14531468
1454template <class _Tp, class _Alloc>1469template <class _Tp, class _Alloc>
1455void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT {1470void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT {
1456 __node_pointer __p = base::__before_begin()->__next_;1471 __node_pointer __p = __base::__before_begin()->__next_;
1457 if (__p != nullptr) {1472 if (__p != nullptr) {
1458 __node_pointer __f = __p->__next_;1473 __node_pointer __f = __p->__next_;
1459 __p->__next_ = nullptr;1474 __p->__next_ = nullptr;
...@@ -1463,7 +1478,7 @@ void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT {...@@ -1463,7 +1478,7 @@ void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT {
1463 __p = __f;1478 __p = __f;
1464 __f = __t;1479 __f = __t;
1465 }1480 }
1466 base::__before_begin()->__next_ = __p;1481 __base::__before_begin()->__next_ = __p;
1467 }1482 }
1468}1483}
14691484
...@@ -1481,7 +1496,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const forward_list<_Tp, _Alloc>& __x, cons...@@ -1481,7 +1496,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const forward_list<_Tp, _Alloc>& __x, cons
1481 return (__ix == __ex) == (__iy == __ey);1496 return (__ix == __ex) == (__iy == __ey);
1482}1497}
14831498
1484#if _LIBCPP_STD_VER <= 171499# if _LIBCPP_STD_VER <= 17
14851500
1486template <class _Tp, class _Alloc>1501template <class _Tp, class _Alloc>
1487inline _LIBCPP_HIDE_FROM_ABI bool1502inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -1513,16 +1528,15 @@ operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>...@@ -1513,16 +1528,15 @@ operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>
1513 return !(__y < __x);1528 return !(__y < __x);
1514}1529}
15151530
1516#else // #if _LIBCPP_STD_VER <= 171531# else // #if _LIBCPP_STD_VER <= 17
15171532
1518template <class _Tp, class _Allocator>1533template <class _Tp, class _Allocator>
1519_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>1534_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
1520operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) {1535operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) {
1521 return std::lexicographical_compare_three_way(1536 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
1522 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
1523}1537}
15241538
1525#endif // #if _LIBCPP_STD_VER <= 171539# endif // #if _LIBCPP_STD_VER <= 17
15261540
1527template <class _Tp, class _Alloc>1541template <class _Tp, class _Alloc>
1528inline _LIBCPP_HIDE_FROM_ABI void swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y)1542inline _LIBCPP_HIDE_FROM_ABI void swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y)
...@@ -1530,7 +1544,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(forward_list<_Tp, _Alloc>& __x, forward_l...@@ -1530,7 +1544,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(forward_list<_Tp, _Alloc>& __x, forward_l
1530 __x.swap(__y);1544 __x.swap(__y);
1531}1545}
15321546
1533#if _LIBCPP_STD_VER >= 201547# if _LIBCPP_STD_VER >= 20
1534template <class _Tp, class _Allocator, class _Predicate>1548template <class _Tp, class _Allocator, class _Predicate>
1535inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type1549inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type
1536erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred) {1550erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred) {
...@@ -1542,34 +1556,46 @@ inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type...@@ -1542,34 +1556,46 @@ inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type
1542erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v) {1556erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v) {
1543 return std::erase_if(__c, [&](auto& __elem) { return __elem == __v; });1557 return std::erase_if(__c, [&](auto& __elem) { return __elem == __v; });
1544}1558}
1545#endif1559# endif
1560
1561template <class _Tp, class _Allocator>
1562struct __container_traits<forward_list<_Tp, _Allocator> > {
1563 // http://eel.is/c++draft/container.reqmts
1564 // Unless otherwise specified (see [associative.reqmts.except], [unord.req.except], [deque.modifiers],
1565 // [inplace.vector.modifiers], and [vector.modifiers]) all container types defined in this Clause meet the following
1566 // additional requirements:
1567 // - If an exception is thrown by an insert() or emplace() function while inserting a single element, that
1568 // function has no effects.
1569 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;
1570};
15461571
1547_LIBCPP_END_NAMESPACE_STD1572_LIBCPP_END_NAMESPACE_STD
15481573
1549#if _LIBCPP_STD_VER >= 171574# if _LIBCPP_STD_VER >= 17
1550_LIBCPP_BEGIN_NAMESPACE_STD1575_LIBCPP_BEGIN_NAMESPACE_STD
1551namespace pmr {1576namespace pmr {
1552template <class _ValueT>1577template <class _ValueT>
1553using forward_list _LIBCPP_AVAILABILITY_PMR = std::forward_list<_ValueT, polymorphic_allocator<_ValueT>>;1578using forward_list _LIBCPP_AVAILABILITY_PMR = std::forward_list<_ValueT, polymorphic_allocator<_ValueT>>;
1554} // namespace pmr1579} // namespace pmr
1555_LIBCPP_END_NAMESPACE_STD1580_LIBCPP_END_NAMESPACE_STD
1556#endif1581# endif
15571582
1558_LIBCPP_POP_MACROS1583_LIBCPP_POP_MACROS
15591584
1560#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 201585# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1561# include <algorithm>1586# include <algorithm>
1562# include <atomic>1587# include <atomic>
1563# include <concepts>1588# include <concepts>
1564# include <cstdint>1589# include <cstdint>
1565# include <cstdlib>1590# include <cstdlib>
1566# include <cstring>1591# include <cstring>
1567# include <functional>1592# include <functional>
1568# include <iosfwd>1593# include <iosfwd>
1569# include <iterator>1594# include <iterator>
1570# include <stdexcept>1595# include <stdexcept>
1571# include <type_traits>1596# include <type_traits>
1572# include <typeinfo>1597# include <typeinfo>
1573#endif1598# endif
1599#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
15741600
1575#endif // _LIBCPP_FORWARD_LIST1601#endif // _LIBCPP_FORWARD_LIST
lib/libcxx/include/fstream+181-159
...@@ -186,41 +186,43 @@ typedef basic_fstream<wchar_t> wfstream;...@@ -186,41 +186,43 @@ typedef basic_fstream<wchar_t> wfstream;
186186
187*/187*/
188188
189#include <__algorithm/max.h>189#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
190#include <__assert>190# include <__cxx03/fstream>
191#include <__config>191#else
192#include <__fwd/fstream.h>192# include <__algorithm/max.h>
193#include <__locale>193# include <__assert>
194#include <__type_traits/enable_if.h>194# include <__config>
195#include <__type_traits/is_same.h>195# include <__filesystem/path.h>
196#include <__utility/move.h>196# include <__fwd/fstream.h>
197#include <__utility/swap.h>197# include <__locale>
198#include <__utility/unreachable.h>198# include <__memory/addressof.h>
199#include <cstdio>199# include <__memory/unique_ptr.h>
200#include <filesystem>200# include <__ostream/basic_ostream.h>
201#include <istream>201# include <__type_traits/enable_if.h>
202#include <ostream>202# include <__type_traits/is_same.h>
203#include <typeinfo>203# include <__utility/move.h>
204#include <version>204# include <__utility/swap.h>
205205# include <__utility/unreachable.h>
206#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)206# include <cstdio>
207# pragma GCC system_header207# include <istream>
208#endif208# include <streambuf>
209# include <typeinfo>
210# include <version>
211
212# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
213# pragma GCC system_header
214# endif
209215
210_LIBCPP_PUSH_MACROS216_LIBCPP_PUSH_MACROS
211#include <__undef_macros>217# include <__undef_macros>
212
213#if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
214# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
215#endif
216218
217#if !defined(_LIBCPP_HAS_NO_FILESYSTEM)219# if _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
218220
219_LIBCPP_BEGIN_NAMESPACE_STD221_LIBCPP_BEGIN_NAMESPACE_STD
220222
221# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API)223# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API)
222_LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) noexcept;224_LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) noexcept;
223# endif225# endif
224226
225template <class _CharT, class _Traits>227template <class _CharT, class _Traits>
226class _LIBCPP_TEMPLATE_VIS basic_filebuf : public basic_streambuf<_CharT, _Traits> {228class _LIBCPP_TEMPLATE_VIS basic_filebuf : public basic_streambuf<_CharT, _Traits> {
...@@ -231,15 +233,15 @@ public:...@@ -231,15 +233,15 @@ public:
231 typedef typename traits_type::pos_type pos_type;233 typedef typename traits_type::pos_type pos_type;
232 typedef typename traits_type::off_type off_type;234 typedef typename traits_type::off_type off_type;
233 typedef typename traits_type::state_type state_type;235 typedef typename traits_type::state_type state_type;
234# if _LIBCPP_STD_VER >= 26236# if _LIBCPP_STD_VER >= 26
235# if defined(_LIBCPP_WIN32API)237# if defined(_LIBCPP_WIN32API)
236 using native_handle_type = void*; // HANDLE238 using native_handle_type = void*; // HANDLE
237# elif __has_include(<unistd.h>)239# elif __has_include(<unistd.h>)
238 using native_handle_type = int; // POSIX file descriptor240 using native_handle_type = int; // POSIX file descriptor
239# else241# else
240# error "Provide a native file handle!"242# error "Provide a native file handle!"
243# endif
241# endif244# endif
242# endif
243245
244 // 27.9.1.2 Constructors/destructor:246 // 27.9.1.2 Constructors/destructor:
245 basic_filebuf();247 basic_filebuf();
...@@ -253,36 +255,36 @@ public:...@@ -253,36 +255,36 @@ public:
253 // 27.9.1.4 Members:255 // 27.9.1.4 Members:
254 _LIBCPP_HIDE_FROM_ABI bool is_open() const;256 _LIBCPP_HIDE_FROM_ABI bool is_open() const;
255 basic_filebuf* open(const char* __s, ios_base::openmode __mode);257 basic_filebuf* open(const char* __s, ios_base::openmode __mode);
256# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR258# if _LIBCPP_HAS_OPEN_WITH_WCHAR
257 basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode);259 basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode);
258# endif260# endif
259 _LIBCPP_HIDE_FROM_ABI basic_filebuf* open(const string& __s, ios_base::openmode __mode);261 _LIBCPP_HIDE_FROM_ABI basic_filebuf* open(const string& __s, ios_base::openmode __mode);
260262
261# if _LIBCPP_STD_VER >= 17263# if _LIBCPP_STD_VER >= 17
262 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI basic_filebuf*264 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI basic_filebuf*
263 open(const filesystem::path& __p, ios_base::openmode __mode) {265 open(const filesystem::path& __p, ios_base::openmode __mode) {
264 return open(__p.c_str(), __mode);266 return open(__p.c_str(), __mode);
265 }267 }
266# endif268# endif
267 _LIBCPP_HIDE_FROM_ABI basic_filebuf* __open(int __fd, ios_base::openmode __mode);269 _LIBCPP_HIDE_FROM_ABI basic_filebuf* __open(int __fd, ios_base::openmode __mode);
268 basic_filebuf* close();270 basic_filebuf* close();
269# if _LIBCPP_STD_VER >= 26271# if _LIBCPP_STD_VER >= 26
270 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept {272 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept {
271 _LIBCPP_ASSERT_UNCATEGORIZED(this->is_open(), "File must be opened");273 _LIBCPP_ASSERT_UNCATEGORIZED(this->is_open(), "File must be opened");
272# if defined(_LIBCPP_WIN32API)274# if defined(_LIBCPP_WIN32API)
273 return std::__filebuf_windows_native_handle(__file_);275 return std::__filebuf_windows_native_handle(__file_);
274# elif __has_include(<unistd.h>)276# elif __has_include(<unistd.h>)
275 return fileno(__file_);277 return fileno(__file_);
276# else278# else
277# error "Provide a way to determine the file native handle!"279# error "Provide a way to determine the file native handle!"
278# endif280# endif
279 }281 }
280# endif // _LIBCPP_STD_VER >= 26282# endif // _LIBCPP_STD_VER >= 26
281283
282 _LIBCPP_HIDE_FROM_ABI inline static const char* __make_mdstring(ios_base::openmode __mode) _NOEXCEPT;284 _LIBCPP_HIDE_FROM_ABI inline static const char* __make_mdstring(ios_base::openmode __mode) _NOEXCEPT;
283# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR285# if _LIBCPP_HAS_OPEN_WITH_WCHAR
284 _LIBCPP_HIDE_FROM_ABI inline static const wchar_t* __make_mdwstring(ios_base::openmode __mode) _NOEXCEPT;286 _LIBCPP_HIDE_FROM_ABI inline static const wchar_t* __make_mdwstring(ios_base::openmode __mode) _NOEXCEPT;
285# endif287# endif
286288
287protected:289protected:
288 // 27.9.1.5 Overridden virtual functions:290 // 27.9.1.5 Overridden virtual functions:
...@@ -354,6 +356,9 @@ private:...@@ -354,6 +356,9 @@ private:
354 bool __read_mode();356 bool __read_mode();
355 void __write_mode();357 void __write_mode();
356358
359 _LIBCPP_HIDE_FROM_ABI static int __fseek(FILE* __file, pos_type __offset, int __whence);
360 _LIBCPP_HIDE_FROM_ABI static pos_type __ftell(FILE* __file);
361
357 _LIBCPP_EXPORTED_FROM_ABI friend FILE* __get_ostream_file(ostream&);362 _LIBCPP_EXPORTED_FROM_ABI friend FILE* __get_ostream_file(ostream&);
358363
359 // There are multiple (__)open function, they use different C-API open364 // There are multiple (__)open function, they use different C-API open
...@@ -484,14 +489,14 @@ inline basic_filebuf<_CharT, _Traits>& basic_filebuf<_CharT, _Traits>::operator=...@@ -484,14 +489,14 @@ inline basic_filebuf<_CharT, _Traits>& basic_filebuf<_CharT, _Traits>::operator=
484489
485template <class _CharT, class _Traits>490template <class _CharT, class _Traits>
486basic_filebuf<_CharT, _Traits>::~basic_filebuf() {491basic_filebuf<_CharT, _Traits>::~basic_filebuf() {
487# ifndef _LIBCPP_HAS_NO_EXCEPTIONS492# if _LIBCPP_HAS_EXCEPTIONS
488 try {493 try {
489# endif // _LIBCPP_HAS_NO_EXCEPTIONS494# endif // _LIBCPP_HAS_EXCEPTIONS
490 close();495 close();
491# ifndef _LIBCPP_HAS_NO_EXCEPTIONS496# if _LIBCPP_HAS_EXCEPTIONS
492 } catch (...) {497 } catch (...) {
493 }498 }
494# endif // _LIBCPP_HAS_NO_EXCEPTIONS499# endif // _LIBCPP_HAS_EXCEPTIONS
495 if (__owns_eb_)500 if (__owns_eb_)
496 delete[] __extbuf_;501 delete[] __extbuf_;
497 if (__owns_ib_)502 if (__owns_ib_)
...@@ -611,7 +616,7 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode _...@@ -611,7 +616,7 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode _
611 case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:616 case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
612 case ios_base::in | ios_base::app | ios_base::binary:617 case ios_base::in | ios_base::app | ios_base::binary:
613 return "a+b" _LIBCPP_FOPEN_CLOEXEC_MODE;618 return "a+b" _LIBCPP_FOPEN_CLOEXEC_MODE;
614# if _LIBCPP_STD_VER >= 23619# if _LIBCPP_STD_VER >= 23
615 case ios_base::out | ios_base::noreplace:620 case ios_base::out | ios_base::noreplace:
616 case ios_base::out | ios_base::trunc | ios_base::noreplace:621 case ios_base::out | ios_base::trunc | ios_base::noreplace:
617 return "wx" _LIBCPP_FOPEN_CLOEXEC_MODE;622 return "wx" _LIBCPP_FOPEN_CLOEXEC_MODE;
...@@ -622,14 +627,14 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode _...@@ -622,14 +627,14 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode _
622 return "wbx" _LIBCPP_FOPEN_CLOEXEC_MODE;627 return "wbx" _LIBCPP_FOPEN_CLOEXEC_MODE;
623 case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace:628 case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace:
624 return "w+bx" _LIBCPP_FOPEN_CLOEXEC_MODE;629 return "w+bx" _LIBCPP_FOPEN_CLOEXEC_MODE;
625# endif // _LIBCPP_STD_VER >= 23630# endif // _LIBCPP_STD_VER >= 23
626 default:631 default:
627 return nullptr;632 return nullptr;
628 }633 }
629 __libcpp_unreachable();634 __libcpp_unreachable();
630}635}
631636
632# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR637# if _LIBCPP_HAS_OPEN_WITH_WCHAR
633template <class _CharT, class _Traits>638template <class _CharT, class _Traits>
634const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmode __mode) _NOEXCEPT {639const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmode __mode) _NOEXCEPT {
635 switch (__mode & ~ios_base::ate) {640 switch (__mode & ~ios_base::ate) {
...@@ -663,7 +668,7 @@ const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmo...@@ -663,7 +668,7 @@ const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmo
663 case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:668 case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
664 case ios_base::in | ios_base::app | ios_base::binary:669 case ios_base::in | ios_base::app | ios_base::binary:
665 return L"a+b";670 return L"a+b";
666# if _LIBCPP_STD_VER >= 23671# if _LIBCPP_STD_VER >= 23
667 case ios_base::out | ios_base::noreplace:672 case ios_base::out | ios_base::noreplace:
668 case ios_base::out | ios_base::trunc | ios_base::noreplace:673 case ios_base::out | ios_base::trunc | ios_base::noreplace:
669 return L"wx";674 return L"wx";
...@@ -674,13 +679,13 @@ const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmo...@@ -674,13 +679,13 @@ const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmo
674 return L"wbx";679 return L"wbx";
675 case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace:680 case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace:
676 return L"w+bx";681 return L"w+bx";
677# endif // _LIBCPP_STD_VER >= 23682# endif // _LIBCPP_STD_VER >= 23
678 default:683 default:
679 return nullptr;684 return nullptr;
680 }685 }
681 __libcpp_unreachable();686 __libcpp_unreachable();
682}687}
683# endif688# endif
684689
685template <class _CharT, class _Traits>690template <class _CharT, class _Traits>
686basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) {691basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) {
...@@ -704,7 +709,7 @@ inline basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::__open(in...@@ -704,7 +709,7 @@ inline basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::__open(in
704 return __do_open(fdopen(__fd, __mdstr), __mode);709 return __do_open(fdopen(__fd, __mdstr), __mode);
705}710}
706711
707# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR712# if _LIBCPP_HAS_OPEN_WITH_WCHAR
708// This is basically the same as the char* overload except that it uses _wfopen713// This is basically the same as the char* overload except that it uses _wfopen
709// and long mode strings.714// and long mode strings.
710template <class _CharT, class _Traits>715template <class _CharT, class _Traits>
...@@ -717,7 +722,7 @@ basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const wchar...@@ -717,7 +722,7 @@ basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const wchar
717722
718 return __do_open(_wfopen(__s, __mdstr), __mode);723 return __do_open(_wfopen(__s, __mdstr), __mode);
719}724}
720# endif725# endif
721726
722template <class _CharT, class _Traits>727template <class _CharT, class _Traits>
723inline basic_filebuf<_CharT, _Traits>*728inline basic_filebuf<_CharT, _Traits>*
...@@ -928,31 +933,42 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,...@@ -928,31 +933,42 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
928 default:933 default:
929 return pos_type(off_type(-1));934 return pos_type(off_type(-1));
930 }935 }
931# if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)936 if (__fseek(__file_, __width > 0 ? __width * __off : 0, __whence))
932 if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence))
933 return pos_type(off_type(-1));937 return pos_type(off_type(-1));
934 pos_type __r = ftell(__file_);938 pos_type __r = __ftell(__file_);
935# else
936 if (::fseeko(__file_, __width > 0 ? __width * __off : 0, __whence))
937 return pos_type(off_type(-1));
938 pos_type __r = ftello(__file_);
939# endif
940 __r.state(__st_);939 __r.state(__st_);
941 return __r;940 return __r;
942}941}
943942
943template <class _CharT, class _Traits>
944int basic_filebuf<_CharT, _Traits>::__fseek(FILE* __file, pos_type __offset, int __whence) {
945# if defined(_LIBCPP_MSVCRT_LIKE)
946 return _fseeki64(__file, __offset, __whence);
947# elif defined(_NEWLIB_VERSION)
948 return fseek(__file, __offset, __whence);
949# else
950 return ::fseeko(__file, __offset, __whence);
951# endif
952}
953
954template <class _CharT, class _Traits>
955typename basic_filebuf<_CharT, _Traits>::pos_type basic_filebuf<_CharT, _Traits>::__ftell(FILE* __file) {
956# if defined(_LIBCPP_MSVCRT_LIKE)
957 return _ftelli64(__file);
958# elif defined(_NEWLIB_VERSION)
959 return ftell(__file);
960# else
961 return ftello(__file);
962# endif
963}
964
944template <class _CharT, class _Traits>965template <class _CharT, class _Traits>
945typename basic_filebuf<_CharT, _Traits>::pos_type966typename basic_filebuf<_CharT, _Traits>::pos_type
946basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode) {967basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode) {
947 if (__file_ == nullptr || sync())968 if (__file_ == nullptr || sync())
948 return pos_type(off_type(-1));969 return pos_type(off_type(-1));
949# if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)970 if (__fseek(__file_, __sp, SEEK_SET))
950 if (fseek(__file_, __sp, SEEK_SET))
951 return pos_type(off_type(-1));971 return pos_type(off_type(-1));
952# else
953 if (::fseeko(__file_, __sp, SEEK_SET))
954 return pos_type(off_type(-1));
955# endif
956 __st_ = __sp.state();972 __st_ = __sp.state();
957 return __sp;973 return __sp;
958}974}
...@@ -999,13 +1015,8 @@ int basic_filebuf<_CharT, _Traits>::sync() {...@@ -999,13 +1015,8 @@ int basic_filebuf<_CharT, _Traits>::sync() {
999 }1015 }
1000 }1016 }
1001 }1017 }
1002# if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)1018 if (__fseek(__file_, -__c, SEEK_CUR))
1003 if (fseek(__file_, -__c, SEEK_CUR))
1004 return -1;
1005# else
1006 if (::fseeko(__file_, -__c, SEEK_CUR))
1007 return -1;1019 return -1;
1008# endif
1009 if (__update_st)1020 if (__update_st)
1010 __st_ = __state;1021 __st_ = __state;
1011 __extbufnext_ = __extbufend_ = __extbuf_;1022 __extbufnext_ = __extbufend_ = __extbuf_;
...@@ -1091,42 +1102,42 @@ public:...@@ -1091,42 +1102,42 @@ public:
1091 typedef typename traits_type::int_type int_type;1102 typedef typename traits_type::int_type int_type;
1092 typedef typename traits_type::pos_type pos_type;1103 typedef typename traits_type::pos_type pos_type;
1093 typedef typename traits_type::off_type off_type;1104 typedef typename traits_type::off_type off_type;
1094# if _LIBCPP_STD_VER >= 261105# if _LIBCPP_STD_VER >= 26
1095 using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type;1106 using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type;
1096# endif1107# endif
10971108
1098 _LIBCPP_HIDE_FROM_ABI basic_ifstream();1109 _LIBCPP_HIDE_FROM_ABI basic_ifstream();
1099 _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in);1110 _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in);
1100# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR1111# if _LIBCPP_HAS_OPEN_WITH_WCHAR
1101 _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);1112 _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);
1102# endif1113# endif
1103 _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);1114 _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
1104# if _LIBCPP_STD_VER >= 171115# if _LIBCPP_STD_VER >= 17
1105 template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>>1116 template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>>
1106 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY1117 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
1107 _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const _Tp& __p, ios_base::openmode __mode = ios_base::in)1118 _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const _Tp& __p, ios_base::openmode __mode = ios_base::in)
1108 : basic_ifstream(__p.c_str(), __mode) {}1119 : basic_ifstream(__p.c_str(), __mode) {}
1109# endif // _LIBCPP_STD_VER >= 171120# endif // _LIBCPP_STD_VER >= 17
1110 _LIBCPP_HIDE_FROM_ABI basic_ifstream(basic_ifstream&& __rhs);1121 _LIBCPP_HIDE_FROM_ABI basic_ifstream(basic_ifstream&& __rhs);
1111 _LIBCPP_HIDE_FROM_ABI basic_ifstream& operator=(basic_ifstream&& __rhs);1122 _LIBCPP_HIDE_FROM_ABI basic_ifstream& operator=(basic_ifstream&& __rhs);
1112 _LIBCPP_HIDE_FROM_ABI void swap(basic_ifstream& __rhs);1123 _LIBCPP_HIDE_FROM_ABI void swap(basic_ifstream& __rhs);
11131124
1114 _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const;1125 _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const;
1115# if _LIBCPP_STD_VER >= 261126# if _LIBCPP_STD_VER >= 26
1116 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); }1127 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); }
1117# endif1128# endif
1118 _LIBCPP_HIDE_FROM_ABI bool is_open() const;1129 _LIBCPP_HIDE_FROM_ABI bool is_open() const;
1119 void open(const char* __s, ios_base::openmode __mode = ios_base::in);1130 void open(const char* __s, ios_base::openmode __mode = ios_base::in);
1120# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR1131# if _LIBCPP_HAS_OPEN_WITH_WCHAR
1121 void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);1132 void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);
1122# endif1133# endif
1123 void open(const string& __s, ios_base::openmode __mode = ios_base::in);1134 void open(const string& __s, ios_base::openmode __mode = ios_base::in);
1124# if _LIBCPP_STD_VER >= 171135# if _LIBCPP_STD_VER >= 17
1125 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void1136 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void
1126 open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in) {1137 open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in) {
1127 return open(__p.c_str(), __mode);1138 return open(__p.c_str(), __mode);
1128 }1139 }
1129# endif // _LIBCPP_STD_VER >= 171140# endif // _LIBCPP_STD_VER >= 17
11301141
1131 _LIBCPP_HIDE_FROM_ABI void __open(int __fd, ios_base::openmode __mode);1142 _LIBCPP_HIDE_FROM_ABI void __open(int __fd, ios_base::openmode __mode);
1132 _LIBCPP_HIDE_FROM_ABI void close();1143 _LIBCPP_HIDE_FROM_ABI void close();
...@@ -1136,27 +1147,29 @@ private:...@@ -1136,27 +1147,29 @@ private:
1136};1147};
11371148
1138template <class _CharT, class _Traits>1149template <class _CharT, class _Traits>
1139inline basic_ifstream<_CharT, _Traits>::basic_ifstream() : basic_istream<char_type, traits_type>(&__sb_) {}1150inline basic_ifstream<_CharT, _Traits>::basic_ifstream()
1151 : basic_istream<char_type, traits_type>(std::addressof(__sb_)) {}
11401152
1141template <class _CharT, class _Traits>1153template <class _CharT, class _Traits>
1142inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode)1154inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode)
1143 : basic_istream<char_type, traits_type>(&__sb_) {1155 : basic_istream<char_type, traits_type>(std::addressof(__sb_)) {
1144 if (__sb_.open(__s, __mode | ios_base::in) == nullptr)1156 if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
1145 this->setstate(ios_base::failbit);1157 this->setstate(ios_base::failbit);
1146}1158}
11471159
1148# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR1160# if _LIBCPP_HAS_OPEN_WITH_WCHAR
1149template <class _CharT, class _Traits>1161template <class _CharT, class _Traits>
1150inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode)1162inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode)
1151 : basic_istream<char_type, traits_type>(&__sb_) {1163 : basic_istream<char_type, traits_type>(std::addressof(__sb_)) {
1152 if (__sb_.open(__s, __mode | ios_base::in) == nullptr)1164 if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
1153 this->setstate(ios_base::failbit);1165 this->setstate(ios_base::failbit);
1154}1166}
1155# endif1167# endif
11561168
1169// extension
1157template <class _CharT, class _Traits>1170template <class _CharT, class _Traits>
1158inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode)1171inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode)
1159 : basic_istream<char_type, traits_type>(&__sb_) {1172 : basic_istream<char_type, traits_type>(std::addressof(__sb_)) {
1160 if (__sb_.open(__s, __mode | ios_base::in) == nullptr)1173 if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
1161 this->setstate(ios_base::failbit);1174 this->setstate(ios_base::failbit);
1162}1175}
...@@ -1164,7 +1177,7 @@ inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_ba...@@ -1164,7 +1177,7 @@ inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_ba
1164template <class _CharT, class _Traits>1177template <class _CharT, class _Traits>
1165inline basic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs)1178inline basic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs)
1166 : basic_istream<char_type, traits_type>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {1179 : basic_istream<char_type, traits_type>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
1167 this->set_rdbuf(&__sb_);1180 this->set_rdbuf(std::addressof(__sb_));
1168}1181}
11691182
1170template <class _CharT, class _Traits>1183template <class _CharT, class _Traits>
...@@ -1187,7 +1200,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(basic_ifstream<_CharT, _Traits>& __x, bas...@@ -1187,7 +1200,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(basic_ifstream<_CharT, _Traits>& __x, bas
11871200
1188template <class _CharT, class _Traits>1201template <class _CharT, class _Traits>
1189inline basic_filebuf<_CharT, _Traits>* basic_ifstream<_CharT, _Traits>::rdbuf() const {1202inline basic_filebuf<_CharT, _Traits>* basic_ifstream<_CharT, _Traits>::rdbuf() const {
1190 return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);1203 return const_cast<basic_filebuf<char_type, traits_type>*>(std::addressof(__sb_));
1191}1204}
11921205
1193template <class _CharT, class _Traits>1206template <class _CharT, class _Traits>
...@@ -1203,7 +1216,7 @@ void basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode _...@@ -1203,7 +1216,7 @@ void basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode _
1203 this->setstate(ios_base::failbit);1216 this->setstate(ios_base::failbit);
1204}1217}
12051218
1206# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR1219# if _LIBCPP_HAS_OPEN_WITH_WCHAR
1207template <class _CharT, class _Traits>1220template <class _CharT, class _Traits>
1208void basic_ifstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) {1221void basic_ifstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) {
1209 if (__sb_.open(__s, __mode | ios_base::in))1222 if (__sb_.open(__s, __mode | ios_base::in))
...@@ -1211,7 +1224,7 @@ void basic_ifstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmod...@@ -1211,7 +1224,7 @@ void basic_ifstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmod
1211 else1224 else
1212 this->setstate(ios_base::failbit);1225 this->setstate(ios_base::failbit);
1213}1226}
1214# endif1227# endif
12151228
1216template <class _CharT, class _Traits>1229template <class _CharT, class _Traits>
1217void basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) {1230void basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) {
...@@ -1245,45 +1258,45 @@ public:...@@ -1245,45 +1258,45 @@ public:
1245 typedef typename traits_type::int_type int_type;1258 typedef typename traits_type::int_type int_type;
1246 typedef typename traits_type::pos_type pos_type;1259 typedef typename traits_type::pos_type pos_type;
1247 typedef typename traits_type::off_type off_type;1260 typedef typename traits_type::off_type off_type;
1248# if _LIBCPP_STD_VER >= 261261# if _LIBCPP_STD_VER >= 26
1249 using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type;1262 using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type;
1250# endif1263# endif
12511264
1252 _LIBCPP_HIDE_FROM_ABI basic_ofstream();1265 _LIBCPP_HIDE_FROM_ABI basic_ofstream();
1253 _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out);1266 _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out);
1254# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR1267# if _LIBCPP_HAS_OPEN_WITH_WCHAR
1255 _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::out);1268 _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::out);
1256# endif1269# endif
1257 _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);1270 _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
12581271
1259# if _LIBCPP_STD_VER >= 171272# if _LIBCPP_STD_VER >= 17
1260 template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>>1273 template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>>
1261 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY1274 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
1262 _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const _Tp& __p, ios_base::openmode __mode = ios_base::out)1275 _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const _Tp& __p, ios_base::openmode __mode = ios_base::out)
1263 : basic_ofstream(__p.c_str(), __mode) {}1276 : basic_ofstream(__p.c_str(), __mode) {}
1264# endif // _LIBCPP_STD_VER >= 171277# endif // _LIBCPP_STD_VER >= 17
12651278
1266 _LIBCPP_HIDE_FROM_ABI basic_ofstream(basic_ofstream&& __rhs);1279 _LIBCPP_HIDE_FROM_ABI basic_ofstream(basic_ofstream&& __rhs);
1267 _LIBCPP_HIDE_FROM_ABI basic_ofstream& operator=(basic_ofstream&& __rhs);1280 _LIBCPP_HIDE_FROM_ABI basic_ofstream& operator=(basic_ofstream&& __rhs);
1268 _LIBCPP_HIDE_FROM_ABI void swap(basic_ofstream& __rhs);1281 _LIBCPP_HIDE_FROM_ABI void swap(basic_ofstream& __rhs);
12691282
1270 _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const;1283 _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const;
1271# if _LIBCPP_STD_VER >= 261284# if _LIBCPP_STD_VER >= 26
1272 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); }1285 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); }
1273# endif1286# endif
1274 _LIBCPP_HIDE_FROM_ABI bool is_open() const;1287 _LIBCPP_HIDE_FROM_ABI bool is_open() const;
1275 void open(const char* __s, ios_base::openmode __mode = ios_base::out);1288 void open(const char* __s, ios_base::openmode __mode = ios_base::out);
1276# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR1289# if _LIBCPP_HAS_OPEN_WITH_WCHAR
1277 void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out);1290 void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out);
1278# endif1291# endif
1279 void open(const string& __s, ios_base::openmode __mode = ios_base::out);1292 void open(const string& __s, ios_base::openmode __mode = ios_base::out);
12801293
1281# if _LIBCPP_STD_VER >= 171294# if _LIBCPP_STD_VER >= 17
1282 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void1295 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void
1283 open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out) {1296 open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out) {
1284 return open(__p.c_str(), __mode);1297 return open(__p.c_str(), __mode);
1285 }1298 }
1286# endif // _LIBCPP_STD_VER >= 171299# endif // _LIBCPP_STD_VER >= 17
12871300
1288 _LIBCPP_HIDE_FROM_ABI void __open(int __fd, ios_base::openmode __mode);1301 _LIBCPP_HIDE_FROM_ABI void __open(int __fd, ios_base::openmode __mode);
1289 _LIBCPP_HIDE_FROM_ABI void close();1302 _LIBCPP_HIDE_FROM_ABI void close();
...@@ -1293,27 +1306,29 @@ private:...@@ -1293,27 +1306,29 @@ private:
1293};1306};
12941307
1295template <class _CharT, class _Traits>1308template <class _CharT, class _Traits>
1296inline basic_ofstream<_CharT, _Traits>::basic_ofstream() : basic_ostream<char_type, traits_type>(&__sb_) {}1309inline basic_ofstream<_CharT, _Traits>::basic_ofstream()
1310 : basic_ostream<char_type, traits_type>(std::addressof(__sb_)) {}
12971311
1298template <class _CharT, class _Traits>1312template <class _CharT, class _Traits>
1299inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode)1313inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode)
1300 : basic_ostream<char_type, traits_type>(&__sb_) {1314 : basic_ostream<char_type, traits_type>(std::addressof(__sb_)) {
1301 if (__sb_.open(__s, __mode | ios_base::out) == nullptr)1315 if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
1302 this->setstate(ios_base::failbit);1316 this->setstate(ios_base::failbit);
1303}1317}
13041318
1305# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR1319# if _LIBCPP_HAS_OPEN_WITH_WCHAR
1306template <class _CharT, class _Traits>1320template <class _CharT, class _Traits>
1307inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode)1321inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode)
1308 : basic_ostream<char_type, traits_type>(&__sb_) {1322 : basic_ostream<char_type, traits_type>(std::addressof(__sb_)) {
1309 if (__sb_.open(__s, __mode | ios_base::out) == nullptr)1323 if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
1310 this->setstate(ios_base::failbit);1324 this->setstate(ios_base::failbit);
1311}1325}
1312# endif1326# endif
13131327
1328// extension
1314template <class _CharT, class _Traits>1329template <class _CharT, class _Traits>
1315inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode)1330inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode)
1316 : basic_ostream<char_type, traits_type>(&__sb_) {1331 : basic_ostream<char_type, traits_type>(std::addressof(__sb_)) {
1317 if (__sb_.open(__s, __mode | ios_base::out) == nullptr)1332 if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
1318 this->setstate(ios_base::failbit);1333 this->setstate(ios_base::failbit);
1319}1334}
...@@ -1321,7 +1336,7 @@ inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_ba...@@ -1321,7 +1336,7 @@ inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_ba
1321template <class _CharT, class _Traits>1336template <class _CharT, class _Traits>
1322inline basic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs)1337inline basic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs)
1323 : basic_ostream<char_type, traits_type>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {1338 : basic_ostream<char_type, traits_type>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
1324 this->set_rdbuf(&__sb_);1339 this->set_rdbuf(std::addressof(__sb_));
1325}1340}
13261341
1327template <class _CharT, class _Traits>1342template <class _CharT, class _Traits>
...@@ -1344,7 +1359,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(basic_ofstream<_CharT, _Traits>& __x, bas...@@ -1344,7 +1359,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(basic_ofstream<_CharT, _Traits>& __x, bas
13441359
1345template <class _CharT, class _Traits>1360template <class _CharT, class _Traits>
1346inline basic_filebuf<_CharT, _Traits>* basic_ofstream<_CharT, _Traits>::rdbuf() const {1361inline basic_filebuf<_CharT, _Traits>* basic_ofstream<_CharT, _Traits>::rdbuf() const {
1347 return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);1362 return const_cast<basic_filebuf<char_type, traits_type>*>(std::addressof(__sb_));
1348}1363}
13491364
1350template <class _CharT, class _Traits>1365template <class _CharT, class _Traits>
...@@ -1360,7 +1375,7 @@ void basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode _...@@ -1360,7 +1375,7 @@ void basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode _
1360 this->setstate(ios_base::failbit);1375 this->setstate(ios_base::failbit);
1361}1376}
13621377
1363# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR1378# if _LIBCPP_HAS_OPEN_WITH_WCHAR
1364template <class _CharT, class _Traits>1379template <class _CharT, class _Traits>
1365void basic_ofstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) {1380void basic_ofstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) {
1366 if (__sb_.open(__s, __mode | ios_base::out))1381 if (__sb_.open(__s, __mode | ios_base::out))
...@@ -1368,7 +1383,7 @@ void basic_ofstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmod...@@ -1368,7 +1383,7 @@ void basic_ofstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmod
1368 else1383 else
1369 this->setstate(ios_base::failbit);1384 this->setstate(ios_base::failbit);
1370}1385}
1371# endif1386# endif
13721387
1373template <class _CharT, class _Traits>1388template <class _CharT, class _Traits>
1374void basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) {1389void basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) {
...@@ -1402,26 +1417,26 @@ public:...@@ -1402,26 +1417,26 @@ public:
1402 typedef typename traits_type::int_type int_type;1417 typedef typename traits_type::int_type int_type;
1403 typedef typename traits_type::pos_type pos_type;1418 typedef typename traits_type::pos_type pos_type;
1404 typedef typename traits_type::off_type off_type;1419 typedef typename traits_type::off_type off_type;
1405# if _LIBCPP_STD_VER >= 261420# if _LIBCPP_STD_VER >= 26
1406 using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type;1421 using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type;
1407# endif1422# endif
14081423
1409 _LIBCPP_HIDE_FROM_ABI basic_fstream();1424 _LIBCPP_HIDE_FROM_ABI basic_fstream();
1410 _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const char* __s,1425 _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const char* __s,
1411 ios_base::openmode __mode = ios_base::in | ios_base::out);1426 ios_base::openmode __mode = ios_base::in | ios_base::out);
1412# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR1427# if _LIBCPP_HAS_OPEN_WITH_WCHAR
1413 _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const wchar_t* __s,1428 _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const wchar_t* __s,
1414 ios_base::openmode __mode = ios_base::in | ios_base::out);1429 ios_base::openmode __mode = ios_base::in | ios_base::out);
1415# endif1430# endif
1416 _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const string& __s,1431 _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const string& __s,
1417 ios_base::openmode __mode = ios_base::in | ios_base::out);1432 ios_base::openmode __mode = ios_base::in | ios_base::out);
14181433
1419# if _LIBCPP_STD_VER >= 171434# if _LIBCPP_STD_VER >= 17
1420 template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>>1435 template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>>
1421 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(1436 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(
1422 const _Tp& __p, ios_base::openmode __mode = ios_base::in | ios_base::out)1437 const _Tp& __p, ios_base::openmode __mode = ios_base::in | ios_base::out)
1423 : basic_fstream(__p.c_str(), __mode) {}1438 : basic_fstream(__p.c_str(), __mode) {}
1424# endif // _LIBCPP_STD_VER >= 171439# endif // _LIBCPP_STD_VER >= 17
14251440
1426 _LIBCPP_HIDE_FROM_ABI basic_fstream(basic_fstream&& __rhs);1441 _LIBCPP_HIDE_FROM_ABI basic_fstream(basic_fstream&& __rhs);
14271442
...@@ -1430,22 +1445,22 @@ public:...@@ -1430,22 +1445,22 @@ public:
1430 _LIBCPP_HIDE_FROM_ABI void swap(basic_fstream& __rhs);1445 _LIBCPP_HIDE_FROM_ABI void swap(basic_fstream& __rhs);
14311446
1432 _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const;1447 _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const;
1433# if _LIBCPP_STD_VER >= 261448# if _LIBCPP_STD_VER >= 26
1434 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); }1449 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); }
1435# endif1450# endif
1436 _LIBCPP_HIDE_FROM_ABI bool is_open() const;1451 _LIBCPP_HIDE_FROM_ABI bool is_open() const;
1437 _LIBCPP_HIDE_FROM_ABI void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);1452 _LIBCPP_HIDE_FROM_ABI void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
1438# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR1453# if _LIBCPP_HAS_OPEN_WITH_WCHAR
1439 void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);1454 void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
1440# endif1455# endif
1441 _LIBCPP_HIDE_FROM_ABI void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);1456 _LIBCPP_HIDE_FROM_ABI void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
14421457
1443# if _LIBCPP_STD_VER >= 171458# if _LIBCPP_STD_VER >= 17
1444 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void1459 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void
1445 open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out) {1460 open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out) {
1446 return open(__p.c_str(), __mode);1461 return open(__p.c_str(), __mode);
1447 }1462 }
1448# endif // _LIBCPP_STD_VER >= 171463# endif // _LIBCPP_STD_VER >= 17
14491464
1450 _LIBCPP_HIDE_FROM_ABI void close();1465 _LIBCPP_HIDE_FROM_ABI void close();
14511466
...@@ -1454,35 +1469,37 @@ private:...@@ -1454,35 +1469,37 @@ private:
1454};1469};
14551470
1456template <class _CharT, class _Traits>1471template <class _CharT, class _Traits>
1457inline basic_fstream<_CharT, _Traits>::basic_fstream() : basic_iostream<char_type, traits_type>(&__sb_) {}1472inline basic_fstream<_CharT, _Traits>::basic_fstream()
1473 : basic_iostream<char_type, traits_type>(std::addressof(__sb_)) {}
14581474
1459template <class _CharT, class _Traits>1475template <class _CharT, class _Traits>
1460inline basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode)1476inline basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode)
1461 : basic_iostream<char_type, traits_type>(&__sb_) {1477 : basic_iostream<char_type, traits_type>(std::addressof(__sb_)) {
1462 if (__sb_.open(__s, __mode) == nullptr)1478 if (__sb_.open(__s, __mode) == nullptr)
1463 this->setstate(ios_base::failbit);1479 this->setstate(ios_base::failbit);
1464}1480}
14651481
1466# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR1482# if _LIBCPP_HAS_OPEN_WITH_WCHAR
1467template <class _CharT, class _Traits>1483template <class _CharT, class _Traits>
1468inline basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode)1484inline basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode)
1469 : basic_iostream<char_type, traits_type>(&__sb_) {1485 : basic_iostream<char_type, traits_type>(std::addressof(__sb_)) {
1470 if (__sb_.open(__s, __mode) == nullptr)1486 if (__sb_.open(__s, __mode) == nullptr)
1471 this->setstate(ios_base::failbit);1487 this->setstate(ios_base::failbit);
1472}1488}
1473# endif1489# endif
14741490
1475template <class _CharT, class _Traits>1491template <class _CharT, class _Traits>
1476inline basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode)1492inline basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode)
1477 : basic_iostream<char_type, traits_type>(&__sb_) {1493 : basic_iostream<char_type, traits_type>(std::addressof(__sb_)) {
1478 if (__sb_.open(__s, __mode) == nullptr)1494 if (__sb_.open(__s, __mode) == nullptr)
1479 this->setstate(ios_base::failbit);1495 this->setstate(ios_base::failbit);
1480}1496}
14811497
1498// extension
1482template <class _CharT, class _Traits>1499template <class _CharT, class _Traits>
1483inline basic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs)1500inline basic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs)
1484 : basic_iostream<char_type, traits_type>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {1501 : basic_iostream<char_type, traits_type>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
1485 this->set_rdbuf(&__sb_);1502 this->set_rdbuf(std::addressof(__sb_));
1486}1503}
14871504
1488template <class _CharT, class _Traits>1505template <class _CharT, class _Traits>
...@@ -1505,7 +1522,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(basic_fstream<_CharT, _Traits>& __x, basi...@@ -1505,7 +1522,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(basic_fstream<_CharT, _Traits>& __x, basi
15051522
1506template <class _CharT, class _Traits>1523template <class _CharT, class _Traits>
1507inline basic_filebuf<_CharT, _Traits>* basic_fstream<_CharT, _Traits>::rdbuf() const {1524inline basic_filebuf<_CharT, _Traits>* basic_fstream<_CharT, _Traits>::rdbuf() const {
1508 return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);1525 return const_cast<basic_filebuf<char_type, traits_type>*>(std::addressof(__sb_));
1509}1526}
15101527
1511template <class _CharT, class _Traits>1528template <class _CharT, class _Traits>
...@@ -1521,7 +1538,7 @@ void basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __...@@ -1521,7 +1538,7 @@ void basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __
1521 this->setstate(ios_base::failbit);1538 this->setstate(ios_base::failbit);
1522}1539}
15231540
1524# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR1541# if _LIBCPP_HAS_OPEN_WITH_WCHAR
1525template <class _CharT, class _Traits>1542template <class _CharT, class _Traits>
1526void basic_fstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) {1543void basic_fstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) {
1527 if (__sb_.open(__s, __mode))1544 if (__sb_.open(__s, __mode))
...@@ -1529,7 +1546,7 @@ void basic_fstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode...@@ -1529,7 +1546,7 @@ void basic_fstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode
1529 else1546 else
1530 this->setstate(ios_base::failbit);1547 this->setstate(ios_base::failbit);
1531}1548}
1532# endif1549# endif
15331550
1534template <class _CharT, class _Traits>1551template <class _CharT, class _Traits>
1535void basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) {1552void basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) {
...@@ -1545,28 +1562,33 @@ inline void basic_fstream<_CharT, _Traits>::close() {...@@ -1545,28 +1562,33 @@ inline void basic_fstream<_CharT, _Traits>::close() {
1545 this->setstate(ios_base::failbit);1562 this->setstate(ios_base::failbit);
1546}1563}
15471564
1548# if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_11565# if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
1549extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream<char>;1566extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream<char>;
1550extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>;1567extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>;
1551extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>;1568extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>;
1552# endif1569# endif
15531570
1554_LIBCPP_END_NAMESPACE_STD1571_LIBCPP_END_NAMESPACE_STD
15551572
1556#endif // _LIBCPP_HAS_NO_FILESYSTEM1573# endif // _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
15571574
1558_LIBCPP_POP_MACROS1575_LIBCPP_POP_MACROS
15591576
1560#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 201577# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1561# include <atomic>1578# include <atomic>
1562# include <concepts>1579# include <concepts>
1563# include <cstdlib>1580# include <cstdlib>
1564# include <iosfwd>1581# include <iosfwd>
1565# include <limits>1582# include <limits>
1566# include <mutex>1583# include <mutex>
1567# include <new>1584# include <new>
1568# include <stdexcept>1585# include <stdexcept>
1569# include <type_traits>1586# include <type_traits>
1570#endif1587# endif
1588
1589# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
1590# include <filesystem>
1591# endif
1592#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
15711593
1572#endif // _LIBCPP_FSTREAM1594#endif // _LIBCPP_FSTREAM
lib/libcxx/include/functional+75-69
...@@ -214,7 +214,9 @@ template <class Predicate> // deprecated in C++17, removed in C++20...@@ -214,7 +214,9 @@ template <class Predicate> // deprecated in C++17, removed in C++20
214binary_negate<Predicate> not2(const Predicate& pred);214binary_negate<Predicate> not2(const Predicate& pred);
215215
216template <class F>216template <class F>
217constexpr unspecified not_fn(F&& f); // C++17, constexpr in C++20217 constexpr unspecified not_fn(F&& f); // C++17, constexpr in C++20
218template <auto f>
219 constexpr unspecified not_fn() noexcept; // C++26
218220
219// [func.bind.partial], function templates bind_front and bind_back221// [func.bind.partial], function templates bind_front and bind_back
220template<class F, class... Args>222template<class F, class... Args>
...@@ -395,7 +397,7 @@ const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const);...@@ -395,7 +397,7 @@ const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const);
395template <class S, class T, class A>397template <class S, class T, class A>
396const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); // deprecated in C++11, removed in C++17398const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); // deprecated in C++11, removed in C++17
397399
398template<class R, class T> constexpr unspecified mem_fn(R T::*); // constexpr in C++20400template<class R, class T> constexpr unspecified mem_fn(R T::*) noexcept; // constexpr in C++20
399401
400class bad_function_call402class bad_function_call
401 : public exception403 : public exception
...@@ -527,72 +529,76 @@ POLICY: For non-variadic implementations, the number of arguments is limited...@@ -527,72 +529,76 @@ POLICY: For non-variadic implementations, the number of arguments is limited
527529
528*/530*/
529531
530#include <__config>532#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
531533# include <__cxx03/functional>
532#include <__functional/binary_function.h>534#else
533#include <__functional/binary_negate.h>535# include <__config>
534#include <__functional/bind.h>536
535#include <__functional/binder1st.h>537# include <__functional/binary_function.h>
536#include <__functional/binder2nd.h>538# include <__functional/binary_negate.h>
537#include <__functional/hash.h>539# include <__functional/bind.h>
538#include <__functional/mem_fn.h> // TODO: deprecate540# include <__functional/binder1st.h>
539#include <__functional/mem_fun_ref.h>541# include <__functional/binder2nd.h>
540#include <__functional/operations.h>542# include <__functional/hash.h>
541#include <__functional/pointer_to_binary_function.h>543# include <__functional/mem_fn.h> // TODO: deprecate
542#include <__functional/pointer_to_unary_function.h>544# include <__functional/mem_fun_ref.h>
543#include <__functional/reference_wrapper.h>545# include <__functional/operations.h>
544#include <__functional/unary_function.h>546# include <__functional/pointer_to_binary_function.h>
545#include <__functional/unary_negate.h>547# include <__functional/pointer_to_unary_function.h>
546548# include <__functional/reference_wrapper.h>
547#ifndef _LIBCPP_CXX03_LANG549# include <__functional/unary_function.h>
548# include <__functional/function.h>550# include <__functional/unary_negate.h>
549#endif551
550552# ifndef _LIBCPP_CXX03_LANG
551#if _LIBCPP_STD_VER >= 17553# include <__functional/function.h>
552# include <__functional/boyer_moore_searcher.h>554# endif
553# include <__functional/default_searcher.h>555
554# include <__functional/invoke.h>556# if _LIBCPP_STD_VER >= 17
555# include <__functional/not_fn.h>557# include <__functional/boyer_moore_searcher.h>
556#endif558# include <__functional/default_searcher.h>
557559# include <__functional/invoke.h>
558#if _LIBCPP_STD_VER >= 20560# include <__functional/not_fn.h>
559# include <__functional/bind_back.h>561# endif
560# include <__functional/bind_front.h>562
561# include <__functional/identity.h>563# if _LIBCPP_STD_VER >= 20
562# include <__functional/ranges_operations.h>564# include <__functional/bind_back.h>
563# include <__type_traits/unwrap_ref.h>565# include <__functional/bind_front.h>
564#endif566# include <__functional/identity.h>
565567# include <__functional/ranges_operations.h>
566#include <version>568# include <__type_traits/unwrap_ref.h>
567569# endif
568#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)570
569# pragma GCC system_header571# include <version>
570#endif572
571573# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
572#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && defined(_LIBCPP_CXX03_LANG)574# pragma GCC system_header
573# include <limits>575# endif
574# include <new>576
575#endif577# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && defined(_LIBCPP_CXX03_LANG)
576578# include <limits>
577#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14579# include <new>
578# include <array>580# endif
579# include <initializer_list>581
580# include <unordered_map>582# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14
581# include <vector>583# include <array>
582#endif584# include <initializer_list>
583585# include <unordered_map>
584#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20586# endif
585# include <atomic>587
586# include <concepts>588# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
587# include <cstdlib>589# include <atomic>
588# include <exception>590# include <concepts>
589# include <iosfwd>591# include <cstdlib>
590# include <memory>592# include <exception>
591# include <stdexcept>593# include <iosfwd>
592# include <tuple>594# include <memory>
593# include <type_traits>595# include <stdexcept>
594# include <typeinfo>596# include <tuple>
595# include <utility>597# include <type_traits>
596#endif598# include <typeinfo>
599# include <utility>
600# include <vector>
601# endif
602#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
597603
598#endif // _LIBCPP_FUNCTIONAL604#endif // _LIBCPP_FUNCTIONAL
lib/libcxx/include/future+153-125
...@@ -329,7 +329,7 @@ public:...@@ -329,7 +329,7 @@ public:
329 template <class F>329 template <class F>
330 explicit packaged_task(F&& f);330 explicit packaged_task(F&& f);
331 template <class F, class Allocator>331 template <class F, class Allocator>
332 packaged_task(allocator_arg_t, const Allocator& a, F&& f);332 packaged_task(allocator_arg_t, const Allocator& a, F&& f); // removed in C++17
333 ~packaged_task();333 ~packaged_task();
334334
335 // no copy335 // no copy
...@@ -356,50 +356,68 @@ public:...@@ -356,50 +356,68 @@ public:
356template <class R>356template <class R>
357 void swap(packaged_task<R(ArgTypes...)&, packaged_task<R(ArgTypes...)>&) noexcept;357 void swap(packaged_task<R(ArgTypes...)&, packaged_task<R(ArgTypes...)>&) noexcept;
358358
359template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;359template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; // removed in C++17
360360
361} // std361} // std
362362
363*/363*/
364364
365#include <__config>365#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
366366# include <__cxx03/future>
367#if !defined(_LIBCPP_HAS_NO_THREADS)367#else
368368# include <__config>
369# include <__assert>369
370# include <__chrono/duration.h>370# if _LIBCPP_HAS_THREADS
371# include <__chrono/time_point.h>371
372# include <__exception/exception_ptr.h>372# include <__assert>
373# include <__memory/addressof.h>373# include <__chrono/duration.h>
374# include <__memory/allocator.h>374# include <__chrono/steady_clock.h>
375# include <__memory/allocator_arg_t.h>375# include <__chrono/time_point.h>
376# include <__memory/allocator_destructor.h>376# include <__condition_variable/condition_variable.h>
377# include <__memory/allocator_traits.h>377# include <__cstddef/nullptr_t.h>
378# include <__memory/compressed_pair.h>378# include <__exception/exception_ptr.h>
379# include <__memory/pointer_traits.h>379# include <__memory/addressof.h>
380# include <__memory/shared_ptr.h>380# include <__memory/allocator.h>
381# include <__memory/unique_ptr.h>381# include <__memory/allocator_arg_t.h>
382# include <__memory/uses_allocator.h>382# include <__memory/allocator_destructor.h>
383# include <__system_error/error_category.h>383# include <__memory/allocator_traits.h>
384# include <__system_error/error_code.h>384# include <__memory/compressed_pair.h>
385# include <__system_error/error_condition.h>385# include <__memory/pointer_traits.h>
386# include <__type_traits/aligned_storage.h>386# include <__memory/shared_count.h>
387# include <__type_traits/strip_signature.h>387# include <__memory/unique_ptr.h>
388# include <__utility/auto_cast.h>388# include <__memory/uses_allocator.h>
389# include <__utility/forward.h>389# include <__mutex/lock_guard.h>
390# include <__utility/move.h>390# include <__mutex/mutex.h>
391# include <mutex>391# include <__mutex/unique_lock.h>
392# include <new>392# include <__system_error/error_category.h>
393# include <stdexcept>393# include <__system_error/error_code.h>
394# include <thread>394# include <__system_error/error_condition.h>
395# include <version>395# include <__thread/thread.h>
396396# include <__type_traits/add_lvalue_reference.h>
397# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)397# include <__type_traits/aligned_storage.h>
398# pragma GCC system_header398# include <__type_traits/conditional.h>
399# endif399# include <__type_traits/decay.h>
400# include <__type_traits/enable_if.h>
401# include <__type_traits/invoke.h>
402# include <__type_traits/is_same.h>
403# include <__type_traits/remove_cvref.h>
404# include <__type_traits/remove_reference.h>
405# include <__type_traits/strip_signature.h>
406# include <__type_traits/underlying_type.h>
407# include <__utility/auto_cast.h>
408# include <__utility/forward.h>
409# include <__utility/move.h>
410# include <__utility/swap.h>
411# include <stdexcept>
412# include <tuple>
413# include <version>
414
415# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
416# pragma GCC system_header
417# endif
400418
401_LIBCPP_PUSH_MACROS419_LIBCPP_PUSH_MACROS
402# include <__undef_macros>420# include <__undef_macros>
403421
404_LIBCPP_BEGIN_NAMESPACE_STD422_LIBCPP_BEGIN_NAMESPACE_STD
405423
...@@ -411,16 +429,16 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc)...@@ -411,16 +429,16 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc)
411template <>429template <>
412struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {};430struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {};
413431
414# ifdef _LIBCPP_CXX03_LANG432# ifdef _LIBCPP_CXX03_LANG
415template <>433template <>
416struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type {};434struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type {};
417# endif435# endif
418436
419// enum class launch437// enum class launch
420_LIBCPP_DECLARE_STRONG_ENUM(launch){async = 1, deferred = 2, any = async | deferred};438_LIBCPP_DECLARE_STRONG_ENUM(launch){async = 1, deferred = 2, any = async | deferred};
421_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)439_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)
422440
423# ifndef _LIBCPP_CXX03_LANG441# ifndef _LIBCPP_CXX03_LANG
424442
425typedef underlying_type<launch>::type __launch_underlying_type;443typedef underlying_type<launch>::type __launch_underlying_type;
426444
...@@ -455,7 +473,7 @@ inline _LIBCPP_HIDE_FROM_ABI launch& operator^=(launch& __x, launch __y) {...@@ -455,7 +473,7 @@ inline _LIBCPP_HIDE_FROM_ABI launch& operator^=(launch& __x, launch __y) {
455 return __x;473 return __x;
456}474}
457475
458# endif // !_LIBCPP_CXX03_LANG476# endif // !_LIBCPP_CXX03_LANG
459477
460// enum class future_status478// enum class future_status
461_LIBCPP_DECLARE_STRONG_ENUM(future_status){ready, timeout, deferred};479_LIBCPP_DECLARE_STRONG_ENUM(future_status){ready, timeout, deferred};
...@@ -471,7 +489,7 @@ inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(future_errc __...@@ -471,7 +489,7 @@ inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(future_errc __
471 return error_condition(static_cast<int>(__e), future_category());489 return error_condition(static_cast<int>(__e), future_category());
472}490}
473491
474_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_future_error(future_errc __ev);492[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_future_error(future_errc __ev);
475493
476class _LIBCPP_EXPORTED_FROM_ABI future_error : public logic_error {494class _LIBCPP_EXPORTED_FROM_ABI future_error : public logic_error {
477 error_code __ec_;495 error_code __ec_;
...@@ -482,9 +500,9 @@ class _LIBCPP_EXPORTED_FROM_ABI future_error : public logic_error {...@@ -482,9 +500,9 @@ class _LIBCPP_EXPORTED_FROM_ABI future_error : public logic_error {
482 friend class promise;500 friend class promise;
483501
484public:502public:
485# if _LIBCPP_STD_VER >= 17503# if _LIBCPP_STD_VER >= 17
486 _LIBCPP_HIDE_FROM_ABI explicit future_error(future_errc __ec) : future_error(std::make_error_code(__ec)) {}504 _LIBCPP_HIDE_FROM_ABI explicit future_error(future_errc __ec) : future_error(std::make_error_code(__ec)) {}
487# endif505# endif
488506
489 _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; }507 _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; }
490508
...@@ -494,12 +512,12 @@ public:...@@ -494,12 +512,12 @@ public:
494512
495// Declared above std::future_error513// Declared above std::future_error
496void __throw_future_error(future_errc __ev) {514void __throw_future_error(future_errc __ev) {
497# ifndef _LIBCPP_HAS_NO_EXCEPTIONS515# if _LIBCPP_HAS_EXCEPTIONS
498 throw future_error(make_error_code(__ev));516 throw future_error(make_error_code(__ev));
499# else517# else
500 (void)__ev;518 (void)__ev;
501 _LIBCPP_VERBOSE_ABORT("future_error was thrown in -fno-exceptions mode");519 _LIBCPP_VERBOSE_ABORT("future_error was thrown in -fno-exceptions mode");
502# endif520# endif
503}521}
504522
505class _LIBCPP_EXPORTED_FROM_ABI __assoc_sub_state : public __shared_count {523class _LIBCPP_EXPORTED_FROM_ABI __assoc_sub_state : public __shared_count {
...@@ -588,7 +606,7 @@ public:...@@ -588,7 +606,7 @@ public:
588 _LIBCPP_HIDE_FROM_ABI void set_value_at_thread_exit(_Arg&& __arg);606 _LIBCPP_HIDE_FROM_ABI void set_value_at_thread_exit(_Arg&& __arg);
589607
590 _LIBCPP_HIDE_FROM_ABI _Rp move();608 _LIBCPP_HIDE_FROM_ABI _Rp move();
591 _LIBCPP_HIDE_FROM_ABI __add_lvalue_reference_t<_Rp> copy();609 _LIBCPP_HIDE_FROM_ABI _Rp& copy();
592};610};
593611
594template <class _Rp>612template <class _Rp>
...@@ -630,7 +648,7 @@ _Rp __assoc_state<_Rp>::move() {...@@ -630,7 +648,7 @@ _Rp __assoc_state<_Rp>::move() {
630}648}
631649
632template <class _Rp>650template <class _Rp>
633__add_lvalue_reference_t<_Rp> __assoc_state<_Rp>::copy() {651_Rp& __assoc_state<_Rp>::copy() {
634 unique_lock<mutex> __lk(this->__mut_);652 unique_lock<mutex> __lk(this->__mut_);
635 this->__sub_wait(__lk);653 this->__sub_wait(__lk);
636 if (this->__exception_ != nullptr)654 if (this->__exception_ != nullptr)
...@@ -773,15 +791,15 @@ inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __f...@@ -773,15 +791,15 @@ inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __f
773791
774template <class _Rp, class _Fp>792template <class _Rp, class _Fp>
775void __deferred_assoc_state<_Rp, _Fp>::__execute() {793void __deferred_assoc_state<_Rp, _Fp>::__execute() {
776# ifndef _LIBCPP_HAS_NO_EXCEPTIONS794# if _LIBCPP_HAS_EXCEPTIONS
777 try {795 try {
778# endif // _LIBCPP_HAS_NO_EXCEPTIONS796# endif // _LIBCPP_HAS_EXCEPTIONS
779 this->set_value(__func_());797 this->set_value(__func_());
780# ifndef _LIBCPP_HAS_NO_EXCEPTIONS798# if _LIBCPP_HAS_EXCEPTIONS
781 } catch (...) {799 } catch (...) {
782 this->set_exception(current_exception());800 this->set_exception(current_exception());
783 }801 }
784# endif // _LIBCPP_HAS_NO_EXCEPTIONS802# endif // _LIBCPP_HAS_EXCEPTIONS
785}803}
786804
787template <class _Fp>805template <class _Fp>
...@@ -803,16 +821,16 @@ inline __deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f) : __...@@ -803,16 +821,16 @@ inline __deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f) : __
803821
804template <class _Fp>822template <class _Fp>
805void __deferred_assoc_state<void, _Fp>::__execute() {823void __deferred_assoc_state<void, _Fp>::__execute() {
806# ifndef _LIBCPP_HAS_NO_EXCEPTIONS824# if _LIBCPP_HAS_EXCEPTIONS
807 try {825 try {
808# endif // _LIBCPP_HAS_NO_EXCEPTIONS826# endif // _LIBCPP_HAS_EXCEPTIONS
809 __func_();827 __func_();
810 this->set_value();828 this->set_value();
811# ifndef _LIBCPP_HAS_NO_EXCEPTIONS829# if _LIBCPP_HAS_EXCEPTIONS
812 } catch (...) {830 } catch (...) {
813 this->set_exception(current_exception());831 this->set_exception(current_exception());
814 }832 }
815# endif // _LIBCPP_HAS_NO_EXCEPTIONS833# endif // _LIBCPP_HAS_EXCEPTIONS
816}834}
817835
818template <class _Rp, class _Fp>836template <class _Rp, class _Fp>
...@@ -834,15 +852,15 @@ inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(s...@@ -834,15 +852,15 @@ inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(s
834852
835template <class _Rp, class _Fp>853template <class _Rp, class _Fp>
836void __async_assoc_state<_Rp, _Fp>::__execute() {854void __async_assoc_state<_Rp, _Fp>::__execute() {
837# ifndef _LIBCPP_HAS_NO_EXCEPTIONS855# if _LIBCPP_HAS_EXCEPTIONS
838 try {856 try {
839# endif // _LIBCPP_HAS_NO_EXCEPTIONS857# endif // _LIBCPP_HAS_EXCEPTIONS
840 this->set_value(__func_());858 this->set_value(__func_());
841# ifndef _LIBCPP_HAS_NO_EXCEPTIONS859# if _LIBCPP_HAS_EXCEPTIONS
842 } catch (...) {860 } catch (...) {
843 this->set_exception(current_exception());861 this->set_exception(current_exception());
844 }862 }
845# endif // _LIBCPP_HAS_NO_EXCEPTIONS863# endif // _LIBCPP_HAS_EXCEPTIONS
846}864}
847865
848template <class _Rp, class _Fp>866template <class _Rp, class _Fp>
...@@ -870,16 +888,16 @@ inline __async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(...@@ -870,16 +888,16 @@ inline __async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(
870888
871template <class _Fp>889template <class _Fp>
872void __async_assoc_state<void, _Fp>::__execute() {890void __async_assoc_state<void, _Fp>::__execute() {
873# ifndef _LIBCPP_HAS_NO_EXCEPTIONS891# if _LIBCPP_HAS_EXCEPTIONS
874 try {892 try {
875# endif // _LIBCPP_HAS_NO_EXCEPTIONS893# endif // _LIBCPP_HAS_EXCEPTIONS
876 __func_();894 __func_();
877 this->set_value();895 this->set_value();
878# ifndef _LIBCPP_HAS_NO_EXCEPTIONS896# if _LIBCPP_HAS_EXCEPTIONS
879 } catch (...) {897 } catch (...) {
880 this->set_exception(current_exception());898 this->set_exception(current_exception());
881 }899 }
882# endif // _LIBCPP_HAS_NO_EXCEPTIONS900# endif // _LIBCPP_HAS_EXCEPTIONS
883}901}
884902
885template <class _Fp>903template <class _Fp>
...@@ -1399,13 +1417,13 @@ class __packaged_task_func;...@@ -1399,13 +1417,13 @@ class __packaged_task_func;
13991417
1400template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>1418template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
1401class __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __packaged_task_base<_Rp(_ArgTypes...)> {1419class __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __packaged_task_base<_Rp(_ArgTypes...)> {
1402 __compressed_pair<_Fp, _Alloc> __f_;1420 _LIBCPP_COMPRESSED_PAIR(_Fp, __func_, _Alloc, __alloc_);
14031421
1404public:1422public:
1405 _LIBCPP_HIDE_FROM_ABI explicit __packaged_task_func(const _Fp& __f) : __f_(__f, __default_init_tag()) {}1423 _LIBCPP_HIDE_FROM_ABI explicit __packaged_task_func(const _Fp& __f) : __func_(__f) {}
1406 _LIBCPP_HIDE_FROM_ABI explicit __packaged_task_func(_Fp&& __f) : __f_(std::move(__f), __default_init_tag()) {}1424 _LIBCPP_HIDE_FROM_ABI explicit __packaged_task_func(_Fp&& __f) : __func_(std::move(__f)) {}
1407 _LIBCPP_HIDE_FROM_ABI __packaged_task_func(const _Fp& __f, const _Alloc& __a) : __f_(__f, __a) {}1425 _LIBCPP_HIDE_FROM_ABI __packaged_task_func(const _Fp& __f, const _Alloc& __a) : __func_(__f), __alloc_(__a) {}
1408 _LIBCPP_HIDE_FROM_ABI __packaged_task_func(_Fp&& __f, const _Alloc& __a) : __f_(std::move(__f), __a) {}1426 _LIBCPP_HIDE_FROM_ABI __packaged_task_func(_Fp&& __f, const _Alloc& __a) : __func_(std::move(__f)), __alloc_(__a) {}
1409 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __move_to(__packaged_task_base<_Rp(_ArgTypes...)>*) _NOEXCEPT;1427 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __move_to(__packaged_task_base<_Rp(_ArgTypes...)>*) _NOEXCEPT;
1410 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy();1428 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy();
1411 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate();1429 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate();
...@@ -1415,12 +1433,13 @@ public:...@@ -1415,12 +1433,13 @@ public:
1415template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>1433template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
1416void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__move_to(1434void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__move_to(
1417 __packaged_task_base<_Rp(_ArgTypes...)>* __p) _NOEXCEPT {1435 __packaged_task_base<_Rp(_ArgTypes...)>* __p) _NOEXCEPT {
1418 ::new ((void*)__p) __packaged_task_func(std::move(__f_.first()), std::move(__f_.second()));1436 ::new ((void*)__p) __packaged_task_func(std::move(__func_), std::move(__alloc_));
1419}1437}
14201438
1421template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>1439template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
1422void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() {1440void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() {
1423 __f_.~__compressed_pair<_Fp, _Alloc>();1441 __func_.~_Fp();
1442 __alloc_.~_Alloc();
1424}1443}
14251444
1426template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>1445template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
...@@ -1428,14 +1447,15 @@ void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate()...@@ -1428,14 +1447,15 @@ void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate()
1428 typedef typename __allocator_traits_rebind<_Alloc, __packaged_task_func>::type _Ap;1447 typedef typename __allocator_traits_rebind<_Alloc, __packaged_task_func>::type _Ap;
1429 typedef allocator_traits<_Ap> _ATraits;1448 typedef allocator_traits<_Ap> _ATraits;
1430 typedef pointer_traits<typename _ATraits::pointer> _PTraits;1449 typedef pointer_traits<typename _ATraits::pointer> _PTraits;
1431 _Ap __a(__f_.second());1450 _Ap __a(__alloc_);
1432 __f_.~__compressed_pair<_Fp, _Alloc>();1451 __func_.~_Fp();
1452 __alloc_.~_Alloc();
1433 __a.deallocate(_PTraits::pointer_to(*this), 1);1453 __a.deallocate(_PTraits::pointer_to(*this), 1);
1434}1454}
14351455
1436template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>1456template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
1437_Rp __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&&... __arg) {1457_Rp __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&&... __arg) {
1438 return std::__invoke(__f_.first(), std::forward<_ArgTypes>(__arg)...);1458 return std::__invoke(__func_, std::forward<_ArgTypes>(__arg)...);
1439}1459}
14401460
1441template <class _Callable>1461template <class _Callable>
...@@ -1472,7 +1492,7 @@ public:...@@ -1472,7 +1492,7 @@ public:
14721492
1473 _LIBCPP_HIDE_FROM_ABI void swap(__packaged_task_function&) _NOEXCEPT;1493 _LIBCPP_HIDE_FROM_ABI void swap(__packaged_task_function&) _NOEXCEPT;
14741494
1475 _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes...) const;1495 _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes...) const;
1476};1496};
14771497
1478template <class _Rp, class... _ArgTypes>1498template <class _Rp, class... _ArgTypes>
...@@ -1592,11 +1612,11 @@ inline _Rp __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes......@@ -1592,11 +1612,11 @@ inline _Rp __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes...
1592template <class _Rp, class... _ArgTypes>1612template <class _Rp, class... _ArgTypes>
1593class _LIBCPP_TEMPLATE_VIS packaged_task<_Rp(_ArgTypes...)> {1613class _LIBCPP_TEMPLATE_VIS packaged_task<_Rp(_ArgTypes...)> {
1594public:1614public:
1595 typedef _Rp result_type; // extension1615 using result_type _LIBCPP_DEPRECATED = _Rp; // extension
15961616
1597private:1617private:
1598 __packaged_task_function<result_type(_ArgTypes...)> __f_;1618 __packaged_task_function<_Rp(_ArgTypes...)> __f_;
1599 promise<result_type> __p_;1619 promise<_Rp> __p_;
16001620
1601public:1621public:
1602 // construction and destruction1622 // construction and destruction
...@@ -1605,9 +1625,11 @@ public:...@@ -1605,9 +1625,11 @@ public:
1605 template <class _Fp, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0>1625 template <class _Fp, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0>
1606 _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {}1626 _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {}
16071627
1628# if _LIBCPP_STD_VER <= 14
1608 template <class _Fp, class _Allocator, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0>1629 template <class _Fp, class _Allocator, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0>
1609 _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)1630 _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
1610 : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {}1631 : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {}
1632# endif
1611 // ~packaged_task() = default;1633 // ~packaged_task() = default;
16121634
1613 // no copy1635 // no copy
...@@ -1631,7 +1653,7 @@ public:...@@ -1631,7 +1653,7 @@ public:
1631 _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __p_.__state_ != nullptr; }1653 _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __p_.__state_ != nullptr; }
16321654
1633 // result retrieval1655 // result retrieval
1634 _LIBCPP_HIDE_FROM_ABI future<result_type> get_future() { return __p_.get_future(); }1656 _LIBCPP_HIDE_FROM_ABI future<_Rp> get_future() { return __p_.get_future(); }
16351657
1636 // execution1658 // execution
1637 _LIBCPP_HIDE_FROM_ABI void operator()(_ArgTypes... __args);1659 _LIBCPP_HIDE_FROM_ABI void operator()(_ArgTypes... __args);
...@@ -1646,15 +1668,15 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) {...@@ -1646,15 +1668,15 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) {
1646 __throw_future_error(future_errc::no_state);1668 __throw_future_error(future_errc::no_state);
1647 if (__p_.__state_->__has_value())1669 if (__p_.__state_->__has_value())
1648 __throw_future_error(future_errc::promise_already_satisfied);1670 __throw_future_error(future_errc::promise_already_satisfied);
1649# ifndef _LIBCPP_HAS_NO_EXCEPTIONS1671# if _LIBCPP_HAS_EXCEPTIONS
1650 try {1672 try {
1651# endif // _LIBCPP_HAS_NO_EXCEPTIONS1673# endif // _LIBCPP_HAS_EXCEPTIONS
1652 __p_.set_value(__f_(std::forward<_ArgTypes>(__args)...));1674 __p_.set_value(__f_(std::forward<_ArgTypes>(__args)...));
1653# ifndef _LIBCPP_HAS_NO_EXCEPTIONS1675# if _LIBCPP_HAS_EXCEPTIONS
1654 } catch (...) {1676 } catch (...) {
1655 __p_.set_exception(current_exception());1677 __p_.set_exception(current_exception());
1656 }1678 }
1657# endif // _LIBCPP_HAS_NO_EXCEPTIONS1679# endif // _LIBCPP_HAS_EXCEPTIONS
1658}1680}
16591681
1660template <class _Rp, class... _ArgTypes>1682template <class _Rp, class... _ArgTypes>
...@@ -1663,41 +1685,43 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __...@@ -1663,41 +1685,43 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __
1663 __throw_future_error(future_errc::no_state);1685 __throw_future_error(future_errc::no_state);
1664 if (__p_.__state_->__has_value())1686 if (__p_.__state_->__has_value())
1665 __throw_future_error(future_errc::promise_already_satisfied);1687 __throw_future_error(future_errc::promise_already_satisfied);
1666# ifndef _LIBCPP_HAS_NO_EXCEPTIONS1688# if _LIBCPP_HAS_EXCEPTIONS
1667 try {1689 try {
1668# endif // _LIBCPP_HAS_NO_EXCEPTIONS1690# endif // _LIBCPP_HAS_EXCEPTIONS
1669 __p_.set_value_at_thread_exit(__f_(std::forward<_ArgTypes>(__args)...));1691 __p_.set_value_at_thread_exit(__f_(std::forward<_ArgTypes>(__args)...));
1670# ifndef _LIBCPP_HAS_NO_EXCEPTIONS1692# if _LIBCPP_HAS_EXCEPTIONS
1671 } catch (...) {1693 } catch (...) {
1672 __p_.set_exception_at_thread_exit(current_exception());1694 __p_.set_exception_at_thread_exit(current_exception());
1673 }1695 }
1674# endif // _LIBCPP_HAS_NO_EXCEPTIONS1696# endif // _LIBCPP_HAS_EXCEPTIONS
1675}1697}
16761698
1677template <class _Rp, class... _ArgTypes>1699template <class _Rp, class... _ArgTypes>
1678void packaged_task<_Rp(_ArgTypes...)>::reset() {1700void packaged_task<_Rp(_ArgTypes...)>::reset() {
1679 if (!valid())1701 if (!valid())
1680 __throw_future_error(future_errc::no_state);1702 __throw_future_error(future_errc::no_state);
1681 __p_ = promise<result_type>();1703 __p_ = promise<_Rp>();
1682}1704}
16831705
1684template <class... _ArgTypes>1706template <class... _ArgTypes>
1685class _LIBCPP_TEMPLATE_VIS packaged_task<void(_ArgTypes...)> {1707class _LIBCPP_TEMPLATE_VIS packaged_task<void(_ArgTypes...)> {
1686public:1708public:
1687 typedef void result_type; // extension1709 using result_type _LIBCPP_DEPRECATED = void; // extension
16881710
1689private:1711private:
1690 __packaged_task_function<result_type(_ArgTypes...)> __f_;1712 __packaged_task_function<void(_ArgTypes...)> __f_;
1691 promise<result_type> __p_;1713 promise<void> __p_;
16921714
1693public:1715public:
1694 // construction and destruction1716 // construction and destruction
1695 _LIBCPP_HIDE_FROM_ABI packaged_task() _NOEXCEPT : __p_(nullptr) {}1717 _LIBCPP_HIDE_FROM_ABI packaged_task() _NOEXCEPT : __p_(nullptr) {}
1696 template <class _Fp, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0>1718 template <class _Fp, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0>
1697 _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {}1719 _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {}
1720# if _LIBCPP_STD_VER <= 14
1698 template <class _Fp, class _Allocator, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0>1721 template <class _Fp, class _Allocator, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0>
1699 _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)1722 _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
1700 : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {}1723 : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {}
1724# endif
1701 // ~packaged_task() = default;1725 // ~packaged_task() = default;
17021726
1703 // no copy1727 // no copy
...@@ -1721,7 +1745,7 @@ public:...@@ -1721,7 +1745,7 @@ public:
1721 _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __p_.__state_ != nullptr; }1745 _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __p_.__state_ != nullptr; }
17221746
1723 // result retrieval1747 // result retrieval
1724 _LIBCPP_HIDE_FROM_ABI future<result_type> get_future() { return __p_.get_future(); }1748 _LIBCPP_HIDE_FROM_ABI future<void> get_future() { return __p_.get_future(); }
17251749
1726 // execution1750 // execution
1727 _LIBCPP_HIDE_FROM_ABI void operator()(_ArgTypes... __args);1751 _LIBCPP_HIDE_FROM_ABI void operator()(_ArgTypes... __args);
...@@ -1730,7 +1754,7 @@ public:...@@ -1730,7 +1754,7 @@ public:
1730 _LIBCPP_HIDE_FROM_ABI void reset();1754 _LIBCPP_HIDE_FROM_ABI void reset();
1731};1755};
17321756
1733# if _LIBCPP_STD_VER >= 171757# if _LIBCPP_STD_VER >= 17
17341758
1735template <class _Rp, class... _Args>1759template <class _Rp, class... _Args>
1736packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>;1760packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>;
...@@ -1738,7 +1762,7 @@ packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>;...@@ -1738,7 +1762,7 @@ packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>;
1738template <class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>1762template <class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>
1739packaged_task(_Fp) -> packaged_task<_Stripped>;1763packaged_task(_Fp) -> packaged_task<_Stripped>;
17401764
1741# endif1765# endif
17421766
1743template <class... _ArgTypes>1767template <class... _ArgTypes>
1744void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) {1768void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) {
...@@ -1746,16 +1770,16 @@ void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) {...@@ -1746,16 +1770,16 @@ void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) {
1746 __throw_future_error(future_errc::no_state);1770 __throw_future_error(future_errc::no_state);
1747 if (__p_.__state_->__has_value())1771 if (__p_.__state_->__has_value())
1748 __throw_future_error(future_errc::promise_already_satisfied);1772 __throw_future_error(future_errc::promise_already_satisfied);
1749# ifndef _LIBCPP_HAS_NO_EXCEPTIONS1773# if _LIBCPP_HAS_EXCEPTIONS
1750 try {1774 try {
1751# endif // _LIBCPP_HAS_NO_EXCEPTIONS1775# endif // _LIBCPP_HAS_EXCEPTIONS
1752 __f_(std::forward<_ArgTypes>(__args)...);1776 __f_(std::forward<_ArgTypes>(__args)...);
1753 __p_.set_value();1777 __p_.set_value();
1754# ifndef _LIBCPP_HAS_NO_EXCEPTIONS1778# if _LIBCPP_HAS_EXCEPTIONS
1755 } catch (...) {1779 } catch (...) {
1756 __p_.set_exception(current_exception());1780 __p_.set_exception(current_exception());
1757 }1781 }
1758# endif // _LIBCPP_HAS_NO_EXCEPTIONS1782# endif // _LIBCPP_HAS_EXCEPTIONS
1759}1783}
17601784
1761template <class... _ArgTypes>1785template <class... _ArgTypes>
...@@ -1764,23 +1788,23 @@ void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... _...@@ -1764,23 +1788,23 @@ void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... _
1764 __throw_future_error(future_errc::no_state);1788 __throw_future_error(future_errc::no_state);
1765 if (__p_.__state_->__has_value())1789 if (__p_.__state_->__has_value())
1766 __throw_future_error(future_errc::promise_already_satisfied);1790 __throw_future_error(future_errc::promise_already_satisfied);
1767# ifndef _LIBCPP_HAS_NO_EXCEPTIONS1791# if _LIBCPP_HAS_EXCEPTIONS
1768 try {1792 try {
1769# endif // _LIBCPP_HAS_NO_EXCEPTIONS1793# endif // _LIBCPP_HAS_EXCEPTIONS
1770 __f_(std::forward<_ArgTypes>(__args)...);1794 __f_(std::forward<_ArgTypes>(__args)...);
1771 __p_.set_value_at_thread_exit();1795 __p_.set_value_at_thread_exit();
1772# ifndef _LIBCPP_HAS_NO_EXCEPTIONS1796# if _LIBCPP_HAS_EXCEPTIONS
1773 } catch (...) {1797 } catch (...) {
1774 __p_.set_exception_at_thread_exit(current_exception());1798 __p_.set_exception_at_thread_exit(current_exception());
1775 }1799 }
1776# endif // _LIBCPP_HAS_NO_EXCEPTIONS1800# endif // _LIBCPP_HAS_EXCEPTIONS
1777}1801}
17781802
1779template <class... _ArgTypes>1803template <class... _ArgTypes>
1780void packaged_task<void(_ArgTypes...)>::reset() {1804void packaged_task<void(_ArgTypes...)>::reset() {
1781 if (!valid())1805 if (!valid())
1782 __throw_future_error(future_errc::no_state);1806 __throw_future_error(future_errc::no_state);
1783 __p_ = promise<result_type>();1807 __p_ = promise<void>();
1784}1808}
17851809
1786template <class _Rp, class... _ArgTypes>1810template <class _Rp, class... _ArgTypes>
...@@ -1789,8 +1813,10 @@ swap(packaged_task<_Rp(_ArgTypes...)>& __x, packaged_task<_Rp(_ArgTypes...)>& __...@@ -1789,8 +1813,10 @@ swap(packaged_task<_Rp(_ArgTypes...)>& __x, packaged_task<_Rp(_ArgTypes...)>& __
1789 __x.swap(__y);1813 __x.swap(__y);
1790}1814}
17911815
1816# if _LIBCPP_STD_VER <= 14
1792template <class _Callable, class _Alloc>1817template <class _Callable, class _Alloc>
1793struct _LIBCPP_TEMPLATE_VIS uses_allocator<packaged_task<_Callable>, _Alloc> : public true_type {};1818struct _LIBCPP_TEMPLATE_VIS uses_allocator<packaged_task<_Callable>, _Alloc> : public true_type {};
1819# endif
17941820
1795template <class _Rp, class _Fp>1821template <class _Rp, class _Fp>
1796_LIBCPP_HIDE_FROM_ABI future<_Rp> __make_deferred_assoc_state(_Fp&& __f) {1822_LIBCPP_HIDE_FROM_ABI future<_Rp> __make_deferred_assoc_state(_Fp&& __f) {
...@@ -1807,14 +1833,14 @@ _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) {...@@ -1807,14 +1833,14 @@ _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) {
1807 return future<_Rp>(__h.get());1833 return future<_Rp>(__h.get());
1808}1834}
18091835
1810# ifndef _LIBCPP_CXX03_LANG1836# ifndef _LIBCPP_CXX03_LANG
18111837
1812template <class _Fp, class... _Args>1838template <class _Fp, class... _Args>
1813class _LIBCPP_HIDDEN __async_func {1839class _LIBCPP_HIDDEN __async_func {
1814 tuple<_Fp, _Args...> __f_;1840 tuple<_Fp, _Args...> __f_;
18151841
1816public:1842public:
1817 typedef typename __invoke_of<_Fp, _Args...>::type _Rp;1843 using _Rp _LIBCPP_NODEBUG = __invoke_result_t<_Fp, _Args...>;
18181844
1819 _LIBCPP_HIDE_FROM_ABI explicit __async_func(_Fp&& __f, _Args&&... __args)1845 _LIBCPP_HIDE_FROM_ABI explicit __async_func(_Fp&& __f, _Args&&... __args)
1820 : __f_(std::move(__f), std::move(__args)...) {}1846 : __f_(std::move(__f), std::move(__args)...) {}
...@@ -1838,23 +1864,23 @@ inline _LIBCPP_HIDE_FROM_ABI bool __does_policy_contain(launch __policy, launch...@@ -1838,23 +1864,23 @@ inline _LIBCPP_HIDE_FROM_ABI bool __does_policy_contain(launch __policy, launch
1838}1864}
18391865
1840template <class _Fp, class... _Args>1866template <class _Fp, class... _Args>
1841_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type>1867[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI future<__invoke_result_t<__decay_t<_Fp>, __decay_t<_Args>...> >
1842async(launch __policy, _Fp&& __f, _Args&&... __args) {1868async(launch __policy, _Fp&& __f, _Args&&... __args) {
1843 typedef __async_func<__decay_t<_Fp>, __decay_t<_Args>...> _BF;1869 typedef __async_func<__decay_t<_Fp>, __decay_t<_Args>...> _BF;
1844 typedef typename _BF::_Rp _Rp;1870 typedef typename _BF::_Rp _Rp;
18451871
1846# ifndef _LIBCPP_HAS_NO_EXCEPTIONS1872# if _LIBCPP_HAS_EXCEPTIONS
1847 try {1873 try {
1848# endif1874# endif
1849 if (__does_policy_contain(__policy, launch::async))1875 if (__does_policy_contain(__policy, launch::async))
1850 return std::__make_async_assoc_state<_Rp>(1876 return std::__make_async_assoc_state<_Rp>(
1851 _BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...));1877 _BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...));
1852# ifndef _LIBCPP_HAS_NO_EXCEPTIONS1878# if _LIBCPP_HAS_EXCEPTIONS
1853 } catch (...) {1879 } catch (...) {
1854 if (__policy == launch::async)1880 if (__policy == launch::async)
1855 throw;1881 throw;
1856 }1882 }
1857# endif1883# endif
18581884
1859 if (__does_policy_contain(__policy, launch::deferred))1885 if (__does_policy_contain(__policy, launch::deferred))
1860 return std::__make_deferred_assoc_state<_Rp>(1886 return std::__make_deferred_assoc_state<_Rp>(
...@@ -1863,12 +1889,12 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) {...@@ -1863,12 +1889,12 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) {
1863}1889}
18641890
1865template <class _Fp, class... _Args>1891template <class _Fp, class... _Args>
1866_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type>1892[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI future<__invoke_result_t<__decay_t<_Fp>, __decay_t<_Args>...> >
1867async(_Fp&& __f, _Args&&... __args) {1893async(_Fp&& __f, _Args&&... __args) {
1868 return std::async(launch::any, std::forward<_Fp>(__f), std::forward<_Args>(__args)...);1894 return std::async(launch::any, std::forward<_Fp>(__f), std::forward<_Args>(__args)...);
1869}1895}
18701896
1871# endif // C++031897# endif // C++03
18721898
1873// shared_future1899// shared_future
18741900
...@@ -2045,18 +2071,20 @@ _LIBCPP_END_NAMESPACE_STD...@@ -2045,18 +2071,20 @@ _LIBCPP_END_NAMESPACE_STD
20452071
2046_LIBCPP_POP_MACROS2072_LIBCPP_POP_MACROS
20472073
2048#endif // !defined(_LIBCPP_HAS_NO_THREADS)2074# endif // _LIBCPP_HAS_THREADS
20492075
2050#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 172076# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
2051# include <chrono>2077# include <chrono>
2052#endif2078# endif
20532079
2054#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 202080# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2055# include <atomic>2081# include <atomic>
2056# include <cstdlib>2082# include <cstdlib>
2057# include <exception>2083# include <exception>
2058# include <iosfwd>2084# include <iosfwd>
2059# include <system_error>2085# include <system_error>
2060#endif2086# include <thread>
2087# endif
2088#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
20612089
2062#endif // _LIBCPP_FUTURE2090#endif // _LIBCPP_FUTURE
lib/libcxx/include/initializer_list+16-7
...@@ -42,17 +42,21 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in...@@ -42,17 +42,21 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in
4242
43*/43*/
4444
45#include <__config>45#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
46#include <cstddef>46# include <__cxx03/initializer_list>
47#else
48# include <__config>
49# include <__cstddef/size_t.h>
50# include <version>
4751
48#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)52# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
49# pragma GCC system_header53# pragma GCC system_header
50#endif54# endif
5155
52namespace std // purposefully not versioned56namespace std // purposefully not versioned
53{57{
5458
55#ifndef _LIBCPP_CXX03_LANG59# ifndef _LIBCPP_CXX03_LANG
5660
57template <class _Ep>61template <class _Ep>
58class _LIBCPP_TEMPLATE_VIS initializer_list {62class _LIBCPP_TEMPLATE_VIS initializer_list {
...@@ -91,8 +95,13 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end(initia...@@ -91,8 +95,13 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end(initia
91 return __il.end();95 return __il.end();
92}96}
9397
94#endif // !defined(_LIBCPP_CXX03_LANG)98# endif // !defined(_LIBCPP_CXX03_LANG)
9599
96} // namespace std100} // namespace std
97101
102# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
103# include <cstddef>
104# endif
105#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
106
98#endif // _LIBCPP_INITIALIZER_LIST107#endif // _LIBCPP_INITIALIZER_LIST
lib/libcxx/include/inttypes.h+19-15
...@@ -235,30 +235,34 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int...@@ -235,30 +235,34 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
235235
236*/236*/
237237
238#include <__config>238#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
239# include <__cxx03/inttypes.h>
240#else
241# include <__config>
239242
240#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)243# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
241# pragma GCC system_header244# pragma GCC system_header
242#endif245# endif
243246
244/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed247/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
245 for C++11 unless __STDC_FORMAT_MACROS is defined248 for C++11 unless __STDC_FORMAT_MACROS is defined
246*/249*/
247#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)250# if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
248# define __STDC_FORMAT_MACROS251# define __STDC_FORMAT_MACROS
249#endif252# endif
250253
251#if __has_include_next(<inttypes.h>)254# if __has_include_next(<inttypes.h>)
252# include_next <inttypes.h>255# include_next <inttypes.h>
253#endif256# endif
254257
255#ifdef __cplusplus258# ifdef __cplusplus
256259
257# include <stdint.h>260# include <stdint.h>
258261
259# undef imaxabs262# undef imaxabs
260# undef imaxdiv263# undef imaxdiv
261264
262#endif // __cplusplus265# endif // __cplusplus
266#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
263267
264#endif // _LIBCPP_INTTYPES_H268#endif // _LIBCPP_INTTYPES_H
lib/libcxx/include/iomanip+51-24
...@@ -42,13 +42,22 @@ template <class charT, class traits, class Allocator>...@@ -42,13 +42,22 @@ template <class charT, class traits, class Allocator>
4242
43*/43*/
4444
45#include <__config>45#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
46#include <istream>46# include <__cxx03/iomanip>
47#include <version>47#else
48# include <__config>
4849
49#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)50# if _LIBCPP_HAS_LOCALIZATION
50# pragma GCC system_header51
51#endif52# include <__ostream/put_character_sequence.h>
53# include <ios>
54# include <iosfwd>
55# include <locale>
56# include <version>
57
58# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
59# pragma GCC system_header
60# endif
5261
53_LIBCPP_BEGIN_NAMESPACE_STD62_LIBCPP_BEGIN_NAMESPACE_STD
5463
...@@ -231,9 +240,9 @@ public:...@@ -231,9 +240,9 @@ public:
231template <class _CharT, class _Traits, class _MoneyT>240template <class _CharT, class _Traits, class _MoneyT>
232_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&241_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
233operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) {242operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) {
234#ifndef _LIBCPP_HAS_NO_EXCEPTIONS243# if _LIBCPP_HAS_EXCEPTIONS
235 try {244 try {
236#endif // _LIBCPP_HAS_NO_EXCEPTIONS245# endif // _LIBCPP_HAS_EXCEPTIONS
237 typename basic_istream<_CharT, _Traits>::sentry __s(__is);246 typename basic_istream<_CharT, _Traits>::sentry __s(__is);
238 if (__s) {247 if (__s) {
239 typedef istreambuf_iterator<_CharT, _Traits> _Ip;248 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
...@@ -243,11 +252,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) {...@@ -243,11 +252,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) {
243 __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_);252 __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_);
244 __is.setstate(__err);253 __is.setstate(__err);
245 }254 }
246#ifndef _LIBCPP_HAS_NO_EXCEPTIONS255# if _LIBCPP_HAS_EXCEPTIONS
247 } catch (...) {256 } catch (...) {
248 __is.__set_badbit_and_consider_rethrow();257 __is.__set_badbit_and_consider_rethrow();
249 }258 }
250#endif // _LIBCPP_HAS_NO_EXCEPTIONS259# endif // _LIBCPP_HAS_EXCEPTIONS
251 return __is;260 return __is;
252}261}
253262
...@@ -280,9 +289,9 @@ public:...@@ -280,9 +289,9 @@ public:
280template <class _CharT, class _Traits, class _MoneyT>289template <class _CharT, class _Traits, class _MoneyT>
281_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&290_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
282operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) {291operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) {
283#ifndef _LIBCPP_HAS_NO_EXCEPTIONS292# if _LIBCPP_HAS_EXCEPTIONS
284 try {293 try {
285#endif // _LIBCPP_HAS_NO_EXCEPTIONS294# endif // _LIBCPP_HAS_EXCEPTIONS
286 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);295 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
287 if (__s) {296 if (__s) {
288 typedef ostreambuf_iterator<_CharT, _Traits> _Op;297 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
...@@ -291,11 +300,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) {...@@ -291,11 +300,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) {
291 if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())300 if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())
292 __os.setstate(ios_base::badbit);301 __os.setstate(ios_base::badbit);
293 }302 }
294#ifndef _LIBCPP_HAS_NO_EXCEPTIONS303# if _LIBCPP_HAS_EXCEPTIONS
295 } catch (...) {304 } catch (...) {
296 __os.__set_badbit_and_consider_rethrow();305 __os.__set_badbit_and_consider_rethrow();
297 }306 }
298#endif // _LIBCPP_HAS_NO_EXCEPTIONS307# endif // _LIBCPP_HAS_EXCEPTIONS
299 return __os;308 return __os;
300}309}
301310
...@@ -328,9 +337,9 @@ public:...@@ -328,9 +337,9 @@ public:
328template <class _CharT, class _Traits>337template <class _CharT, class _Traits>
329_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&338_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
330operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) {339operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) {
331#ifndef _LIBCPP_HAS_NO_EXCEPTIONS340# if _LIBCPP_HAS_EXCEPTIONS
332 try {341 try {
333#endif // _LIBCPP_HAS_NO_EXCEPTIONS342# endif // _LIBCPP_HAS_EXCEPTIONS
334 typename basic_istream<_CharT, _Traits>::sentry __s(__is);343 typename basic_istream<_CharT, _Traits>::sentry __s(__is);
335 if (__s) {344 if (__s) {
336 typedef istreambuf_iterator<_CharT, _Traits> _Ip;345 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
...@@ -340,11 +349,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) {...@@ -340,11 +349,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) {
340 __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_, __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_));349 __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_, __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_));
341 __is.setstate(__err);350 __is.setstate(__err);
342 }351 }
343#ifndef _LIBCPP_HAS_NO_EXCEPTIONS352# if _LIBCPP_HAS_EXCEPTIONS
344 } catch (...) {353 } catch (...) {
345 __is.__set_badbit_and_consider_rethrow();354 __is.__set_badbit_and_consider_rethrow();
346 }355 }
347#endif // _LIBCPP_HAS_NO_EXCEPTIONS356# endif // _LIBCPP_HAS_EXCEPTIONS
348 return __is;357 return __is;
349}358}
350359
...@@ -377,9 +386,9 @@ public:...@@ -377,9 +386,9 @@ public:
377template <class _CharT, class _Traits>386template <class _CharT, class _Traits>
378_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&387_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
379operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) {388operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) {
380#ifndef _LIBCPP_HAS_NO_EXCEPTIONS389# if _LIBCPP_HAS_EXCEPTIONS
381 try {390 try {
382#endif // _LIBCPP_HAS_NO_EXCEPTIONS391# endif // _LIBCPP_HAS_EXCEPTIONS
383 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);392 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
384 if (__s) {393 if (__s) {
385 typedef ostreambuf_iterator<_CharT, _Traits> _Op;394 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
...@@ -389,11 +398,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) {...@@ -389,11 +398,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) {
389 .failed())398 .failed())
390 __os.setstate(ios_base::badbit);399 __os.setstate(ios_base::badbit);
391 }400 }
392#ifndef _LIBCPP_HAS_NO_EXCEPTIONS401# if _LIBCPP_HAS_EXCEPTIONS
393 } catch (...) {402 } catch (...) {
394 __os.__set_badbit_and_consider_rethrow();403 __os.__set_badbit_and_consider_rethrow();
395 }404 }
396#endif // _LIBCPP_HAS_NO_EXCEPTIONS405# endif // _LIBCPP_HAS_EXCEPTIONS
397 return __os;406 return __os;
398}407}
399408
...@@ -505,7 +514,7 @@ __quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT...@@ -505,7 +514,7 @@ __quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT
505 return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape);514 return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape);
506}515}
507516
508#if _LIBCPP_STD_VER >= 14517# if _LIBCPP_STD_VER >= 14
509518
510template <class _CharT>519template <class _CharT>
511_LIBCPP_HIDE_FROM_ABI auto quoted(const _CharT* __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) {520_LIBCPP_HIDE_FROM_ABI auto quoted(const _CharT* __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) {
...@@ -535,8 +544,26 @@ quoted(basic_string_view<_CharT, _Traits> __sv, _CharT __delim = _CharT('"'), _C...@@ -535,8 +544,26 @@ quoted(basic_string_view<_CharT, _Traits> __sv, _CharT __delim = _CharT('"'), _C
535 return __quoted_output_proxy<_CharT, _Traits>(__sv.data(), __sv.data() + __sv.size(), __delim, __escape);544 return __quoted_output_proxy<_CharT, _Traits>(__sv.data(), __sv.data() + __sv.size(), __delim, __escape);
536}545}
537546
538#endif // _LIBCPP_STD_VER >= 14547# endif // _LIBCPP_STD_VER >= 14
539548
540_LIBCPP_END_NAMESPACE_STD549_LIBCPP_END_NAMESPACE_STD
541550
551# endif // _LIBCPP_HAS_LOCALIZATION
552
553# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
554# include <array>
555# include <bitset>
556# include <deque>
557# include <format>
558# include <functional>
559# include <istream>
560# include <ostream>
561# include <print>
562# include <queue>
563# include <stack>
564# include <unordered_map>
565# include <vector>
566# endif
567#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
568
542#endif // _LIBCPP_IOMANIP569#endif // _LIBCPP_IOMANIP
lib/libcxx/include/ios+73-65
...@@ -211,36 +211,40 @@ storage-class-specifier const error_category& iostream_category() noexcept;...@@ -211,36 +211,40 @@ storage-class-specifier const error_category& iostream_category() noexcept;
211211
212*/212*/
213213
214#include <__config>214#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
215215# include <__cxx03/ios>
216#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)216#else
217217# include <__config>
218# include <__fwd/ios.h>218
219# include <__ios/fpos.h>219# if _LIBCPP_HAS_LOCALIZATION
220# include <__locale>220
221# include <__system_error/error_category.h>221# include <__fwd/ios.h>
222# include <__system_error/error_code.h>222# include <__ios/fpos.h>
223# include <__system_error/error_condition.h>223# include <__locale>
224# include <__system_error/system_error.h>224# include <__memory/addressof.h>
225# include <__utility/swap.h>225# include <__system_error/error_category.h>
226# include <__verbose_abort>226# include <__system_error/error_code.h>
227# include <version>227# include <__system_error/error_condition.h>
228# include <__system_error/system_error.h>
229# include <__utility/swap.h>
230# include <__verbose_abort>
231# include <version>
228232
229// standard-mandated includes233// standard-mandated includes
230234
231// [ios.syn]235// [ios.syn]
232# include <iosfwd>236# include <iosfwd>
233237
234# if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)238# if _LIBCPP_HAS_ATOMIC_HEADER
235# include <__atomic/atomic.h> // for __xindex_239# include <__atomic/atomic.h> // for __xindex_
236# endif240# endif
237241
238# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)242# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
239# pragma GCC system_header243# pragma GCC system_header
240# endif244# endif
241245
242_LIBCPP_PUSH_MACROS246_LIBCPP_PUSH_MACROS
243# include <__undef_macros>247# include <__undef_macros>
244248
245_LIBCPP_BEGIN_NAMESPACE_STD249_LIBCPP_BEGIN_NAMESPACE_STD
246250
...@@ -283,20 +287,20 @@ public:...@@ -283,20 +287,20 @@ public:
283 static const openmode in = 0x08;287 static const openmode in = 0x08;
284 static const openmode out = 0x10;288 static const openmode out = 0x10;
285 static const openmode trunc = 0x20;289 static const openmode trunc = 0x20;
286# if _LIBCPP_STD_VER >= 23290# if _LIBCPP_STD_VER >= 23
287 static const openmode noreplace = 0x40;291 static const openmode noreplace = 0x40;
288# endif292# endif
289293
290 enum seekdir { beg, cur, end };294 enum seekdir { beg, cur, end };
291295
292# if _LIBCPP_STD_VER <= 14296# if _LIBCPP_STD_VER <= 14
293 typedef iostate io_state;297 typedef iostate io_state;
294 typedef openmode open_mode;298 typedef openmode open_mode;
295 typedef seekdir seek_dir;299 typedef seekdir seek_dir;
296300
297 typedef std::streamoff streamoff;301 typedef std::streamoff streamoff;
298 typedef std::streampos streampos;302 typedef std::streampos streampos;
299# endif303# endif
300304
301 class _LIBCPP_EXPORTED_FROM_ABI Init;305 class _LIBCPP_EXPORTED_FROM_ABI Init;
302306
...@@ -396,11 +400,11 @@ private:...@@ -396,11 +400,11 @@ private:
396 size_t __event_cap_;400 size_t __event_cap_;
397// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only401// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only
398// enabled with clang.402// enabled with clang.
399# if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)403# if _LIBCPP_HAS_C_ATOMIC_IMP && _LIBCPP_HAS_THREADS
400 static atomic<int> __xindex_;404 static atomic<int> __xindex_;
401# else405# else
402 static int __xindex_;406 static int __xindex_;
403# endif407# endif
404 long* __iarray_;408 long* __iarray_;
405 size_t __iarray_size_;409 size_t __iarray_size_;
406 size_t __iarray_cap_;410 size_t __iarray_cap_;
...@@ -416,10 +420,10 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)...@@ -416,10 +420,10 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
416template <>420template <>
417struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type {};421struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type {};
418422
419# ifdef _LIBCPP_CXX03_LANG423# ifdef _LIBCPP_CXX03_LANG
420template <>424template <>
421struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type {};425struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type {};
422# endif426# endif
423427
424_LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT;428_LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT;
425429
...@@ -439,12 +443,12 @@ public:...@@ -439,12 +443,12 @@ public:
439 ~failure() _NOEXCEPT override;443 ~failure() _NOEXCEPT override;
440};444};
441445
442_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) {446[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) {
443# ifndef _LIBCPP_HAS_NO_EXCEPTIONS447# if _LIBCPP_HAS_EXCEPTIONS
444 throw ios_base::failure(__msg);448 throw ios_base::failure(__msg);
445# else449# else
446 _LIBCPP_VERBOSE_ABORT("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg);450 _LIBCPP_VERBOSE_ABORT("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg);
447# endif451# endif
448}452}
449453
450class _LIBCPP_EXPORTED_FROM_ABI ios_base::Init {454class _LIBCPP_EXPORTED_FROM_ABI ios_base::Init {
...@@ -523,7 +527,10 @@ template <class _Traits>...@@ -523,7 +527,10 @@ template <class _Traits>
523// Attribute 'packed' is used to keep the layout compatible with the previous527// Attribute 'packed' is used to keep the layout compatible with the previous
524// definition of the '__fill_' and '_set_' pair in basic_ios on AIX & z/OS.528// definition of the '__fill_' and '_set_' pair in basic_ios on AIX & z/OS.
525struct _LIBCPP_PACKED _FillHelper {529struct _LIBCPP_PACKED _FillHelper {
526 _LIBCPP_HIDE_FROM_ABI void __init() { __set_ = false; }530 _LIBCPP_HIDE_FROM_ABI void __init() {
531 __set_ = false;
532 __fill_val_ = _Traits::eof();
533 }
527 _LIBCPP_HIDE_FROM_ABI _FillHelper& operator=(typename _Traits::int_type __x) {534 _LIBCPP_HIDE_FROM_ABI _FillHelper& operator=(typename _Traits::int_type __x) {
528 __set_ = true;535 __set_ = true;
529 __fill_val_ = __x;536 __fill_val_ = __x;
...@@ -565,13 +572,13 @@ public:...@@ -565,13 +572,13 @@ public:
565 static_assert(is_same<_CharT, typename traits_type::char_type>::value,572 static_assert(is_same<_CharT, typename traits_type::char_type>::value,
566 "traits_type::char_type must be the same type as CharT");573 "traits_type::char_type must be the same type as CharT");
567574
568# ifdef _LIBCPP_CXX03_LANG575# ifdef _LIBCPP_CXX03_LANG
569 // Preserve the ability to compare with literal 0,576 // Preserve the ability to compare with literal 0,
570 // and implicitly convert to bool, but not implicitly convert to int.577 // and implicitly convert to bool, but not implicitly convert to int.
571 _LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; }578 _LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; }
572# else579# else
573 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); }580 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); }
574# endif581# endif
575582
576 _LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); }583 _LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); }
577 _LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); }584 _LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); }
...@@ -621,11 +628,11 @@ protected:...@@ -621,11 +628,11 @@ protected:
621private:628private:
622 basic_ostream<char_type, traits_type>* __tie_;629 basic_ostream<char_type, traits_type>* __tie_;
623630
624#if defined(_LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE)631# if defined(_LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE)
625 using _FillType = _FillHelper<traits_type>;632 using _FillType _LIBCPP_NODEBUG = _FillHelper<traits_type>;
626#else633# else
627 using _FillType = _SentinelValueFill<traits_type>;634 using _FillType _LIBCPP_NODEBUG = _SentinelValueFill<traits_type>;
628#endif635# endif
629 mutable _FillType __fill_;636 mutable _FillType __fill_;
630};637};
631638
...@@ -640,7 +647,7 @@ basic_ios<_CharT, _Traits>::~basic_ios() {}...@@ -640,7 +647,7 @@ basic_ios<_CharT, _Traits>::~basic_ios() {}
640template <class _CharT, class _Traits>647template <class _CharT, class _Traits>
641inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) {648inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) {
642 ios_base::init(__sb);649 ios_base::init(__sb);
643 __tie_ = nullptr;650 __tie_ = nullptr;
644 __fill_.__init();651 __fill_.__init();
645}652}
646653
...@@ -707,7 +714,7 @@ inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill(char_type _...@@ -707,7 +714,7 @@ inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill(char_type _
707714
708template <class _CharT, class _Traits>715template <class _CharT, class _Traits>
709basic_ios<_CharT, _Traits>& basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) {716basic_ios<_CharT, _Traits>& basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) {
710 if (this != &__rhs) {717 if (this != std::addressof(__rhs)) {
711 __call_callbacks(erase_event);718 __call_callbacks(erase_event);
712 ios_base::copyfmt(__rhs);719 ios_base::copyfmt(__rhs);
713 __tie_ = __rhs.__tie_;720 __tie_ = __rhs.__tie_;
...@@ -740,9 +747,9 @@ inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::set_rdbuf(basic_st...@@ -740,9 +747,9 @@ inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::set_rdbuf(basic_st
740747
741extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>;748extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>;
742749
743# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS750# if _LIBCPP_HAS_WIDE_CHARACTERS
744extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;751extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;
745# endif752# endif
746753
747_LIBCPP_HIDE_FROM_ABI inline ios_base& boolalpha(ios_base& __str) {754_LIBCPP_HIDE_FROM_ABI inline ios_base& boolalpha(ios_base& __str) {
748 __str.setf(ios_base::boolalpha);755 __str.setf(ios_base::boolalpha);
...@@ -868,22 +875,23 @@ _LIBCPP_END_NAMESPACE_STD...@@ -868,22 +875,23 @@ _LIBCPP_END_NAMESPACE_STD
868875
869_LIBCPP_POP_MACROS876_LIBCPP_POP_MACROS
870877
871#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)878# endif // _LIBCPP_HAS_LOCALIZATION
872879
873#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20880# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
874# include <atomic>881# include <atomic>
875# include <concepts>882# include <concepts>
876# include <cstddef>883# include <cstddef>
877# include <cstdlib>884# include <cstdlib>
878# include <cstring>885# include <cstring>
879# include <initializer_list>886# include <initializer_list>
880# include <limits>887# include <limits>
881# include <mutex>888# include <mutex>
882# include <new>889# include <new>
883# include <stdexcept>890# include <stdexcept>
884# include <system_error>891# include <system_error>
885# include <type_traits>892# include <type_traits>
886# include <typeinfo>893# include <typeinfo>
887#endif894# endif
895#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
888896
889#endif // _LIBCPP_IOS897#endif // _LIBCPP_IOS
lib/libcxx/include/iosfwd+32-27
...@@ -105,21 +105,24 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20...@@ -105,21 +105,24 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20
105105
106*/106*/
107107
108#include <__config>108#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
109#include <__fwd/fstream.h>109# include <__cxx03/iosfwd>
110#include <__fwd/ios.h>110#else
111#include <__fwd/istream.h>111# include <__config>
112#include <__fwd/memory.h>112# include <__fwd/fstream.h>
113#include <__fwd/ostream.h>113# include <__fwd/ios.h>
114#include <__fwd/sstream.h>114# include <__fwd/istream.h>
115#include <__fwd/streambuf.h>115# include <__fwd/memory.h>
116#include <__fwd/string.h>116# include <__fwd/ostream.h>
117#include <__std_mbstate_t.h>117# include <__fwd/sstream.h>
118#include <version>118# include <__fwd/streambuf.h>
119119# include <__fwd/string.h>
120#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)120# include <__std_mbstate_t.h>
121# pragma GCC system_header121# include <version>
122#endif122
123# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
124# pragma GCC system_header
125# endif
123126
124_LIBCPP_BEGIN_NAMESPACE_STD127_LIBCPP_BEGIN_NAMESPACE_STD
125128
...@@ -131,34 +134,34 @@ class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator;...@@ -131,34 +134,34 @@ class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator;
131template <class _State>134template <class _State>
132class _LIBCPP_TEMPLATE_VIS fpos;135class _LIBCPP_TEMPLATE_VIS fpos;
133typedef fpos<mbstate_t> streampos;136typedef fpos<mbstate_t> streampos;
134#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS137# if _LIBCPP_HAS_WIDE_CHARACTERS
135typedef fpos<mbstate_t> wstreampos;138typedef fpos<mbstate_t> wstreampos;
136#endif139# endif
137#ifndef _LIBCPP_HAS_NO_CHAR8_T140# if _LIBCPP_HAS_CHAR8_T
138typedef fpos<mbstate_t> u8streampos;141typedef fpos<mbstate_t> u8streampos;
139#endif142# endif
140typedef fpos<mbstate_t> u16streampos;143typedef fpos<mbstate_t> u16streampos;
141typedef fpos<mbstate_t> u32streampos;144typedef fpos<mbstate_t> u32streampos;
142145
143#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)146# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM
144147
145template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT>>148template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT>>
146class basic_syncbuf;149class basic_syncbuf;
147150
148using syncbuf = basic_syncbuf<char>;151using syncbuf = basic_syncbuf<char>;
149# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS152# if _LIBCPP_HAS_WIDE_CHARACTERS
150using wsyncbuf = basic_syncbuf<wchar_t>;153using wsyncbuf = basic_syncbuf<wchar_t>;
151# endif154# endif
152155
153template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT>>156template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT>>
154class basic_osyncstream;157class basic_osyncstream;
155158
156using osyncstream = basic_osyncstream<char>;159using osyncstream = basic_osyncstream<char>;
157# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS160# if _LIBCPP_HAS_WIDE_CHARACTERS
158using wosyncstream = basic_osyncstream<wchar_t>;161using wosyncstream = basic_osyncstream<wchar_t>;
159# endif162# endif
160163
161#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)164# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM
162165
163template <class _CharT, class _Traits>166template <class _CharT, class _Traits>
164class __save_flags {167class __save_flags {
...@@ -170,8 +173,8 @@ class __save_flags {...@@ -170,8 +173,8 @@ class __save_flags {
170 _CharT __fill_;173 _CharT __fill_;
171174
172public:175public:
173 __save_flags(const __save_flags&) = delete;176 __save_flags(const __save_flags&) = delete;
174 __save_flags& operator=(const __save_flags&) = delete;177 __save_flags& operator=(const __save_flags&) = delete;
175178
176 _LIBCPP_HIDE_FROM_ABI explicit __save_flags(__stream_type& __stream)179 _LIBCPP_HIDE_FROM_ABI explicit __save_flags(__stream_type& __stream)
177 : __stream_(__stream), __fmtflags_(__stream.flags()), __fill_(__stream.fill()) {}180 : __stream_(__stream), __fmtflags_(__stream.flags()), __fill_(__stream.fill()) {}
...@@ -183,4 +186,6 @@ public:...@@ -183,4 +186,6 @@ public:
183186
184_LIBCPP_END_NAMESPACE_STD187_LIBCPP_END_NAMESPACE_STD
185188
189#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
190
186#endif // _LIBCPP_IOSFWD191#endif // _LIBCPP_IOSFWD
lib/libcxx/include/iostream+16-11
...@@ -33,20 +33,23 @@ extern wostream wclog;...@@ -33,20 +33,23 @@ extern wostream wclog;
3333
34*/34*/
3535
36#include <__config>36#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
37#include <version>37# include <__cxx03/iostream>
38#else
39# include <__config>
40# include <version>
3841
39// standard-mandated includes42// standard-mandated includes
4043
41// [iostream.syn]44// [iostream.syn]
42#include <ios>45# include <ios>
43#include <istream>46# include <istream>
44#include <ostream>47# include <ostream>
45#include <streambuf>48# include <streambuf>
4649
47#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)50# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
48# pragma GCC system_header51# pragma GCC system_header
49#endif52# endif
5053
51_LIBCPP_BEGIN_NAMESPACE_STD54_LIBCPP_BEGIN_NAMESPACE_STD
5255
...@@ -55,13 +58,15 @@ extern _LIBCPP_EXPORTED_FROM_ABI ostream cout;...@@ -55,13 +58,15 @@ extern _LIBCPP_EXPORTED_FROM_ABI ostream cout;
55extern _LIBCPP_EXPORTED_FROM_ABI ostream cerr;58extern _LIBCPP_EXPORTED_FROM_ABI ostream cerr;
56extern _LIBCPP_EXPORTED_FROM_ABI ostream clog;59extern _LIBCPP_EXPORTED_FROM_ABI ostream clog;
5760
58#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS61# if _LIBCPP_HAS_WIDE_CHARACTERS
59extern _LIBCPP_EXPORTED_FROM_ABI wistream wcin;62extern _LIBCPP_EXPORTED_FROM_ABI wistream wcin;
60extern _LIBCPP_EXPORTED_FROM_ABI wostream wcout;63extern _LIBCPP_EXPORTED_FROM_ABI wostream wcout;
61extern _LIBCPP_EXPORTED_FROM_ABI wostream wcerr;64extern _LIBCPP_EXPORTED_FROM_ABI wostream wcerr;
62extern _LIBCPP_EXPORTED_FROM_ABI wostream wclog;65extern _LIBCPP_EXPORTED_FROM_ABI wostream wclog;
63#endif66# endif
6467
65_LIBCPP_END_NAMESPACE_STD68_LIBCPP_END_NAMESPACE_STD
6669
70#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
71
67#endif // _LIBCPP_IOSTREAM72#endif // _LIBCPP_IOSTREAM
lib/libcxx/include/istream+143-127
...@@ -158,26 +158,33 @@ template <class Stream, class T>...@@ -158,26 +158,33 @@ template <class Stream, class T>
158158
159*/159*/
160160
161#include <__config>161#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
162#include <__fwd/istream.h>162# include <__cxx03/istream>
163#include <__iterator/istreambuf_iterator.h>163#else
164#include <__ostream/basic_ostream.h>164# include <__config>
165#include <__type_traits/conjunction.h>165
166#include <__type_traits/enable_if.h>166# if _LIBCPP_HAS_LOCALIZATION
167#include <__type_traits/is_base_of.h>167
168#include <__utility/declval.h>168# include <__fwd/istream.h>
169#include <__utility/forward.h>169# include <__iterator/istreambuf_iterator.h>
170#include <bitset>170# include <__ostream/basic_ostream.h>
171#include <ios>171# include <__type_traits/conjunction.h>
172#include <locale>172# include <__type_traits/enable_if.h>
173#include <version>173# include <__type_traits/is_base_of.h>
174174# include <__type_traits/make_unsigned.h>
175#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)175# include <__utility/declval.h>
176# pragma GCC system_header176# include <__utility/forward.h>
177#endif177# include <bitset>
178# include <ios>
179# include <locale>
180# include <version>
181
182# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
183# pragma GCC system_header
184# endif
178185
179_LIBCPP_PUSH_MACROS186_LIBCPP_PUSH_MACROS
180#include <__undef_macros>187# include <__undef_macros>
181188
182_LIBCPP_BEGIN_NAMESPACE_STD189_LIBCPP_BEGIN_NAMESPACE_STD
183190
...@@ -353,13 +360,13 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {...@@ -353,13 +360,13 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
353 ios_base::iostate __state = ios_base::goodbit;360 ios_base::iostate __state = ios_base::goodbit;
354 typename basic_istream<_CharT, _Traits>::sentry __s(__is);361 typename basic_istream<_CharT, _Traits>::sentry __s(__is);
355 if (__s) {362 if (__s) {
356#ifndef _LIBCPP_HAS_NO_EXCEPTIONS363# if _LIBCPP_HAS_EXCEPTIONS
357 try {364 try {
358#endif // _LIBCPP_HAS_NO_EXCEPTIONS365# endif // _LIBCPP_HAS_EXCEPTIONS
359 typedef istreambuf_iterator<_CharT, _Traits> _Ip;366 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
360 typedef num_get<_CharT, _Ip> _Fp;367 typedef num_get<_CharT, _Ip> _Fp;
361 std::use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n);368 std::use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n);
362#ifndef _LIBCPP_HAS_NO_EXCEPTIONS369# if _LIBCPP_HAS_EXCEPTIONS
363 } catch (...) {370 } catch (...) {
364 __state |= ios_base::badbit;371 __state |= ios_base::badbit;
365 __is.__setstate_nothrow(__state);372 __is.__setstate_nothrow(__state);
...@@ -367,7 +374,7 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {...@@ -367,7 +374,7 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
367 throw;374 throw;
368 }375 }
369 }376 }
370#endif377# endif
371 __is.setstate(__state);378 __is.setstate(__state);
372 }379 }
373 return __is;380 return __is;
...@@ -434,9 +441,9 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp...@@ -434,9 +441,9 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
434 ios_base::iostate __state = ios_base::goodbit;441 ios_base::iostate __state = ios_base::goodbit;
435 typename basic_istream<_CharT, _Traits>::sentry __s(__is);442 typename basic_istream<_CharT, _Traits>::sentry __s(__is);
436 if (__s) {443 if (__s) {
437#ifndef _LIBCPP_HAS_NO_EXCEPTIONS444# if _LIBCPP_HAS_EXCEPTIONS
438 try {445 try {
439#endif // _LIBCPP_HAS_NO_EXCEPTIONS446# endif // _LIBCPP_HAS_EXCEPTIONS
440 typedef istreambuf_iterator<_CharT, _Traits> _Ip;447 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
441 typedef num_get<_CharT, _Ip> _Fp;448 typedef num_get<_CharT, _Ip> _Fp;
442 long __temp;449 long __temp;
...@@ -450,7 +457,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp...@@ -450,7 +457,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
450 } else {457 } else {
451 __n = static_cast<_Tp>(__temp);458 __n = static_cast<_Tp>(__temp);
452 }459 }
453#ifndef _LIBCPP_HAS_NO_EXCEPTIONS460# if _LIBCPP_HAS_EXCEPTIONS
454 } catch (...) {461 } catch (...) {
455 __state |= ios_base::badbit;462 __state |= ios_base::badbit;
456 __is.__setstate_nothrow(__state);463 __is.__setstate_nothrow(__state);
...@@ -458,7 +465,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp...@@ -458,7 +465,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
458 throw;465 throw;
459 }466 }
460 }467 }
461#endif // _LIBCPP_HAS_NO_EXCEPTIONS468# endif // _LIBCPP_HAS_EXCEPTIONS
462 __is.setstate(__state);469 __is.setstate(__state);
463 }470 }
464 return __is;471 return __is;
...@@ -480,9 +487,9 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)...@@ -480,9 +487,9 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
480 ios_base::iostate __state = ios_base::goodbit;487 ios_base::iostate __state = ios_base::goodbit;
481 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);488 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
482 if (__sen) {489 if (__sen) {
483#ifndef _LIBCPP_HAS_NO_EXCEPTIONS490# if _LIBCPP_HAS_EXCEPTIONS
484 try {491 try {
485#endif492# endif
486 _CharT* __s = __p;493 _CharT* __s = __p;
487 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());494 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
488 while (__s != __p + (__n - 1)) {495 while (__s != __p + (__n - 1)) {
...@@ -501,7 +508,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)...@@ -501,7 +508,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
501 __is.width(0);508 __is.width(0);
502 if (__s == __p)509 if (__s == __p)
503 __state |= ios_base::failbit;510 __state |= ios_base::failbit;
504#ifndef _LIBCPP_HAS_NO_EXCEPTIONS511# if _LIBCPP_HAS_EXCEPTIONS
505 } catch (...) {512 } catch (...) {
506 __state |= ios_base::badbit;513 __state |= ios_base::badbit;
507 __is.__setstate_nothrow(__state);514 __is.__setstate_nothrow(__state);
...@@ -509,13 +516,13 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)...@@ -509,13 +516,13 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
509 throw;516 throw;
510 }517 }
511 }518 }
512#endif519# endif
513 __is.setstate(__state);520 __is.setstate(__state);
514 }521 }
515 return __is;522 return __is;
516}523}
517524
518#if _LIBCPP_STD_VER >= 20525# if _LIBCPP_STD_VER >= 20
519526
520template <class _CharT, class _Traits, size_t _Np>527template <class _CharT, class _Traits, size_t _Np>
521inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&528inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
...@@ -538,7 +545,7 @@ operator>>(basic_istream<char, _Traits>& __is, signed char (&__buf)[_Np]) {...@@ -538,7 +545,7 @@ operator>>(basic_istream<char, _Traits>& __is, signed char (&__buf)[_Np]) {
538 return __is >> (char(&)[_Np])__buf;545 return __is >> (char(&)[_Np])__buf;
539}546}
540547
541#else548# else
542549
543template <class _CharT, class _Traits>550template <class _CharT, class _Traits>
544inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&551inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
...@@ -561,22 +568,22 @@ operator>>(basic_istream<char, _Traits>& __is, signed char* __s) {...@@ -561,22 +568,22 @@ operator>>(basic_istream<char, _Traits>& __is, signed char* __s) {
561 return __is >> (char*)__s;568 return __is >> (char*)__s;
562}569}
563570
564#endif // _LIBCPP_STD_VER >= 20571# endif // _LIBCPP_STD_VER >= 20
565572
566template <class _CharT, class _Traits>573template <class _CharT, class _Traits>
567_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c) {574_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c) {
568 ios_base::iostate __state = ios_base::goodbit;575 ios_base::iostate __state = ios_base::goodbit;
569 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);576 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
570 if (__sen) {577 if (__sen) {
571#ifndef _LIBCPP_HAS_NO_EXCEPTIONS578# if _LIBCPP_HAS_EXCEPTIONS
572 try {579 try {
573#endif580# endif
574 typename _Traits::int_type __i = __is.rdbuf()->sbumpc();581 typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
575 if (_Traits::eq_int_type(__i, _Traits::eof()))582 if (_Traits::eq_int_type(__i, _Traits::eof()))
576 __state |= ios_base::eofbit | ios_base::failbit;583 __state |= ios_base::eofbit | ios_base::failbit;
577 else584 else
578 __c = _Traits::to_char_type(__i);585 __c = _Traits::to_char_type(__i);
579#ifndef _LIBCPP_HAS_NO_EXCEPTIONS586# if _LIBCPP_HAS_EXCEPTIONS
580 } catch (...) {587 } catch (...) {
581 __state |= ios_base::badbit;588 __state |= ios_base::badbit;
582 __is.__setstate_nothrow(__state);589 __is.__setstate_nothrow(__state);
...@@ -584,7 +591,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_...@@ -584,7 +591,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_
584 throw;591 throw;
585 }592 }
586 }593 }
587#endif594# endif
588 __is.setstate(__state);595 __is.setstate(__state);
589 }596 }
590 return __is;597 return __is;
...@@ -610,9 +617,9 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ...@@ -610,9 +617,9 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
610 sentry __s(*this, true);617 sentry __s(*this, true);
611 if (__s) {618 if (__s) {
612 if (__sb) {619 if (__sb) {
613#ifndef _LIBCPP_HAS_NO_EXCEPTIONS620# if _LIBCPP_HAS_EXCEPTIONS
614 try {621 try {
615#endif // _LIBCPP_HAS_NO_EXCEPTIONS622# endif // _LIBCPP_HAS_EXCEPTIONS
616 while (true) {623 while (true) {
617 typename traits_type::int_type __i = this->rdbuf()->sgetc();624 typename traits_type::int_type __i = this->rdbuf()->sgetc();
618 if (traits_type::eq_int_type(__i, _Traits::eof())) {625 if (traits_type::eq_int_type(__i, _Traits::eof())) {
...@@ -626,7 +633,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ...@@ -626,7 +633,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
626 }633 }
627 if (__gc_ == 0)634 if (__gc_ == 0)
628 __state |= ios_base::failbit;635 __state |= ios_base::failbit;
629#ifndef _LIBCPP_HAS_NO_EXCEPTIONS636# if _LIBCPP_HAS_EXCEPTIONS
630 } catch (...) {637 } catch (...) {
631 __state |= ios_base::badbit;638 __state |= ios_base::badbit;
632 if (__gc_ == 0)639 if (__gc_ == 0)
...@@ -637,7 +644,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ...@@ -637,7 +644,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
637 throw;644 throw;
638 }645 }
639 }646 }
640#endif // _LIBCPP_HAS_NO_EXCEPTIONS647# endif // _LIBCPP_HAS_EXCEPTIONS
641 } else {648 } else {
642 __state |= ios_base::failbit;649 __state |= ios_base::failbit;
643 }650 }
...@@ -653,22 +660,22 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>...@@ -653,22 +660,22 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>
653 int_type __r = traits_type::eof();660 int_type __r = traits_type::eof();
654 sentry __s(*this, true);661 sentry __s(*this, true);
655 if (__s) {662 if (__s) {
656#ifndef _LIBCPP_HAS_NO_EXCEPTIONS663# if _LIBCPP_HAS_EXCEPTIONS
657 try {664 try {
658#endif665# endif
659 __r = this->rdbuf()->sbumpc();666 __r = this->rdbuf()->sbumpc();
660 if (traits_type::eq_int_type(__r, traits_type::eof()))667 if (traits_type::eq_int_type(__r, traits_type::eof()))
661 __state |= ios_base::failbit | ios_base::eofbit;668 __state |= ios_base::failbit | ios_base::eofbit;
662 else669 else
663 __gc_ = 1;670 __gc_ = 1;
664#ifndef _LIBCPP_HAS_NO_EXCEPTIONS671# if _LIBCPP_HAS_EXCEPTIONS
665 } catch (...) {672 } catch (...) {
666 this->__setstate_nothrow(this->rdstate() | ios_base::badbit);673 this->__setstate_nothrow(this->rdstate() | ios_base::badbit);
667 if (this->exceptions() & ios_base::badbit) {674 if (this->exceptions() & ios_base::badbit) {
668 throw;675 throw;
669 }676 }
670 }677 }
671#endif678# endif
672 this->setstate(__state);679 this->setstate(__state);
673 }680 }
674 return __r;681 return __r;
...@@ -681,9 +688,9 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _...@@ -681,9 +688,9 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _
681 sentry __sen(*this, true);688 sentry __sen(*this, true);
682 if (__sen) {689 if (__sen) {
683 if (__n > 0) {690 if (__n > 0) {
684#ifndef _LIBCPP_HAS_NO_EXCEPTIONS691# if _LIBCPP_HAS_EXCEPTIONS
685 try {692 try {
686#endif693# endif
687 while (__gc_ < __n - 1) {694 while (__gc_ < __n - 1) {
688 int_type __i = this->rdbuf()->sgetc();695 int_type __i = this->rdbuf()->sgetc();
689 if (traits_type::eq_int_type(__i, traits_type::eof())) {696 if (traits_type::eq_int_type(__i, traits_type::eof())) {
...@@ -699,7 +706,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _...@@ -699,7 +706,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _
699 }706 }
700 if (__gc_ == 0)707 if (__gc_ == 0)
701 __state |= ios_base::failbit;708 __state |= ios_base::failbit;
702#ifndef _LIBCPP_HAS_NO_EXCEPTIONS709# if _LIBCPP_HAS_EXCEPTIONS
703 } catch (...) {710 } catch (...) {
704 __state |= ios_base::badbit;711 __state |= ios_base::badbit;
705 this->__setstate_nothrow(__state);712 this->__setstate_nothrow(__state);
...@@ -709,7 +716,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _...@@ -709,7 +716,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _
709 throw;716 throw;
710 }717 }
711 }718 }
712#endif719# endif
713 } else {720 } else {
714 __state |= ios_base::failbit;721 __state |= ios_base::failbit;
715 }722 }
...@@ -730,9 +737,9 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s...@@ -730,9 +737,9 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s
730 __gc_ = 0;737 __gc_ = 0;
731 sentry __sen(*this, true);738 sentry __sen(*this, true);
732 if (__sen) {739 if (__sen) {
733#ifndef _LIBCPP_HAS_NO_EXCEPTIONS740# if _LIBCPP_HAS_EXCEPTIONS
734 try {741 try {
735#endif // _LIBCPP_HAS_NO_EXCEPTIONS742# endif // _LIBCPP_HAS_EXCEPTIONS
736 while (true) {743 while (true) {
737 typename traits_type::int_type __i = this->rdbuf()->sgetc();744 typename traits_type::int_type __i = this->rdbuf()->sgetc();
738 if (traits_type::eq_int_type(__i, traits_type::eof())) {745 if (traits_type::eq_int_type(__i, traits_type::eof())) {
...@@ -747,12 +754,12 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s...@@ -747,12 +754,12 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s
747 __inc_gcount();754 __inc_gcount();
748 this->rdbuf()->sbumpc();755 this->rdbuf()->sbumpc();
749 }756 }
750#ifndef _LIBCPP_HAS_NO_EXCEPTIONS757# if _LIBCPP_HAS_EXCEPTIONS
751 } catch (...) {758 } catch (...) {
752 __state |= ios_base::badbit;759 __state |= ios_base::badbit;
753 // according to the spec, exceptions here are caught but not rethrown760 // according to the spec, exceptions here are caught but not rethrown
754 }761 }
755#endif // _LIBCPP_HAS_NO_EXCEPTIONS762# endif // _LIBCPP_HAS_EXCEPTIONS
756 if (__gc_ == 0)763 if (__gc_ == 0)
757 __state |= ios_base::failbit;764 __state |= ios_base::failbit;
758 this->setstate(__state);765 this->setstate(__state);
...@@ -767,9 +774,9 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ...@@ -767,9 +774,9 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
767 __gc_ = 0;774 __gc_ = 0;
768 sentry __sen(*this, true);775 sentry __sen(*this, true);
769 if (__sen) {776 if (__sen) {
770#ifndef _LIBCPP_HAS_NO_EXCEPTIONS777# if _LIBCPP_HAS_EXCEPTIONS
771 try {778 try {
772#endif // _LIBCPP_HAS_NO_EXCEPTIONS779# endif // _LIBCPP_HAS_EXCEPTIONS
773 while (true) {780 while (true) {
774 typename traits_type::int_type __i = this->rdbuf()->sgetc();781 typename traits_type::int_type __i = this->rdbuf()->sgetc();
775 if (traits_type::eq_int_type(__i, traits_type::eof())) {782 if (traits_type::eq_int_type(__i, traits_type::eof())) {
...@@ -790,7 +797,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ...@@ -790,7 +797,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
790 this->rdbuf()->sbumpc();797 this->rdbuf()->sbumpc();
791 __inc_gcount();798 __inc_gcount();
792 }799 }
793#ifndef _LIBCPP_HAS_NO_EXCEPTIONS800# if _LIBCPP_HAS_EXCEPTIONS
794 } catch (...) {801 } catch (...) {
795 __state |= ios_base::badbit;802 __state |= ios_base::badbit;
796 this->__setstate_nothrow(__state);803 this->__setstate_nothrow(__state);
...@@ -802,7 +809,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ...@@ -802,7 +809,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
802 throw;809 throw;
803 }810 }
804 }811 }
805#endif // _LIBCPP_HAS_NO_EXCEPTIONS812# endif // _LIBCPP_HAS_EXCEPTIONS
806 }813 }
807 if (__n > 0)814 if (__n > 0)
808 *__s = char_type();815 *__s = char_type();
...@@ -818,9 +825,9 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz...@@ -818,9 +825,9 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz
818 __gc_ = 0;825 __gc_ = 0;
819 sentry __sen(*this, true);826 sentry __sen(*this, true);
820 if (__sen) {827 if (__sen) {
821#ifndef _LIBCPP_HAS_NO_EXCEPTIONS828# if _LIBCPP_HAS_EXCEPTIONS
822 try {829 try {
823#endif // _LIBCPP_HAS_NO_EXCEPTIONS830# endif // _LIBCPP_HAS_EXCEPTIONS
824 if (__n == numeric_limits<streamsize>::max()) {831 if (__n == numeric_limits<streamsize>::max()) {
825 while (true) {832 while (true) {
826 typename traits_type::int_type __i = this->rdbuf()->sbumpc();833 typename traits_type::int_type __i = this->rdbuf()->sbumpc();
...@@ -844,7 +851,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz...@@ -844,7 +851,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz
844 break;851 break;
845 }852 }
846 }853 }
847#ifndef _LIBCPP_HAS_NO_EXCEPTIONS854# if _LIBCPP_HAS_EXCEPTIONS
848 } catch (...) {855 } catch (...) {
849 __state |= ios_base::badbit;856 __state |= ios_base::badbit;
850 this->__setstate_nothrow(__state);857 this->__setstate_nothrow(__state);
...@@ -852,7 +859,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz...@@ -852,7 +859,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz
852 throw;859 throw;
853 }860 }
854 }861 }
855#endif // _LIBCPP_HAS_NO_EXCEPTIONS862# endif // _LIBCPP_HAS_EXCEPTIONS
856 this->setstate(__state);863 this->setstate(__state);
857 }864 }
858 return *this;865 return *this;
...@@ -865,13 +872,13 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>...@@ -865,13 +872,13 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>
865 int_type __r = traits_type::eof();872 int_type __r = traits_type::eof();
866 sentry __sen(*this, true);873 sentry __sen(*this, true);
867 if (__sen) {874 if (__sen) {
868#ifndef _LIBCPP_HAS_NO_EXCEPTIONS875# if _LIBCPP_HAS_EXCEPTIONS
869 try {876 try {
870#endif // _LIBCPP_HAS_NO_EXCEPTIONS877# endif // _LIBCPP_HAS_EXCEPTIONS
871 __r = this->rdbuf()->sgetc();878 __r = this->rdbuf()->sgetc();
872 if (traits_type::eq_int_type(__r, traits_type::eof()))879 if (traits_type::eq_int_type(__r, traits_type::eof()))
873 __state |= ios_base::eofbit;880 __state |= ios_base::eofbit;
874#ifndef _LIBCPP_HAS_NO_EXCEPTIONS881# if _LIBCPP_HAS_EXCEPTIONS
875 } catch (...) {882 } catch (...) {
876 __state |= ios_base::badbit;883 __state |= ios_base::badbit;
877 this->__setstate_nothrow(__state);884 this->__setstate_nothrow(__state);
...@@ -879,7 +886,7 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>...@@ -879,7 +886,7 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>
879 throw;886 throw;
880 }887 }
881 }888 }
882#endif // _LIBCPP_HAS_NO_EXCEPTIONS889# endif // _LIBCPP_HAS_EXCEPTIONS
883 this->setstate(__state);890 this->setstate(__state);
884 }891 }
885 return __r;892 return __r;
...@@ -891,13 +898,13 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type*...@@ -891,13 +898,13 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type*
891 __gc_ = 0;898 __gc_ = 0;
892 sentry __sen(*this, true);899 sentry __sen(*this, true);
893 if (__sen) {900 if (__sen) {
894#ifndef _LIBCPP_HAS_NO_EXCEPTIONS901# if _LIBCPP_HAS_EXCEPTIONS
895 try {902 try {
896#endif // _LIBCPP_HAS_NO_EXCEPTIONS903# endif // _LIBCPP_HAS_EXCEPTIONS
897 __gc_ = this->rdbuf()->sgetn(__s, __n);904 __gc_ = this->rdbuf()->sgetn(__s, __n);
898 if (__gc_ != __n)905 if (__gc_ != __n)
899 __state |= ios_base::failbit | ios_base::eofbit;906 __state |= ios_base::failbit | ios_base::eofbit;
900#ifndef _LIBCPP_HAS_NO_EXCEPTIONS907# if _LIBCPP_HAS_EXCEPTIONS
901 } catch (...) {908 } catch (...) {
902 __state |= ios_base::badbit;909 __state |= ios_base::badbit;
903 this->__setstate_nothrow(__state);910 this->__setstate_nothrow(__state);
...@@ -905,7 +912,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type*...@@ -905,7 +912,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type*
905 throw;912 throw;
906 }913 }
907 }914 }
908#endif // _LIBCPP_HAS_NO_EXCEPTIONS915# endif // _LIBCPP_HAS_EXCEPTIONS
909 } else {916 } else {
910 __state |= ios_base::failbit;917 __state |= ios_base::failbit;
911 }918 }
...@@ -919,9 +926,9 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _...@@ -919,9 +926,9 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _
919 __gc_ = 0;926 __gc_ = 0;
920 sentry __sen(*this, true);927 sentry __sen(*this, true);
921 if (__sen) {928 if (__sen) {
922#ifndef _LIBCPP_HAS_NO_EXCEPTIONS929# if _LIBCPP_HAS_EXCEPTIONS
923 try {930 try {
924#endif // _LIBCPP_HAS_NO_EXCEPTIONS931# endif // _LIBCPP_HAS_EXCEPTIONS
925 streamsize __c = this->rdbuf()->in_avail();932 streamsize __c = this->rdbuf()->in_avail();
926 switch (__c) {933 switch (__c) {
927 case -1:934 case -1:
...@@ -936,7 +943,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _...@@ -936,7 +943,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _
936 __state |= ios_base::failbit | ios_base::eofbit;943 __state |= ios_base::failbit | ios_base::eofbit;
937 break;944 break;
938 }945 }
939#ifndef _LIBCPP_HAS_NO_EXCEPTIONS946# if _LIBCPP_HAS_EXCEPTIONS
940 } catch (...) {947 } catch (...) {
941 __state |= ios_base::badbit;948 __state |= ios_base::badbit;
942 this->__setstate_nothrow(__state);949 this->__setstate_nothrow(__state);
...@@ -944,7 +951,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _...@@ -944,7 +951,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _
944 throw;951 throw;
945 }952 }
946 }953 }
947#endif // _LIBCPP_HAS_NO_EXCEPTIONS954# endif // _LIBCPP_HAS_EXCEPTIONS
948 } else {955 } else {
949 __state |= ios_base::failbit;956 __state |= ios_base::failbit;
950 }957 }
...@@ -959,12 +966,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ...@@ -959,12 +966,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ
959 this->clear(__state);966 this->clear(__state);
960 sentry __sen(*this, true);967 sentry __sen(*this, true);
961 if (__sen) {968 if (__sen) {
962#ifndef _LIBCPP_HAS_NO_EXCEPTIONS969# if _LIBCPP_HAS_EXCEPTIONS
963 try {970 try {
964#endif // _LIBCPP_HAS_NO_EXCEPTIONS971# endif // _LIBCPP_HAS_EXCEPTIONS
965 if (this->rdbuf() == nullptr || this->rdbuf()->sputbackc(__c) == traits_type::eof())972 if (this->rdbuf() == nullptr || this->rdbuf()->sputbackc(__c) == traits_type::eof())
966 __state |= ios_base::badbit;973 __state |= ios_base::badbit;
967#ifndef _LIBCPP_HAS_NO_EXCEPTIONS974# if _LIBCPP_HAS_EXCEPTIONS
968 } catch (...) {975 } catch (...) {
969 __state |= ios_base::badbit;976 __state |= ios_base::badbit;
970 this->__setstate_nothrow(__state);977 this->__setstate_nothrow(__state);
...@@ -972,7 +979,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ...@@ -972,7 +979,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ
972 throw;979 throw;
973 }980 }
974 }981 }
975#endif // _LIBCPP_HAS_NO_EXCEPTIONS982# endif // _LIBCPP_HAS_EXCEPTIONS
976 } else {983 } else {
977 __state |= ios_base::failbit;984 __state |= ios_base::failbit;
978 }985 }
...@@ -987,12 +994,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() {...@@ -987,12 +994,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() {
987 this->clear(__state);994 this->clear(__state);
988 sentry __sen(*this, true);995 sentry __sen(*this, true);
989 if (__sen) {996 if (__sen) {
990#ifndef _LIBCPP_HAS_NO_EXCEPTIONS997# if _LIBCPP_HAS_EXCEPTIONS
991 try {998 try {
992#endif // _LIBCPP_HAS_NO_EXCEPTIONS999# endif // _LIBCPP_HAS_EXCEPTIONS
993 if (this->rdbuf() == nullptr || this->rdbuf()->sungetc() == traits_type::eof())1000 if (this->rdbuf() == nullptr || this->rdbuf()->sungetc() == traits_type::eof())
994 __state |= ios_base::badbit;1001 __state |= ios_base::badbit;
995#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1002# if _LIBCPP_HAS_EXCEPTIONS
996 } catch (...) {1003 } catch (...) {
997 __state |= ios_base::badbit;1004 __state |= ios_base::badbit;
998 this->__setstate_nothrow(__state);1005 this->__setstate_nothrow(__state);
...@@ -1000,7 +1007,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() {...@@ -1000,7 +1007,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() {
1000 throw;1007 throw;
1001 }1008 }
1002 }1009 }
1003#endif // _LIBCPP_HAS_NO_EXCEPTIONS1010# endif // _LIBCPP_HAS_EXCEPTIONS
1004 } else {1011 } else {
1005 __state |= ios_base::failbit;1012 __state |= ios_base::failbit;
1006 }1013 }
...@@ -1017,14 +1024,14 @@ int basic_istream<_CharT, _Traits>::sync() {...@@ -1017,14 +1024,14 @@ int basic_istream<_CharT, _Traits>::sync() {
10171024
1018 int __r = 0;1025 int __r = 0;
1019 if (__sen) {1026 if (__sen) {
1020#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1027# if _LIBCPP_HAS_EXCEPTIONS
1021 try {1028 try {
1022#endif // _LIBCPP_HAS_NO_EXCEPTIONS1029# endif // _LIBCPP_HAS_EXCEPTIONS
1023 if (this->rdbuf()->pubsync() == -1) {1030 if (this->rdbuf()->pubsync() == -1) {
1024 __state |= ios_base::badbit;1031 __state |= ios_base::badbit;
1025 __r = -1;1032 __r = -1;
1026 }1033 }
1027#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1034# if _LIBCPP_HAS_EXCEPTIONS
1028 } catch (...) {1035 } catch (...) {
1029 __state |= ios_base::badbit;1036 __state |= ios_base::badbit;
1030 this->__setstate_nothrow(__state);1037 this->__setstate_nothrow(__state);
...@@ -1032,7 +1039,7 @@ int basic_istream<_CharT, _Traits>::sync() {...@@ -1032,7 +1039,7 @@ int basic_istream<_CharT, _Traits>::sync() {
1032 throw;1039 throw;
1033 }1040 }
1034 }1041 }
1035#endif // _LIBCPP_HAS_NO_EXCEPTIONS1042# endif // _LIBCPP_HAS_EXCEPTIONS
1036 this->setstate(__state);1043 this->setstate(__state);
1037 }1044 }
1038 return __r;1045 return __r;
...@@ -1044,11 +1051,11 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits>...@@ -1044,11 +1051,11 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits>
1044 pos_type __r(-1);1051 pos_type __r(-1);
1045 sentry __sen(*this, true);1052 sentry __sen(*this, true);
1046 if (__sen) {1053 if (__sen) {
1047#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1054# if _LIBCPP_HAS_EXCEPTIONS
1048 try {1055 try {
1049#endif // _LIBCPP_HAS_NO_EXCEPTIONS1056# endif // _LIBCPP_HAS_EXCEPTIONS
1050 __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);1057 __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
1051#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1058# if _LIBCPP_HAS_EXCEPTIONS
1052 } catch (...) {1059 } catch (...) {
1053 __state |= ios_base::badbit;1060 __state |= ios_base::badbit;
1054 this->__setstate_nothrow(__state);1061 this->__setstate_nothrow(__state);
...@@ -1056,7 +1063,7 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits>...@@ -1056,7 +1063,7 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits>
1056 throw;1063 throw;
1057 }1064 }
1058 }1065 }
1059#endif // _LIBCPP_HAS_NO_EXCEPTIONS1066# endif // _LIBCPP_HAS_EXCEPTIONS
1060 this->setstate(__state);1067 this->setstate(__state);
1061 }1068 }
1062 return __r;1069 return __r;
...@@ -1068,12 +1075,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _...@@ -1068,12 +1075,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _
1068 this->clear(__state);1075 this->clear(__state);
1069 sentry __sen(*this, true);1076 sentry __sen(*this, true);
1070 if (__sen) {1077 if (__sen) {
1071#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1078# if _LIBCPP_HAS_EXCEPTIONS
1072 try {1079 try {
1073#endif // _LIBCPP_HAS_NO_EXCEPTIONS1080# endif // _LIBCPP_HAS_EXCEPTIONS
1074 if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))1081 if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))
1075 __state |= ios_base::failbit;1082 __state |= ios_base::failbit;
1076#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1083# if _LIBCPP_HAS_EXCEPTIONS
1077 } catch (...) {1084 } catch (...) {
1078 __state |= ios_base::badbit;1085 __state |= ios_base::badbit;
1079 this->__setstate_nothrow(__state);1086 this->__setstate_nothrow(__state);
...@@ -1081,7 +1088,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _...@@ -1081,7 +1088,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _
1081 throw;1088 throw;
1082 }1089 }
1083 }1090 }
1084#endif // _LIBCPP_HAS_NO_EXCEPTIONS1091# endif // _LIBCPP_HAS_EXCEPTIONS
1085 this->setstate(__state);1092 this->setstate(__state);
1086 }1093 }
1087 return *this;1094 return *this;
...@@ -1093,12 +1100,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _...@@ -1093,12 +1100,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _
1093 this->clear(__state);1100 this->clear(__state);
1094 sentry __sen(*this, true);1101 sentry __sen(*this, true);
1095 if (__sen) {1102 if (__sen) {
1096#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1103# if _LIBCPP_HAS_EXCEPTIONS
1097 try {1104 try {
1098#endif // _LIBCPP_HAS_NO_EXCEPTIONS1105# endif // _LIBCPP_HAS_EXCEPTIONS
1099 if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1))1106 if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1))
1100 __state |= ios_base::failbit;1107 __state |= ios_base::failbit;
1101#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1108# if _LIBCPP_HAS_EXCEPTIONS
1102 } catch (...) {1109 } catch (...) {
1103 __state |= ios_base::badbit;1110 __state |= ios_base::badbit;
1104 this->__setstate_nothrow(__state);1111 this->__setstate_nothrow(__state);
...@@ -1106,7 +1113,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _...@@ -1106,7 +1113,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _
1106 throw;1113 throw;
1107 }1114 }
1108 }1115 }
1109#endif // _LIBCPP_HAS_NO_EXCEPTIONS1116# endif // _LIBCPP_HAS_EXCEPTIONS
1110 this->setstate(__state);1117 this->setstate(__state);
1111 }1118 }
1112 return *this;1119 return *this;
...@@ -1117,9 +1124,9 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _...@@ -1117,9 +1124,9 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _
1117 ios_base::iostate __state = ios_base::goodbit;1124 ios_base::iostate __state = ios_base::goodbit;
1118 typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);1125 typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
1119 if (__sen) {1126 if (__sen) {
1120#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1127# if _LIBCPP_HAS_EXCEPTIONS
1121 try {1128 try {
1122#endif // _LIBCPP_HAS_NO_EXCEPTIONS1129# endif // _LIBCPP_HAS_EXCEPTIONS
1123 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());1130 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
1124 while (true) {1131 while (true) {
1125 typename _Traits::int_type __i = __is.rdbuf()->sgetc();1132 typename _Traits::int_type __i = __is.rdbuf()->sgetc();
...@@ -1131,7 +1138,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _...@@ -1131,7 +1138,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _
1131 break;1138 break;
1132 __is.rdbuf()->sbumpc();1139 __is.rdbuf()->sbumpc();
1133 }1140 }
1134#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1141# if _LIBCPP_HAS_EXCEPTIONS
1135 } catch (...) {1142 } catch (...) {
1136 __state |= ios_base::badbit;1143 __state |= ios_base::badbit;
1137 __is.__setstate_nothrow(__state);1144 __is.__setstate_nothrow(__state);
...@@ -1139,7 +1146,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _...@@ -1139,7 +1146,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _
1139 throw;1146 throw;
1140 }1147 }
1141 }1148 }
1142#endif // _LIBCPP_HAS_NO_EXCEPTIONS1149# endif // _LIBCPP_HAS_EXCEPTIONS
1143 __is.setstate(__state);1150 __is.setstate(__state);
1144 }1151 }
1145 return __is;1152 return __is;
...@@ -1207,16 +1214,21 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _...@@ -1207,16 +1214,21 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _
1207 ios_base::iostate __state = ios_base::goodbit;1214 ios_base::iostate __state = ios_base::goodbit;
1208 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);1215 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
1209 if (__sen) {1216 if (__sen) {
1210#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1217# if _LIBCPP_HAS_EXCEPTIONS
1211 try {1218 try {
1212#endif1219# endif
1213 __str.clear();1220 __str.clear();
1214 streamsize __n = __is.width();1221 using _Size = typename basic_string<_CharT, _Traits, _Allocator>::size_type;
1215 if (__n <= 0)1222 streamsize const __width = __is.width();
1216 __n = __str.max_size();1223 _Size const __max_size = __str.max_size();
1217 if (__n <= 0)1224 _Size __n;
1218 __n = numeric_limits<streamsize>::max();1225 if (__width <= 0) {
1219 streamsize __c = 0;1226 __n = __max_size;
1227 } else {
1228 __n = std::__to_unsigned_like(__width) < __max_size ? static_cast<_Size>(__width) : __max_size;
1229 }
1230
1231 _Size __c = 0;
1220 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());1232 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
1221 while (__c < __n) {1233 while (__c < __n) {
1222 typename _Traits::int_type __i = __is.rdbuf()->sgetc();1234 typename _Traits::int_type __i = __is.rdbuf()->sgetc();
...@@ -1234,7 +1246,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _...@@ -1234,7 +1246,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _
1234 __is.width(0);1246 __is.width(0);
1235 if (__c == 0)1247 if (__c == 0)
1236 __state |= ios_base::failbit;1248 __state |= ios_base::failbit;
1237#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1249# if _LIBCPP_HAS_EXCEPTIONS
1238 } catch (...) {1250 } catch (...) {
1239 __state |= ios_base::badbit;1251 __state |= ios_base::badbit;
1240 __is.__setstate_nothrow(__state);1252 __is.__setstate_nothrow(__state);
...@@ -1242,7 +1254,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _...@@ -1242,7 +1254,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _
1242 throw;1254 throw;
1243 }1255 }
1244 }1256 }
1245#endif1257# endif
1246 __is.setstate(__state);1258 __is.setstate(__state);
1247 }1259 }
1248 return __is;1260 return __is;
...@@ -1254,9 +1266,9 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All...@@ -1254,9 +1266,9 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All
1254 ios_base::iostate __state = ios_base::goodbit;1266 ios_base::iostate __state = ios_base::goodbit;
1255 typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);1267 typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
1256 if (__sen) {1268 if (__sen) {
1257#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1269# if _LIBCPP_HAS_EXCEPTIONS
1258 try {1270 try {
1259#endif1271# endif
1260 __str.clear();1272 __str.clear();
1261 streamsize __extr = 0;1273 streamsize __extr = 0;
1262 while (true) {1274 while (true) {
...@@ -1277,7 +1289,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All...@@ -1277,7 +1289,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All
1277 }1289 }
1278 if (__extr == 0)1290 if (__extr == 0)
1279 __state |= ios_base::failbit;1291 __state |= ios_base::failbit;
1280#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1292# if _LIBCPP_HAS_EXCEPTIONS
1281 } catch (...) {1293 } catch (...) {
1282 __state |= ios_base::badbit;1294 __state |= ios_base::badbit;
1283 __is.__setstate_nothrow(__state);1295 __is.__setstate_nothrow(__state);
...@@ -1285,7 +1297,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All...@@ -1285,7 +1297,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All
1285 throw;1297 throw;
1286 }1298 }
1287 }1299 }
1288#endif1300# endif
1289 __is.setstate(__state);1301 __is.setstate(__state);
1290 }1302 }
1291 return __is;1303 return __is;
...@@ -1315,9 +1327,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) {...@@ -1315,9 +1327,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) {
1315 ios_base::iostate __state = ios_base::goodbit;1327 ios_base::iostate __state = ios_base::goodbit;
1316 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);1328 typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
1317 if (__sen) {1329 if (__sen) {
1318#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1330# if _LIBCPP_HAS_EXCEPTIONS
1319 try {1331 try {
1320#endif1332# endif
1321 basic_string<_CharT, _Traits> __str;1333 basic_string<_CharT, _Traits> __str;
1322 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());1334 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
1323 size_t __c = 0;1335 size_t __c = 0;
...@@ -1339,7 +1351,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) {...@@ -1339,7 +1351,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) {
1339 __x = bitset<_Size>(__str);1351 __x = bitset<_Size>(__str);
1340 if (_Size > 0 && __c == 0)1352 if (_Size > 0 && __c == 0)
1341 __state |= ios_base::failbit;1353 __state |= ios_base::failbit;
1342#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1354# if _LIBCPP_HAS_EXCEPTIONS
1343 } catch (...) {1355 } catch (...) {
1344 __state |= ios_base::badbit;1356 __state |= ios_base::badbit;
1345 __is.__setstate_nothrow(__state);1357 __is.__setstate_nothrow(__state);
...@@ -1347,27 +1359,31 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) {...@@ -1347,27 +1359,31 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) {
1347 throw;1359 throw;
1348 }1360 }
1349 }1361 }
1350#endif1362# endif
1351 __is.setstate(__state);1363 __is.setstate(__state);
1352 }1364 }
1353 return __is;1365 return __is;
1354}1366}
13551367
1356extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>;1368extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>;
1357#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1369# if _LIBCPP_HAS_WIDE_CHARACTERS
1358extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>;1370extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>;
1359#endif1371# endif
1360extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>;1372extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>;
13611373
1362_LIBCPP_END_NAMESPACE_STD1374_LIBCPP_END_NAMESPACE_STD
13631375
1364#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 201376# endif // _LIBCPP_HAS_LOCALIZATION
1365# include <concepts>1377
1366# include <iosfwd>1378# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1367# include <ostream>1379# include <concepts>
1368# include <type_traits>1380# include <iosfwd>
1369#endif1381# include <ostream>
1382# include <type_traits>
1383# endif
13701384
1371_LIBCPP_POP_MACROS1385_LIBCPP_POP_MACROS
13721386
1387#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
1388
1373#endif // _LIBCPP_ISTREAM1389#endif // _LIBCPP_ISTREAM
lib/libcxx/include/iterator+72-67
...@@ -679,76 +679,81 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;...@@ -679,76 +679,81 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
679679
680*/680*/
681681
682#include <__config>682#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
683#include <__iterator/access.h>683# include <__cxx03/iterator>
684#include <__iterator/advance.h>684#else
685#include <__iterator/back_insert_iterator.h>685# include <__config>
686#include <__iterator/distance.h>686# include <__iterator/access.h>
687#include <__iterator/front_insert_iterator.h>687# include <__iterator/advance.h>
688#include <__iterator/insert_iterator.h>688# include <__iterator/back_insert_iterator.h>
689#include <__iterator/istream_iterator.h>689# include <__iterator/distance.h>
690#include <__iterator/istreambuf_iterator.h>690# include <__iterator/front_insert_iterator.h>
691#include <__iterator/iterator.h>691# include <__iterator/insert_iterator.h>
692#include <__iterator/iterator_traits.h>692# include <__iterator/istream_iterator.h>
693#include <__iterator/move_iterator.h>693# include <__iterator/istreambuf_iterator.h>
694#include <__iterator/next.h>694# include <__iterator/iterator.h>
695#include <__iterator/ostream_iterator.h>695# include <__iterator/iterator_traits.h>
696#include <__iterator/ostreambuf_iterator.h>696# include <__iterator/move_iterator.h>
697#include <__iterator/prev.h>697# include <__iterator/next.h>
698#include <__iterator/reverse_iterator.h>698# include <__iterator/ostream_iterator.h>
699#include <__iterator/wrap_iter.h>699# include <__iterator/ostreambuf_iterator.h>
700700# include <__iterator/prev.h>
701#if _LIBCPP_STD_VER >= 14701# include <__iterator/reverse_iterator.h>
702# include <__iterator/reverse_access.h>702# include <__iterator/wrap_iter.h>
703#endif703
704704# if _LIBCPP_STD_VER >= 14
705#if _LIBCPP_STD_VER >= 17705# include <__iterator/reverse_access.h>
706# include <__iterator/data.h>706# endif
707# include <__iterator/empty.h>707
708# include <__iterator/size.h>708# if _LIBCPP_STD_VER >= 17
709#endif709# include <__iterator/data.h>
710710# include <__iterator/empty.h>
711#if _LIBCPP_STD_VER >= 20711# include <__iterator/size.h>
712# include <__iterator/common_iterator.h>712# endif
713# include <__iterator/concepts.h>713
714# include <__iterator/counted_iterator.h>714# if _LIBCPP_STD_VER >= 20
715# include <__iterator/default_sentinel.h>715# include <__iterator/common_iterator.h>
716# include <__iterator/incrementable_traits.h>716# include <__iterator/concepts.h>
717# include <__iterator/indirectly_comparable.h>717# include <__iterator/counted_iterator.h>
718# include <__iterator/iter_move.h>718# include <__iterator/default_sentinel.h>
719# include <__iterator/iter_swap.h>719# include <__iterator/incrementable_traits.h>
720# include <__iterator/mergeable.h>720# include <__iterator/indirectly_comparable.h>
721# include <__iterator/move_sentinel.h>721# include <__iterator/iter_move.h>
722# include <__iterator/permutable.h>722# include <__iterator/iter_swap.h>
723# include <__iterator/projected.h>723# include <__iterator/mergeable.h>
724# include <__iterator/readable_traits.h>724# include <__iterator/move_sentinel.h>
725# include <__iterator/sortable.h>725# include <__iterator/permutable.h>
726# include <__iterator/unreachable_sentinel.h>726# include <__iterator/projected.h>
727#endif727# include <__iterator/readable_traits.h>
728728# include <__iterator/sortable.h>
729#include <version>729# include <__iterator/unreachable_sentinel.h>
730# endif
731
732# include <version>
730733
731// standard-mandated includes734// standard-mandated includes
732735
733// [iterator.synopsis]736// [iterator.synopsis]
734#include <compare>737# include <compare>
735#include <concepts>738# include <concepts>
736739
737#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)740# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
738# pragma GCC system_header741# pragma GCC system_header
739#endif742# endif
740743
741#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17744# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
742# include <variant>745# include <variant>
743#endif746# endif
744747
745#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20748# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
746# include <cstdlib>749# include <cstddef>
747# include <exception>750# include <cstdlib>
748# include <new>751# include <exception>
749# include <type_traits>752# include <new>
750# include <typeinfo>753# include <type_traits>
751# include <utility>754# include <typeinfo>
752#endif755# include <utility>
756# endif
757#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
753758
754#endif // _LIBCPP_ITERATOR759#endif // _LIBCPP_ITERATOR
lib/libcxx/include/latch+31-25
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16namespace std16namespace std
17{17{
1818
19 class latch19 class latch // since C++20
20 {20 {
21 public:21 public:
22 static constexpr ptrdiff_t max() noexcept;22 static constexpr ptrdiff_t max() noexcept;
...@@ -40,31 +40,34 @@ namespace std...@@ -40,31 +40,34 @@ namespace std
4040
41*/41*/
4242
43#include <__config>43#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
44# include <__cxx03/latch>
45#else
46# include <__config>
4447
45#if !defined(_LIBCPP_HAS_NO_THREADS)48# if _LIBCPP_HAS_THREADS
4649
47# include <__assert>50# include <__assert>
48# include <__atomic/atomic_base.h>51# include <__atomic/atomic.h>
49# include <__atomic/atomic_sync.h>52# include <__atomic/atomic_sync.h>
50# include <__atomic/memory_order.h>53# include <__atomic/memory_order.h>
51# include <cstddef>54# include <__cstddef/ptrdiff_t.h>
52# include <limits>55# include <limits>
53# include <version>56# include <version>
5457
55# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)58# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
56# pragma GCC system_header59# pragma GCC system_header
57# endif60# endif
5861
59_LIBCPP_PUSH_MACROS62_LIBCPP_PUSH_MACROS
60# include <__undef_macros>63# include <__undef_macros>
6164
62# if _LIBCPP_STD_VER >= 1465# if _LIBCPP_STD_VER >= 20
6366
64_LIBCPP_BEGIN_NAMESPACE_STD67_LIBCPP_BEGIN_NAMESPACE_STD
6568
66class _LIBCPP_DEPRECATED_ATOMIC_SYNC latch {69class latch {
67 __atomic_base<ptrdiff_t> __a_;70 atomic<ptrdiff_t> __a_;
6871
69public:72public:
70 static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { return numeric_limits<ptrdiff_t>::max(); }73 static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { return numeric_limits<ptrdiff_t>::max(); }
...@@ -99,8 +102,9 @@ public:...@@ -99,8 +102,9 @@ public:
99 return try_wait_impl(__value);102 return try_wait_impl(__value);
100 }103 }
101 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait() const {104 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait() const {
102 std::__atomic_wait_unless(105 std::__atomic_wait_unless(__a_, memory_order_acquire, [this](ptrdiff_t& __value) -> bool {
103 __a_, [this](ptrdiff_t& __value) -> bool { return try_wait_impl(__value); }, memory_order_acquire);106 return try_wait_impl(__value);
107 });
104 }108 }
105 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_wait(ptrdiff_t __update = 1) {109 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_wait(ptrdiff_t __update = 1) {
106 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "latch::arrive_and_wait called with a negative value");110 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "latch::arrive_and_wait called with a negative value");
...@@ -116,14 +120,16 @@ private:...@@ -116,14 +120,16 @@ private:
116120
117_LIBCPP_END_NAMESPACE_STD121_LIBCPP_END_NAMESPACE_STD
118122
119# endif // _LIBCPP_STD_VER >= 14123# endif // _LIBCPP_STD_VER >= 20
120124
121_LIBCPP_POP_MACROS125_LIBCPP_POP_MACROS
122126
123#endif // !defined(_LIBCPP_HAS_NO_THREADS)127# endif // _LIBCPP_HAS_THREADS
124128
125#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20129# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
126# include <atomic>130# include <atomic>
127#endif131# include <cstddef>
132# endif
133#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
128134
129#endif //_LIBCPP_LATCH135#endif // _LIBCPP_LATCH
lib/libcxx/include/limits+118-161
...@@ -102,18 +102,21 @@ template<> class numeric_limits<cv long double>;...@@ -102,18 +102,21 @@ template<> class numeric_limits<cv long double>;
102102
103*/103*/
104104
105#include <__config>105#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
106#include <__type_traits/is_arithmetic.h>106# include <__cxx03/limits>
107#include <__type_traits/is_signed.h>107#else
108#include <__type_traits/remove_cv.h>108# include <__config>
109# include <__type_traits/is_arithmetic.h>
110# include <__type_traits/is_signed.h>
111# include <__type_traits/remove_cv.h>
109112
110#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)113# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
111# pragma GCC system_header114# pragma GCC system_header
112#endif115# endif
113116
114_LIBCPP_PUSH_MACROS117_LIBCPP_PUSH_MACROS
115#include <__undef_macros>118# include <__undef_macros>
116#include <version>119# include <version>
117120
118_LIBCPP_BEGIN_NAMESPACE_STD121_LIBCPP_BEGIN_NAMESPACE_STD
119122
...@@ -137,9 +140,9 @@ protected:...@@ -137,9 +140,9 @@ protected:
137 typedef _Tp type;140 typedef _Tp type;
138141
139 static _LIBCPP_CONSTEXPR const bool is_specialized = false;142 static _LIBCPP_CONSTEXPR const bool is_specialized = false;
140 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); }143 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); }
141 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); }144 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); }
142 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); }145 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); }
143146
144 static _LIBCPP_CONSTEXPR const int digits = 0;147 static _LIBCPP_CONSTEXPR const int digits = 0;
145 static _LIBCPP_CONSTEXPR const int digits10 = 0;148 static _LIBCPP_CONSTEXPR const int digits10 = 0;
...@@ -148,8 +151,8 @@ protected:...@@ -148,8 +151,8 @@ protected:
148 static _LIBCPP_CONSTEXPR const bool is_integer = false;151 static _LIBCPP_CONSTEXPR const bool is_integer = false;
149 static _LIBCPP_CONSTEXPR const bool is_exact = false;152 static _LIBCPP_CONSTEXPR const bool is_exact = false;
150 static _LIBCPP_CONSTEXPR const int radix = 0;153 static _LIBCPP_CONSTEXPR const int radix = 0;
151 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); }154 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); }
152 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); }155 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); }
153156
154 static _LIBCPP_CONSTEXPR const int min_exponent = 0;157 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
155 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;158 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
...@@ -161,10 +164,10 @@ protected:...@@ -161,10 +164,10 @@ protected:
161 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;164 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
162 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;165 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
163 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;166 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
164 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); }167 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); }
165 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); }168 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); }
166 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); }169 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); }
167 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); }170 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); }
168171
169 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;172 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
170 static _LIBCPP_CONSTEXPR const bool is_bounded = false;173 static _LIBCPP_CONSTEXPR const bool is_bounded = false;
...@@ -198,15 +201,15 @@ protected:...@@ -198,15 +201,15 @@ protected:
198 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;201 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
199 static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value;202 static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value;
200 static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);203 static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
201 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }204 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }
202 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }205 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }
203 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }206 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }
204207
205 static _LIBCPP_CONSTEXPR const bool is_integer = true;208 static _LIBCPP_CONSTEXPR const bool is_integer = true;
206 static _LIBCPP_CONSTEXPR const bool is_exact = true;209 static _LIBCPP_CONSTEXPR const bool is_exact = true;
207 static _LIBCPP_CONSTEXPR const int radix = 2;210 static _LIBCPP_CONSTEXPR const int radix = 2;
208 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }211 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }
209 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }212 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }
210213
211 static _LIBCPP_CONSTEXPR const int min_exponent = 0;214 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
212 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;215 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
...@@ -218,20 +221,20 @@ protected:...@@ -218,20 +221,20 @@ protected:
218 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;221 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
219 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;222 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
220 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;223 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
221 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }224 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }
222 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }225 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }
223 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }226 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }
224 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }227 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }
225228
226 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;229 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
227 static _LIBCPP_CONSTEXPR const bool is_bounded = true;230 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
228 static _LIBCPP_CONSTEXPR const bool is_modulo = !std::is_signed<_Tp>::value;231 static _LIBCPP_CONSTEXPR const bool is_modulo = !std::is_signed<_Tp>::value;
229232
230#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || defined(__wasm__)233# if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || defined(__wasm__)
231 static _LIBCPP_CONSTEXPR const bool traps = true;234 static _LIBCPP_CONSTEXPR const bool traps = true;
232#else235# else
233 static _LIBCPP_CONSTEXPR const bool traps = false;236 static _LIBCPP_CONSTEXPR const bool traps = false;
234#endif237# endif
235 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;238 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
236 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;239 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
237};240};
...@@ -249,15 +252,15 @@ protected:...@@ -249,15 +252,15 @@ protected:
249 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;252 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
250 static _LIBCPP_CONSTEXPR const type __min = false;253 static _LIBCPP_CONSTEXPR const type __min = false;
251 static _LIBCPP_CONSTEXPR const type __max = true;254 static _LIBCPP_CONSTEXPR const type __max = true;
252 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }255 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }
253 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }256 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }
254 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }257 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }
255258
256 static _LIBCPP_CONSTEXPR const bool is_integer = true;259 static _LIBCPP_CONSTEXPR const bool is_integer = true;
257 static _LIBCPP_CONSTEXPR const bool is_exact = true;260 static _LIBCPP_CONSTEXPR const bool is_exact = true;
258 static _LIBCPP_CONSTEXPR const int radix = 2;261 static _LIBCPP_CONSTEXPR const int radix = 2;
259 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }262 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }
260 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }263 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }
261264
262 static _LIBCPP_CONSTEXPR const int min_exponent = 0;265 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
263 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;266 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
...@@ -269,10 +272,10 @@ protected:...@@ -269,10 +272,10 @@ protected:
269 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;272 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
270 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;273 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
271 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;274 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
272 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }275 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }
273 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }276 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }
274 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }277 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }
275 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }278 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }
276279
277 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;280 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
278 static _LIBCPP_CONSTEXPR const bool is_bounded = true;281 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
...@@ -294,15 +297,15 @@ protected:...@@ -294,15 +297,15 @@ protected:
294 static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__;297 static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__;
295 static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__;298 static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__;
296 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;299 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;
297 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; }300 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; }
298 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; }301 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; }
299 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }302 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
300303
301 static _LIBCPP_CONSTEXPR const bool is_integer = false;304 static _LIBCPP_CONSTEXPR const bool is_integer = false;
302 static _LIBCPP_CONSTEXPR const bool is_exact = false;305 static _LIBCPP_CONSTEXPR const bool is_exact = false;
303 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;306 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
304 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; }307 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; }
305 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; }308 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; }
306309
307 static _LIBCPP_CONSTEXPR const int min_exponent = __FLT_MIN_EXP__;310 static _LIBCPP_CONSTEXPR const int min_exponent = __FLT_MIN_EXP__;
308 static _LIBCPP_CONSTEXPR const int min_exponent10 = __FLT_MIN_10_EXP__;311 static _LIBCPP_CONSTEXPR const int min_exponent10 = __FLT_MIN_10_EXP__;
...@@ -314,16 +317,16 @@ protected:...@@ -314,16 +317,16 @@ protected:
314 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;317 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
315 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;318 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
316 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;319 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
317 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {320 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
318 return __builtin_huge_valf();321 return __builtin_huge_valf();
319 }322 }
320 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {323 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
321 return __builtin_nanf("");324 return __builtin_nanf("");
322 }325 }
323 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {326 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
324 return __builtin_nansf("");327 return __builtin_nansf("");
325 }328 }
326 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {329 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
327 return __FLT_DENORM_MIN__;330 return __FLT_DENORM_MIN__;
328 }331 }
329332
...@@ -332,11 +335,11 @@ protected:...@@ -332,11 +335,11 @@ protected:
332 static _LIBCPP_CONSTEXPR const bool is_modulo = false;335 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
333336
334 static _LIBCPP_CONSTEXPR const bool traps = false;337 static _LIBCPP_CONSTEXPR const bool traps = false;
335#if (defined(__arm__) || defined(__aarch64__))338# if (defined(__arm__) || defined(__aarch64__))
336 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;339 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
337#else340# else
338 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;341 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
339#endif342# endif
340 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;343 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
341};344};
342345
...@@ -351,15 +354,15 @@ protected:...@@ -351,15 +354,15 @@ protected:
351 static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__;354 static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__;
352 static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__;355 static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__;
353 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;356 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;
354 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; }357 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; }
355 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; }358 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; }
356 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }359 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
357360
358 static _LIBCPP_CONSTEXPR const bool is_integer = false;361 static _LIBCPP_CONSTEXPR const bool is_integer = false;
359 static _LIBCPP_CONSTEXPR const bool is_exact = false;362 static _LIBCPP_CONSTEXPR const bool is_exact = false;
360 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;363 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
361 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; }364 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; }
362 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; }365 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; }
363366
364 static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__;367 static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__;
365 static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__;368 static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__;
...@@ -371,16 +374,16 @@ protected:...@@ -371,16 +374,16 @@ protected:
371 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;374 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
372 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;375 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
373 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;376 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
374 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {377 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
375 return __builtin_huge_val();378 return __builtin_huge_val();
376 }379 }
377 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {380 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
378 return __builtin_nan("");381 return __builtin_nan("");
379 }382 }
380 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {383 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
381 return __builtin_nans("");384 return __builtin_nans("");
382 }385 }
383 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {386 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
384 return __DBL_DENORM_MIN__;387 return __DBL_DENORM_MIN__;
385 }388 }
386389
...@@ -389,11 +392,11 @@ protected:...@@ -389,11 +392,11 @@ protected:
389 static _LIBCPP_CONSTEXPR const bool is_modulo = false;392 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
390393
391 static _LIBCPP_CONSTEXPR const bool traps = false;394 static _LIBCPP_CONSTEXPR const bool traps = false;
392#if (defined(__arm__) || defined(__aarch64__))395# if (defined(__arm__) || defined(__aarch64__))
393 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;396 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
394#else397# else
395 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;398 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
396#endif399# endif
397 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;400 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
398};401};
399402
...@@ -408,15 +411,15 @@ protected:...@@ -408,15 +411,15 @@ protected:
408 static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__;411 static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__;
409 static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__;412 static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__;
410 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;413 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;
411 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; }414 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; }
412 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; }415 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; }
413 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }416 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
414417
415 static _LIBCPP_CONSTEXPR const bool is_integer = false;418 static _LIBCPP_CONSTEXPR const bool is_integer = false;
416 static _LIBCPP_CONSTEXPR const bool is_exact = false;419 static _LIBCPP_CONSTEXPR const bool is_exact = false;
417 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;420 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
418 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; }421 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; }
419 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; }422 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; }
420423
421 static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__;424 static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__;
422 static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__;425 static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__;
...@@ -428,33 +431,33 @@ protected:...@@ -428,33 +431,33 @@ protected:
428 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;431 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
429 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;432 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
430 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;433 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
431 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {434 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
432 return __builtin_huge_vall();435 return __builtin_huge_vall();
433 }436 }
434 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {437 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
435 return __builtin_nanl("");438 return __builtin_nanl("");
436 }439 }
437 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {440 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
438 return __builtin_nansl("");441 return __builtin_nansl("");
439 }442 }
440 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {443 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
441 return __LDBL_DENORM_MIN__;444 return __LDBL_DENORM_MIN__;
442 }445 }
443446
444#if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__)447# if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__)
445 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;448 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
446#else449# else
447 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;450 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
448#endif451# endif
449 static _LIBCPP_CONSTEXPR const bool is_bounded = true;452 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
450 static _LIBCPP_CONSTEXPR const bool is_modulo = false;453 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
451454
452 static _LIBCPP_CONSTEXPR const bool traps = false;455 static _LIBCPP_CONSTEXPR const bool traps = false;
453#if (defined(__arm__) || defined(__aarch64__))456# if (defined(__arm__) || defined(__aarch64__))
454 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;457 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
455#else458# else
456 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;459 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
457#endif460# endif
458 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;461 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
459};462};
460463
...@@ -464,106 +467,59 @@ class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp>...@@ -464,106 +467,59 @@ class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp>
464 typedef typename __base::type type;467 typedef typename __base::type type;
465468
466public:469public:
467 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;470 static inline _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
468 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }471 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }
469 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }472 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }
470 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }473 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }
471474
472 static _LIBCPP_CONSTEXPR const int digits = __base::digits;475 static inline _LIBCPP_CONSTEXPR const int digits = __base::digits;
473 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;476 static inline _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
474 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;477 static inline _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
475 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;478 static inline _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
476 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;479 static inline _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
477 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;480 static inline _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
478 static _LIBCPP_CONSTEXPR const int radix = __base::radix;481 static inline _LIBCPP_CONSTEXPR const int radix = __base::radix;
479 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {482 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {
480 return __base::epsilon();483 return __base::epsilon();
481 }484 }
482 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {485 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {
483 return __base::round_error();486 return __base::round_error();
484 }487 }
485488
486 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;489 static inline _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
487 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;490 static inline _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
488 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;491 static inline _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
489 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;492 static inline _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
490493
491 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;494 static inline _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
492 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;495 static inline _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
493 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;496 static inline _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
494 _LIBCPP_SUPPRESS_DEPRECATED_PUSH497 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
495 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;498 static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
496 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;499 static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
497 _LIBCPP_SUPPRESS_DEPRECATED_POP500 _LIBCPP_SUPPRESS_DEPRECATED_POP
498 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {501 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
499 return __base::infinity();502 return __base::infinity();
500 }503 }
501 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {504 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
502 return __base::quiet_NaN();505 return __base::quiet_NaN();
503 }506 }
504 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {507 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
505 return __base::signaling_NaN();508 return __base::signaling_NaN();
506 }509 }
507 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {510 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
508 return __base::denorm_min();511 return __base::denorm_min();
509 }512 }
510513
511 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;514 static inline _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
512 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;515 static inline _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
513 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;516 static inline _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
514517
515 static _LIBCPP_CONSTEXPR const bool traps = __base::traps;518 static inline _LIBCPP_CONSTEXPR const bool traps = __base::traps;
516 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;519 static inline _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
517 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;520 static inline _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
518};521};
519522
520template <class _Tp>
521_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_specialized;
522template <class _Tp>
523_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits;
524template <class _Tp>
525_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits10;
526template <class _Tp>
527_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_digits10;
528template <class _Tp>
529_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_signed;
530template <class _Tp>
531_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_integer;
532template <class _Tp>
533_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_exact;
534template <class _Tp>
535_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::radix;
536template <class _Tp>
537_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent;
538template <class _Tp>
539_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent10;
540template <class _Tp>
541_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent;
542template <class _Tp>
543_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent10;
544template <class _Tp>
545_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_infinity;
546template <class _Tp>
547_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_quiet_NaN;
548template <class _Tp>
549_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_signaling_NaN;
550template <class _Tp>
551_LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<_Tp>::has_denorm;
552template <class _Tp>
553_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_denorm_loss;
554template <class _Tp>
555_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_iec559;
556template <class _Tp>
557_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_bounded;
558template <class _Tp>
559_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_modulo;
560template <class _Tp>
561_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::traps;
562template <class _Tp>
563_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::tinyness_before;
564template <class _Tp>
565_LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style;
566
567template <class _Tp>523template <class _Tp>
568class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {};524class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {};
569525
...@@ -577,8 +533,9 @@ _LIBCPP_END_NAMESPACE_STD...@@ -577,8 +533,9 @@ _LIBCPP_END_NAMESPACE_STD
577533
578_LIBCPP_POP_MACROS534_LIBCPP_POP_MACROS
579535
580#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20536# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
581# include <type_traits>537# include <type_traits>
582#endif538# endif
539#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
583540
584#endif // _LIBCPP_LIMITS541#endif // _LIBCPP_LIMITS
lib/libcxx/include/list+369-357
...@@ -197,67 +197,72 @@ template <class T, class Allocator, class Predicate>...@@ -197,67 +197,72 @@ template <class T, class Allocator, class Predicate>
197197
198*/198*/
199199
200#include <__algorithm/comp.h>200#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
201#include <__algorithm/equal.h>201# include <__cxx03/list>
202#include <__algorithm/lexicographical_compare.h>202#else
203#include <__algorithm/lexicographical_compare_three_way.h>203# include <__algorithm/comp.h>
204#include <__algorithm/min.h>204# include <__algorithm/equal.h>
205#include <__assert>205# include <__algorithm/lexicographical_compare.h>
206#include <__config>206# include <__algorithm/lexicographical_compare_three_way.h>
207#include <__format/enable_insertable.h>207# include <__algorithm/min.h>
208#include <__iterator/distance.h>208# include <__assert>
209#include <__iterator/iterator_traits.h>209# include <__config>
210#include <__iterator/move_iterator.h>210# include <__format/enable_insertable.h>
211#include <__iterator/next.h>211# include <__iterator/distance.h>
212#include <__iterator/prev.h>212# include <__iterator/iterator_traits.h>
213#include <__iterator/reverse_iterator.h>213# include <__iterator/move_iterator.h>
214#include <__memory/addressof.h>214# include <__iterator/next.h>
215#include <__memory/allocation_guard.h>215# include <__iterator/prev.h>
216#include <__memory/allocator.h>216# include <__iterator/reverse_iterator.h>
217#include <__memory/allocator_traits.h>217# include <__memory/addressof.h>
218#include <__memory/compressed_pair.h>218# include <__memory/allocation_guard.h>
219#include <__memory/construct_at.h>219# include <__memory/allocator.h>
220#include <__memory/pointer_traits.h>220# include <__memory/allocator_traits.h>
221#include <__memory/swap_allocator.h>221# include <__memory/compressed_pair.h>
222#include <__memory_resource/polymorphic_allocator.h>222# include <__memory/construct_at.h>
223#include <__ranges/access.h>223# include <__memory/pointer_traits.h>
224#include <__ranges/concepts.h>224# include <__memory/swap_allocator.h>
225#include <__ranges/container_compatible_range.h>225# include <__memory_resource/polymorphic_allocator.h>
226#include <__ranges/from_range.h>226# include <__new/launder.h>
227#include <__type_traits/conditional.h>227# include <__ranges/access.h>
228#include <__type_traits/is_allocator.h>228# include <__ranges/concepts.h>
229#include <__type_traits/is_nothrow_assignable.h>229# include <__ranges/container_compatible_range.h>
230#include <__type_traits/is_nothrow_constructible.h>230# include <__ranges/from_range.h>
231#include <__type_traits/is_pointer.h>231# include <__type_traits/conditional.h>
232#include <__type_traits/is_same.h>232# include <__type_traits/container_traits.h>
233#include <__type_traits/type_identity.h>233# include <__type_traits/enable_if.h>
234#include <__utility/forward.h>234# include <__type_traits/is_allocator.h>
235#include <__utility/move.h>235# include <__type_traits/is_nothrow_assignable.h>
236#include <__utility/swap.h>236# include <__type_traits/is_nothrow_constructible.h>
237#include <cstring>237# include <__type_traits/is_pointer.h>
238#include <limits>238# include <__type_traits/is_same.h>
239#include <new> // __launder239# include <__type_traits/type_identity.h>
240#include <version>240# include <__utility/forward.h>
241# include <__utility/move.h>
242# include <__utility/swap.h>
243# include <cstring>
244# include <limits>
245# include <version>
241246
242// standard-mandated includes247// standard-mandated includes
243248
244// [iterator.range]249// [iterator.range]
245#include <__iterator/access.h>250# include <__iterator/access.h>
246#include <__iterator/data.h>251# include <__iterator/data.h>
247#include <__iterator/empty.h>252# include <__iterator/empty.h>
248#include <__iterator/reverse_access.h>253# include <__iterator/reverse_access.h>
249#include <__iterator/size.h>254# include <__iterator/size.h>
250255
251// [list.syn]256// [list.syn]
252#include <compare>257# include <compare>
253#include <initializer_list>258# include <initializer_list>
254259
255#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)260# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
256# pragma GCC system_header261# pragma GCC system_header
257#endif262# endif
258263
259_LIBCPP_PUSH_MACROS264_LIBCPP_PUSH_MACROS
260#include <__undef_macros>265# include <__undef_macros>
261266
262_LIBCPP_BEGIN_NAMESPACE_STD267_LIBCPP_BEGIN_NAMESPACE_STD
263268
...@@ -271,19 +276,21 @@ struct __list_node_pointer_traits {...@@ -271,19 +276,21 @@ struct __list_node_pointer_traits {
271 typedef __rebind_pointer_t<_VoidPtr, __list_node<_Tp, _VoidPtr> > __node_pointer;276 typedef __rebind_pointer_t<_VoidPtr, __list_node<_Tp, _VoidPtr> > __node_pointer;
272 typedef __rebind_pointer_t<_VoidPtr, __list_node_base<_Tp, _VoidPtr> > __base_pointer;277 typedef __rebind_pointer_t<_VoidPtr, __list_node_base<_Tp, _VoidPtr> > __base_pointer;
273278
274#if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB)279// TODO(LLVM 22): Remove this check
275 typedef __base_pointer __link_pointer;280# ifndef _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
276#else281 static_assert(sizeof(__node_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__base_pointer) ==
277 typedef __conditional_t<is_pointer<_VoidPtr>::value, __base_pointer, __node_pointer> __link_pointer;282 _LIBCPP_ALIGNOF(__node_pointer),
278#endif283 "It looks like you are using std::list with a fancy pointer type that thas a different representation "
279284 "depending on whether it points to a list base pointer or a list node pointer (both of which are "
280 typedef __conditional_t<is_same<__link_pointer, __node_pointer>::value, __base_pointer, __node_pointer>285 "implementation details of the standard library). This means that your ABI is being broken between "
281 __non_link_pointer;286 "LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define the "
287 "_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic.");
288# endif
282289
283 static _LIBCPP_HIDE_FROM_ABI __link_pointer __unsafe_link_pointer_cast(__link_pointer __p) { return __p; }290 static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__base_pointer __p) { return __p; }
284291
285 static _LIBCPP_HIDE_FROM_ABI __link_pointer __unsafe_link_pointer_cast(__non_link_pointer __p) {292 static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__node_pointer __p) {
286 return static_cast<__link_pointer>(static_cast<_VoidPtr>(__p));293 return static_cast<__base_pointer>(static_cast<_VoidPtr>(__p));
287 }294 }
288};295};
289296
...@@ -292,16 +299,13 @@ struct __list_node_base {...@@ -292,16 +299,13 @@ struct __list_node_base {
292 typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;299 typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
293 typedef typename _NodeTraits::__node_pointer __node_pointer;300 typedef typename _NodeTraits::__node_pointer __node_pointer;
294 typedef typename _NodeTraits::__base_pointer __base_pointer;301 typedef typename _NodeTraits::__base_pointer __base_pointer;
295 typedef typename _NodeTraits::__link_pointer __link_pointer;
296302
297 __link_pointer __prev_;303 __base_pointer __prev_;
298 __link_pointer __next_;304 __base_pointer __next_;
299305
300 _LIBCPP_HIDE_FROM_ABI __list_node_base()306 _LIBCPP_HIDE_FROM_ABI __list_node_base() : __prev_(__self()), __next_(__self()) {}
301 : __prev_(_NodeTraits::__unsafe_link_pointer_cast(__self())),
302 __next_(_NodeTraits::__unsafe_link_pointer_cast(__self())) {}
303307
304 _LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__link_pointer __prev, __link_pointer __next)308 _LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__base_pointer __prev, __base_pointer __next)
305 : __prev_(__prev), __next_(__next) {}309 : __prev_(__prev), __next_(__next) {}
306310
307 _LIBCPP_HIDE_FROM_ABI __base_pointer __self() { return pointer_traits<__base_pointer>::pointer_to(*this); }311 _LIBCPP_HIDE_FROM_ABI __base_pointer __self() { return pointer_traits<__base_pointer>::pointer_to(*this); }
...@@ -313,7 +317,7 @@ template <class _Tp, class _VoidPtr>...@@ -313,7 +317,7 @@ template <class _Tp, class _VoidPtr>
313struct __list_node : public __list_node_base<_Tp, _VoidPtr> {317struct __list_node : public __list_node_base<_Tp, _VoidPtr> {
314 // We allow starting the lifetime of nodes without initializing the value held by the node,318 // We allow starting the lifetime of nodes without initializing the value held by the node,
315 // since that is handled by the list itself in order to be allocator-aware.319 // since that is handled by the list itself in order to be allocator-aware.
316#ifndef _LIBCPP_CXX03_LANG320# ifndef _LIBCPP_CXX03_LANG
317321
318private:322private:
319 union {323 union {
...@@ -322,22 +326,22 @@ private:...@@ -322,22 +326,22 @@ private:
322326
323public:327public:
324 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }328 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }
325#else329# else
326330
327private:331private:
328 _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)];332 _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)];
329333
330public:334public:
331 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); }335 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); }
332#endif336# endif
333337
334 typedef __list_node_base<_Tp, _VoidPtr> __base;338 typedef __list_node_base<_Tp, _VoidPtr> __base;
335 typedef typename __base::__link_pointer __link_pointer;339 typedef typename __base::__base_pointer __base_pointer;
336340
337 _LIBCPP_HIDE_FROM_ABI explicit __list_node(__link_pointer __prev, __link_pointer __next) : __base(__prev, __next) {}341 _LIBCPP_HIDE_FROM_ABI explicit __list_node(__base_pointer __prev, __base_pointer __next) : __base(__prev, __next) {}
338 _LIBCPP_HIDE_FROM_ABI ~__list_node() {}342 _LIBCPP_HIDE_FROM_ABI ~__list_node() {}
339343
340 _LIBCPP_HIDE_FROM_ABI __link_pointer __as_link() { return static_cast<__link_pointer>(__base::__self()); }344 _LIBCPP_HIDE_FROM_ABI __base_pointer __as_link() { return __base::__self(); }
341};345};
342346
343template <class _Tp, class _Alloc = allocator<_Tp> >347template <class _Tp, class _Alloc = allocator<_Tp> >
...@@ -350,11 +354,11 @@ class _LIBCPP_TEMPLATE_VIS __list_const_iterator;...@@ -350,11 +354,11 @@ class _LIBCPP_TEMPLATE_VIS __list_const_iterator;
350template <class _Tp, class _VoidPtr>354template <class _Tp, class _VoidPtr>
351class _LIBCPP_TEMPLATE_VIS __list_iterator {355class _LIBCPP_TEMPLATE_VIS __list_iterator {
352 typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;356 typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
353 typedef typename _NodeTraits::__link_pointer __link_pointer;357 typedef typename _NodeTraits::__base_pointer __base_pointer;
354358
355 __link_pointer __ptr_;359 __base_pointer __ptr_;
356360
357 _LIBCPP_HIDE_FROM_ABI explicit __list_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}361 _LIBCPP_HIDE_FROM_ABI explicit __list_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {}
358362
359 template <class, class>363 template <class, class>
360 friend class list;364 friend class list;
...@@ -408,11 +412,11 @@ public:...@@ -408,11 +412,11 @@ public:
408template <class _Tp, class _VoidPtr>412template <class _Tp, class _VoidPtr>
409class _LIBCPP_TEMPLATE_VIS __list_const_iterator {413class _LIBCPP_TEMPLATE_VIS __list_const_iterator {
410 typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;414 typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
411 typedef typename _NodeTraits::__link_pointer __link_pointer;415 typedef typename _NodeTraits::__base_pointer __base_pointer;
412416
413 __link_pointer __ptr_;417 __base_pointer __ptr_;
414418
415 _LIBCPP_HIDE_FROM_ABI explicit __list_const_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}419 _LIBCPP_HIDE_FROM_ABI explicit __list_const_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {}
416420
417 template <class, class>421 template <class, class>
418 friend class list;422 friend class list;
...@@ -466,7 +470,7 @@ public:...@@ -466,7 +470,7 @@ public:
466template <class _Tp, class _Alloc>470template <class _Tp, class _Alloc>
467class __list_imp {471class __list_imp {
468public:472public:
469 __list_imp(const __list_imp&) = delete;473 __list_imp(const __list_imp&) = delete;
470 __list_imp& operator=(const __list_imp&) = delete;474 __list_imp& operator=(const __list_imp&) = delete;
471475
472 typedef _Alloc allocator_type;476 typedef _Alloc allocator_type;
...@@ -485,8 +489,8 @@ protected:...@@ -485,8 +489,8 @@ protected:
485 typedef typename __node_alloc_traits::pointer __node_pointer;489 typedef typename __node_alloc_traits::pointer __node_pointer;
486 typedef typename __node_alloc_traits::pointer __node_const_pointer;490 typedef typename __node_alloc_traits::pointer __node_const_pointer;
487 typedef __list_node_pointer_traits<value_type, __void_pointer> __node_pointer_traits;491 typedef __list_node_pointer_traits<value_type, __void_pointer> __node_pointer_traits;
488 typedef typename __node_pointer_traits::__link_pointer __link_pointer;492 typedef typename __node_pointer_traits::__base_pointer __base_pointer;
489 typedef __link_pointer __link_const_pointer;493 typedef __base_pointer __link_const_pointer;
490 typedef typename __alloc_traits::pointer pointer;494 typedef typename __alloc_traits::pointer pointer;
491 typedef typename __alloc_traits::const_pointer const_pointer;495 typedef typename __alloc_traits::const_pointer const_pointer;
492 typedef typename __alloc_traits::difference_type difference_type;496 typedef typename __alloc_traits::difference_type difference_type;
...@@ -497,31 +501,26 @@ protected:...@@ -497,31 +501,26 @@ protected:
497 "internal allocator type must differ from user-specified type; otherwise overload resolution breaks");501 "internal allocator type must differ from user-specified type; otherwise overload resolution breaks");
498502
499 __node_base __end_;503 __node_base __end_;
500 __compressed_pair<size_type, __node_allocator> __size_alloc_;504 _LIBCPP_COMPRESSED_PAIR(size_type, __size_, __node_allocator, __node_alloc_);
501505
502 _LIBCPP_HIDE_FROM_ABI __link_pointer __end_as_link() const _NOEXCEPT {506 _LIBCPP_HIDE_FROM_ABI __base_pointer __end_as_link() const _NOEXCEPT {
503 return __node_pointer_traits::__unsafe_link_pointer_cast(const_cast<__node_base&>(__end_).__self());507 return __node_pointer_traits::__unsafe_link_pointer_cast(const_cast<__node_base&>(__end_).__self());
504 }508 }
505509
506 _LIBCPP_HIDE_FROM_ABI size_type& __sz() _NOEXCEPT { return __size_alloc_.first(); }
507 _LIBCPP_HIDE_FROM_ABI const size_type& __sz() const _NOEXCEPT { return __size_alloc_.first(); }
508 _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __size_alloc_.second(); }
509 _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __size_alloc_.second(); }
510
511 _LIBCPP_HIDE_FROM_ABI size_type __node_alloc_max_size() const _NOEXCEPT {510 _LIBCPP_HIDE_FROM_ABI size_type __node_alloc_max_size() const _NOEXCEPT {
512 return __node_alloc_traits::max_size(__node_alloc());511 return __node_alloc_traits::max_size(__node_alloc_);
513 }512 }
514 _LIBCPP_HIDE_FROM_ABI static void __unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT;513 _LIBCPP_HIDE_FROM_ABI static void __unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT;
515514
516 _LIBCPP_HIDE_FROM_ABI __list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);515 _LIBCPP_HIDE_FROM_ABI __list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);
517 _LIBCPP_HIDE_FROM_ABI __list_imp(const allocator_type& __a);516 _LIBCPP_HIDE_FROM_ABI __list_imp(const allocator_type& __a);
518 _LIBCPP_HIDE_FROM_ABI __list_imp(const __node_allocator& __a);517 _LIBCPP_HIDE_FROM_ABI __list_imp(const __node_allocator& __a);
519#ifndef _LIBCPP_CXX03_LANG518# ifndef _LIBCPP_CXX03_LANG
520 _LIBCPP_HIDE_FROM_ABI __list_imp(__node_allocator&& __a) _NOEXCEPT;519 _LIBCPP_HIDE_FROM_ABI __list_imp(__node_allocator&& __a) _NOEXCEPT;
521#endif520# endif
522 _LIBCPP_HIDE_FROM_ABI ~__list_imp();521 _LIBCPP_HIDE_FROM_ABI ~__list_imp();
523 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;522 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
524 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __sz() == 0; }523 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __size_ == 0; }
525524
526 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__end_.__next_); }525 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__end_.__next_); }
527 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__end_.__next_); }526 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__end_.__next_); }
...@@ -529,11 +528,11 @@ protected:...@@ -529,11 +528,11 @@ protected:
529 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(__end_as_link()); }528 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(__end_as_link()); }
530529
531 _LIBCPP_HIDE_FROM_ABI void swap(__list_imp& __c)530 _LIBCPP_HIDE_FROM_ABI void swap(__list_imp& __c)
532#if _LIBCPP_STD_VER >= 14531# if _LIBCPP_STD_VER >= 14
533 _NOEXCEPT;532 _NOEXCEPT;
534#else533# else
535 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);534 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
536#endif535# endif
537536
538 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) {537 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) {
539 __copy_assign_alloc(538 __copy_assign_alloc(
...@@ -548,9 +547,8 @@ protected:...@@ -548,9 +547,8 @@ protected:
548 }547 }
549548
550 template <class... _Args>549 template <class... _Args>
551 _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__link_pointer __prev, __link_pointer __next, _Args&&... __args) {550 _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__base_pointer __prev, __base_pointer __next, _Args&&... __args) {
552 __node_allocator& __alloc = __node_alloc();551 __allocation_guard<__node_allocator> __guard(__node_alloc_, 1);
553 __allocation_guard<__node_allocator> __guard(__alloc, 1);
554 // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value552 // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value
555 // held inside the node, since we need to use the allocator's construct() method for that.553 // held inside the node, since we need to use the allocator's construct() method for that.
556 //554 //
...@@ -561,31 +559,30 @@ protected:...@@ -561,31 +559,30 @@ protected:
561559
562 // Now construct the value_type using the allocator's construct() method.560 // Now construct the value_type using the allocator's construct() method.
563 __node_alloc_traits::construct(561 __node_alloc_traits::construct(
564 __alloc, std::addressof(__guard.__get()->__get_value()), std::forward<_Args>(__args)...);562 __node_alloc_, std::addressof(__guard.__get()->__get_value()), std::forward<_Args>(__args)...);
565 return __guard.__release_ptr();563 return __guard.__release_ptr();
566 }564 }
567565
568 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {566 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {
569 // For the same reason as above, we use the allocator's destroy() method for the value_type,567 // For the same reason as above, we use the allocator's destroy() method for the value_type,
570 // but not for the node itself.568 // but not for the node itself.
571 __node_allocator& __alloc = __node_alloc();569 __node_alloc_traits::destroy(__node_alloc_, std::addressof(__node->__get_value()));
572 __node_alloc_traits::destroy(__alloc, std::addressof(__node->__get_value()));
573 std::__destroy_at(std::addressof(*__node));570 std::__destroy_at(std::addressof(*__node));
574 __node_alloc_traits::deallocate(__alloc, __node, 1);571 __node_alloc_traits::deallocate(__node_alloc_, __node, 1);
575 }572 }
576573
577private:574private:
578 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c, true_type) {575 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c, true_type) {
579 if (__node_alloc() != __c.__node_alloc())576 if (__node_alloc_ != __c.__node_alloc_)
580 clear();577 clear();
581 __node_alloc() = __c.__node_alloc();578 __node_alloc_ = __c.__node_alloc_;
582 }579 }
583580
584 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp&, false_type) {}581 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp&, false_type) {}
585582
586 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c, true_type)583 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c, true_type)
587 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {584 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {
588 __node_alloc() = std::move(__c.__node_alloc());585 __node_alloc_ = std::move(__c.__node_alloc_);
589 }586 }
590587
591 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp&, false_type) _NOEXCEPT {}588 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp&, false_type) _NOEXCEPT {}
...@@ -593,25 +590,28 @@ private:...@@ -593,25 +590,28 @@ private:
593590
594// Unlink nodes [__f, __l]591// Unlink nodes [__f, __l]
595template <class _Tp, class _Alloc>592template <class _Tp, class _Alloc>
596inline void __list_imp<_Tp, _Alloc>::__unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT {593inline void __list_imp<_Tp, _Alloc>::__unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT {
597 __f->__prev_->__next_ = __l->__next_;594 __f->__prev_->__next_ = __l->__next_;
598 __l->__next_->__prev_ = __f->__prev_;595 __l->__next_->__prev_ = __f->__prev_;
599}596}
600597
601template <class _Tp, class _Alloc>598template <class _Tp, class _Alloc>
602inline __list_imp<_Tp, _Alloc>::__list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)599inline __list_imp<_Tp, _Alloc>::__list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
603 : __size_alloc_(0, __default_init_tag()) {}600 : __size_(0) {}
604601
605template <class _Tp, class _Alloc>602template <class _Tp, class _Alloc>
606inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a) : __size_alloc_(0, __node_allocator(__a)) {}603inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a)
604 : __size_(0), __node_alloc_(__node_allocator(__a)) {}
607605
608template <class _Tp, class _Alloc>606template <class _Tp, class _Alloc>
609inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a) : __size_alloc_(0, __a) {}607inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a) : __size_(0), __node_alloc_(__a) {}
610608
611#ifndef _LIBCPP_CXX03_LANG609# ifndef _LIBCPP_CXX03_LANG
612template <class _Tp, class _Alloc>610template <class _Tp, class _Alloc>
613inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT : __size_alloc_(0, std::move(__a)) {}611inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT
614#endif612 : __size_(0),
613 __node_alloc_(std::move(__a)) {}
614# endif
615615
616template <class _Tp, class _Alloc>616template <class _Tp, class _Alloc>
617__list_imp<_Tp, _Alloc>::~__list_imp() {617__list_imp<_Tp, _Alloc>::~__list_imp() {
...@@ -621,10 +621,10 @@ __list_imp<_Tp, _Alloc>::~__list_imp() {...@@ -621,10 +621,10 @@ __list_imp<_Tp, _Alloc>::~__list_imp() {
621template <class _Tp, class _Alloc>621template <class _Tp, class _Alloc>
622void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT {622void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT {
623 if (!empty()) {623 if (!empty()) {
624 __link_pointer __f = __end_.__next_;624 __base_pointer __f = __end_.__next_;
625 __link_pointer __l = __end_as_link();625 __base_pointer __l = __end_as_link();
626 __unlink_nodes(__f, __l->__prev_);626 __unlink_nodes(__f, __l->__prev_);
627 __sz() = 0;627 __size_ = 0;
628 while (__f != __l) {628 while (__f != __l) {
629 __node_pointer __np = __f->__as_node();629 __node_pointer __np = __f->__as_node();
630 __f = __f->__next_;630 __f = __f->__next_;
...@@ -635,25 +635,25 @@ void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT {...@@ -635,25 +635,25 @@ void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT {
635635
636template <class _Tp, class _Alloc>636template <class _Tp, class _Alloc>
637void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)637void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
638#if _LIBCPP_STD_VER >= 14638# if _LIBCPP_STD_VER >= 14
639 _NOEXCEPT639 _NOEXCEPT
640#else640# else
641 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)641 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
642#endif642# endif
643{643{
644 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(644 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
645 __alloc_traits::propagate_on_container_swap::value || this->__node_alloc() == __c.__node_alloc(),645 __alloc_traits::propagate_on_container_swap::value || this->__node_alloc_ == __c.__node_alloc_,
646 "list::swap: Either propagate_on_container_swap must be true"646 "list::swap: Either propagate_on_container_swap must be true"
647 " or the allocators must compare equal");647 " or the allocators must compare equal");
648 using std::swap;648 using std::swap;
649 std::__swap_allocator(__node_alloc(), __c.__node_alloc());649 std::__swap_allocator(__node_alloc_, __c.__node_alloc_);
650 swap(__sz(), __c.__sz());650 swap(__size_, __c.__size_);
651 swap(__end_, __c.__end_);651 swap(__end_, __c.__end_);
652 if (__sz() == 0)652 if (__size_ == 0)
653 __end_.__next_ = __end_.__prev_ = __end_as_link();653 __end_.__next_ = __end_.__prev_ = __end_as_link();
654 else654 else
655 __end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_as_link();655 __end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_as_link();
656 if (__c.__sz() == 0)656 if (__c.__size_ == 0)
657 __c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_as_link();657 __c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_as_link();
658 else658 else
659 __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link();659 __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link();
...@@ -661,14 +661,14 @@ void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)...@@ -661,14 +661,14 @@ void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
661661
662template <class _Tp, class _Alloc /*= allocator<_Tp>*/>662template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
663class _LIBCPP_TEMPLATE_VIS list : private __list_imp<_Tp, _Alloc> {663class _LIBCPP_TEMPLATE_VIS list : private __list_imp<_Tp, _Alloc> {
664 typedef __list_imp<_Tp, _Alloc> base;664 typedef __list_imp<_Tp, _Alloc> __base;
665 typedef typename base::__node_type __node_type;665 typedef typename __base::__node_type __node_type;
666 typedef typename base::__node_allocator __node_allocator;666 typedef typename __base::__node_allocator __node_allocator;
667 typedef typename base::__node_pointer __node_pointer;667 typedef typename __base::__node_pointer __node_pointer;
668 typedef typename base::__node_alloc_traits __node_alloc_traits;668 typedef typename __base::__node_alloc_traits __node_alloc_traits;
669 typedef typename base::__node_base __node_base;669 typedef typename __base::__node_base __node_base;
670 typedef typename base::__node_base_pointer __node_base_pointer;670 typedef typename __base::__node_base_pointer __node_base_pointer;
671 typedef typename base::__link_pointer __link_pointer;671 typedef typename __base::__base_pointer __base_pointer;
672672
673public:673public:
674 typedef _Tp value_type;674 typedef _Tp value_type;
...@@ -678,29 +678,29 @@ public:...@@ -678,29 +678,29 @@ public:
678 "Allocator::value_type must be same type as value_type");678 "Allocator::value_type must be same type as value_type");
679 typedef value_type& reference;679 typedef value_type& reference;
680 typedef const value_type& const_reference;680 typedef const value_type& const_reference;
681 typedef typename base::pointer pointer;681 typedef typename __base::pointer pointer;
682 typedef typename base::const_pointer const_pointer;682 typedef typename __base::const_pointer const_pointer;
683 typedef typename base::size_type size_type;683 typedef typename __base::size_type size_type;
684 typedef typename base::difference_type difference_type;684 typedef typename __base::difference_type difference_type;
685 typedef typename base::iterator iterator;685 typedef typename __base::iterator iterator;
686 typedef typename base::const_iterator const_iterator;686 typedef typename __base::const_iterator const_iterator;
687 typedef std::reverse_iterator<iterator> reverse_iterator;687 typedef std::reverse_iterator<iterator> reverse_iterator;
688 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;688 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
689#if _LIBCPP_STD_VER >= 20689# if _LIBCPP_STD_VER >= 20
690 typedef size_type __remove_return_type;690 typedef size_type __remove_return_type;
691#else691# else
692 typedef void __remove_return_type;692 typedef void __remove_return_type;
693#endif693# endif
694694
695 _LIBCPP_HIDE_FROM_ABI list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {}695 _LIBCPP_HIDE_FROM_ABI list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {}
696 _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : base(__a) {}696 _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : __base(__a) {}
697 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n);697 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n);
698#if _LIBCPP_STD_VER >= 14698# if _LIBCPP_STD_VER >= 14
699 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a);699 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a);
700#endif700# endif
701 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x);701 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x);
702 template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0>702 template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
703 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x, const allocator_type& __a) : base(__a) {703 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x, const allocator_type& __a) : __base(__a) {
704 for (; __n > 0; --__n)704 for (; __n > 0; --__n)
705 push_back(__x);705 push_back(__x);
706 }706 }
...@@ -711,17 +711,18 @@ public:...@@ -711,17 +711,18 @@ public:
711 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>711 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
712 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l, const allocator_type& __a);712 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l, const allocator_type& __a);
713713
714#if _LIBCPP_STD_VER >= 23714# if _LIBCPP_STD_VER >= 23
715 template <_ContainerCompatibleRange<_Tp> _Range>715 template <_ContainerCompatibleRange<_Tp> _Range>
716 _LIBCPP_HIDE_FROM_ABI list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) : base(__a) {716 _LIBCPP_HIDE_FROM_ABI list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())
717 : __base(__a) {
717 prepend_range(std::forward<_Range>(__range));718 prepend_range(std::forward<_Range>(__range));
718 }719 }
719#endif720# endif
720721
721 _LIBCPP_HIDE_FROM_ABI list(const list& __c);722 _LIBCPP_HIDE_FROM_ABI list(const list& __c);
722 _LIBCPP_HIDE_FROM_ABI list(const list& __c, const __type_identity_t<allocator_type>& __a);723 _LIBCPP_HIDE_FROM_ABI list(const list& __c, const __type_identity_t<allocator_type>& __a);
723 _LIBCPP_HIDE_FROM_ABI list& operator=(const list& __c);724 _LIBCPP_HIDE_FROM_ABI list& operator=(const list& __c);
724#ifndef _LIBCPP_CXX03_LANG725# ifndef _LIBCPP_CXX03_LANG
725 _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il);726 _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il);
726 _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il, const allocator_type& __a);727 _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il, const allocator_type& __a);
727728
...@@ -737,34 +738,34 @@ public:...@@ -737,34 +738,34 @@ public:
737 }738 }
738739
739 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); }740 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); }
740#endif // _LIBCPP_CXX03_LANG741# endif // _LIBCPP_CXX03_LANG
741742
742 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>743 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
743 _LIBCPP_HIDE_FROM_ABI void assign(_InpIter __f, _InpIter __l);744 _LIBCPP_HIDE_FROM_ABI void assign(_InpIter __f, _InpIter __l);
744745
745#if _LIBCPP_STD_VER >= 23746# if _LIBCPP_STD_VER >= 23
746 template <_ContainerCompatibleRange<_Tp> _Range>747 template <_ContainerCompatibleRange<_Tp> _Range>
747 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) {748 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) {
748 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));749 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));
749 }750 }
750#endif751# endif
751752
752 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __x);753 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __x);
753754
754 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT;755 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT;
755756
756 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return base::__sz(); }757 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return this->__size_; }
757 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return base::empty(); }758 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __base::empty(); }
758 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {759 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
759 return std::min<size_type>(base::__node_alloc_max_size(), numeric_limits<difference_type >::max());760 return std::min<size_type>(this->__node_alloc_max_size(), numeric_limits<difference_type >::max());
760 }761 }
761762
762 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return base::begin(); }763 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __base::begin(); }
763 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return base::begin(); }764 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __base::begin(); }
764 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return base::end(); }765 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __base::end(); }
765 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return base::end(); }766 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __base::end(); }
766 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return base::begin(); }767 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __base::begin(); }
767 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return base::end(); }768 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __base::end(); }
768769
769 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }770 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }
770 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }771 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }
...@@ -775,26 +776,26 @@ public:...@@ -775,26 +776,26 @@ public:
775776
776 _LIBCPP_HIDE_FROM_ABI reference front() {777 _LIBCPP_HIDE_FROM_ABI reference front() {
777 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list");778 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list");
778 return base::__end_.__next_->__as_node()->__get_value();779 return __base::__end_.__next_->__as_node()->__get_value();
779 }780 }
780 _LIBCPP_HIDE_FROM_ABI const_reference front() const {781 _LIBCPP_HIDE_FROM_ABI const_reference front() const {
781 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list");782 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list");
782 return base::__end_.__next_->__as_node()->__get_value();783 return __base::__end_.__next_->__as_node()->__get_value();
783 }784 }
784 _LIBCPP_HIDE_FROM_ABI reference back() {785 _LIBCPP_HIDE_FROM_ABI reference back() {
785 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list");786 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list");
786 return base::__end_.__prev_->__as_node()->__get_value();787 return __base::__end_.__prev_->__as_node()->__get_value();
787 }788 }
788 _LIBCPP_HIDE_FROM_ABI const_reference back() const {789 _LIBCPP_HIDE_FROM_ABI const_reference back() const {
789 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list");790 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list");
790 return base::__end_.__prev_->__as_node()->__get_value();791 return __base::__end_.__prev_->__as_node()->__get_value();
791 }792 }
792793
793#ifndef _LIBCPP_CXX03_LANG794# ifndef _LIBCPP_CXX03_LANG
794 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x);795 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x);
795 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);796 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);
796797
797# if _LIBCPP_STD_VER >= 23798# if _LIBCPP_STD_VER >= 23
798 template <_ContainerCompatibleRange<_Tp> _Range>799 template <_ContainerCompatibleRange<_Tp> _Range>
799 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) {800 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) {
800 insert_range(begin(), std::forward<_Range>(__range));801 insert_range(begin(), std::forward<_Range>(__range));
...@@ -804,20 +805,20 @@ public:...@@ -804,20 +805,20 @@ public:
804 _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) {805 _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) {
805 insert_range(end(), std::forward<_Range>(__range));806 insert_range(end(), std::forward<_Range>(__range));
806 }807 }
807# endif808# endif
808809
809 template <class... _Args>810 template <class... _Args>
810# if _LIBCPP_STD_VER >= 17811# if _LIBCPP_STD_VER >= 17
811 _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);812 _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);
812# else813# else
813 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);814 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);
814# endif815# endif
815 template <class... _Args>816 template <class... _Args>
816# if _LIBCPP_STD_VER >= 17817# if _LIBCPP_STD_VER >= 17
817 _LIBCPP_HIDE_FROM_ABI reference emplace_back(_Args&&... __args);818 _LIBCPP_HIDE_FROM_ABI reference emplace_back(_Args&&... __args);
818# else819# else
819 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args);820 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args);
820# endif821# endif
821 template <class... _Args>822 template <class... _Args>
822 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args);823 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args);
823824
...@@ -826,19 +827,19 @@ public:...@@ -826,19 +827,19 @@ public:
826 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list<value_type> __il) {827 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list<value_type> __il) {
827 return insert(__p, __il.begin(), __il.end());828 return insert(__p, __il.begin(), __il.end());
828 }829 }
829#endif // _LIBCPP_CXX03_LANG830# endif // _LIBCPP_CXX03_LANG
830831
831 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __x);832 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __x);
832 _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __x);833 _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __x);
833834
834#ifndef _LIBCPP_CXX03_LANG835# ifndef _LIBCPP_CXX03_LANG
835 template <class _Arg>836 template <class _Arg>
836 _LIBCPP_HIDE_FROM_ABI void __emplace_back(_Arg&& __arg) {837 _LIBCPP_HIDE_FROM_ABI void __emplace_back(_Arg&& __arg) {
837 emplace_back(std::forward<_Arg>(__arg));838 emplace_back(std::forward<_Arg>(__arg));
838 }839 }
839#else840# else
840 _LIBCPP_HIDE_FROM_ABI void __emplace_back(value_type const& __arg) { push_back(__arg); }841 _LIBCPP_HIDE_FROM_ABI void __emplace_back(value_type const& __arg) { push_back(__arg); }
841#endif842# endif
842843
843 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x);844 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x);
844 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __x);845 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __x);
...@@ -846,23 +847,23 @@ public:...@@ -846,23 +847,23 @@ public:
846 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>847 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
847 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InpIter __f, _InpIter __l);848 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InpIter __f, _InpIter __l);
848849
849#if _LIBCPP_STD_VER >= 23850# if _LIBCPP_STD_VER >= 23
850 template <_ContainerCompatibleRange<_Tp> _Range>851 template <_ContainerCompatibleRange<_Tp> _Range>
851 _LIBCPP_HIDE_FROM_ABI iterator insert_range(const_iterator __position, _Range&& __range) {852 _LIBCPP_HIDE_FROM_ABI iterator insert_range(const_iterator __position, _Range&& __range) {
852 return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));853 return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));
853 }854 }
854#endif855# endif
855856
856 _LIBCPP_HIDE_FROM_ABI void swap(list& __c)857 _LIBCPP_HIDE_FROM_ABI void swap(list& __c)
857#if _LIBCPP_STD_VER >= 14858# if _LIBCPP_STD_VER >= 14
858 _NOEXCEPT859 _NOEXCEPT
859#else860# else
860 _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)861 _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)
861#endif862# endif
862 {863 {
863 base::swap(__c);864 __base::swap(__c);
864 }865 }
865 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { base::clear(); }866 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); }
866867
867 _LIBCPP_HIDE_FROM_ABI void pop_front();868 _LIBCPP_HIDE_FROM_ABI void pop_front();
868 _LIBCPP_HIDE_FROM_ABI void pop_back();869 _LIBCPP_HIDE_FROM_ABI void pop_back();
...@@ -874,13 +875,13 @@ public:...@@ -874,13 +875,13 @@ public:
874 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __x);875 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __x);
875876
876 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c);877 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c);
877#ifndef _LIBCPP_CXX03_LANG878# ifndef _LIBCPP_CXX03_LANG
878 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c) { splice(__p, __c); }879 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c) { splice(__p, __c); }
879 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __i) { splice(__p, __c, __i); }880 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __i) { splice(__p, __c, __i); }
880 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l) {881 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l) {
881 splice(__p, __c, __f, __l);882 splice(__p, __c, __f, __l);
882 }883 }
883#endif884# endif
884 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __i);885 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __i);
885 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l);886 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l);
886887
...@@ -891,14 +892,14 @@ public:...@@ -891,14 +892,14 @@ public:
891 template <class _BinaryPred>892 template <class _BinaryPred>
892 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPred __binary_pred);893 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPred __binary_pred);
893 _LIBCPP_HIDE_FROM_ABI void merge(list& __c);894 _LIBCPP_HIDE_FROM_ABI void merge(list& __c);
894#ifndef _LIBCPP_CXX03_LANG895# ifndef _LIBCPP_CXX03_LANG
895 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c) { merge(__c); }896 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c) { merge(__c); }
896897
897 template <class _Comp>898 template <class _Comp>
898 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c, _Comp __comp) {899 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c, _Comp __comp) {
899 merge(__c, __comp);900 merge(__c, __comp);
900 }901 }
901#endif902# endif
902 template <class _Comp>903 template <class _Comp>
903 _LIBCPP_HIDE_FROM_ABI void merge(list& __c, _Comp __comp);904 _LIBCPP_HIDE_FROM_ABI void merge(list& __c, _Comp __comp);
904905
...@@ -917,9 +918,9 @@ private:...@@ -917,9 +918,9 @@ private:
917 template <class _Iterator, class _Sentinel>918 template <class _Iterator, class _Sentinel>
918 _LIBCPP_HIDE_FROM_ABI iterator __insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l);919 _LIBCPP_HIDE_FROM_ABI iterator __insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l);
919920
920 _LIBCPP_HIDE_FROM_ABI static void __link_nodes(__link_pointer __p, __link_pointer __f, __link_pointer __l);921 _LIBCPP_HIDE_FROM_ABI static void __link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l);
921 _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_front(__link_pointer __f, __link_pointer __l);922 _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_front(__base_pointer __f, __base_pointer __l);
922 _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_back(__link_pointer __f, __link_pointer __l);923 _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_back(__base_pointer __f, __base_pointer __l);
923 _LIBCPP_HIDE_FROM_ABI iterator __iterator(size_type __n);924 _LIBCPP_HIDE_FROM_ABI iterator __iterator(size_type __n);
924 // TODO: Make this _LIBCPP_HIDE_FROM_ABI925 // TODO: Make this _LIBCPP_HIDE_FROM_ABI
925 template <class _Comp>926 template <class _Comp>
...@@ -930,7 +931,7 @@ private:...@@ -930,7 +931,7 @@ private:
930 _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, false_type);931 _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, false_type);
931};932};
932933
933#if _LIBCPP_STD_VER >= 17934# if _LIBCPP_STD_VER >= 17
934template <class _InputIterator,935template <class _InputIterator,
935 class _Alloc = allocator<__iter_value_type<_InputIterator>>,936 class _Alloc = allocator<__iter_value_type<_InputIterator>>,
936 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,937 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
...@@ -942,18 +943,18 @@ template <class _InputIterator,...@@ -942,18 +943,18 @@ template <class _InputIterator,
942 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,943 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
943 class = enable_if_t<__is_allocator<_Alloc>::value> >944 class = enable_if_t<__is_allocator<_Alloc>::value> >
944list(_InputIterator, _InputIterator, _Alloc) -> list<__iter_value_type<_InputIterator>, _Alloc>;945list(_InputIterator, _InputIterator, _Alloc) -> list<__iter_value_type<_InputIterator>, _Alloc>;
945#endif946# endif
946947
947#if _LIBCPP_STD_VER >= 23948# if _LIBCPP_STD_VER >= 23
948template <ranges::input_range _Range,949template <ranges::input_range _Range,
949 class _Alloc = allocator<ranges::range_value_t<_Range>>,950 class _Alloc = allocator<ranges::range_value_t<_Range>>,
950 class = enable_if_t<__is_allocator<_Alloc>::value> >951 class = enable_if_t<__is_allocator<_Alloc>::value> >
951list(from_range_t, _Range&&, _Alloc = _Alloc()) -> list<ranges::range_value_t<_Range>, _Alloc>;952list(from_range_t, _Range&&, _Alloc = _Alloc()) -> list<ranges::range_value_t<_Range>, _Alloc>;
952#endif953# endif
953954
954// Link in nodes [__f, __l] just prior to __p955// Link in nodes [__f, __l] just prior to __p
955template <class _Tp, class _Alloc>956template <class _Tp, class _Alloc>
956inline void list<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer __f, __link_pointer __l) {957inline void list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l) {
957 __p->__prev_->__next_ = __f;958 __p->__prev_->__next_ = __f;
958 __f->__prev_ = __p->__prev_;959 __f->__prev_ = __p->__prev_;
959 __p->__prev_ = __l;960 __p->__prev_ = __l;
...@@ -962,44 +963,44 @@ inline void list<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer _...@@ -962,44 +963,44 @@ inline void list<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer _
962963
963// Link in nodes [__f, __l] at the front of the list964// Link in nodes [__f, __l] at the front of the list
964template <class _Tp, class _Alloc>965template <class _Tp, class _Alloc>
965inline void list<_Tp, _Alloc>::__link_nodes_at_front(__link_pointer __f, __link_pointer __l) {966inline void list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_pointer __l) {
966 __f->__prev_ = base::__end_as_link();967 __f->__prev_ = __base::__end_as_link();
967 __l->__next_ = base::__end_.__next_;968 __l->__next_ = __base::__end_.__next_;
968 __l->__next_->__prev_ = __l;969 __l->__next_->__prev_ = __l;
969 base::__end_.__next_ = __f;970 __base::__end_.__next_ = __f;
970}971}
971972
972// Link in nodes [__f, __l] at the back of the list973// Link in nodes [__f, __l] at the back of the list
973template <class _Tp, class _Alloc>974template <class _Tp, class _Alloc>
974inline void list<_Tp, _Alloc>::__link_nodes_at_back(__link_pointer __f, __link_pointer __l) {975inline void list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_pointer __l) {
975 __l->__next_ = base::__end_as_link();976 __l->__next_ = __base::__end_as_link();
976 __f->__prev_ = base::__end_.__prev_;977 __f->__prev_ = __base::__end_.__prev_;
977 __f->__prev_->__next_ = __f;978 __f->__prev_->__next_ = __f;
978 base::__end_.__prev_ = __l;979 __base::__end_.__prev_ = __l;
979}980}
980981
981template <class _Tp, class _Alloc>982template <class _Tp, class _Alloc>
982inline typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::__iterator(size_type __n) {983inline typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::__iterator(size_type __n) {
983 return __n <= base::__sz() / 2 ? std::next(begin(), __n) : std::prev(end(), base::__sz() - __n);984 return __n <= this->__size_ / 2 ? std::next(begin(), __n) : std::prev(end(), this->__size_ - __n);
984}985}
985986
986template <class _Tp, class _Alloc>987template <class _Tp, class _Alloc>
987list<_Tp, _Alloc>::list(size_type __n) {988list<_Tp, _Alloc>::list(size_type __n) {
988 for (; __n > 0; --__n)989 for (; __n > 0; --__n)
989#ifndef _LIBCPP_CXX03_LANG990# ifndef _LIBCPP_CXX03_LANG
990 emplace_back();991 emplace_back();
991#else992# else
992 push_back(value_type());993 push_back(value_type());
993#endif994# endif
994}995}
995996
996#if _LIBCPP_STD_VER >= 14997# if _LIBCPP_STD_VER >= 14
997template <class _Tp, class _Alloc>998template <class _Tp, class _Alloc>
998list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a) {999list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : __base(__a) {
999 for (; __n > 0; --__n)1000 for (; __n > 0; --__n)
1000 emplace_back();1001 emplace_back();
1001}1002}
1002#endif1003# endif
10031004
1004template <class _Tp, class _Alloc>1005template <class _Tp, class _Alloc>
1005list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) {1006list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) {
...@@ -1016,28 +1017,28 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l) {...@@ -1016,28 +1017,28 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l) {
10161017
1017template <class _Tp, class _Alloc>1018template <class _Tp, class _Alloc>
1018template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >1019template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
1019list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a) : base(__a) {1020list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a) : __base(__a) {
1020 for (; __f != __l; ++__f)1021 for (; __f != __l; ++__f)
1021 __emplace_back(*__f);1022 __emplace_back(*__f);
1022}1023}
10231024
1024template <class _Tp, class _Alloc>1025template <class _Tp, class _Alloc>
1025list<_Tp, _Alloc>::list(const list& __c)1026list<_Tp, _Alloc>::list(const list& __c)
1026 : base(__node_alloc_traits::select_on_container_copy_construction(__c.__node_alloc())) {1027 : __base(__node_alloc_traits::select_on_container_copy_construction(__c.__node_alloc_)) {
1027 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)1028 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
1028 push_back(*__i);1029 push_back(*__i);
1029}1030}
10301031
1031template <class _Tp, class _Alloc>1032template <class _Tp, class _Alloc>
1032list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a) : base(__a) {1033list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a) : __base(__a) {
1033 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)1034 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
1034 push_back(*__i);1035 push_back(*__i);
1035}1036}
10361037
1037#ifndef _LIBCPP_CXX03_LANG1038# ifndef _LIBCPP_CXX03_LANG
10381039
1039template <class _Tp, class _Alloc>1040template <class _Tp, class _Alloc>
1040list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a) : base(__a) {1041list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a) : __base(__a) {
1041 for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i)1042 for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i)
1042 push_back(*__i);1043 push_back(*__i);
1043}1044}
...@@ -1050,12 +1051,12 @@ list<_Tp, _Alloc>::list(initializer_list<value_type> __il) {...@@ -1050,12 +1051,12 @@ list<_Tp, _Alloc>::list(initializer_list<value_type> __il) {
10501051
1051template <class _Tp, class _Alloc>1052template <class _Tp, class _Alloc>
1052inline list<_Tp, _Alloc>::list(list&& __c) noexcept(is_nothrow_move_constructible<__node_allocator>::value)1053inline list<_Tp, _Alloc>::list(list&& __c) noexcept(is_nothrow_move_constructible<__node_allocator>::value)
1053 : base(std::move(__c.__node_alloc())) {1054 : __base(std::move(__c.__node_alloc_)) {
1054 splice(end(), __c);1055 splice(end(), __c);
1055}1056}
10561057
1057template <class _Tp, class _Alloc>1058template <class _Tp, class _Alloc>
1058inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a) : base(__a) {1059inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a) : __base(__a) {
1059 if (__a == __c.get_allocator())1060 if (__a == __c.get_allocator())
1060 splice(end(), __c);1061 splice(end(), __c);
1061 else {1062 else {
...@@ -1074,7 +1075,7 @@ inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept(...@@ -1074,7 +1075,7 @@ inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept(
10741075
1075template <class _Tp, class _Alloc>1076template <class _Tp, class _Alloc>
1076void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) {1077void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) {
1077 if (base::__node_alloc() != __c.__node_alloc()) {1078 if (this->__node_alloc_ != __c.__node_alloc_) {
1078 typedef move_iterator<iterator> _Ip;1079 typedef move_iterator<iterator> _Ip;
1079 assign(_Ip(__c.begin()), _Ip(__c.end()));1080 assign(_Ip(__c.begin()), _Ip(__c.end()));
1080 } else1081 } else
...@@ -1085,16 +1086,16 @@ template <class _Tp, class _Alloc>...@@ -1085,16 +1086,16 @@ template <class _Tp, class _Alloc>
1085void list<_Tp, _Alloc>::__move_assign(list& __c,1086void list<_Tp, _Alloc>::__move_assign(list& __c,
1086 true_type) noexcept(is_nothrow_move_assignable<__node_allocator>::value) {1087 true_type) noexcept(is_nothrow_move_assignable<__node_allocator>::value) {
1087 clear();1088 clear();
1088 base::__move_assign_alloc(__c);1089 __base::__move_assign_alloc(__c);
1089 splice(end(), __c);1090 splice(end(), __c);
1090}1091}
10911092
1092#endif // _LIBCPP_CXX03_LANG1093# endif // _LIBCPP_CXX03_LANG
10931094
1094template <class _Tp, class _Alloc>1095template <class _Tp, class _Alloc>
1095inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) {1096inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) {
1096 if (this != std::addressof(__c)) {1097 if (this != std::addressof(__c)) {
1097 base::__copy_assign_alloc(__c);1098 __base::__copy_assign_alloc(__c);
1098 assign(__c.begin(), __c.end());1099 assign(__c.begin(), __c.end());
1099 }1100 }
1100 return *this;1101 return *this;
...@@ -1133,14 +1134,14 @@ void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) {...@@ -1133,14 +1134,14 @@ void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) {
11331134
1134template <class _Tp, class _Alloc>1135template <class _Tp, class _Alloc>
1135inline _Alloc list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT {1136inline _Alloc list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT {
1136 return allocator_type(base::__node_alloc());1137 return allocator_type(this->__node_alloc_);
1137}1138}
11381139
1139template <class _Tp, class _Alloc>1140template <class _Tp, class _Alloc>
1140typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) {1141typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) {
1141 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);1142 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
1142 __link_nodes(__p.__ptr_, __node->__as_link(), __node->__as_link());1143 __link_nodes(__p.__ptr_, __node->__as_link(), __node->__as_link());
1143 ++base::__sz();1144 ++this->__size_;
1144 return iterator(__node->__as_link());1145 return iterator(__node->__as_link());
1145}1146}
11461147
...@@ -1154,16 +1155,16 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _...@@ -1154,16 +1155,16 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
1154 ++__ds;1155 ++__ds;
1155 __r = iterator(__node->__as_link());1156 __r = iterator(__node->__as_link());
1156 iterator __e = __r;1157 iterator __e = __r;
1157#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1158# if _LIBCPP_HAS_EXCEPTIONS
1158 try {1159 try {
1159#endif // _LIBCPP_HAS_NO_EXCEPTIONS1160# endif // _LIBCPP_HAS_EXCEPTIONS
1160 for (--__n; __n != 0; --__n, (void)++__e, ++__ds) {1161 for (--__n; __n != 0; --__n, (void)++__e, ++__ds) {
1161 __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link();1162 __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link();
1162 }1163 }
1163#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1164# if _LIBCPP_HAS_EXCEPTIONS
1164 } catch (...) {1165 } catch (...) {
1165 while (true) {1166 while (true) {
1166 __link_pointer __prev = __e.__ptr_->__prev_;1167 __base_pointer __prev = __e.__ptr_->__prev_;
1167 __node_pointer __current = __e.__ptr_->__as_node();1168 __node_pointer __current = __e.__ptr_->__as_node();
1168 this->__delete_node(__current);1169 this->__delete_node(__current);
1169 if (__prev == 0)1170 if (__prev == 0)
...@@ -1172,9 +1173,9 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _...@@ -1172,9 +1173,9 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
1172 }1173 }
1173 throw;1174 throw;
1174 }1175 }
1175#endif // _LIBCPP_HAS_NO_EXCEPTIONS1176# endif // _LIBCPP_HAS_EXCEPTIONS
1176 __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);1177 __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
1177 base::__sz() += __ds;1178 this->__size_ += __ds;
1178 }1179 }
1179 return __r;1180 return __r;
1180}1181}
...@@ -1196,16 +1197,16 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se...@@ -1196,16 +1197,16 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se
1196 ++__ds;1197 ++__ds;
1197 __r = iterator(__node->__as_link());1198 __r = iterator(__node->__as_link());
1198 iterator __e = __r;1199 iterator __e = __r;
1199#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1200# if _LIBCPP_HAS_EXCEPTIONS
1200 try {1201 try {
1201#endif // _LIBCPP_HAS_NO_EXCEPTIONS1202# endif // _LIBCPP_HAS_EXCEPTIONS
1202 for (++__f; __f != __l; ++__f, (void)++__e, ++__ds) {1203 for (++__f; __f != __l; ++__f, (void)++__e, ++__ds) {
1203 __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, *__f)->__as_link();1204 __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, *__f)->__as_link();
1204 }1205 }
1205#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1206# if _LIBCPP_HAS_EXCEPTIONS
1206 } catch (...) {1207 } catch (...) {
1207 while (true) {1208 while (true) {
1208 __link_pointer __prev = __e.__ptr_->__prev_;1209 __base_pointer __prev = __e.__ptr_->__prev_;
1209 __node_pointer __current = __e.__ptr_->__as_node();1210 __node_pointer __current = __e.__ptr_->__as_node();
1210 this->__delete_node(__current);1211 this->__delete_node(__current);
1211 if (__prev == 0)1212 if (__prev == 0)
...@@ -1214,9 +1215,9 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se...@@ -1214,9 +1215,9 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se
1214 }1215 }
1215 throw;1216 throw;
1216 }1217 }
1217#endif // _LIBCPP_HAS_NO_EXCEPTIONS1218# endif // _LIBCPP_HAS_EXCEPTIONS
1218 __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);1219 __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
1219 base::__sz() += __ds;1220 this->__size_ += __ds;
1220 }1221 }
1221 return __r;1222 return __r;
1222}1223}
...@@ -1224,71 +1225,71 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se...@@ -1224,71 +1225,71 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se
1224template <class _Tp, class _Alloc>1225template <class _Tp, class _Alloc>
1225void list<_Tp, _Alloc>::push_front(const value_type& __x) {1226void list<_Tp, _Alloc>::push_front(const value_type& __x) {
1226 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);1227 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
1227 __link_pointer __nl = __node->__as_link();1228 __base_pointer __nl = __node->__as_link();
1228 __link_nodes_at_front(__nl, __nl);1229 __link_nodes_at_front(__nl, __nl);
1229 ++base::__sz();1230 ++this->__size_;
1230}1231}
12311232
1232template <class _Tp, class _Alloc>1233template <class _Tp, class _Alloc>
1233void list<_Tp, _Alloc>::push_back(const value_type& __x) {1234void list<_Tp, _Alloc>::push_back(const value_type& __x) {
1234 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);1235 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
1235 __link_pointer __nl = __node->__as_link();1236 __base_pointer __nl = __node->__as_link();
1236 __link_nodes_at_back(__nl, __nl);1237 __link_nodes_at_back(__nl, __nl);
1237 ++base::__sz();1238 ++this->__size_;
1238}1239}
12391240
1240#ifndef _LIBCPP_CXX03_LANG1241# ifndef _LIBCPP_CXX03_LANG
12411242
1242template <class _Tp, class _Alloc>1243template <class _Tp, class _Alloc>
1243void list<_Tp, _Alloc>::push_front(value_type&& __x) {1244void list<_Tp, _Alloc>::push_front(value_type&& __x) {
1244 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));1245 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));
1245 __link_pointer __nl = __node->__as_link();1246 __base_pointer __nl = __node->__as_link();
1246 __link_nodes_at_front(__nl, __nl);1247 __link_nodes_at_front(__nl, __nl);
1247 ++base::__sz();1248 ++this->__size_;
1248}1249}
12491250
1250template <class _Tp, class _Alloc>1251template <class _Tp, class _Alloc>
1251void list<_Tp, _Alloc>::push_back(value_type&& __x) {1252void list<_Tp, _Alloc>::push_back(value_type&& __x) {
1252 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));1253 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));
1253 __link_pointer __nl = __node->__as_link();1254 __base_pointer __nl = __node->__as_link();
1254 __link_nodes_at_back(__nl, __nl);1255 __link_nodes_at_back(__nl, __nl);
1255 ++base::__sz();1256 ++this->__size_;
1256}1257}
12571258
1258template <class _Tp, class _Alloc>1259template <class _Tp, class _Alloc>
1259template <class... _Args>1260template <class... _Args>
1260# if _LIBCPP_STD_VER >= 171261# if _LIBCPP_STD_VER >= 17
1261typename list<_Tp, _Alloc>::reference1262typename list<_Tp, _Alloc>::reference
1262# else1263# else
1263void1264void
1264# endif1265# endif
1265list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {1266list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {
1266 __node_pointer __node =1267 __node_pointer __node =
1267 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);1268 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);
1268 __link_pointer __nl = __node->__as_link();1269 __base_pointer __nl = __node->__as_link();
1269 __link_nodes_at_front(__nl, __nl);1270 __link_nodes_at_front(__nl, __nl);
1270 ++base::__sz();1271 ++this->__size_;
1271# if _LIBCPP_STD_VER >= 171272# if _LIBCPP_STD_VER >= 17
1272 return __node->__get_value();1273 return __node->__get_value();
1273# endif1274# endif
1274}1275}
12751276
1276template <class _Tp, class _Alloc>1277template <class _Tp, class _Alloc>
1277template <class... _Args>1278template <class... _Args>
1278# if _LIBCPP_STD_VER >= 171279# if _LIBCPP_STD_VER >= 17
1279typename list<_Tp, _Alloc>::reference1280typename list<_Tp, _Alloc>::reference
1280# else1281# else
1281void1282void
1282# endif1283# endif
1283list<_Tp, _Alloc>::emplace_back(_Args&&... __args) {1284list<_Tp, _Alloc>::emplace_back(_Args&&... __args) {
1284 __node_pointer __node =1285 __node_pointer __node =
1285 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);1286 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);
1286 __link_pointer __nl = __node->__as_link();1287 __base_pointer __nl = __node->__as_link();
1287 __link_nodes_at_back(__nl, __nl);1288 __link_nodes_at_back(__nl, __nl);
1288 ++base::__sz();1289 ++this->__size_;
1289# if _LIBCPP_STD_VER >= 171290# if _LIBCPP_STD_VER >= 17
1290 return __node->__get_value();1291 return __node->__get_value();
1291# endif1292# endif
1292}1293}
12931294
1294template <class _Tp, class _Alloc>1295template <class _Tp, class _Alloc>
...@@ -1296,48 +1297,48 @@ template <class... _Args>...@@ -1296,48 +1297,48 @@ template <class... _Args>
1296typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) {1297typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) {
1297 __node_pointer __node =1298 __node_pointer __node =
1298 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);1299 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);
1299 __link_pointer __nl = __node->__as_link();1300 __base_pointer __nl = __node->__as_link();
1300 __link_nodes(__p.__ptr_, __nl, __nl);1301 __link_nodes(__p.__ptr_, __nl, __nl);
1301 ++base::__sz();1302 ++this->__size_;
1302 return iterator(__nl);1303 return iterator(__nl);
1303}1304}
13041305
1305template <class _Tp, class _Alloc>1306template <class _Tp, class _Alloc>
1306typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) {1307typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) {
1307 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));1308 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));
1308 __link_pointer __nl = __node->__as_link();1309 __base_pointer __nl = __node->__as_link();
1309 __link_nodes(__p.__ptr_, __nl, __nl);1310 __link_nodes(__p.__ptr_, __nl, __nl);
1310 ++base::__sz();1311 ++this->__size_;
1311 return iterator(__nl);1312 return iterator(__nl);
1312}1313}
13131314
1314#endif // _LIBCPP_CXX03_LANG1315# endif // _LIBCPP_CXX03_LANG
13151316
1316template <class _Tp, class _Alloc>1317template <class _Tp, class _Alloc>
1317void list<_Tp, _Alloc>::pop_front() {1318void list<_Tp, _Alloc>::pop_front() {
1318 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_front() called with empty list");1319 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_front() called with empty list");
1319 __link_pointer __n = base::__end_.__next_;1320 __base_pointer __n = __base::__end_.__next_;
1320 base::__unlink_nodes(__n, __n);1321 __base::__unlink_nodes(__n, __n);
1321 --base::__sz();1322 --this->__size_;
1322 this->__delete_node(__n->__as_node());1323 this->__delete_node(__n->__as_node());
1323}1324}
13241325
1325template <class _Tp, class _Alloc>1326template <class _Tp, class _Alloc>
1326void list<_Tp, _Alloc>::pop_back() {1327void list<_Tp, _Alloc>::pop_back() {
1327 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_back() called on an empty list");1328 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_back() called on an empty list");
1328 __link_pointer __n = base::__end_.__prev_;1329 __base_pointer __n = __base::__end_.__prev_;
1329 base::__unlink_nodes(__n, __n);1330 __base::__unlink_nodes(__n, __n);
1330 --base::__sz();1331 --this->__size_;
1331 this->__delete_node(__n->__as_node());1332 this->__delete_node(__n->__as_node());
1332}1333}
13331334
1334template <class _Tp, class _Alloc>1335template <class _Tp, class _Alloc>
1335typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p) {1336typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p) {
1336 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p != end(), "list::erase(iterator) called with a non-dereferenceable iterator");1337 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p != end(), "list::erase(iterator) called with a non-dereferenceable iterator");
1337 __link_pointer __n = __p.__ptr_;1338 __base_pointer __n = __p.__ptr_;
1338 __link_pointer __r = __n->__next_;1339 __base_pointer __r = __n->__next_;
1339 base::__unlink_nodes(__n, __n);1340 __base::__unlink_nodes(__n, __n);
1340 --base::__sz();1341 --this->__size_;
1341 this->__delete_node(__n->__as_node());1342 this->__delete_node(__n->__as_node());
1342 return iterator(__r);1343 return iterator(__r);
1343}1344}
...@@ -1345,11 +1346,11 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p...@@ -1345,11 +1346,11 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p
1345template <class _Tp, class _Alloc>1346template <class _Tp, class _Alloc>
1346typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) {1347typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) {
1347 if (__f != __l) {1348 if (__f != __l) {
1348 base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_);1349 __base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_);
1349 while (__f != __l) {1350 while (__f != __l) {
1350 __link_pointer __n = __f.__ptr_;1351 __base_pointer __n = __f.__ptr_;
1351 ++__f;1352 ++__f;
1352 --base::__sz();1353 --this->__size_;
1353 this->__delete_node(__n->__as_node());1354 this->__delete_node(__n->__as_node());
1354 }1355 }
1355 }1356 }
...@@ -1358,25 +1359,25 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f...@@ -1358,25 +1359,25 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f
13581359
1359template <class _Tp, class _Alloc>1360template <class _Tp, class _Alloc>
1360void list<_Tp, _Alloc>::resize(size_type __n) {1361void list<_Tp, _Alloc>::resize(size_type __n) {
1361 if (__n < base::__sz())1362 if (__n < this->__size_)
1362 erase(__iterator(__n), end());1363 erase(__iterator(__n), end());
1363 else if (__n > base::__sz()) {1364 else if (__n > this->__size_) {
1364 __n -= base::__sz();1365 __n -= this->__size_;
1365 size_type __ds = 0;1366 size_type __ds = 0;
1366 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr);1367 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr);
1367 ++__ds;1368 ++__ds;
1368 iterator __r = iterator(__node->__as_link());1369 iterator __r = iterator(__node->__as_link());
1369 iterator __e = __r;1370 iterator __e = __r;
1370#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1371# if _LIBCPP_HAS_EXCEPTIONS
1371 try {1372 try {
1372#endif // _LIBCPP_HAS_NO_EXCEPTIONS1373# endif // _LIBCPP_HAS_EXCEPTIONS
1373 for (--__n; __n != 0; --__n, (void)++__e, ++__ds) {1374 for (--__n; __n != 0; --__n, (void)++__e, ++__ds) {
1374 __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr)->__as_link();1375 __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr)->__as_link();
1375 }1376 }
1376#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1377# if _LIBCPP_HAS_EXCEPTIONS
1377 } catch (...) {1378 } catch (...) {
1378 while (true) {1379 while (true) {
1379 __link_pointer __prev = __e.__ptr_->__prev_;1380 __base_pointer __prev = __e.__ptr_->__prev_;
1380 __node_pointer __current = __e.__ptr_->__as_node();1381 __node_pointer __current = __e.__ptr_->__as_node();
1381 this->__delete_node(__current);1382 this->__delete_node(__current);
1382 if (__prev == 0)1383 if (__prev == 0)
...@@ -1385,34 +1386,34 @@ void list<_Tp, _Alloc>::resize(size_type __n) {...@@ -1385,34 +1386,34 @@ void list<_Tp, _Alloc>::resize(size_type __n) {
1385 }1386 }
1386 throw;1387 throw;
1387 }1388 }
1388#endif // _LIBCPP_HAS_NO_EXCEPTIONS1389# endif // _LIBCPP_HAS_EXCEPTIONS
1389 __link_nodes_at_back(__r.__ptr_, __e.__ptr_);1390 __link_nodes_at_back(__r.__ptr_, __e.__ptr_);
1390 base::__sz() += __ds;1391 this->__size_ += __ds;
1391 }1392 }
1392}1393}
13931394
1394template <class _Tp, class _Alloc>1395template <class _Tp, class _Alloc>
1395void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {1396void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {
1396 if (__n < base::__sz())1397 if (__n < this->__size_)
1397 erase(__iterator(__n), end());1398 erase(__iterator(__n), end());
1398 else if (__n > base::__sz()) {1399 else if (__n > this->__size_) {
1399 __n -= base::__sz();1400 __n -= this->__size_;
1400 size_type __ds = 0;1401 size_type __ds = 0;
1401 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);1402 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
1402 ++__ds;1403 ++__ds;
1403 __link_pointer __nl = __node->__as_link();1404 __base_pointer __nl = __node->__as_link();
1404 iterator __r = iterator(__nl);1405 iterator __r = iterator(__nl);
1405 iterator __e = __r;1406 iterator __e = __r;
1406#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1407# if _LIBCPP_HAS_EXCEPTIONS
1407 try {1408 try {
1408#endif // _LIBCPP_HAS_NO_EXCEPTIONS1409# endif // _LIBCPP_HAS_EXCEPTIONS
1409 for (--__n; __n != 0; --__n, (void)++__e, ++__ds) {1410 for (--__n; __n != 0; --__n, (void)++__e, ++__ds) {
1410 __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link();1411 __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link();
1411 }1412 }
1412#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1413# if _LIBCPP_HAS_EXCEPTIONS
1413 } catch (...) {1414 } catch (...) {
1414 while (true) {1415 while (true) {
1415 __link_pointer __prev = __e.__ptr_->__prev_;1416 __base_pointer __prev = __e.__ptr_->__prev_;
1416 __node_pointer __current = __e.__ptr_->__as_node();1417 __node_pointer __current = __e.__ptr_->__as_node();
1417 this->__delete_node(__current);1418 this->__delete_node(__current);
1418 if (__prev == 0)1419 if (__prev == 0)
...@@ -1421,9 +1422,9 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {...@@ -1421,9 +1422,9 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {
1421 }1422 }
1422 throw;1423 throw;
1423 }1424 }
1424#endif // _LIBCPP_HAS_NO_EXCEPTIONS1425# endif // _LIBCPP_HAS_EXCEPTIONS
1425 __link_nodes(base::__end_as_link(), __r.__ptr_, __e.__ptr_);1426 __link_nodes(__base::__end_as_link(), __r.__ptr_, __e.__ptr_);
1426 base::__sz() += __ds;1427 this->__size_ += __ds;
1427 }1428 }
1428}1429}
14291430
...@@ -1432,38 +1433,38 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) {...@@ -1432,38 +1433,38 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) {
1432 _LIBCPP_ASSERT_VALID_INPUT_RANGE(1433 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
1433 this != std::addressof(__c), "list::splice(iterator, list) called with this == &list");1434 this != std::addressof(__c), "list::splice(iterator, list) called with this == &list");
1434 if (!__c.empty()) {1435 if (!__c.empty()) {
1435 __link_pointer __f = __c.__end_.__next_;1436 __base_pointer __f = __c.__end_.__next_;
1436 __link_pointer __l = __c.__end_.__prev_;1437 __base_pointer __l = __c.__end_.__prev_;
1437 base::__unlink_nodes(__f, __l);1438 __base::__unlink_nodes(__f, __l);
1438 __link_nodes(__p.__ptr_, __f, __l);1439 __link_nodes(__p.__ptr_, __f, __l);
1439 base::__sz() += __c.__sz();1440 this->__size_ += __c.__size_;
1440 __c.__sz() = 0;1441 __c.__size_ = 0;
1441 }1442 }
1442}1443}
14431444
1444template <class _Tp, class _Alloc>1445template <class _Tp, class _Alloc>
1445void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) {1446void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) {
1446 if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_) {1447 if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_) {
1447 __link_pointer __f = __i.__ptr_;1448 __base_pointer __f = __i.__ptr_;
1448 base::__unlink_nodes(__f, __f);1449 __base::__unlink_nodes(__f, __f);
1449 __link_nodes(__p.__ptr_, __f, __f);1450 __link_nodes(__p.__ptr_, __f, __f);
1450 --__c.__sz();1451 --__c.__size_;
1451 ++base::__sz();1452 ++this->__size_;
1452 }1453 }
1453}1454}
14541455
1455template <class _Tp, class _Alloc>1456template <class _Tp, class _Alloc>
1456void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) {1457void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) {
1457 if (__f != __l) {1458 if (__f != __l) {
1458 __link_pointer __first = __f.__ptr_;1459 __base_pointer __first = __f.__ptr_;
1459 --__l;1460 --__l;
1460 __link_pointer __last = __l.__ptr_;1461 __base_pointer __last = __l.__ptr_;
1461 if (this != std::addressof(__c)) {1462 if (this != std::addressof(__c)) {
1462 size_type __s = std::distance(__f, __l) + 1;1463 size_type __s = std::distance(__f, __l) + 1;
1463 __c.__sz() -= __s;1464 __c.__size_ -= __s;
1464 base::__sz() += __s;1465 this->__size_ += __s;
1465 }1466 }
1466 base::__unlink_nodes(__first, __last);1467 __base::__unlink_nodes(__first, __last);
1467 __link_nodes(__p.__ptr_, __first, __last);1468 __link_nodes(__p.__ptr_, __first, __last);
1468 }1469 }
1469}1470}
...@@ -1543,12 +1544,12 @@ void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) {...@@ -1543,12 +1544,12 @@ void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) {
1543 iterator __m2 = std::next(__f2);1544 iterator __m2 = std::next(__f2);
1544 for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2, (void)++__ds)1545 for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2, (void)++__ds)
1545 ;1546 ;
1546 base::__sz() += __ds;1547 this->__size_ += __ds;
1547 __c.__sz() -= __ds;1548 __c.__size_ -= __ds;
1548 __link_pointer __f = __f2.__ptr_;1549 __base_pointer __f = __f2.__ptr_;
1549 __link_pointer __l = __m2.__ptr_->__prev_;1550 __base_pointer __l = __m2.__ptr_->__prev_;
1550 __f2 = __m2;1551 __f2 = __m2;
1551 base::__unlink_nodes(__f, __l);1552 __base::__unlink_nodes(__f, __l);
1552 __m2 = std::next(__f1);1553 __m2 = std::next(__f1);
1553 __link_nodes(__f1.__ptr_, __f, __l);1554 __link_nodes(__f1.__ptr_, __f, __l);
1554 __f1 = __m2;1555 __f1 = __m2;
...@@ -1567,7 +1568,7 @@ inline void list<_Tp, _Alloc>::sort() {...@@ -1567,7 +1568,7 @@ inline void list<_Tp, _Alloc>::sort() {
1567template <class _Tp, class _Alloc>1568template <class _Tp, class _Alloc>
1568template <class _Comp>1569template <class _Comp>
1569inline void list<_Tp, _Alloc>::sort(_Comp __comp) {1570inline void list<_Tp, _Alloc>::sort(_Comp __comp) {
1570 __sort(begin(), end(), base::__sz(), __comp);1571 __sort(begin(), end(), this->__size_, __comp);
1571}1572}
15721573
1573template <class _Tp, class _Alloc>1574template <class _Tp, class _Alloc>
...@@ -1580,8 +1581,8 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __...@@ -1580,8 +1581,8 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __
1580 return __f1;1581 return __f1;
1581 case 2:1582 case 2:
1582 if (__comp(*--__e2, *__f1)) {1583 if (__comp(*--__e2, *__f1)) {
1583 __link_pointer __f = __e2.__ptr_;1584 __base_pointer __f = __e2.__ptr_;
1584 base::__unlink_nodes(__f, __f);1585 __base::__unlink_nodes(__f, __f);
1585 __link_nodes(__f1.__ptr_, __f, __f);1586 __link_nodes(__f1.__ptr_, __f, __f);
1586 return __e2;1587 return __e2;
1587 }1588 }
...@@ -1595,11 +1596,11 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __...@@ -1595,11 +1596,11 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __
1595 iterator __m2 = std::next(__f2);1596 iterator __m2 = std::next(__f2);
1596 for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)1597 for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
1597 ;1598 ;
1598 __link_pointer __f = __f2.__ptr_;1599 __base_pointer __f = __f2.__ptr_;
1599 __link_pointer __l = __m2.__ptr_->__prev_;1600 __base_pointer __l = __m2.__ptr_->__prev_;
1600 __r = __f2;1601 __r = __f2;
1601 __e1 = __f2 = __m2;1602 __e1 = __f2 = __m2;
1602 base::__unlink_nodes(__f, __l);1603 __base::__unlink_nodes(__f, __l);
1603 __m2 = std::next(__f1);1604 __m2 = std::next(__f1);
1604 __link_nodes(__f1.__ptr_, __f, __l);1605 __link_nodes(__f1.__ptr_, __f, __l);
1605 __f1 = __m2;1606 __f1 = __m2;
...@@ -1610,12 +1611,12 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __...@@ -1610,12 +1611,12 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __
1610 iterator __m2 = std::next(__f2);1611 iterator __m2 = std::next(__f2);
1611 for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)1612 for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
1612 ;1613 ;
1613 __link_pointer __f = __f2.__ptr_;1614 __base_pointer __f = __f2.__ptr_;
1614 __link_pointer __l = __m2.__ptr_->__prev_;1615 __base_pointer __l = __m2.__ptr_->__prev_;
1615 if (__e1 == __f2)1616 if (__e1 == __f2)
1616 __e1 = __m2;1617 __e1 = __m2;
1617 __f2 = __m2;1618 __f2 = __m2;
1618 base::__unlink_nodes(__f, __l);1619 __base::__unlink_nodes(__f, __l);
1619 __m2 = std::next(__f1);1620 __m2 = std::next(__f1);
1620 __link_nodes(__f1.__ptr_, __f, __l);1621 __link_nodes(__f1.__ptr_, __f, __l);
1621 __f1 = __m2;1622 __f1 = __m2;
...@@ -1627,7 +1628,7 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __...@@ -1627,7 +1628,7 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __
16271628
1628template <class _Tp, class _Alloc>1629template <class _Tp, class _Alloc>
1629void list<_Tp, _Alloc>::reverse() _NOEXCEPT {1630void list<_Tp, _Alloc>::reverse() _NOEXCEPT {
1630 if (base::__sz() > 1) {1631 if (this->__size_ > 1) {
1631 iterator __e = end();1632 iterator __e = end();
1632 for (iterator __i = begin(); __i.__ptr_ != __e.__ptr_;) {1633 for (iterator __i = begin(); __i.__ptr_ != __e.__ptr_;) {
1633 std::swap(__i.__ptr_->__prev_, __i.__ptr_->__next_);1634 std::swap(__i.__ptr_->__prev_, __i.__ptr_->__next_);
...@@ -1647,7 +1648,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const list<_Tp, _Alloc>& __x, const...@@ -1647,7 +1648,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const list<_Tp, _Alloc>& __x, const
1647 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());1648 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
1648}1649}
16491650
1650#if _LIBCPP_STD_VER <= 171651# if _LIBCPP_STD_VER <= 17
16511652
1652template <class _Tp, class _Alloc>1653template <class _Tp, class _Alloc>
1653inline _LIBCPP_HIDE_FROM_ABI bool operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {1654inline _LIBCPP_HIDE_FROM_ABI bool operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
...@@ -1674,16 +1675,15 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const list<_Tp, _Alloc>& __x, const...@@ -1674,16 +1675,15 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const list<_Tp, _Alloc>& __x, const
1674 return !(__y < __x);1675 return !(__y < __x);
1675}1676}
16761677
1677#else // _LIBCPP_STD_VER <= 171678# else // _LIBCPP_STD_VER <= 17
16781679
1679template <class _Tp, class _Allocator>1680template <class _Tp, class _Allocator>
1680_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>1681_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
1681operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) {1682operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) {
1682 return std::lexicographical_compare_three_way(1683 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
1683 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
1684}1684}
16851685
1686#endif // _LIBCPP_STD_VER <= 171686# endif // _LIBCPP_STD_VER <= 17
16871687
1688template <class _Tp, class _Alloc>1688template <class _Tp, class _Alloc>
1689inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)1689inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
...@@ -1691,7 +1691,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>...@@ -1691,7 +1691,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>
1691 __x.swap(__y);1691 __x.swap(__y);
1692}1692}
16931693
1694#if _LIBCPP_STD_VER >= 201694# if _LIBCPP_STD_VER >= 20
1695template <class _Tp, class _Allocator, class _Predicate>1695template <class _Tp, class _Allocator, class _Predicate>
1696inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type1696inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type
1697erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) {1697erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) {
...@@ -1706,38 +1706,50 @@ erase(list<_Tp, _Allocator>& __c, const _Up& __v) {...@@ -1706,38 +1706,50 @@ erase(list<_Tp, _Allocator>& __c, const _Up& __v) {
17061706
1707template <>1707template <>
1708inline constexpr bool __format::__enable_insertable<std::list<char>> = true;1708inline constexpr bool __format::__enable_insertable<std::list<char>> = true;
1709# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1709# if _LIBCPP_HAS_WIDE_CHARACTERS
1710template <>1710template <>
1711inline constexpr bool __format::__enable_insertable<std::list<wchar_t>> = true;1711inline constexpr bool __format::__enable_insertable<std::list<wchar_t>> = true;
1712# endif1712# endif
17131713
1714#endif // _LIBCPP_STD_VER >= 201714# endif // _LIBCPP_STD_VER >= 20
1715
1716template <class _Tp, class _Allocator>
1717struct __container_traits<list<_Tp, _Allocator> > {
1718 // http://eel.is/c++draft/container.reqmts
1719 // Unless otherwise specified (see [associative.reqmts.except], [unord.req.except], [deque.modifiers],
1720 // [inplace.vector.modifiers], and [vector.modifiers]) all container types defined in this Clause meet the following
1721 // additional requirements:
1722 // - If an exception is thrown by an insert() or emplace() function while inserting a single element, that
1723 // function has no effects.
1724 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;
1725};
17151726
1716_LIBCPP_END_NAMESPACE_STD1727_LIBCPP_END_NAMESPACE_STD
17171728
1718#if _LIBCPP_STD_VER >= 171729# if _LIBCPP_STD_VER >= 17
1719_LIBCPP_BEGIN_NAMESPACE_STD1730_LIBCPP_BEGIN_NAMESPACE_STD
1720namespace pmr {1731namespace pmr {
1721template <class _ValueT>1732template <class _ValueT>
1722using list _LIBCPP_AVAILABILITY_PMR = std::list<_ValueT, polymorphic_allocator<_ValueT>>;1733using list _LIBCPP_AVAILABILITY_PMR = std::list<_ValueT, polymorphic_allocator<_ValueT>>;
1723} // namespace pmr1734} // namespace pmr
1724_LIBCPP_END_NAMESPACE_STD1735_LIBCPP_END_NAMESPACE_STD
1725#endif1736# endif
17261737
1727_LIBCPP_POP_MACROS1738_LIBCPP_POP_MACROS
17281739
1729#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 201740# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1730# include <algorithm>1741# include <algorithm>
1731# include <atomic>1742# include <atomic>
1732# include <concepts>1743# include <concepts>
1733# include <cstdint>1744# include <cstdint>
1734# include <cstdlib>1745# include <cstdlib>
1735# include <functional>1746# include <functional>
1736# include <iosfwd>1747# include <iosfwd>
1737# include <iterator>1748# include <iterator>
1738# include <stdexcept>1749# include <stdexcept>
1739# include <type_traits>1750# include <type_traits>
1740# include <typeinfo>1751# include <typeinfo>
1741#endif1752# endif
1753#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
17421754
1743#endif // _LIBCPP_LIST1755#endif // _LIBCPP_LIST
lib/libcxx/include/locale+179-240
...@@ -187,74 +187,72 @@ template <class charT> class messages_byname;...@@ -187,74 +187,72 @@ template <class charT> class messages_byname;
187187
188*/188*/
189189
190#include <__config>190#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
191191# include <__cxx03/locale>
192#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)192#else
193193# include <__config>
194# include <__algorithm/copy.h>194
195# include <__algorithm/equal.h>195# if _LIBCPP_HAS_LOCALIZATION
196# include <__algorithm/find.h>196
197# include <__algorithm/max.h>197# include <__algorithm/copy.h>
198# include <__algorithm/reverse.h>198# include <__algorithm/equal.h>
199# include <__algorithm/unwrap_iter.h>199# include <__algorithm/find.h>
200# include <__assert>200# include <__algorithm/max.h>
201# include <__iterator/access.h>201# include <__algorithm/reverse.h>
202# include <__iterator/back_insert_iterator.h>202# include <__algorithm/unwrap_iter.h>
203# include <__iterator/istreambuf_iterator.h>203# include <__assert>
204# include <__iterator/ostreambuf_iterator.h>204# include <__iterator/access.h>
205# include <__locale>205# include <__iterator/back_insert_iterator.h>
206# include <__memory/unique_ptr.h>206# include <__iterator/istreambuf_iterator.h>
207# include <__type_traits/make_unsigned.h>207# include <__iterator/ostreambuf_iterator.h>
208# include <cerrno>208# include <__locale>
209# include <cstdio>209# include <__locale_dir/pad_and_output.h>
210# include <cstdlib>210# include <__memory/unique_ptr.h>
211# include <ctime>211# include <__new/exceptions.h>
212# include <ios>212# include <__type_traits/make_unsigned.h>
213# include <limits>213# include <cerrno>
214# include <new>214# include <cstdio>
215# include <streambuf>215# include <cstdlib>
216# include <version>216# include <ctime>
217217# include <ios>
218// TODO: Fix __bsd_locale_defaults.h218# include <limits>
219# include <streambuf>
220# include <version>
221
222// TODO: Properly qualify calls now that the locale base API defines functions instead of macros
219// NOLINTBEGIN(libcpp-robust-against-adl)223// NOLINTBEGIN(libcpp-robust-against-adl)
220224
221# if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))225# if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
222// Most unix variants have catopen. These are the specific ones that don't.226// Most unix variants have catopen. These are the specific ones that don't.
223# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)227# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)
224# define _LIBCPP_HAS_CATOPEN 1228# define _LIBCPP_HAS_CATOPEN 1
225# include <nl_types.h>229# include <nl_types.h>
230# else
231# define _LIBCPP_HAS_CATOPEN 0
232# endif
233# else
234# define _LIBCPP_HAS_CATOPEN 0
226# endif235# endif
227# endif
228
229# ifdef _LIBCPP_LOCALE__L_EXTENSIONS
230# include <__locale_dir/locale_base_api/bsd_locale_defaults.h>
231# else
232# include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h>
233# endif
234
235# if defined(__APPLE__) || defined(__FreeBSD__)
236# include <xlocale.h>
237# endif
238236
239# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)237# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
240# pragma GCC system_header238# pragma GCC system_header
241# endif239# endif
242240
243_LIBCPP_PUSH_MACROS241_LIBCPP_PUSH_MACROS
244# include <__undef_macros>242# include <__undef_macros>
245243
246_LIBCPP_BEGIN_NAMESPACE_STD244_LIBCPP_BEGIN_NAMESPACE_STD
247245
248# if defined(__APPLE__) || defined(__FreeBSD__)246# if defined(__APPLE__) || defined(__FreeBSD__)
249# define _LIBCPP_GET_C_LOCALE 0247# define _LIBCPP_GET_C_LOCALE 0
250# elif defined(__NetBSD__)248# elif defined(__NetBSD__)
251# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE249# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
252# else250# else
253# define _LIBCPP_GET_C_LOCALE __cloc()251# define _LIBCPP_GET_C_LOCALE __cloc()
254// Get the C locale object252// Get the C locale object
255_LIBCPP_EXPORTED_FROM_ABI locale_t __cloc();253_LIBCPP_EXPORTED_FROM_ABI __locale::__locale_t __cloc();
256# define __cloc_defined254# define __cloc_defined
257# endif255# endif
258256
259// __scan_keyword257// __scan_keyword
260// Scans [__b, __e) until a match is found in the basic_strings range258// Scans [__b, __e) until a match is found in the basic_strings range
...@@ -402,7 +400,7 @@ struct __num_get : protected __num_get_base {...@@ -402,7 +400,7 @@ struct __num_get : protected __num_get_base {
402 unsigned*& __g_end,400 unsigned*& __g_end,
403 unsigned& __dc,401 unsigned& __dc,
404 _CharT* __atoms);402 _CharT* __atoms);
405# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET403# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
406 static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);404 static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
407 static int __stage2_int_loop(405 static int __stage2_int_loop(
408 _CharT __ct,406 _CharT __ct,
...@@ -416,7 +414,7 @@ struct __num_get : protected __num_get_base {...@@ -416,7 +414,7 @@ struct __num_get : protected __num_get_base {
416 unsigned*& __g_end,414 unsigned*& __g_end,
417 _CharT* __atoms);415 _CharT* __atoms);
418416
419# else417# else
420 static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep) {418 static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep) {
421 locale __loc = __iob.getloc();419 locale __loc = __iob.getloc();
422 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);420 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
...@@ -451,10 +449,10 @@ private:...@@ -451,10 +449,10 @@ private:
451 (void)__atoms;449 (void)__atoms;
452 return __src;450 return __src;
453 }451 }
454# endif452# endif
455};453};
456454
457# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET455# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
458template <class _CharT>456template <class _CharT>
459string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep) {457string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep) {
460 locale __loc = __iob.getloc();458 locale __loc = __iob.getloc();
...@@ -463,7 +461,7 @@ string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _C...@@ -463,7 +461,7 @@ string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _C
463 __thousands_sep = __np.thousands_sep();461 __thousands_sep = __np.thousands_sep();
464 return __np.grouping();462 return __np.grouping();
465}463}
466# endif464# endif
467465
468template <class _CharT>466template <class _CharT>
469string __num_get<_CharT>::__stage2_float_prep(467string __num_get<_CharT>::__stage2_float_prep(
...@@ -478,16 +476,16 @@ string __num_get<_CharT>::__stage2_float_prep(...@@ -478,16 +476,16 @@ string __num_get<_CharT>::__stage2_float_prep(
478476
479template <class _CharT>477template <class _CharT>
480int478int
481# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET479# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
482__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,480__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
483 unsigned& __dc, _CharT __thousands_sep, const string& __grouping,481 unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
484 unsigned* __g, unsigned*& __g_end, _CharT* __atoms)482 unsigned* __g, unsigned*& __g_end, _CharT* __atoms)
485# else483# else
486__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,484__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
487 unsigned& __dc, _CharT __thousands_sep, const string& __grouping,485 unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
488 unsigned* __g, unsigned*& __g_end, const _CharT* __atoms)486 unsigned* __g, unsigned*& __g_end, const _CharT* __atoms)
489487
490# endif488# endif
491{489{
492 if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) {490 if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) {
493 *__a_end++ = __ct == __atoms[24] ? '+' : '-';491 *__a_end++ = __ct == __atoms[24] ? '+' : '-';
...@@ -586,9 +584,9 @@ int __num_get<_CharT>::__stage2_float_loop(...@@ -586,9 +584,9 @@ int __num_get<_CharT>::__stage2_float_loop(
586}584}
587585
588extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>;586extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>;
589# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS587# if _LIBCPP_HAS_WIDE_CHARACTERS
590extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>;588extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>;
591# endif589# endif
592590
593template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >591template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
594class _LIBCPP_TEMPLATE_VIS num_get : public locale::facet, private __num_get<_CharT> {592class _LIBCPP_TEMPLATE_VIS num_get : public locale::facet, private __num_get<_CharT> {
...@@ -727,7 +725,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end, ios_base::iostat...@@ -727,7 +725,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end, ios_base::iostat
727 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;725 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
728 errno = 0;726 errno = 0;
729 char* __p2;727 char* __p2;
730 long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);728 long long __ll = __locale::__strtoll(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
731 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;729 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
732 if (__current_errno == 0)730 if (__current_errno == 0)
733 errno = __save_errno;731 errno = __save_errno;
...@@ -759,7 +757,7 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end, ios_base::iost...@@ -759,7 +757,7 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end, ios_base::iost
759 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;757 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
760 errno = 0;758 errno = 0;
761 char* __p2;759 char* __p2;
762 unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);760 unsigned long long __ll = __locale::__strtoull(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
763 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;761 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
764 if (__current_errno == 0)762 if (__current_errno == 0)
765 errno = __save_errno;763 errno = __save_errno;
...@@ -784,17 +782,17 @@ _LIBCPP_HIDE_FROM_ABI _Tp __do_strtod(const char* __a, char** __p2);...@@ -784,17 +782,17 @@ _LIBCPP_HIDE_FROM_ABI _Tp __do_strtod(const char* __a, char** __p2);
784782
785template <>783template <>
786inline _LIBCPP_HIDE_FROM_ABI float __do_strtod<float>(const char* __a, char** __p2) {784inline _LIBCPP_HIDE_FROM_ABI float __do_strtod<float>(const char* __a, char** __p2) {
787 return strtof_l(__a, __p2, _LIBCPP_GET_C_LOCALE);785 return __locale::__strtof(__a, __p2, _LIBCPP_GET_C_LOCALE);
788}786}
789787
790template <>788template <>
791inline _LIBCPP_HIDE_FROM_ABI double __do_strtod<double>(const char* __a, char** __p2) {789inline _LIBCPP_HIDE_FROM_ABI double __do_strtod<double>(const char* __a, char** __p2) {
792 return strtod_l(__a, __p2, _LIBCPP_GET_C_LOCALE);790 return __locale::__strtod(__a, __p2, _LIBCPP_GET_C_LOCALE);
793}791}
794792
795template <>793template <>
796inline _LIBCPP_HIDE_FROM_ABI long double __do_strtod<long double>(const char* __a, char** __p2) {794inline _LIBCPP_HIDE_FROM_ABI long double __do_strtod<long double>(const char* __a, char** __p2) {
797 return strtold_l(__a, __p2, _LIBCPP_GET_C_LOCALE);795 return __locale::__strtold(__a, __p2, _LIBCPP_GET_C_LOCALE);
798}796}
799797
800template <class _Tp>798template <class _Tp>
...@@ -858,14 +856,14 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_signed(...@@ -858,14 +856,14 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_signed(
858 // Stage 2856 // Stage 2
859 char_type __thousands_sep;857 char_type __thousands_sep;
860 const int __atoms_size = __num_get_base::__int_chr_cnt;858 const int __atoms_size = __num_get_base::__int_chr_cnt;
861# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET859# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
862 char_type __atoms1[__atoms_size];860 char_type __atoms1[__atoms_size];
863 const char_type* __atoms = this->__do_widen(__iob, __atoms1);861 const char_type* __atoms = this->__do_widen(__iob, __atoms1);
864 string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);862 string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
865# else863# else
866 char_type __atoms[__atoms_size];864 char_type __atoms[__atoms_size];
867 string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);865 string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
868# endif866# endif
869 string __buf;867 string __buf;
870 __buf.resize(__buf.capacity());868 __buf.resize(__buf.capacity());
871 char* __a = &__buf[0];869 char* __a = &__buf[0];
...@@ -907,14 +905,14 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_unsigned(...@@ -907,14 +905,14 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_unsigned(
907 // Stage 2905 // Stage 2
908 char_type __thousands_sep;906 char_type __thousands_sep;
909 const int __atoms_size = __num_get_base::__int_chr_cnt;907 const int __atoms_size = __num_get_base::__int_chr_cnt;
910# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET908# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
911 char_type __atoms1[__atoms_size];909 char_type __atoms1[__atoms_size];
912 const char_type* __atoms = this->__do_widen(__iob, __atoms1);910 const char_type* __atoms = this->__do_widen(__iob, __atoms1);
913 string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);911 string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
914# else912# else
915 char_type __atoms[__atoms_size];913 char_type __atoms[__atoms_size];
916 string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);914 string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
917# endif915# endif
918 string __buf;916 string __buf;
919 __buf.resize(__buf.capacity());917 __buf.resize(__buf.capacity());
920 char* __a = &__buf[0];918 char* __a = &__buf[0];
...@@ -1048,7 +1046,7 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get(...@@ -1048,7 +1046,7 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get(
1048 }1046 }
1049 // Stage 31047 // Stage 3
1050 __buf.resize(__a_end - __a);1048 __buf.resize(__a_end - __a);
1051 if (__libcpp_sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)1049 if (__locale::__sscanf(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
1052 __err = ios_base::failbit;1050 __err = ios_base::failbit;
1053 // EOF checked1051 // EOF checked
1054 if (__b == __e)1052 if (__b == __e)
...@@ -1057,9 +1055,9 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get(...@@ -1057,9 +1055,9 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get(
1057}1055}
10581056
1059extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>;1057extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>;
1060# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1058# if _LIBCPP_HAS_WIDE_CHARACTERS
1061extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>;1059extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>;
1062# endif1060# endif
10631061
1064struct _LIBCPP_EXPORTED_FROM_ABI __num_put_base {1062struct _LIBCPP_EXPORTED_FROM_ABI __num_put_base {
1065protected:1063protected:
...@@ -1131,11 +1129,11 @@ void __num_put<_CharT>::__widen_and_group_float(...@@ -1131,11 +1129,11 @@ void __num_put<_CharT>::__widen_and_group_float(
1131 *__oe++ = __ct.widen(*__nf++);1129 *__oe++ = __ct.widen(*__nf++);
1132 *__oe++ = __ct.widen(*__nf++);1130 *__oe++ = __ct.widen(*__nf++);
1133 for (__ns = __nf; __ns < __ne; ++__ns)1131 for (__ns = __nf; __ns < __ne; ++__ns)
1134 if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))1132 if (!__locale::__isxdigit(*__ns, _LIBCPP_GET_C_LOCALE))
1135 break;1133 break;
1136 } else {1134 } else {
1137 for (__ns = __nf; __ns < __ne; ++__ns)1135 for (__ns = __nf; __ns < __ne; ++__ns)
1138 if (!isdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))1136 if (!__locale::__isdigit(*__ns, _LIBCPP_GET_C_LOCALE))
1139 break;1137 break;
1140 }1138 }
1141 if (__grouping.empty()) {1139 if (__grouping.empty()) {
...@@ -1175,9 +1173,9 @@ void __num_put<_CharT>::__widen_and_group_float(...@@ -1175,9 +1173,9 @@ void __num_put<_CharT>::__widen_and_group_float(
1175}1173}
11761174
1177extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>;1175extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>;
1178# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1176# if _LIBCPP_HAS_WIDE_CHARACTERS
1179extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>;1177extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>;
1180# endif1178# endif
11811179
1182template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >1180template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
1183class _LIBCPP_TEMPLATE_VIS num_put : public locale::facet, private __num_put<_CharT> {1181class _LIBCPP_TEMPLATE_VIS num_put : public locale::facet, private __num_put<_CharT> {
...@@ -1245,66 +1243,6 @@ protected:...@@ -1245,66 +1243,6 @@ protected:
1245template <class _CharT, class _OutputIterator>1243template <class _CharT, class _OutputIterator>
1246locale::id num_put<_CharT, _OutputIterator>::id;1244locale::id num_put<_CharT, _OutputIterator>::id;
12471245
1248template <class _CharT, class _OutputIterator>
1249_LIBCPP_HIDE_FROM_ABI _OutputIterator __pad_and_output(
1250 _OutputIterator __s, const _CharT* __ob, const _CharT* __op, const _CharT* __oe, ios_base& __iob, _CharT __fl) {
1251 streamsize __sz = __oe - __ob;
1252 streamsize __ns = __iob.width();
1253 if (__ns > __sz)
1254 __ns -= __sz;
1255 else
1256 __ns = 0;
1257 for (; __ob < __op; ++__ob, ++__s)
1258 *__s = *__ob;
1259 for (; __ns; --__ns, ++__s)
1260 *__s = __fl;
1261 for (; __ob < __oe; ++__ob, ++__s)
1262 *__s = *__ob;
1263 __iob.width(0);
1264 return __s;
1265}
1266
1267template <class _CharT, class _Traits>
1268_LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_CharT, _Traits> __pad_and_output(
1269 ostreambuf_iterator<_CharT, _Traits> __s,
1270 const _CharT* __ob,
1271 const _CharT* __op,
1272 const _CharT* __oe,
1273 ios_base& __iob,
1274 _CharT __fl) {
1275 if (__s.__sbuf_ == nullptr)
1276 return __s;
1277 streamsize __sz = __oe - __ob;
1278 streamsize __ns = __iob.width();
1279 if (__ns > __sz)
1280 __ns -= __sz;
1281 else
1282 __ns = 0;
1283 streamsize __np = __op - __ob;
1284 if (__np > 0) {
1285 if (__s.__sbuf_->sputn(__ob, __np) != __np) {
1286 __s.__sbuf_ = nullptr;
1287 return __s;
1288 }
1289 }
1290 if (__ns > 0) {
1291 basic_string<_CharT, _Traits> __sp(__ns, __fl);
1292 if (__s.__sbuf_->sputn(__sp.data(), __ns) != __ns) {
1293 __s.__sbuf_ = nullptr;
1294 return __s;
1295 }
1296 }
1297 __np = __oe - __op;
1298 if (__np > 0) {
1299 if (__s.__sbuf_->sputn(__op, __np) != __np) {
1300 __s.__sbuf_ = nullptr;
1301 return __s;
1302 }
1303 }
1304 __iob.width(0);
1305 return __s;
1306}
1307
1308template <class _CharT, class _OutputIterator>1246template <class _CharT, class _OutputIterator>
1309_OutputIterator1247_OutputIterator
1310num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const {1248num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const {
...@@ -1336,7 +1274,7 @@ _LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::_...@@ -1336,7 +1274,7 @@ _LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::_
1336 _LIBCPP_DIAGNOSTIC_PUSH1274 _LIBCPP_DIAGNOSTIC_PUSH
1337 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")1275 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1338 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")1276 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1339 int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);1277 int __nc = __locale::__snprintf(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
1340 _LIBCPP_DIAGNOSTIC_POP1278 _LIBCPP_DIAGNOSTIC_POP
1341 char* __ne = __nar + __nc;1279 char* __ne = __nar + __nc;
1342 char* __np = this->__identify_padding(__nar, __ne, __iob);1280 char* __np = this->__identify_padding(__nar, __ne, __iob);
...@@ -1389,15 +1327,15 @@ _LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::_...@@ -1389,15 +1327,15 @@ _LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::_
1389 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")1327 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1390 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")1328 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1391 if (__specify_precision)1329 if (__specify_precision)
1392 __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);1330 __nc = __locale::__snprintf(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
1393 else1331 else
1394 __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);1332 __nc = __locale::__snprintf(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
1395 unique_ptr<char, void (*)(void*)> __nbh(nullptr, free);1333 unique_ptr<char, void (*)(void*)> __nbh(nullptr, free);
1396 if (__nc > static_cast<int>(__nbuf - 1)) {1334 if (__nc > static_cast<int>(__nbuf - 1)) {
1397 if (__specify_precision)1335 if (__specify_precision)
1398 __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);1336 __nc = __locale::__asprintf(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
1399 else1337 else
1400 __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);1338 __nc = __locale::__asprintf(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
1401 if (__nc == -1)1339 if (__nc == -1)
1402 __throw_bad_alloc();1340 __throw_bad_alloc();
1403 __nbh.reset(__nb);1341 __nbh.reset(__nb);
...@@ -1442,7 +1380,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty...@@ -1442,7 +1380,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty
1442 // Stage 1 - Get pointer in narrow char1380 // Stage 1 - Get pointer in narrow char
1443 const unsigned __nbuf = 20;1381 const unsigned __nbuf = 20;
1444 char __nar[__nbuf];1382 char __nar[__nbuf];
1445 int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, "%p", __v);1383 int __nc = __locale::__snprintf(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, "%p", __v);
1446 char* __ne = __nar + __nc;1384 char* __ne = __nar + __nc;
1447 char* __np = this->__identify_padding(__nar, __ne, __iob);1385 char* __np = this->__identify_padding(__nar, __ne, __iob);
1448 // Stage 2 - Widen __nar1386 // Stage 2 - Widen __nar
...@@ -1462,9 +1400,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty...@@ -1462,9 +1400,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty
1462}1400}
14631401
1464extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>;1402extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>;
1465# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1403# if _LIBCPP_HAS_WIDE_CHARACTERS
1466extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>;1404extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>;
1467# endif1405# endif
14681406
1469template <class _CharT, class _InputIterator>1407template <class _CharT, class _InputIterator>
1470_LIBCPP_HIDE_FROM_ABI int __get_up_to_n_digits(1408_LIBCPP_HIDE_FROM_ABI int __get_up_to_n_digits(
...@@ -1529,7 +1467,7 @@ _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__x() const;...@@ -1529,7 +1467,7 @@ _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__x() const;
1529template <>1467template <>
1530_LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__X() const;1468_LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__X() const;
15311469
1532# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1470# if _LIBCPP_HAS_WIDE_CHARACTERS
1533template <>1471template <>
1534_LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__weeks() const;1472_LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__weeks() const;
1535template <>1473template <>
...@@ -1544,7 +1482,7 @@ template <>...@@ -1544,7 +1482,7 @@ template <>
1544_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__x() const;1482_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__x() const;
1545template <>1483template <>
1546_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__X() const;1484_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__X() const;
1547# endif1485# endif
15481486
1549template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >1487template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
1550class _LIBCPP_TEMPLATE_VIS time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> {1488class _LIBCPP_TEMPLATE_VIS time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> {
...@@ -1998,13 +1936,13 @@ _InputIterator time_get<_CharT, _InputIterator>::do_get(...@@ -1998,13 +1936,13 @@ _InputIterator time_get<_CharT, _InputIterator>::do_get(
1998}1936}
19991937
2000extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>;1938extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>;
2001# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1939# if _LIBCPP_HAS_WIDE_CHARACTERS
2002extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>;1940extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>;
2003# endif1941# endif
20041942
2005class _LIBCPP_EXPORTED_FROM_ABI __time_get {1943class _LIBCPP_EXPORTED_FROM_ABI __time_get {
2006protected:1944protected:
2007 locale_t __loc_;1945 __locale::__locale_t __loc_;
20081946
2009 __time_get(const char* __nm);1947 __time_get(const char* __nm);
2010 __time_get(const string& __nm);1948 __time_get(const string& __nm);
...@@ -2036,32 +1974,32 @@ private:...@@ -2036,32 +1974,32 @@ private:
2036 string_type __analyze(char __fmt, const ctype<_CharT>&);1974 string_type __analyze(char __fmt, const ctype<_CharT>&);
2037};1975};
20381976
2039# define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \1977# define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \
2040 template <> \1978 template <> \
2041 _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \1979 _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \
2042 template <> \1980 template <> \
2043 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \1981 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \
2044 template <> \1982 template <> \
2045 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \1983 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \
2046 template <> \1984 template <> \
2047 _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \1985 _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \
2048 template <> \1986 template <> \
2049 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \1987 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \
2050 char, const ctype<_CharT>&); \1988 char, const ctype<_CharT>&); \
2051 extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \1989 extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \
2052 const; \1990 const; \
2053 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \1991 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \
2054 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \1992 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \
2055 extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \1993 extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \
2056 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \1994 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \
2057 __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \1995 __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \
2058 /**/1996 /**/
20591997
2060_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char)1998_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char)
2061# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1999# if _LIBCPP_HAS_WIDE_CHARACTERS
2062_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t)2000_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t)
2063# endif2001# endif
2064# undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION2002# undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION
20652003
2066template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >2004template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
2067class _LIBCPP_TEMPLATE_VIS time_get_byname2005class _LIBCPP_TEMPLATE_VIS time_get_byname
...@@ -2094,12 +2032,12 @@ private:...@@ -2094,12 +2032,12 @@ private:
2094};2032};
20952033
2096extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>;2034extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>;
2097# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2035# if _LIBCPP_HAS_WIDE_CHARACTERS
2098extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>;2036extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>;
2099# endif2037# endif
21002038
2101class _LIBCPP_EXPORTED_FROM_ABI __time_put {2039class _LIBCPP_EXPORTED_FROM_ABI __time_put {
2102 locale_t __loc_;2040 __locale::__locale_t __loc_;
21032041
2104protected:2042protected:
2105 _LIBCPP_HIDE_FROM_ABI __time_put() : __loc_(_LIBCPP_GET_C_LOCALE) {}2043 _LIBCPP_HIDE_FROM_ABI __time_put() : __loc_(_LIBCPP_GET_C_LOCALE) {}
...@@ -2107,9 +2045,9 @@ protected:...@@ -2107,9 +2045,9 @@ protected:
2107 __time_put(const string& __nm);2045 __time_put(const string& __nm);
2108 ~__time_put();2046 ~__time_put();
2109 void __do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const;2047 void __do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const;
2110# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2048# if _LIBCPP_HAS_WIDE_CHARACTERS
2111 void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const;2049 void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const;
2112# endif2050# endif
2113};2051};
21142052
2115template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >2053template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
...@@ -2183,9 +2121,9 @@ _OutputIterator time_put<_CharT, _OutputIterator>::do_put(...@@ -2183,9 +2121,9 @@ _OutputIterator time_put<_CharT, _OutputIterator>::do_put(
2183}2121}
21842122
2185extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>;2123extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>;
2186# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2124# if _LIBCPP_HAS_WIDE_CHARACTERS
2187extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>;2125extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>;
2188# endif2126# endif
21892127
2190template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >2128template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
2191class _LIBCPP_TEMPLATE_VIS time_put_byname : public time_put<_CharT, _OutputIterator> {2129class _LIBCPP_TEMPLATE_VIS time_put_byname : public time_put<_CharT, _OutputIterator> {
...@@ -2201,9 +2139,9 @@ protected:...@@ -2201,9 +2139,9 @@ protected:
2201};2139};
22022140
2203extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>;2141extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>;
2204# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2142# if _LIBCPP_HAS_WIDE_CHARACTERS
2205extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>;2143extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>;
2206# endif2144# endif
22072145
2208// money_base2146// money_base
22092147
...@@ -2268,10 +2206,10 @@ const bool moneypunct<_CharT, _International>::intl;...@@ -2268,10 +2206,10 @@ const bool moneypunct<_CharT, _International>::intl;
22682206
2269extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>;2207extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>;
2270extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>;2208extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>;
2271# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2209# if _LIBCPP_HAS_WIDE_CHARACTERS
2272extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>;2210extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>;
2273extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>;2211extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>;
2274# endif2212# endif
22752213
2276// moneypunct_byname2214// moneypunct_byname
22772215
...@@ -2326,14 +2264,14 @@ _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, true>::init(const char*);...@@ -2326,14 +2264,14 @@ _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, true>::init(const char*);
2326extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>;2264extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>;
2327extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>;2265extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>;
23282266
2329# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2267# if _LIBCPP_HAS_WIDE_CHARACTERS
2330template <>2268template <>
2331_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, false>::init(const char*);2269_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, false>::init(const char*);
2332template <>2270template <>
2333_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, true>::init(const char*);2271_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, true>::init(const char*);
2334extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>;2272extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>;
2335extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>;2273extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>;
2336# endif2274# endif
23372275
2338// money_get2276// money_get
23392277
...@@ -2394,9 +2332,9 @@ void __money_get<_CharT>::__gather_info(...@@ -2394,9 +2332,9 @@ void __money_get<_CharT>::__gather_info(
2394}2332}
23952333
2396extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>;2334extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>;
2397# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2335# if _LIBCPP_HAS_WIDE_CHARACTERS
2398extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>;2336extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>;
2399# endif2337# endif
24002338
2401template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >2339template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
2402class _LIBCPP_TEMPLATE_VIS money_get : public locale::facet, private __money_get<_CharT> {2340class _LIBCPP_TEMPLATE_VIS money_get : public locale::facet, private __money_get<_CharT> {
...@@ -2704,9 +2642,9 @@ _InputIterator money_get<_CharT, _InputIterator>::do_get(...@@ -2704,9 +2642,9 @@ _InputIterator money_get<_CharT, _InputIterator>::do_get(
2704}2642}
27052643
2706extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>;2644extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>;
2707# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2645# if _LIBCPP_HAS_WIDE_CHARACTERS
2708extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>;2646extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>;
2709# endif2647# endif
27102648
2711// money_put2649// money_put
27122650
...@@ -2882,9 +2820,9 @@ void __money_put<_CharT>::__format(...@@ -2882,9 +2820,9 @@ void __money_put<_CharT>::__format(
2882}2820}
28832821
2884extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>;2822extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>;
2885# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2823# if _LIBCPP_HAS_WIDE_CHARACTERS
2886extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>;2824extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>;
2887# endif2825# endif
28882826
2889template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >2827template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
2890class _LIBCPP_TEMPLATE_VIS money_put : public locale::facet, private __money_put<_CharT> {2828class _LIBCPP_TEMPLATE_VIS money_put : public locale::facet, private __money_put<_CharT> {
...@@ -2932,7 +2870,7 @@ _OutputIterator money_put<_CharT, _OutputIterator>::do_put(...@@ -2932,7 +2870,7 @@ _OutputIterator money_put<_CharT, _OutputIterator>::do_put(
2932 unique_ptr<char_type, void (*)(void*)> __hd(0, free);2870 unique_ptr<char_type, void (*)(void*)> __hd(0, free);
2933 // secure memory for digit storage2871 // secure memory for digit storage
2934 if (static_cast<size_t>(__n) > __bs - 1) {2872 if (static_cast<size_t>(__n) > __bs - 1) {
2935 __n = __libcpp_asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units);2873 __n = __locale::__asprintf(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units);
2936 if (__n == -1)2874 if (__n == -1)
2937 __throw_bad_alloc();2875 __throw_bad_alloc();
2938 __hn.reset(__bb);2876 __hn.reset(__bb);
...@@ -3028,9 +2966,9 @@ _OutputIterator money_put<_CharT, _OutputIterator>::do_put(...@@ -3028,9 +2966,9 @@ _OutputIterator money_put<_CharT, _OutputIterator>::do_put(
3028}2966}
30292967
3030extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>;2968extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>;
3031# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2969# if _LIBCPP_HAS_WIDE_CHARACTERS
3032extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>;2970extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>;
3033# endif2971# endif
30342972
3035// messages2973// messages
30362974
...@@ -3074,18 +3012,18 @@ locale::id messages<_CharT>::id;...@@ -3074,18 +3012,18 @@ locale::id messages<_CharT>::id;
30743012
3075template <class _CharT>3013template <class _CharT>
3076typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const {3014typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const {
3077# ifdef _LIBCPP_HAS_CATOPEN3015# if _LIBCPP_HAS_CATOPEN
3078 return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE);3016 return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE);
3079# else // !_LIBCPP_HAS_CATOPEN3017# else // !_LIBCPP_HAS_CATOPEN
3080 (void)__nm;3018 (void)__nm;
3081 return -1;3019 return -1;
3082# endif // _LIBCPP_HAS_CATOPEN3020# endif // _LIBCPP_HAS_CATOPEN
3083}3021}
30843022
3085template <class _CharT>3023template <class _CharT>
3086typename messages<_CharT>::string_type3024typename messages<_CharT>::string_type
3087messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const {3025messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const {
3088# ifdef _LIBCPP_HAS_CATOPEN3026# if _LIBCPP_HAS_CATOPEN
3089 string __ndflt;3027 string __ndflt;
3090 __narrow_to_utf8<sizeof(char_type) * __CHAR_BIT__>()(3028 __narrow_to_utf8<sizeof(char_type) * __CHAR_BIT__>()(
3091 std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size());3029 std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size());
...@@ -3095,27 +3033,27 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type&...@@ -3095,27 +3033,27 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type&
3095 string_type __w;3033 string_type __w;
3096 __widen_from_utf8<sizeof(char_type) * __CHAR_BIT__>()(std::back_inserter(__w), __n, __n + std::strlen(__n));3034 __widen_from_utf8<sizeof(char_type) * __CHAR_BIT__>()(std::back_inserter(__w), __n, __n + std::strlen(__n));
3097 return __w;3035 return __w;
3098# else // !_LIBCPP_HAS_CATOPEN3036# else // !_LIBCPP_HAS_CATOPEN
3099 (void)__c;3037 (void)__c;
3100 (void)__set;3038 (void)__set;
3101 (void)__msgid;3039 (void)__msgid;
3102 return __dflt;3040 return __dflt;
3103# endif // _LIBCPP_HAS_CATOPEN3041# endif // _LIBCPP_HAS_CATOPEN
3104}3042}
31053043
3106template <class _CharT>3044template <class _CharT>
3107void messages<_CharT>::do_close(catalog __c) const {3045void messages<_CharT>::do_close(catalog __c) const {
3108# ifdef _LIBCPP_HAS_CATOPEN3046# if _LIBCPP_HAS_CATOPEN
3109 catclose((nl_catd)__c);3047 catclose((nl_catd)__c);
3110# else // !_LIBCPP_HAS_CATOPEN3048# else // !_LIBCPP_HAS_CATOPEN
3111 (void)__c;3049 (void)__c;
3112# endif // _LIBCPP_HAS_CATOPEN3050# endif // _LIBCPP_HAS_CATOPEN
3113}3051}
31143052
3115extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>;3053extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>;
3116# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS3054# if _LIBCPP_HAS_WIDE_CHARACTERS
3117extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>;3055extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>;
3118# endif3056# endif
31193057
3120template <class _CharT>3058template <class _CharT>
3121class _LIBCPP_TEMPLATE_VIS messages_byname : public messages<_CharT> {3059class _LIBCPP_TEMPLATE_VIS messages_byname : public messages<_CharT> {
...@@ -3132,11 +3070,11 @@ protected:...@@ -3132,11 +3070,11 @@ protected:
3132};3070};
31333071
3134extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>;3072extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>;
3135# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS3073# if _LIBCPP_HAS_WIDE_CHARACTERS
3136extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>;3074extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>;
3137# endif3075# endif
31383076
3139# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT)3077# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT)
31403078
3141template <class _Codecvt,3079template <class _Codecvt,
3142 class _Elem = wchar_t,3080 class _Elem = wchar_t,
...@@ -3157,19 +3095,19 @@ private:...@@ -3157,19 +3095,19 @@ private:
3157 size_t __cvtcount_;3095 size_t __cvtcount_;
31583096
3159public:3097public:
3160# ifndef _LIBCPP_CXX03_LANG3098# ifndef _LIBCPP_CXX03_LANG
3161 _LIBCPP_HIDE_FROM_ABI wstring_convert() : wstring_convert(new _Codecvt) {}3099 _LIBCPP_HIDE_FROM_ABI wstring_convert() : wstring_convert(new _Codecvt) {}
3162 _LIBCPP_HIDE_FROM_ABI explicit wstring_convert(_Codecvt* __pcvt);3100 _LIBCPP_HIDE_FROM_ABI explicit wstring_convert(_Codecvt* __pcvt);
3163# else3101# else
3164 _LIBCPP_HIDE_FROM_ABI _LIBCPP_EXPLICIT_SINCE_CXX14 wstring_convert(_Codecvt* __pcvt = new _Codecvt);3102 _LIBCPP_HIDE_FROM_ABI _LIBCPP_EXPLICIT_SINCE_CXX14 wstring_convert(_Codecvt* __pcvt = new _Codecvt);
3165# endif3103# endif
31663104
3167 _LIBCPP_HIDE_FROM_ABI wstring_convert(_Codecvt* __pcvt, state_type __state);3105 _LIBCPP_HIDE_FROM_ABI wstring_convert(_Codecvt* __pcvt, state_type __state);
3168 _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI3106 _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
3169 wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string());3107 wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string());
3170# ifndef _LIBCPP_CXX03_LANG3108# ifndef _LIBCPP_CXX03_LANG
3171 _LIBCPP_HIDE_FROM_ABI wstring_convert(wstring_convert&& __wc);3109 _LIBCPP_HIDE_FROM_ABI wstring_convert(wstring_convert&& __wc);
3172# endif3110# endif
3173 _LIBCPP_HIDE_FROM_ABI ~wstring_convert();3111 _LIBCPP_HIDE_FROM_ABI ~wstring_convert();
31743112
3175 wstring_convert(const wstring_convert& __wc) = delete;3113 wstring_convert(const wstring_convert& __wc) = delete;
...@@ -3214,7 +3152,7 @@ wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(...@@ -3214,7 +3152,7 @@ wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(
3214 __cvtptr_ = new _Codecvt;3152 __cvtptr_ = new _Codecvt;
3215}3153}
32163154
3217# ifndef _LIBCPP_CXX03_LANG3155# ifndef _LIBCPP_CXX03_LANG
32183156
3219template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>3157template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
3220inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(wstring_convert&& __wc)3158inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(wstring_convert&& __wc)
...@@ -3226,7 +3164,7 @@ inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert...@@ -3226,7 +3164,7 @@ inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert
3226 __wc.__cvtptr_ = nullptr;3164 __wc.__cvtptr_ = nullptr;
3227}3165}
32283166
3229# endif // _LIBCPP_CXX03_LANG3167# endif // _LIBCPP_CXX03_LANG
32303168
3231_LIBCPP_SUPPRESS_DEPRECATED_PUSH3169_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3232template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>3170template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
...@@ -3380,14 +3318,14 @@ private:...@@ -3380,14 +3318,14 @@ private:
3380 bool __always_noconv_;3318 bool __always_noconv_;
33813319
3382public:3320public:
3383# ifndef _LIBCPP_CXX03_LANG3321# ifndef _LIBCPP_CXX03_LANG
3384 _LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {}3322 _LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {}
3385 explicit _LIBCPP_HIDE_FROM_ABI3323 explicit _LIBCPP_HIDE_FROM_ABI
3386 wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());3324 wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());
3387# else3325# else
3388 _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI3326 _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
3389 wbuffer_convert(streambuf* __bytebuf = nullptr, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());3327 wbuffer_convert(streambuf* __bytebuf = nullptr, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());
3390# endif3328# endif
33913329
3392 _LIBCPP_HIDE_FROM_ABI ~wbuffer_convert();3330 _LIBCPP_HIDE_FROM_ABI ~wbuffer_convert();
33933331
...@@ -3743,7 +3681,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__...@@ -3743,7 +3681,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__
37433681
3744_LIBCPP_SUPPRESS_DEPRECATED_POP3682_LIBCPP_SUPPRESS_DEPRECATED_POP
37453683
3746# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT)3684# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT)
37473685
3748_LIBCPP_END_NAMESPACE_STD3686_LIBCPP_END_NAMESPACE_STD
37493687
...@@ -3751,17 +3689,18 @@ _LIBCPP_POP_MACROS...@@ -3751,17 +3689,18 @@ _LIBCPP_POP_MACROS
37513689
3752// NOLINTEND(libcpp-robust-against-adl)3690// NOLINTEND(libcpp-robust-against-adl)
37533691
3754#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)3692# endif // _LIBCPP_HAS_LOCALIZATION
37553693
3756#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 203694# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
3757# include <atomic>3695# include <atomic>
3758# include <concepts>3696# include <concepts>
3759# include <cstdarg>3697# include <cstdarg>
3760# include <iterator>3698# include <iterator>
3761# include <mutex>3699# include <mutex>
3762# include <stdexcept>3700# include <stdexcept>
3763# include <type_traits>3701# include <type_traits>
3764# include <typeinfo>3702# include <typeinfo>
3765#endif3703# endif
3704#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
37663705
3767#endif // _LIBCPP_LOCALE3706#endif // _LIBCPP_LOCALE
lib/libcxx/include/locale.h deleted-46
...@@ -1,46 +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_LOCALE_H
11#define _LIBCPP_LOCALE_H
12
13/*
14 locale.h synopsis
15
16Macros:
17
18 LC_ALL
19 LC_COLLATE
20 LC_CTYPE
21 LC_MONETARY
22 LC_NUMERIC
23 LC_TIME
24
25Types:
26
27 lconv
28
29Functions:
30
31 setlocale
32 localeconv
33
34*/
35
36#include <__config>
37
38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
39# pragma GCC system_header
40#endif
41
42#if __has_include_next(<locale.h>)
43# include_next <locale.h>
44#endif
45
46#endif // _LIBCPP_LOCALE_H
lib/libcxx/include/map+194-166
...@@ -571,53 +571,64 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20...@@ -571,53 +571,64 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
571571
572*/572*/
573573
574#include <__algorithm/equal.h>574#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
575#include <__algorithm/lexicographical_compare.h>575# include <__cxx03/map>
576#include <__algorithm/lexicographical_compare_three_way.h>576#else
577#include <__assert>577# include <__algorithm/equal.h>
578#include <__config>578# include <__algorithm/lexicographical_compare.h>
579#include <__functional/binary_function.h>579# include <__algorithm/lexicographical_compare_three_way.h>
580#include <__functional/is_transparent.h>580# include <__assert>
581#include <__functional/operations.h>581# include <__config>
582#include <__iterator/erase_if_container.h>582# include <__functional/binary_function.h>
583#include <__iterator/iterator_traits.h>583# include <__functional/is_transparent.h>
584#include <__iterator/ranges_iterator_traits.h>584# include <__functional/operations.h>
585#include <__iterator/reverse_iterator.h>585# include <__iterator/erase_if_container.h>
586#include <__memory/addressof.h>586# include <__iterator/iterator_traits.h>
587#include <__memory/allocator.h>587# include <__iterator/ranges_iterator_traits.h>
588#include <__memory_resource/polymorphic_allocator.h>588# include <__iterator/reverse_iterator.h>
589#include <__node_handle>589# include <__memory/addressof.h>
590#include <__ranges/concepts.h>590# include <__memory/allocator.h>
591#include <__ranges/container_compatible_range.h>591# include <__memory/allocator_traits.h>
592#include <__ranges/from_range.h>592# include <__memory/pointer_traits.h>
593#include <__tree>593# include <__memory/unique_ptr.h>
594#include <__type_traits/is_allocator.h>594# include <__memory_resource/polymorphic_allocator.h>
595#include <__utility/forward.h>595# include <__new/launder.h>
596#include <__utility/piecewise_construct.h>596# include <__node_handle>
597#include <__utility/swap.h>597# include <__ranges/concepts.h>
598#include <stdexcept>598# include <__ranges/container_compatible_range.h>
599#include <tuple>599# include <__ranges/from_range.h>
600#include <version>600# include <__tree>
601# include <__type_traits/container_traits.h>
602# include <__type_traits/is_allocator.h>
603# include <__type_traits/remove_const.h>
604# include <__type_traits/type_identity.h>
605# include <__utility/forward.h>
606# include <__utility/pair.h>
607# include <__utility/piecewise_construct.h>
608# include <__utility/swap.h>
609# include <stdexcept>
610# include <tuple>
611# include <version>
601612
602// standard-mandated includes613// standard-mandated includes
603614
604// [iterator.range]615// [iterator.range]
605#include <__iterator/access.h>616# include <__iterator/access.h>
606#include <__iterator/data.h>617# include <__iterator/data.h>
607#include <__iterator/empty.h>618# include <__iterator/empty.h>
608#include <__iterator/reverse_access.h>619# include <__iterator/reverse_access.h>
609#include <__iterator/size.h>620# include <__iterator/size.h>
610621
611// [associative.map.syn]622// [associative.map.syn]
612#include <compare>623# include <compare>
613#include <initializer_list>624# include <initializer_list>
614625
615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)626# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
616# pragma GCC system_header627# pragma GCC system_header
617#endif628# endif
618629
619_LIBCPP_PUSH_MACROS630_LIBCPP_PUSH_MACROS
620#include <__undef_macros>631# include <__undef_macros>
621632
622_LIBCPP_BEGIN_NAMESPACE_STD633_LIBCPP_BEGIN_NAMESPACE_STD
623634
...@@ -646,7 +657,7 @@ public:...@@ -646,7 +657,7 @@ public:
646 swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y));657 swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y));
647 }658 }
648659
649#if _LIBCPP_STD_VER >= 14660# if _LIBCPP_STD_VER >= 14
650 template <typename _K2>661 template <typename _K2>
651 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const {662 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const {
652 return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);663 return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);
...@@ -656,7 +667,7 @@ public:...@@ -656,7 +667,7 @@ public:
656 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const {667 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const {
657 return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);668 return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);
658 }669 }
659#endif670# endif
660};671};
661672
662template <class _Key, class _CP, class _Compare>673template <class _Key, class _CP, class _Compare>
...@@ -684,7 +695,7 @@ public:...@@ -684,7 +695,7 @@ public:
684 swap(__comp_, __y.__comp_);695 swap(__comp_, __y.__comp_);
685 }696 }
686697
687#if _LIBCPP_STD_VER >= 14698# if _LIBCPP_STD_VER >= 14
688 template <typename _K2>699 template <typename _K2>
689 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const {700 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const {
690 return __comp_(__x, __y.__get_value().first);701 return __comp_(__x, __y.__get_value().first);
...@@ -694,7 +705,7 @@ public:...@@ -694,7 +705,7 @@ public:
694 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const {705 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const {
695 return __comp_(__x.__get_value().first, __y);706 return __comp_(__x.__get_value().first, __y);
696 }707 }
697#endif708# endif
698};709};
699710
700template <class _Key, class _CP, class _Compare, bool __b>711template <class _Key, class _CP, class _Compare, bool __b>
...@@ -724,14 +735,14 @@ public:...@@ -724,14 +735,14 @@ public:
724 __first_constructed(false),735 __first_constructed(false),
725 __second_constructed(false) {}736 __second_constructed(false) {}
726737
727#ifndef _LIBCPP_CXX03_LANG738# ifndef _LIBCPP_CXX03_LANG
728 _LIBCPP_HIDE_FROM_ABI __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT739 _LIBCPP_HIDE_FROM_ABI __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT
729 : __na_(__x.__na_),740 : __na_(__x.__na_),
730 __first_constructed(__x.__value_constructed),741 __first_constructed(__x.__value_constructed),
731 __second_constructed(__x.__value_constructed) {742 __second_constructed(__x.__value_constructed) {
732 __x.__value_constructed = false;743 __x.__value_constructed = false;
733 }744 }
734#endif // _LIBCPP_CXX03_LANG745# endif // _LIBCPP_CXX03_LANG
735746
736 __map_node_destructor& operator=(const __map_node_destructor&) = delete;747 __map_node_destructor& operator=(const __map_node_destructor&) = delete;
737748
...@@ -752,7 +763,7 @@ class multimap;...@@ -752,7 +763,7 @@ class multimap;
752template <class _TreeIterator>763template <class _TreeIterator>
753class __map_const_iterator;764class __map_const_iterator;
754765
755#ifndef _LIBCPP_CXX03_LANG766# ifndef _LIBCPP_CXX03_LANG
756767
757template <class _Key, class _Tp>768template <class _Key, class _Tp>
758struct _LIBCPP_STANDALONE_DEBUG __value_type {769struct _LIBCPP_STANDALONE_DEBUG __value_type {
...@@ -767,19 +778,19 @@ private:...@@ -767,19 +778,19 @@ private:
767778
768public:779public:
769 _LIBCPP_HIDE_FROM_ABI value_type& __get_value() {780 _LIBCPP_HIDE_FROM_ABI value_type& __get_value() {
770# if _LIBCPP_STD_VER >= 17781# if _LIBCPP_STD_VER >= 17
771 return *std::launder(std::addressof(__cc_));782 return *std::launder(std::addressof(__cc_));
772# else783# else
773 return __cc_;784 return __cc_;
774# endif785# endif
775 }786 }
776787
777 _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const {788 _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const {
778# if _LIBCPP_STD_VER >= 17789# if _LIBCPP_STD_VER >= 17
779 return *std::launder(std::addressof(__cc_));790 return *std::launder(std::addressof(__cc_));
780# else791# else
781 return __cc_;792 return __cc_;
782# endif793# endif
783 }794 }
784795
785 _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() {796 _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() {
...@@ -814,7 +825,7 @@ public:...@@ -814,7 +825,7 @@ public:
814 __value_type(__value_type&&) = delete;825 __value_type(__value_type&&) = delete;
815};826};
816827
817#else828# else
818829
819template <class _Key, class _Tp>830template <class _Key, class _Tp>
820struct __value_type {831struct __value_type {
...@@ -835,7 +846,7 @@ public:...@@ -835,7 +846,7 @@ public:
835 ~__value_type() = delete;846 ~__value_type() = delete;
836};847};
837848
838#endif // _LIBCPP_CXX03_LANG849# endif // _LIBCPP_CXX03_LANG
839850
840template <class _Tp>851template <class _Tp>
841struct __extract_key_value_types;852struct __extract_key_value_types;
...@@ -1011,10 +1022,10 @@ public:...@@ -1011,10 +1022,10 @@ public:
1011 typedef std::reverse_iterator<iterator> reverse_iterator;1022 typedef std::reverse_iterator<iterator> reverse_iterator;
1012 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;1023 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
10131024
1014#if _LIBCPP_STD_VER >= 171025# if _LIBCPP_STD_VER >= 17
1015 typedef __map_node_handle<typename __base::__node, allocator_type> node_type;1026 typedef __map_node_handle<typename __base::__node, allocator_type> node_type;
1016 typedef __insert_return_type<iterator, node_type> insert_return_type;1027 typedef __insert_return_type<iterator, node_type> insert_return_type;
1017#endif1028# endif
10181029
1019 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>1030 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
1020 friend class _LIBCPP_TEMPLATE_VIS map;1031 friend class _LIBCPP_TEMPLATE_VIS map;
...@@ -1046,7 +1057,7 @@ public:...@@ -1046,7 +1057,7 @@ public:
1046 insert(__f, __l);1057 insert(__f, __l);
1047 }1058 }
10481059
1049#if _LIBCPP_STD_VER >= 231060# if _LIBCPP_STD_VER >= 23
1050 template <_ContainerCompatibleRange<value_type> _Range>1061 template <_ContainerCompatibleRange<value_type> _Range>
1051 _LIBCPP_HIDE_FROM_ABI1062 _LIBCPP_HIDE_FROM_ABI
1052 map(from_range_t,1063 map(from_range_t,
...@@ -1056,37 +1067,37 @@ public:...@@ -1056,37 +1067,37 @@ public:
1056 : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {1067 : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {
1057 insert_range(std::forward<_Range>(__range));1068 insert_range(std::forward<_Range>(__range));
1058 }1069 }
1059#endif1070# endif
10601071
1061#if _LIBCPP_STD_VER >= 141072# if _LIBCPP_STD_VER >= 14
1062 template <class _InputIterator>1073 template <class _InputIterator>
1063 _LIBCPP_HIDE_FROM_ABI map(_InputIterator __f, _InputIterator __l, const allocator_type& __a)1074 _LIBCPP_HIDE_FROM_ABI map(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
1064 : map(__f, __l, key_compare(), __a) {}1075 : map(__f, __l, key_compare(), __a) {}
1065#endif1076# endif
10661077
1067#if _LIBCPP_STD_VER >= 231078# if _LIBCPP_STD_VER >= 23
1068 template <_ContainerCompatibleRange<value_type> _Range>1079 template <_ContainerCompatibleRange<value_type> _Range>
1069 _LIBCPP_HIDE_FROM_ABI map(from_range_t, _Range&& __range, const allocator_type& __a)1080 _LIBCPP_HIDE_FROM_ABI map(from_range_t, _Range&& __range, const allocator_type& __a)
1070 : map(from_range, std::forward<_Range>(__range), key_compare(), __a) {}1081 : map(from_range, std::forward<_Range>(__range), key_compare(), __a) {}
1071#endif1082# endif
10721083
1073 _LIBCPP_HIDE_FROM_ABI map(const map& __m) : __tree_(__m.__tree_) { insert(__m.begin(), __m.end()); }1084 _LIBCPP_HIDE_FROM_ABI map(const map& __m) : __tree_(__m.__tree_) { insert(__m.begin(), __m.end()); }
10741085
1075 _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) {1086 _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) {
1076#ifndef _LIBCPP_CXX03_LANG1087# ifndef _LIBCPP_CXX03_LANG
1077 __tree_ = __m.__tree_;1088 __tree_ = __m.__tree_;
1078#else1089# else
1079 if (this != std::addressof(__m)) {1090 if (this != std::addressof(__m)) {
1080 __tree_.clear();1091 __tree_.clear();
1081 __tree_.value_comp() = __m.__tree_.value_comp();1092 __tree_.value_comp() = __m.__tree_.value_comp();
1082 __tree_.__copy_assign_alloc(__m.__tree_);1093 __tree_.__copy_assign_alloc(__m.__tree_);
1083 insert(__m.begin(), __m.end());1094 insert(__m.begin(), __m.end());
1084 }1095 }
1085#endif1096# endif
1086 return *this;1097 return *this;
1087 }1098 }
10881099
1089#ifndef _LIBCPP_CXX03_LANG1100# ifndef _LIBCPP_CXX03_LANG
10901101
1091 _LIBCPP_HIDE_FROM_ABI map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value)1102 _LIBCPP_HIDE_FROM_ABI map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value)
1092 : __tree_(std::move(__m.__tree_)) {}1103 : __tree_(std::move(__m.__tree_)) {}
...@@ -1108,17 +1119,17 @@ public:...@@ -1108,17 +1119,17 @@ public:
1108 insert(__il.begin(), __il.end());1119 insert(__il.begin(), __il.end());
1109 }1120 }
11101121
1111# if _LIBCPP_STD_VER >= 141122# if _LIBCPP_STD_VER >= 14
1112 _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const allocator_type& __a)1123 _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const allocator_type& __a)
1113 : map(__il, key_compare(), __a) {}1124 : map(__il, key_compare(), __a) {}
1114# endif1125# endif
11151126
1116 _LIBCPP_HIDE_FROM_ABI map& operator=(initializer_list<value_type> __il) {1127 _LIBCPP_HIDE_FROM_ABI map& operator=(initializer_list<value_type> __il) {
1117 __tree_.__assign_unique(__il.begin(), __il.end());1128 __tree_.__assign_unique(__il.begin(), __il.end());
1118 return *this;1129 return *this;
1119 }1130 }
11201131
1121#endif // _LIBCPP_CXX03_LANG1132# endif // _LIBCPP_CXX03_LANG
11221133
1123 _LIBCPP_HIDE_FROM_ABI explicit map(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {}1134 _LIBCPP_HIDE_FROM_ABI explicit map(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {}
11241135
...@@ -1144,14 +1155,14 @@ public:...@@ -1144,14 +1155,14 @@ public:
1144 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }1155 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
1145 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }1156 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
11461157
1147 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }1158 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
1148 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }1159 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
1149 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }1160 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
11501161
1151 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k);1162 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k);
1152#ifndef _LIBCPP_CXX03_LANG1163# ifndef _LIBCPP_CXX03_LANG
1153 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k);1164 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k);
1154#endif1165# endif
11551166
1156 _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k);1167 _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k);
1157 _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const;1168 _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const;
...@@ -1160,7 +1171,7 @@ public:...@@ -1160,7 +1171,7 @@ public:
1160 _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); }1171 _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); }
1161 _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); }1172 _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); }
11621173
1163#ifndef _LIBCPP_CXX03_LANG1174# ifndef _LIBCPP_CXX03_LANG
1164 template <class... _Args>1175 template <class... _Args>
1165 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {1176 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {
1166 return __tree_.__emplace_unique(std::forward<_Args>(__args)...);1177 return __tree_.__emplace_unique(std::forward<_Args>(__args)...);
...@@ -1181,7 +1192,7 @@ public:...@@ -1181,7 +1192,7 @@ public:
1181 return __tree_.__insert_unique(__pos.__i_, std::forward<_Pp>(__p));1192 return __tree_.__insert_unique(__pos.__i_, std::forward<_Pp>(__p));
1182 }1193 }
11831194
1184#endif // _LIBCPP_CXX03_LANG1195# endif // _LIBCPP_CXX03_LANG
11851196
1186 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); }1197 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); }
11871198
...@@ -1189,7 +1200,7 @@ public:...@@ -1189,7 +1200,7 @@ public:
1189 return __tree_.__insert_unique(__p.__i_, __v);1200 return __tree_.__insert_unique(__p.__i_, __v);
1190 }1201 }
11911202
1192#ifndef _LIBCPP_CXX03_LANG1203# ifndef _LIBCPP_CXX03_LANG
1193 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) {1204 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) {
1194 return __tree_.__insert_unique(std::move(__v));1205 return __tree_.__insert_unique(std::move(__v));
1195 }1206 }
...@@ -1199,7 +1210,7 @@ public:...@@ -1199,7 +1210,7 @@ public:
1199 }1210 }
12001211
1201 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }1212 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
1202#endif1213# endif
12031214
1204 template <class _InputIterator>1215 template <class _InputIterator>
1205 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {1216 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {
...@@ -1207,7 +1218,7 @@ public:...@@ -1207,7 +1218,7 @@ public:
1207 insert(__e.__i_, *__f);1218 insert(__e.__i_, *__f);
1208 }1219 }
12091220
1210#if _LIBCPP_STD_VER >= 231221# if _LIBCPP_STD_VER >= 23
1211 template <_ContainerCompatibleRange<value_type> _Range>1222 template <_ContainerCompatibleRange<value_type> _Range>
1212 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {1223 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
1213 const_iterator __end = cend();1224 const_iterator __end = cend();
...@@ -1215,9 +1226,9 @@ public:...@@ -1215,9 +1226,9 @@ public:
1215 insert(__end.__i_, std::forward<decltype(__element)>(__element));1226 insert(__end.__i_, std::forward<decltype(__element)>(__element));
1216 }1227 }
1217 }1228 }
1218#endif1229# endif
12191230
1220#if _LIBCPP_STD_VER >= 171231# if _LIBCPP_STD_VER >= 17
12211232
1222 template <class... _Args>1233 template <class... _Args>
1223 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) {1234 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) {
...@@ -1302,7 +1313,7 @@ public:...@@ -1302,7 +1313,7 @@ public:
1302 return __r;1313 return __r;
1303 }1314 }
13041315
1305#endif // _LIBCPP_STD_VER >= 171316# endif // _LIBCPP_STD_VER >= 17
13061317
1307 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); }1318 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); }
1308 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); }1319 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); }
...@@ -1312,7 +1323,7 @@ public:...@@ -1312,7 +1323,7 @@ public:
1312 }1323 }
1313 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }1324 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }
13141325
1315#if _LIBCPP_STD_VER >= 171326# if _LIBCPP_STD_VER >= 17
1316 _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {1327 _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {
1317 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),1328 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
1318 "node_type with incompatible allocator passed to map::insert()");1329 "node_type with incompatible allocator passed to map::insert()");
...@@ -1353,13 +1364,13 @@ public:...@@ -1353,13 +1364,13 @@ public:
1353 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");1364 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
1354 __tree_.__node_handle_merge_unique(__source.__tree_);1365 __tree_.__node_handle_merge_unique(__source.__tree_);
1355 }1366 }
1356#endif1367# endif
13571368
1358 _LIBCPP_HIDE_FROM_ABI void swap(map& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__m.__tree_); }1369 _LIBCPP_HIDE_FROM_ABI void swap(map& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__m.__tree_); }
13591370
1360 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }1371 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
1361 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }1372 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
1362#if _LIBCPP_STD_VER >= 141373# if _LIBCPP_STD_VER >= 14
1363 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1374 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1364 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {1375 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
1365 return __tree_.find(__k);1376 return __tree_.find(__k);
...@@ -1368,27 +1379,27 @@ public:...@@ -1368,27 +1379,27 @@ public:
1368 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {1379 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
1369 return __tree_.find(__k);1380 return __tree_.find(__k);
1370 }1381 }
1371#endif1382# endif
13721383
1373 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); }1384 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); }
1374#if _LIBCPP_STD_VER >= 141385# if _LIBCPP_STD_VER >= 14
1375 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1386 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1376 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {1387 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
1377 return __tree_.__count_multi(__k);1388 return __tree_.__count_multi(__k);
1378 }1389 }
1379#endif1390# endif
13801391
1381#if _LIBCPP_STD_VER >= 201392# if _LIBCPP_STD_VER >= 20
1382 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }1393 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1383 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1394 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1384 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {1395 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
1385 return find(__k) != end();1396 return find(__k) != end();
1386 }1397 }
1387#endif // _LIBCPP_STD_VER >= 201398# endif // _LIBCPP_STD_VER >= 20
13881399
1389 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }1400 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
1390 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }1401 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
1391#if _LIBCPP_STD_VER >= 141402# if _LIBCPP_STD_VER >= 14
1392 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1403 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1393 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {1404 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
1394 return __tree_.lower_bound(__k);1405 return __tree_.lower_bound(__k);
...@@ -1398,11 +1409,11 @@ public:...@@ -1398,11 +1409,11 @@ public:
1398 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {1409 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
1399 return __tree_.lower_bound(__k);1410 return __tree_.lower_bound(__k);
1400 }1411 }
1401#endif1412# endif
14021413
1403 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }1414 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
1404 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }1415 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
1405#if _LIBCPP_STD_VER >= 141416# if _LIBCPP_STD_VER >= 14
1406 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1417 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1407 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {1418 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
1408 return __tree_.upper_bound(__k);1419 return __tree_.upper_bound(__k);
...@@ -1411,7 +1422,7 @@ public:...@@ -1411,7 +1422,7 @@ public:
1411 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {1422 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
1412 return __tree_.upper_bound(__k);1423 return __tree_.upper_bound(__k);
1413 }1424 }
1414#endif1425# endif
14151426
1416 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {1427 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
1417 return __tree_.__equal_range_unique(__k);1428 return __tree_.__equal_range_unique(__k);
...@@ -1419,7 +1430,7 @@ public:...@@ -1419,7 +1430,7 @@ public:
1419 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {1430 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
1420 return __tree_.__equal_range_unique(__k);1431 return __tree_.__equal_range_unique(__k);
1421 }1432 }
1422#if _LIBCPP_STD_VER >= 141433# if _LIBCPP_STD_VER >= 14
1423 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1434 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1424 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {1435 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
1425 return __tree_.__equal_range_multi(__k);1436 return __tree_.__equal_range_multi(__k);
...@@ -1428,7 +1439,7 @@ public:...@@ -1428,7 +1439,7 @@ public:
1428 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {1439 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
1429 return __tree_.__equal_range_multi(__k);1440 return __tree_.__equal_range_multi(__k);
1430 }1441 }
1431#endif1442# endif
14321443
1433private:1444private:
1434 typedef typename __base::__node __node;1445 typedef typename __base::__node __node;
...@@ -1440,12 +1451,12 @@ private:...@@ -1440,12 +1451,12 @@ private:
1440 typedef __map_node_destructor<__node_allocator> _Dp;1451 typedef __map_node_destructor<__node_allocator> _Dp;
1441 typedef unique_ptr<__node, _Dp> __node_holder;1452 typedef unique_ptr<__node, _Dp> __node_holder;
14421453
1443#ifdef _LIBCPP_CXX03_LANG1454# ifdef _LIBCPP_CXX03_LANG
1444 _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k);1455 _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k);
1445#endif1456# endif
1446};1457};
14471458
1448#if _LIBCPP_STD_VER >= 171459# if _LIBCPP_STD_VER >= 17
1449template <class _InputIterator,1460template <class _InputIterator,
1450 class _Compare = less<__iter_key_type<_InputIterator>>,1461 class _Compare = less<__iter_key_type<_InputIterator>>,
1451 class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,1462 class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
...@@ -1455,7 +1466,7 @@ template <class _InputIterator,...@@ -1455,7 +1466,7 @@ template <class _InputIterator,
1455map(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())1466map(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
1456 -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;1467 -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;
14571468
1458# if _LIBCPP_STD_VER >= 231469# if _LIBCPP_STD_VER >= 23
1459template <ranges::input_range _Range,1470template <ranges::input_range _Range,
1460 class _Compare = less<__range_key_type<_Range>>,1471 class _Compare = less<__range_key_type<_Range>>,
1461 class _Allocator = allocator<__range_to_alloc_type<_Range>>,1472 class _Allocator = allocator<__range_to_alloc_type<_Range>>,
...@@ -1463,7 +1474,7 @@ template <ranges::input_range _Range,...@@ -1463,7 +1474,7 @@ template <ranges::input_range _Range,
1463 class = enable_if_t<__is_allocator<_Allocator>::value, void>>1474 class = enable_if_t<__is_allocator<_Allocator>::value, void>>
1464map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator())1475map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator())
1465 -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>;1476 -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>;
1466# endif1477# endif
14671478
1468template <class _Key,1479template <class _Key,
1469 class _Tp,1480 class _Tp,
...@@ -1485,18 +1496,18 @@ map(_InputIterator, _InputIterator, _Allocator)...@@ -1485,18 +1496,18 @@ map(_InputIterator, _InputIterator, _Allocator)
1485 less<__iter_key_type<_InputIterator>>,1496 less<__iter_key_type<_InputIterator>>,
1486 _Allocator>;1497 _Allocator>;
14871498
1488# if _LIBCPP_STD_VER >= 231499# if _LIBCPP_STD_VER >= 23
1489template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>1500template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
1490map(from_range_t, _Range&&, _Allocator)1501map(from_range_t, _Range&&, _Allocator)
1491 -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>;1502 -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>;
1492# endif1503# endif
14931504
1494template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>1505template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
1495map(initializer_list<pair<_Key, _Tp>>,1506map(initializer_list<pair<_Key, _Tp>>,
1496 _Allocator) -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;1507 _Allocator) -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
1497#endif1508# endif
14981509
1499#ifndef _LIBCPP_CXX03_LANG1510# ifndef _LIBCPP_CXX03_LANG
1500template <class _Key, class _Tp, class _Compare, class _Allocator>1511template <class _Key, class _Tp, class _Compare, class _Allocator>
1501map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)1512map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
1502 : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) {1513 : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) {
...@@ -1527,7 +1538,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) {...@@ -1527,7 +1538,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) {
1527 // NOLINTEND(bugprone-use-after-move)1538 // NOLINTEND(bugprone-use-after-move)
1528}1539}
15291540
1530#else // _LIBCPP_CXX03_LANG1541# else // _LIBCPP_CXX03_LANG
15311542
1532template <class _Key, class _Tp, class _Compare, class _Allocator>1543template <class _Key, class _Tp, class _Compare, class _Allocator>
1533typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder1544typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
...@@ -1554,7 +1565,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) {...@@ -1554,7 +1565,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) {
1554 return __r->__value_.__get_value().second;1565 return __r->__value_.__get_value().second;
1555}1566}
15561567
1557#endif // _LIBCPP_CXX03_LANG1568# endif // _LIBCPP_CXX03_LANG
15581569
1559template <class _Key, class _Tp, class _Compare, class _Allocator>1570template <class _Key, class _Tp, class _Compare, class _Allocator>
1560_Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) {1571_Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) {
...@@ -1580,7 +1591,7 @@ operator==(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp,...@@ -1580,7 +1591,7 @@ operator==(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp,
1580 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());1591 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
1581}1592}
15821593
1583#if _LIBCPP_STD_VER <= 171594# if _LIBCPP_STD_VER <= 17
15841595
1585template <class _Key, class _Tp, class _Compare, class _Allocator>1596template <class _Key, class _Tp, class _Compare, class _Allocator>
1586inline _LIBCPP_HIDE_FROM_ABI bool1597inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -1612,7 +1623,7 @@ operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp,...@@ -1612,7 +1623,7 @@ operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp,
1612 return !(__y < __x);1623 return !(__y < __x);
1613}1624}
16141625
1615#else // #if _LIBCPP_STD_VER <= 171626# else // #if _LIBCPP_STD_VER <= 17
16161627
1617template <class _Key, class _Tp, class _Compare, class _Allocator>1628template <class _Key, class _Tp, class _Compare, class _Allocator>
1618_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>1629_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>
...@@ -1620,7 +1631,7 @@ operator<=>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp...@@ -1620,7 +1631,7 @@ operator<=>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp
1620 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);1631 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
1621}1632}
16221633
1623#endif // #if _LIBCPP_STD_VER <= 171634# endif // #if _LIBCPP_STD_VER <= 17
16241635
1625template <class _Key, class _Tp, class _Compare, class _Allocator>1636template <class _Key, class _Tp, class _Compare, class _Allocator>
1626inline _LIBCPP_HIDE_FROM_ABI void1637inline _LIBCPP_HIDE_FROM_ABI void
...@@ -1629,13 +1640,21 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x, map<_Key, _Tp, _Compare, _Alloca...@@ -1629,13 +1640,21 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x, map<_Key, _Tp, _Compare, _Alloca
1629 __x.swap(__y);1640 __x.swap(__y);
1630}1641}
16311642
1632#if _LIBCPP_STD_VER >= 201643# if _LIBCPP_STD_VER >= 20
1633template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate>1644template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate>
1634inline _LIBCPP_HIDE_FROM_ABI typename map<_Key, _Tp, _Compare, _Allocator>::size_type1645inline _LIBCPP_HIDE_FROM_ABI typename map<_Key, _Tp, _Compare, _Allocator>::size_type
1635erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) {1646erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) {
1636 return std::__libcpp_erase_if_container(__c, __pred);1647 return std::__libcpp_erase_if_container(__c, __pred);
1637}1648}
1638#endif1649# endif
1650
1651template <class _Key, class _Tp, class _Compare, class _Allocator>
1652struct __container_traits<map<_Key, _Tp, _Compare, _Allocator> > {
1653 // http://eel.is/c++draft/associative.reqmts.except#2
1654 // For associative containers, if an exception is thrown by any operation from within
1655 // an insert or emplace function inserting a single element, the insertion has no effect.
1656 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;
1657};
16391658
1640template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > >1659template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > >
1641class _LIBCPP_TEMPLATE_VIS multimap {1660class _LIBCPP_TEMPLATE_VIS multimap {
...@@ -1687,9 +1706,9 @@ public:...@@ -1687,9 +1706,9 @@ public:
1687 typedef std::reverse_iterator<iterator> reverse_iterator;1706 typedef std::reverse_iterator<iterator> reverse_iterator;
1688 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;1707 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
16891708
1690#if _LIBCPP_STD_VER >= 171709# if _LIBCPP_STD_VER >= 17
1691 typedef __map_node_handle<typename __base::__node, allocator_type> node_type;1710 typedef __map_node_handle<typename __base::__node, allocator_type> node_type;
1692#endif1711# endif
16931712
1694 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>1713 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
1695 friend class _LIBCPP_TEMPLATE_VIS map;1714 friend class _LIBCPP_TEMPLATE_VIS map;
...@@ -1721,7 +1740,7 @@ public:...@@ -1721,7 +1740,7 @@ public:
1721 insert(__f, __l);1740 insert(__f, __l);
1722 }1741 }
17231742
1724#if _LIBCPP_STD_VER >= 231743# if _LIBCPP_STD_VER >= 23
1725 template <_ContainerCompatibleRange<value_type> _Range>1744 template <_ContainerCompatibleRange<value_type> _Range>
1726 _LIBCPP_HIDE_FROM_ABI1745 _LIBCPP_HIDE_FROM_ABI
1727 multimap(from_range_t,1746 multimap(from_range_t,
...@@ -1731,19 +1750,19 @@ public:...@@ -1731,19 +1750,19 @@ public:
1731 : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {1750 : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {
1732 insert_range(std::forward<_Range>(__range));1751 insert_range(std::forward<_Range>(__range));
1733 }1752 }
1734#endif1753# endif
17351754
1736#if _LIBCPP_STD_VER >= 141755# if _LIBCPP_STD_VER >= 14
1737 template <class _InputIterator>1756 template <class _InputIterator>
1738 _LIBCPP_HIDE_FROM_ABI multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a)1757 _LIBCPP_HIDE_FROM_ABI multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
1739 : multimap(__f, __l, key_compare(), __a) {}1758 : multimap(__f, __l, key_compare(), __a) {}
1740#endif1759# endif
17411760
1742#if _LIBCPP_STD_VER >= 231761# if _LIBCPP_STD_VER >= 23
1743 template <_ContainerCompatibleRange<value_type> _Range>1762 template <_ContainerCompatibleRange<value_type> _Range>
1744 _LIBCPP_HIDE_FROM_ABI multimap(from_range_t, _Range&& __range, const allocator_type& __a)1763 _LIBCPP_HIDE_FROM_ABI multimap(from_range_t, _Range&& __range, const allocator_type& __a)
1745 : multimap(from_range, std::forward<_Range>(__range), key_compare(), __a) {}1764 : multimap(from_range, std::forward<_Range>(__range), key_compare(), __a) {}
1746#endif1765# endif
17471766
1748 _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m)1767 _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m)
1749 : __tree_(__m.__tree_.value_comp(),1768 : __tree_(__m.__tree_.value_comp(),
...@@ -1752,20 +1771,20 @@ public:...@@ -1752,20 +1771,20 @@ public:
1752 }1771 }
17531772
1754 _LIBCPP_HIDE_FROM_ABI multimap& operator=(const multimap& __m) {1773 _LIBCPP_HIDE_FROM_ABI multimap& operator=(const multimap& __m) {
1755#ifndef _LIBCPP_CXX03_LANG1774# ifndef _LIBCPP_CXX03_LANG
1756 __tree_ = __m.__tree_;1775 __tree_ = __m.__tree_;
1757#else1776# else
1758 if (this != std::addressof(__m)) {1777 if (this != std::addressof(__m)) {
1759 __tree_.clear();1778 __tree_.clear();
1760 __tree_.value_comp() = __m.__tree_.value_comp();1779 __tree_.value_comp() = __m.__tree_.value_comp();
1761 __tree_.__copy_assign_alloc(__m.__tree_);1780 __tree_.__copy_assign_alloc(__m.__tree_);
1762 insert(__m.begin(), __m.end());1781 insert(__m.begin(), __m.end());
1763 }1782 }
1764#endif1783# endif
1765 return *this;1784 return *this;
1766 }1785 }
17671786
1768#ifndef _LIBCPP_CXX03_LANG1787# ifndef _LIBCPP_CXX03_LANG
17691788
1770 _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) noexcept(is_nothrow_move_constructible<__base>::value)1789 _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) noexcept(is_nothrow_move_constructible<__base>::value)
1771 : __tree_(std::move(__m.__tree_)) {}1790 : __tree_(std::move(__m.__tree_)) {}
...@@ -1788,17 +1807,17 @@ public:...@@ -1788,17 +1807,17 @@ public:
1788 insert(__il.begin(), __il.end());1807 insert(__il.begin(), __il.end());
1789 }1808 }
17901809
1791# if _LIBCPP_STD_VER >= 141810# if _LIBCPP_STD_VER >= 14
1792 _LIBCPP_HIDE_FROM_ABI multimap(initializer_list<value_type> __il, const allocator_type& __a)1811 _LIBCPP_HIDE_FROM_ABI multimap(initializer_list<value_type> __il, const allocator_type& __a)
1793 : multimap(__il, key_compare(), __a) {}1812 : multimap(__il, key_compare(), __a) {}
1794# endif1813# endif
17951814
1796 _LIBCPP_HIDE_FROM_ABI multimap& operator=(initializer_list<value_type> __il) {1815 _LIBCPP_HIDE_FROM_ABI multimap& operator=(initializer_list<value_type> __il) {
1797 __tree_.__assign_multi(__il.begin(), __il.end());1816 __tree_.__assign_multi(__il.begin(), __il.end());
1798 return *this;1817 return *this;
1799 }1818 }
18001819
1801#endif // _LIBCPP_CXX03_LANG1820# endif // _LIBCPP_CXX03_LANG
18021821
1803 _LIBCPP_HIDE_FROM_ABI explicit multimap(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {}1822 _LIBCPP_HIDE_FROM_ABI explicit multimap(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {}
18041823
...@@ -1824,7 +1843,7 @@ public:...@@ -1824,7 +1843,7 @@ public:
1824 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }1843 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
1825 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }1844 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
18261845
1827 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }1846 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
1828 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }1847 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
1829 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }1848 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
18301849
...@@ -1832,7 +1851,7 @@ public:...@@ -1832,7 +1851,7 @@ public:
1832 _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); }1851 _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); }
1833 _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); }1852 _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); }
18341853
1835#ifndef _LIBCPP_CXX03_LANG1854# ifndef _LIBCPP_CXX03_LANG
18361855
1837 template <class... _Args>1856 template <class... _Args>
1838 _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {1857 _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {
...@@ -1862,7 +1881,7 @@ public:...@@ -1862,7 +1881,7 @@ public:
18621881
1863 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }1882 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
18641883
1865#endif // _LIBCPP_CXX03_LANG1884# endif // _LIBCPP_CXX03_LANG
18661885
1867 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); }1886 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); }
18681887
...@@ -1876,7 +1895,7 @@ public:...@@ -1876,7 +1895,7 @@ public:
1876 __tree_.__insert_multi(__e.__i_, *__f);1895 __tree_.__insert_multi(__e.__i_, *__f);
1877 }1896 }
18781897
1879#if _LIBCPP_STD_VER >= 231898# if _LIBCPP_STD_VER >= 23
1880 template <_ContainerCompatibleRange<value_type> _Range>1899 template <_ContainerCompatibleRange<value_type> _Range>
1881 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {1900 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
1882 const_iterator __end = cend();1901 const_iterator __end = cend();
...@@ -1884,7 +1903,7 @@ public:...@@ -1884,7 +1903,7 @@ public:
1884 __tree_.__insert_multi(__end.__i_, std::forward<decltype(__element)>(__element));1903 __tree_.__insert_multi(__end.__i_, std::forward<decltype(__element)>(__element));
1885 }1904 }
1886 }1905 }
1887#endif1906# endif
18881907
1889 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); }1908 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); }
1890 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); }1909 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); }
...@@ -1893,7 +1912,7 @@ public:...@@ -1893,7 +1912,7 @@ public:
1893 return __tree_.erase(__f.__i_, __l.__i_);1912 return __tree_.erase(__f.__i_, __l.__i_);
1894 }1913 }
18951914
1896#if _LIBCPP_STD_VER >= 171915# if _LIBCPP_STD_VER >= 17
1897 _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {1916 _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {
1898 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),1917 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
1899 "node_type with incompatible allocator passed to multimap::insert()");1918 "node_type with incompatible allocator passed to multimap::insert()");
...@@ -1934,7 +1953,7 @@ public:...@@ -1934,7 +1953,7 @@ public:
1934 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");1953 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
1935 return __tree_.__node_handle_merge_multi(__source.__tree_);1954 return __tree_.__node_handle_merge_multi(__source.__tree_);
1936 }1955 }
1937#endif1956# endif
19381957
1939 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }1958 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }
19401959
...@@ -1944,7 +1963,7 @@ public:...@@ -1944,7 +1963,7 @@ public:
19441963
1945 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }1964 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
1946 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }1965 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
1947#if _LIBCPP_STD_VER >= 141966# if _LIBCPP_STD_VER >= 14
1948 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1967 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1949 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {1968 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
1950 return __tree_.find(__k);1969 return __tree_.find(__k);
...@@ -1953,27 +1972,27 @@ public:...@@ -1953,27 +1972,27 @@ public:
1953 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {1972 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
1954 return __tree_.find(__k);1973 return __tree_.find(__k);
1955 }1974 }
1956#endif1975# endif
19571976
1958 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); }1977 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); }
1959#if _LIBCPP_STD_VER >= 141978# if _LIBCPP_STD_VER >= 14
1960 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1979 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1961 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {1980 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
1962 return __tree_.__count_multi(__k);1981 return __tree_.__count_multi(__k);
1963 }1982 }
1964#endif1983# endif
19651984
1966#if _LIBCPP_STD_VER >= 201985# if _LIBCPP_STD_VER >= 20
1967 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }1986 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1968 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1987 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1969 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {1988 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
1970 return find(__k) != end();1989 return find(__k) != end();
1971 }1990 }
1972#endif // _LIBCPP_STD_VER >= 201991# endif // _LIBCPP_STD_VER >= 20
19731992
1974 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }1993 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
1975 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }1994 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
1976#if _LIBCPP_STD_VER >= 141995# if _LIBCPP_STD_VER >= 14
1977 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1996 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1978 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {1997 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
1979 return __tree_.lower_bound(__k);1998 return __tree_.lower_bound(__k);
...@@ -1983,11 +2002,11 @@ public:...@@ -1983,11 +2002,11 @@ public:
1983 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {2002 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
1984 return __tree_.lower_bound(__k);2003 return __tree_.lower_bound(__k);
1985 }2004 }
1986#endif2005# endif
19872006
1988 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }2007 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
1989 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }2008 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
1990#if _LIBCPP_STD_VER >= 142009# if _LIBCPP_STD_VER >= 14
1991 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>2010 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1992 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {2011 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
1993 return __tree_.upper_bound(__k);2012 return __tree_.upper_bound(__k);
...@@ -1996,7 +2015,7 @@ public:...@@ -1996,7 +2015,7 @@ public:
1996 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {2015 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
1997 return __tree_.upper_bound(__k);2016 return __tree_.upper_bound(__k);
1998 }2017 }
1999#endif2018# endif
20002019
2001 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {2020 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
2002 return __tree_.__equal_range_multi(__k);2021 return __tree_.__equal_range_multi(__k);
...@@ -2004,7 +2023,7 @@ public:...@@ -2004,7 +2023,7 @@ public:
2004 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {2023 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
2005 return __tree_.__equal_range_multi(__k);2024 return __tree_.__equal_range_multi(__k);
2006 }2025 }
2007#if _LIBCPP_STD_VER >= 142026# if _LIBCPP_STD_VER >= 14
2008 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>2027 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
2009 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {2028 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
2010 return __tree_.__equal_range_multi(__k);2029 return __tree_.__equal_range_multi(__k);
...@@ -2013,7 +2032,7 @@ public:...@@ -2013,7 +2032,7 @@ public:
2013 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {2032 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
2014 return __tree_.__equal_range_multi(__k);2033 return __tree_.__equal_range_multi(__k);
2015 }2034 }
2016#endif2035# endif
20172036
2018private:2037private:
2019 typedef typename __base::__node __node;2038 typedef typename __base::__node __node;
...@@ -2024,7 +2043,7 @@ private:...@@ -2024,7 +2043,7 @@ private:
2024 typedef unique_ptr<__node, _Dp> __node_holder;2043 typedef unique_ptr<__node, _Dp> __node_holder;
2025};2044};
20262045
2027#if _LIBCPP_STD_VER >= 172046# if _LIBCPP_STD_VER >= 17
2028template <class _InputIterator,2047template <class _InputIterator,
2029 class _Compare = less<__iter_key_type<_InputIterator>>,2048 class _Compare = less<__iter_key_type<_InputIterator>>,
2030 class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,2049 class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
...@@ -2034,7 +2053,7 @@ template <class _InputIterator,...@@ -2034,7 +2053,7 @@ template <class _InputIterator,
2034multimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())2053multimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
2035 -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;2054 -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;
20362055
2037# if _LIBCPP_STD_VER >= 232056# if _LIBCPP_STD_VER >= 23
2038template <ranges::input_range _Range,2057template <ranges::input_range _Range,
2039 class _Compare = less<__range_key_type<_Range>>,2058 class _Compare = less<__range_key_type<_Range>>,
2040 class _Allocator = allocator<__range_to_alloc_type<_Range>>,2059 class _Allocator = allocator<__range_to_alloc_type<_Range>>,
...@@ -2042,7 +2061,7 @@ template <ranges::input_range _Range,...@@ -2042,7 +2061,7 @@ template <ranges::input_range _Range,
2042 class = enable_if_t<__is_allocator<_Allocator>::value, void>>2061 class = enable_if_t<__is_allocator<_Allocator>::value, void>>
2043multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator())2062multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator())
2044 -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>;2063 -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>;
2045# endif2064# endif
20462065
2047template <class _Key,2066template <class _Key,
2048 class _Tp,2067 class _Tp,
...@@ -2064,18 +2083,18 @@ multimap(_InputIterator, _InputIterator, _Allocator)...@@ -2064,18 +2083,18 @@ multimap(_InputIterator, _InputIterator, _Allocator)
2064 less<__iter_key_type<_InputIterator>>,2083 less<__iter_key_type<_InputIterator>>,
2065 _Allocator>;2084 _Allocator>;
20662085
2067# if _LIBCPP_STD_VER >= 232086# if _LIBCPP_STD_VER >= 23
2068template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>2087template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
2069multimap(from_range_t, _Range&&, _Allocator)2088multimap(from_range_t, _Range&&, _Allocator)
2070 -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>;2089 -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>;
2071# endif2090# endif
20722091
2073template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>2092template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
2074multimap(initializer_list<pair<_Key, _Tp>>,2093multimap(initializer_list<pair<_Key, _Tp>>,
2075 _Allocator) -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;2094 _Allocator) -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
2076#endif2095# endif
20772096
2078#ifndef _LIBCPP_CXX03_LANG2097# ifndef _LIBCPP_CXX03_LANG
2079template <class _Key, class _Tp, class _Compare, class _Allocator>2098template <class _Key, class _Tp, class _Compare, class _Allocator>
2080multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a)2099multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a)
2081 : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) {2100 : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) {
...@@ -2085,7 +2104,7 @@ multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const alloca...@@ -2085,7 +2104,7 @@ multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const alloca
2085 __tree_.__insert_multi(__e.__i_, std::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move()));2104 __tree_.__insert_multi(__e.__i_, std::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move()));
2086 }2105 }
2087}2106}
2088#endif2107# endif
20892108
2090template <class _Key, class _Tp, class _Compare, class _Allocator>2109template <class _Key, class _Tp, class _Compare, class _Allocator>
2091inline _LIBCPP_HIDE_FROM_ABI bool2110inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -2093,7 +2112,7 @@ operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<...@@ -2093,7 +2112,7 @@ operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<
2093 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());2112 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
2094}2113}
20952114
2096#if _LIBCPP_STD_VER <= 172115# if _LIBCPP_STD_VER <= 17
20972116
2098template <class _Key, class _Tp, class _Compare, class _Allocator>2117template <class _Key, class _Tp, class _Compare, class _Allocator>
2099inline _LIBCPP_HIDE_FROM_ABI bool2118inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -2125,7 +2144,7 @@ operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<...@@ -2125,7 +2144,7 @@ operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<
2125 return !(__y < __x);2144 return !(__y < __x);
2126}2145}
21272146
2128#else // #if _LIBCPP_STD_VER <= 172147# else // #if _LIBCPP_STD_VER <= 17
21292148
2130template <class _Key, class _Tp, class _Compare, class _Allocator>2149template <class _Key, class _Tp, class _Compare, class _Allocator>
2131_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>2150_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>
...@@ -2134,7 +2153,7 @@ operator<=>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,...@@ -2134,7 +2153,7 @@ operator<=>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
2134 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);2153 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
2135}2154}
21362155
2137#endif // #if _LIBCPP_STD_VER <= 172156# endif // #if _LIBCPP_STD_VER <= 17
21382157
2139template <class _Key, class _Tp, class _Compare, class _Allocator>2158template <class _Key, class _Tp, class _Compare, class _Allocator>
2140inline _LIBCPP_HIDE_FROM_ABI void2159inline _LIBCPP_HIDE_FROM_ABI void
...@@ -2143,17 +2162,25 @@ swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, multimap<_Key, _Tp, _Compar...@@ -2143,17 +2162,25 @@ swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, multimap<_Key, _Tp, _Compar
2143 __x.swap(__y);2162 __x.swap(__y);
2144}2163}
21452164
2146#if _LIBCPP_STD_VER >= 202165# if _LIBCPP_STD_VER >= 20
2147template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate>2166template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate>
2148inline _LIBCPP_HIDE_FROM_ABI typename multimap<_Key, _Tp, _Compare, _Allocator>::size_type2167inline _LIBCPP_HIDE_FROM_ABI typename multimap<_Key, _Tp, _Compare, _Allocator>::size_type
2149erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) {2168erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) {
2150 return std::__libcpp_erase_if_container(__c, __pred);2169 return std::__libcpp_erase_if_container(__c, __pred);
2151}2170}
2152#endif2171# endif
2172
2173template <class _Key, class _Tp, class _Compare, class _Allocator>
2174struct __container_traits<multimap<_Key, _Tp, _Compare, _Allocator> > {
2175 // http://eel.is/c++draft/associative.reqmts.except#2
2176 // For associative containers, if an exception is thrown by any operation from within
2177 // an insert or emplace function inserting a single element, the insertion has no effect.
2178 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;
2179};
21532180
2154_LIBCPP_END_NAMESPACE_STD2181_LIBCPP_END_NAMESPACE_STD
21552182
2156#if _LIBCPP_STD_VER >= 172183# if _LIBCPP_STD_VER >= 17
2157_LIBCPP_BEGIN_NAMESPACE_STD2184_LIBCPP_BEGIN_NAMESPACE_STD
2158namespace pmr {2185namespace pmr {
2159template <class _KeyT, class _ValueT, class _CompareT = std::less<_KeyT>>2186template <class _KeyT, class _ValueT, class _CompareT = std::less<_KeyT>>
...@@ -2165,17 +2192,18 @@ using multimap _LIBCPP_AVAILABILITY_PMR =...@@ -2165,17 +2192,18 @@ using multimap _LIBCPP_AVAILABILITY_PMR =
2165 std::multimap<_KeyT, _ValueT, _CompareT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;2192 std::multimap<_KeyT, _ValueT, _CompareT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
2166} // namespace pmr2193} // namespace pmr
2167_LIBCPP_END_NAMESPACE_STD2194_LIBCPP_END_NAMESPACE_STD
2168#endif2195# endif
21692196
2170_LIBCPP_POP_MACROS2197_LIBCPP_POP_MACROS
21712198
2172#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 202199# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2173# include <concepts>2200# include <concepts>
2174# include <cstdlib>2201# include <cstdlib>
2175# include <functional>2202# include <functional>
2176# include <iterator>2203# include <iterator>
2177# include <type_traits>2204# include <type_traits>
2178# include <utility>2205# include <utility>
2179#endif2206# endif
2207#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
21802208
2181#endif // _LIBCPP_MAP2209#endif // _LIBCPP_MAP
lib/libcxx/include/math.h+90-86
...@@ -291,93 +291,96 @@ long double truncl(long double x);...@@ -291,93 +291,96 @@ long double truncl(long double x);
291291
292*/292*/
293293
294# include <__config>294# if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
295# include <__cxx03/math.h>
296# else
297# include <__config>
295298
296# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)299# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
297# pragma GCC system_header300# pragma GCC system_header
298# endif301# endif
299302
300# if __has_include_next(<math.h>)303# if __has_include_next(<math.h>)
301# include_next <math.h>304# include_next <math.h>
302# endif305# endif
303306
304# ifdef __cplusplus307# ifdef __cplusplus
305308
306// We support including .h headers inside 'extern "C"' contexts, so switch309// We support including .h headers inside 'extern "C"' contexts, so switch
307// back to C++ linkage before including these C++ headers.310// back to C++ linkage before including these C++ headers.
308extern "C++" {311extern "C++" {
309312
310# ifdef fpclassify313# ifdef fpclassify
311# undef fpclassify314# undef fpclassify
312# endif315# endif
313316
314# ifdef signbit317# ifdef signbit
315# undef signbit318# undef signbit
316# endif319# endif
317320
318# ifdef isfinite321# ifdef isfinite
319# undef isfinite322# undef isfinite
320# endif323# endif
321324
322# ifdef isinf325# ifdef isinf
323# undef isinf326# undef isinf
324# endif327# endif
325328
326# ifdef isnan329# ifdef isnan
327# undef isnan330# undef isnan
328# endif331# endif
329332
330# ifdef isnormal333# ifdef isnormal
331# undef isnormal334# undef isnormal
332# endif335# endif
333336
334# ifdef isgreater337# ifdef isgreater
335# undef isgreater338# undef isgreater
336# endif339# endif
337340
338# ifdef isgreaterequal341# ifdef isgreaterequal
339# undef isgreaterequal342# undef isgreaterequal
340# endif343# endif
341344
342# ifdef isless345# ifdef isless
343# undef isless346# undef isless
344# endif347# endif
345348
346# ifdef islessequal349# ifdef islessequal
347# undef islessequal350# undef islessequal
348# endif351# endif
349352
350# ifdef islessgreater353# ifdef islessgreater
351# undef islessgreater354# undef islessgreater
352# endif355# endif
353356
354# ifdef isunordered357# ifdef isunordered
355# undef isunordered358# undef isunordered
356# endif359# endif
357360
358# include <__math/abs.h>361# include <__math/abs.h>
359# include <__math/copysign.h>362# include <__math/copysign.h>
360# include <__math/error_functions.h>363# include <__math/error_functions.h>
361# include <__math/exponential_functions.h>364# include <__math/exponential_functions.h>
362# include <__math/fdim.h>365# include <__math/fdim.h>
363# include <__math/fma.h>366# include <__math/fma.h>
364# include <__math/gamma.h>367# include <__math/gamma.h>
365# include <__math/hyperbolic_functions.h>368# include <__math/hyperbolic_functions.h>
366# include <__math/hypot.h>369# include <__math/hypot.h>
367# include <__math/inverse_hyperbolic_functions.h>370# include <__math/inverse_hyperbolic_functions.h>
368# include <__math/inverse_trigonometric_functions.h>371# include <__math/inverse_trigonometric_functions.h>
369# include <__math/logarithms.h>372# include <__math/logarithms.h>
370# include <__math/min_max.h>373# include <__math/min_max.h>
371# include <__math/modulo.h>374# include <__math/modulo.h>
372# include <__math/remainder.h>375# include <__math/remainder.h>
373# include <__math/roots.h>376# include <__math/roots.h>
374# include <__math/rounding_functions.h>377# include <__math/rounding_functions.h>
375# include <__math/traits.h>378# include <__math/traits.h>
376# include <__math/trigonometric_functions.h>379# include <__math/trigonometric_functions.h>
377# include <__type_traits/enable_if.h>380# include <__type_traits/enable_if.h>
378# include <__type_traits/is_floating_point.h>381# include <__type_traits/is_floating_point.h>
379# include <__type_traits/is_integral.h>382# include <__type_traits/is_integral.h>
380# include <stdlib.h>383# include <stdlib.h>
381384
382// fpclassify relies on implementation-defined constants, so we can't move it to a detail header385// fpclassify relies on implementation-defined constants, so we can't move it to a detail header
383_LIBCPP_BEGIN_NAMESPACE_STD386_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -388,22 +391,22 @@ namespace __math {...@@ -388,22 +391,22 @@ namespace __math {
388391
389// template on non-double overloads to make them weaker than same overloads from MSVC runtime392// template on non-double overloads to make them weaker than same overloads from MSVC runtime
390template <class = int>393template <class = int>
391_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT {394[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT {
392 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);395 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
393}396}
394397
395template <class = int>398template <class = int>
396_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT {399[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT {
397 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);400 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
398}401}
399402
400template <class = int>403template <class = int>
401_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT {404[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT {
402 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);405 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
403}406}
404407
405template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>408template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
406_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {409[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
407 return __x == 0 ? FP_ZERO : FP_NORMAL;410 return __x == 0 ? FP_ZERO : FP_NORMAL;
408}411}
409412
...@@ -415,7 +418,7 @@ using std::__math::fpclassify;...@@ -415,7 +418,7 @@ using std::__math::fpclassify;
415using std::__math::signbit;418using std::__math::signbit;
416419
417// The MSVC runtime already provides these functions as templates420// The MSVC runtime already provides these functions as templates
418# ifndef _LIBCPP_MSVCRT421# ifndef _LIBCPP_MSVCRT
419using std::__math::isfinite;422using std::__math::isfinite;
420using std::__math::isgreater;423using std::__math::isgreater;
421using std::__math::isgreaterequal;424using std::__math::isgreaterequal;
...@@ -426,7 +429,7 @@ using std::__math::islessgreater;...@@ -426,7 +429,7 @@ using std::__math::islessgreater;
426using std::__math::isnan;429using std::__math::isnan;
427using std::__math::isnormal;430using std::__math::isnormal;
428using std::__math::isunordered;431using std::__math::isunordered;
429# endif // _LIBCPP_MSVCRT432# endif // _LIBCPP_MSVCRT
430433
431// abs434// abs
432//435//
...@@ -501,7 +504,8 @@ using std::__math::trunc;...@@ -501,7 +504,8 @@ using std::__math::trunc;
501504
502} // extern "C++"505} // extern "C++"
503506
504# endif // __cplusplus507# endif // __cplusplus
508# endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
505509
506#else // _LIBCPP_MATH_H510#else // _LIBCPP_MATH_H
507511
lib/libcxx/include/mdspan+21-26
...@@ -408,31 +408,26 @@ namespace std {...@@ -408,31 +408,26 @@ namespace std {
408#ifndef _LIBCPP_MDSPAN408#ifndef _LIBCPP_MDSPAN
409#define _LIBCPP_MDSPAN409#define _LIBCPP_MDSPAN
410410
411#include <__config>411#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
412412# include <__cxx03/mdspan>
413#if _LIBCPP_STD_VER >= 23413#else
414# include <__fwd/mdspan.h>414# include <__config>
415# include <__mdspan/default_accessor.h>415
416# include <__mdspan/extents.h>416# if _LIBCPP_STD_VER >= 23
417# include <__mdspan/layout_left.h>417# include <__fwd/mdspan.h>
418# include <__mdspan/layout_right.h>418# include <__mdspan/default_accessor.h>
419# include <__mdspan/layout_stride.h>419# include <__mdspan/extents.h>
420# include <__mdspan/mdspan.h>420# include <__mdspan/layout_left.h>
421#endif421# include <__mdspan/layout_right.h>
422422# include <__mdspan/layout_stride.h>
423#include <version>423# include <__mdspan/mdspan.h>
424424# endif
425#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)425
426# pragma GCC system_header426# include <version>
427#endif427
428428# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
429#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20429# pragma GCC system_header
430# include <array>430# endif
431# include <cinttypes>431#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
432# include <concepts>
433# include <cstddef>
434# include <limits>
435# include <span>
436#endif
437432
438#endif // _LIBCPP_MDSPAN433#endif // _LIBCPP_MDSPAN
lib/libcxx/include/memory+58-54
...@@ -182,8 +182,8 @@ public:...@@ -182,8 +182,8 @@ public:
182 raw_storage_iterator operator++(int);182 raw_storage_iterator operator++(int);
183};183};
184184
185template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;185template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept; // deprecated in C++17, removed in C++20
186template <class T> void return_temporary_buffer(T* p) noexcept;186template <class T> void return_temporary_buffer(T* p) noexcept; // deprecated in C++17, removed in C++20
187187
188template <class T> T* addressof(T& r) noexcept;188template <class T> T* addressof(T& r) noexcept;
189template <class T> T* addressof(const T&& r) noexcept = delete;189template <class T> T* addressof(const T&& r) noexcept = delete;
...@@ -934,65 +934,69 @@ template<class Pointer = void, class Smart, class... Args>...@@ -934,65 +934,69 @@ template<class Pointer = void, class Smart, class... Args>
934934
935// clang-format on935// clang-format on
936936
937#include <__config>937#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
938#include <__memory/addressof.h>938# include <__cxx03/memory>
939#include <__memory/align.h>939#else
940#include <__memory/allocator.h>940# include <__config>
941#include <__memory/allocator_arg_t.h>941# include <__memory/addressof.h>
942#include <__memory/allocator_traits.h>942# include <__memory/align.h>
943#include <__memory/auto_ptr.h>943# include <__memory/allocator.h>
944#include <__memory/inout_ptr.h>944# include <__memory/allocator_arg_t.h>
945#include <__memory/out_ptr.h>945# include <__memory/allocator_traits.h>
946#include <__memory/pointer_traits.h>946# include <__memory/auto_ptr.h>
947#include <__memory/raw_storage_iterator.h>947# include <__memory/inout_ptr.h>
948#include <__memory/shared_ptr.h>948# include <__memory/out_ptr.h>
949#include <__memory/temporary_buffer.h>949# include <__memory/pointer_traits.h>
950#include <__memory/uninitialized_algorithms.h>950# include <__memory/raw_storage_iterator.h>
951#include <__memory/unique_ptr.h>951# include <__memory/shared_ptr.h>
952#include <__memory/uses_allocator.h>952# include <__memory/temporary_buffer.h>
953# include <__memory/uninitialized_algorithms.h>
954# include <__memory/unique_ptr.h>
955# include <__memory/uses_allocator.h>
953956
954// standard-mandated includes957// standard-mandated includes
955958
956#if _LIBCPP_STD_VER >= 17959# if _LIBCPP_STD_VER >= 17
957# include <__memory/construct_at.h>960# include <__memory/construct_at.h>
958#endif961# endif
959962
960#if _LIBCPP_STD_VER >= 20963# if _LIBCPP_STD_VER >= 20
961# include <__memory/assume_aligned.h>964# include <__memory/assume_aligned.h>
962# include <__memory/concepts.h>965# include <__memory/concepts.h>
963# include <__memory/ranges_construct_at.h>966# include <__memory/ranges_construct_at.h>
964# include <__memory/ranges_uninitialized_algorithms.h>967# include <__memory/ranges_uninitialized_algorithms.h>
965# include <__memory/uses_allocator_construction.h>968# include <__memory/uses_allocator_construction.h>
966#endif969# endif
967970
968#if _LIBCPP_STD_VER >= 23971# if _LIBCPP_STD_VER >= 23
969# include <__memory/allocate_at_least.h>972# include <__memory/allocate_at_least.h>
970#endif973# endif
971974
972#include <version>975# include <version>
973976
974// [memory.syn]977// [memory.syn]
975#include <compare>978# include <compare>
976979
977#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)980# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
978# pragma GCC system_header981# pragma GCC system_header
979#endif982# endif
980983
981#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20984# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
982# include <atomic>985# include <atomic>
983# include <concepts>986# include <concepts>
984# include <cstddef>987# include <cstddef>
985# include <cstdint>988# include <cstdint>
986# include <cstdlib>989# include <cstdlib>
987# include <cstring>990# include <cstring>
988# include <iosfwd>991# include <iosfwd>
989# include <iterator>992# include <iterator>
990# include <new>993# include <new>
991# include <stdexcept>994# include <stdexcept>
992# include <tuple>995# include <tuple>
993# include <type_traits>996# include <type_traits>
994# include <typeinfo>997# include <typeinfo>
995# include <utility>998# include <utility>
996#endif999# endif
1000#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
9971001
998#endif // _LIBCPP_MEMORY1002#endif // _LIBCPP_MEMORY
lib/libcxx/include/memory_resource+28-30
...@@ -49,35 +49,33 @@ namespace std::pmr {...@@ -49,35 +49,33 @@ namespace std::pmr {
4949
50 */50 */
5151
52#include <__config>52#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
5353# include <__cxx03/memory_resource>
54#if _LIBCPP_STD_VER >= 1754#else
55# include <__memory_resource/memory_resource.h>55# include <__config>
56# include <__memory_resource/monotonic_buffer_resource.h>56
57# include <__memory_resource/polymorphic_allocator.h>57# if _LIBCPP_STD_VER >= 17
58# include <__memory_resource/pool_options.h>58# include <__memory_resource/memory_resource.h>
59# include <__memory_resource/synchronized_pool_resource.h>59# include <__memory_resource/monotonic_buffer_resource.h>
60# include <__memory_resource/unsynchronized_pool_resource.h>60# include <__memory_resource/polymorphic_allocator.h>
61#endif61# include <__memory_resource/pool_options.h>
6262# include <__memory_resource/synchronized_pool_resource.h>
63#include <version>63# include <__memory_resource/unsynchronized_pool_resource.h>
6464# endif
65#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)65
66# pragma GCC system_header66# include <version>
67#endif67
6868# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
69#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 1469# pragma GCC system_header
70# include <cstddef>70# endif
71# include <cstdint>71
72# include <limits>72# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER >= 17 && _LIBCPP_STD_VER <= 20
73# include <mutex>73# include <mutex>
74# include <new>74# endif
75# include <stdexcept>75
76# include <tuple>76# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
77#endif77# include <stdexcept>
7878# endif
79#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 2079#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
80# include <stdexcept>
81#endif
8280
83#endif /* _LIBCPP_MEMORY_RESOURCE */81#endif /* _LIBCPP_MEMORY_RESOURCE */
lib/libcxx/include/mutex+48-46
...@@ -186,36 +186,37 @@ template<class Callable, class ...Args>...@@ -186,36 +186,37 @@ template<class Callable, class ...Args>
186186
187*/187*/
188188
189#include <__chrono/steady_clock.h>189#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
190#include <__chrono/time_point.h>190# include <__cxx03/mutex>
191#include <__condition_variable/condition_variable.h>191#else
192#include <__config>192# include <__chrono/steady_clock.h>
193#include <__memory/shared_ptr.h>193# include <__chrono/time_point.h>
194#include <__mutex/lock_guard.h>194# include <__condition_variable/condition_variable.h>
195#include <__mutex/mutex.h>195# include <__config>
196#include <__mutex/once_flag.h>196# include <__mutex/lock_guard.h>
197#include <__mutex/tag_types.h>197# include <__mutex/mutex.h>
198#include <__mutex/unique_lock.h>198# include <__mutex/once_flag.h>
199#include <__thread/id.h>199# include <__mutex/tag_types.h>
200#include <__thread/support.h>200# include <__mutex/unique_lock.h>
201#include <__utility/forward.h>201# include <__thread/id.h>
202#include <cstddef>202# include <__thread/support.h>
203#include <limits>203# include <__utility/forward.h>
204#ifndef _LIBCPP_CXX03_LANG204# include <limits>
205# include <tuple>205# ifndef _LIBCPP_CXX03_LANG
206#endif206# include <tuple>
207#include <version>207# endif
208208# include <version>
209#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)209
210# pragma GCC system_header210# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
211#endif211# pragma GCC system_header
212# endif
212213
213_LIBCPP_PUSH_MACROS214_LIBCPP_PUSH_MACROS
214#include <__undef_macros>215# include <__undef_macros>
215216
216_LIBCPP_BEGIN_NAMESPACE_STD217_LIBCPP_BEGIN_NAMESPACE_STD
217218
218#ifndef _LIBCPP_HAS_NO_THREADS219# if _LIBCPP_HAS_THREADS
219220
220class _LIBCPP_EXPORTED_FROM_ABI recursive_mutex {221class _LIBCPP_EXPORTED_FROM_ABI recursive_mutex {
221 __libcpp_recursive_mutex_t __m_;222 __libcpp_recursive_mutex_t __m_;
...@@ -335,7 +336,7 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) {...@@ -335,7 +336,7 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) {
335 return 0;336 return 0;
336}337}
337338
338# ifndef _LIBCPP_CXX03_LANG339# ifndef _LIBCPP_CXX03_LANG
339340
340template <class _L0, class _L1, class _L2, class... _L3>341template <class _L0, class _L1, class _L2, class... _L3>
341_LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {342_LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
...@@ -351,7 +352,7 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3...@@ -351,7 +352,7 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3
351 return __r;352 return __r;
352}353}
353354
354# endif // _LIBCPP_CXX03_LANG355# endif // _LIBCPP_CXX03_LANG
355356
356template <class _L0, class _L1>357template <class _L0, class _L1>
357_LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) {358_LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) {
...@@ -375,7 +376,7 @@ _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) {...@@ -375,7 +376,7 @@ _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) {
375 }376 }
376}377}
377378
378# ifndef _LIBCPP_CXX03_LANG379# ifndef _LIBCPP_CXX03_LANG
379380
380template <class _L0, class _L1, class _L2, class... _L3>381template <class _L0, class _L1, class _L2, class... _L3>
381void __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {382void __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
...@@ -418,9 +419,9 @@ inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&......@@ -418,9 +419,9 @@ inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&...
418 std::__lock_first(0, __l0, __l1, __l2, __l3...);419 std::__lock_first(0, __l0, __l1, __l2, __l3...);
419}420}
420421
421# endif // _LIBCPP_CXX03_LANG422# endif // _LIBCPP_CXX03_LANG
422423
423# if _LIBCPP_STD_VER >= 17424# if _LIBCPP_STD_VER >= 17
424template <class... _Mutexes>425template <class... _Mutexes>
425class _LIBCPP_TEMPLATE_VIS scoped_lock;426class _LIBCPP_TEMPLATE_VIS scoped_lock;
426427
...@@ -491,26 +492,27 @@ private:...@@ -491,26 +492,27 @@ private:
491};492};
492_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scoped_lock);493_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scoped_lock);
493494
494# endif // _LIBCPP_STD_VER >= 17495# endif // _LIBCPP_STD_VER >= 17
495#endif // !_LIBCPP_HAS_NO_THREADS496# endif // _LIBCPP_HAS_THREADS
496497
497_LIBCPP_END_NAMESPACE_STD498_LIBCPP_END_NAMESPACE_STD
498499
499_LIBCPP_POP_MACROS500_LIBCPP_POP_MACROS
500501
501#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20502# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
502# include <atomic>503# include <atomic>
503# include <concepts>504# include <concepts>
504# include <cstdlib>505# include <cstdlib>
505# include <cstring>506# include <cstring>
506# include <ctime>507# include <ctime>
507# include <initializer_list>508# include <initializer_list>
508# include <iosfwd>509# include <iosfwd>
509# include <new>510# include <new>
510# include <stdexcept>511# include <stdexcept>
511# include <system_error>512# include <system_error>
512# include <type_traits>513# include <type_traits>
513# include <typeinfo>514# include <typeinfo>
514#endif515# endif
516#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
515517
516#endif // _LIBCPP_MUTEX518#endif // _LIBCPP_MUTEX
lib/libcxx/include/new+28-266
...@@ -79,284 +79,46 @@ void operator delete[](void* ptr, const std::nothrow_t&) noexcept; // repla...@@ -79,284 +79,46 @@ void operator delete[](void* ptr, const std::nothrow_t&) noexcept; // repla
79void operator delete[](void* ptr, std::align_val_t alignment,79void operator delete[](void* ptr, std::align_val_t alignment,
80 const std::nothrow_t&) noexcept; // replaceable, C++1780 const std::nothrow_t&) noexcept; // replaceable, C++17
8181
82void* operator new (std::size_t size, void* ptr) noexcept; // nodiscard in C++2082void* operator new (std::size_t size, void* ptr) noexcept; // nodiscard in C++20, constexpr since C++26
83void* operator new[](std::size_t size, void* ptr) noexcept; // nodiscard in C++2083void* operator new[](std::size_t size, void* ptr) noexcept; // nodiscard in C++20, constexpr since C++26
84void operator delete (void* ptr, void*) noexcept;84void operator delete (void* ptr, void*) noexcept;
85void operator delete[](void* ptr, void*) noexcept;85void operator delete[](void* ptr, void*) noexcept;
8686
87*/87*/
8888
89#include <__config>89#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
90#include <__exception/exception.h>90# include <__cxx03/new>
91#include <__type_traits/is_function.h>
92#include <__type_traits/is_same.h>
93#include <__type_traits/remove_cv.h>
94#include <__verbose_abort>
95#include <cstddef>
96#include <version>
97
98#if defined(_LIBCPP_ABI_VCRUNTIME)
99# include <new.h>
100#endif
101
102#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
103# pragma GCC system_header
104#endif
105
106#if !defined(__cpp_sized_deallocation) || __cpp_sized_deallocation < 201309L
107# define _LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION
108#endif
109
110#if !defined(_LIBCPP_BUILDING_LIBRARY) && _LIBCPP_STD_VER < 14 && defined(_LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION)
111# define _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
112#endif
113
114#if defined(_LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION) || defined(_LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION)
115# define _LIBCPP_HAS_NO_SIZED_DEALLOCATION
116#endif
117
118namespace std // purposefully not using versioning namespace
119{
120
121#if !defined(_LIBCPP_ABI_VCRUNTIME)
122struct _LIBCPP_EXPORTED_FROM_ABI nothrow_t {
123 explicit nothrow_t() = default;
124};
125extern _LIBCPP_EXPORTED_FROM_ABI const nothrow_t nothrow;
126
127class _LIBCPP_EXPORTED_FROM_ABI bad_alloc : public exception {
128public:
129 bad_alloc() _NOEXCEPT;
130 _LIBCPP_HIDE_FROM_ABI bad_alloc(const bad_alloc&) _NOEXCEPT = default;
131 _LIBCPP_HIDE_FROM_ABI bad_alloc& operator=(const bad_alloc&) _NOEXCEPT = default;
132 ~bad_alloc() _NOEXCEPT override;
133 const char* what() const _NOEXCEPT override;
134};
135
136class _LIBCPP_EXPORTED_FROM_ABI bad_array_new_length : public bad_alloc {
137public:
138 bad_array_new_length() _NOEXCEPT;
139 _LIBCPP_HIDE_FROM_ABI bad_array_new_length(const bad_array_new_length&) _NOEXCEPT = default;
140 _LIBCPP_HIDE_FROM_ABI bad_array_new_length& operator=(const bad_array_new_length&) _NOEXCEPT = default;
141 ~bad_array_new_length() _NOEXCEPT override;
142 const char* what() const _NOEXCEPT override;
143};
144
145typedef void (*new_handler)();
146_LIBCPP_EXPORTED_FROM_ABI new_handler set_new_handler(new_handler) _NOEXCEPT;
147_LIBCPP_EXPORTED_FROM_ABI new_handler get_new_handler() _NOEXCEPT;
148
149#elif defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 // !_LIBCPP_ABI_VCRUNTIME
150
151// When _HAS_EXCEPTIONS == 0, these complete definitions are needed,
152// since they would normally be provided in vcruntime_exception.h
153class bad_alloc : public exception {
154public:
155 bad_alloc() noexcept : exception("bad allocation") {}
156
157private:
158 friend class bad_array_new_length;
159
160 bad_alloc(char const* const __message) noexcept : exception(__message) {}
161};
162
163class bad_array_new_length : public bad_alloc {
164public:
165 bad_array_new_length() noexcept : bad_alloc("bad array new length") {}
166};
167#endif // defined(_LIBCPP_ABI_VCRUNTIME) && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0
168
169_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_bad_alloc(); // not in C++ spec
170
171_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_array_new_length() {
172#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
173 throw bad_array_new_length();
174#else
175 _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode");
176#endif
177}
178
179#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) && !defined(_LIBCPP_ABI_VCRUNTIME)
180# ifndef _LIBCPP_CXX03_LANG
181enum class align_val_t : size_t {};
182# else
183enum align_val_t { __zero = 0, __max = (size_t)-1 };
184# endif
185#endif
186
187#if _LIBCPP_STD_VER >= 20
188// Enable the declaration even if the compiler doesn't support the language
189// feature.
190struct destroying_delete_t {
191 explicit destroying_delete_t() = default;
192};
193inline constexpr destroying_delete_t destroying_delete{};
194#endif // _LIBCPP_STD_VER >= 20
195
196} // namespace std
197
198#if defined(_LIBCPP_CXX03_LANG)
199# define _THROW_BAD_ALLOC throw(std::bad_alloc)
200#else91#else
201# define _THROW_BAD_ALLOC92# include <__config>
202#endif93# include <__new/align_val_t.h>
20394# include <__new/allocate.h>
204#if !defined(_LIBCPP_ABI_VCRUNTIME)95# include <__new/exceptions.h>
20596# include <__new/global_new_delete.h>
206_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;97# include <__new/new_handler.h>
207_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT98# include <__new/nothrow_t.h>
208 _LIBCPP_NOALIAS;99# include <__new/placement_new_delete.h>
209_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT;100
210_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;101# if _LIBCPP_STD_VER >= 17
211# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION102# include <__new/interference_size.h>
212_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;103# include <__new/launder.h>
213# endif104# endif
214105
215_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC;106# if _LIBCPP_STD_VER >= 20
216_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT107# include <__new/destroying_delete_t.h>
217 _LIBCPP_NOALIAS;
218_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT;
219_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
220# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
221_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
222# endif108# endif
223109
224# ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION110// feature-test macros
225_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;111# include <version>
226_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void*
227operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
228_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
229_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
230# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
231_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
232# endif
233112
234_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void*113# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
235operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;114# pragma GCC system_header
236_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void*
237operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
238_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
239_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
240# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
241_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
242# endif
243# endif115# endif
244116
245_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI void* operator new(std::size_t, void* __p) _NOEXCEPT { return __p; }117# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
246_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI void* operator new[](std::size_t, void* __p) _NOEXCEPT { return __p; }118# include <cstddef>
247inline _LIBCPP_HIDE_FROM_ABI void operator delete(void*, void*) _NOEXCEPT {}119# include <cstdlib>
248inline _LIBCPP_HIDE_FROM_ABI void operator delete[](void*, void*) _NOEXCEPT {}120# include <type_traits>
249121# endif
250#endif // !_LIBCPP_ABI_VCRUNTIME122#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
251
252_LIBCPP_BEGIN_NAMESPACE_STD
253
254_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI bool __is_overaligned_for_new(size_t __align) _NOEXCEPT {
255#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
256 return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
257#else
258 return __align > _LIBCPP_ALIGNOF(max_align_t);
259#endif
260}
261
262template <class... _Args>
263_LIBCPP_HIDE_FROM_ABI void* __libcpp_operator_new(_Args... __args) {
264#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
265 return __builtin_operator_new(__args...);
266#else
267 return ::operator new(__args...);
268#endif
269}
270
271template <class... _Args>
272_LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) {
273#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
274 __builtin_operator_delete(__args...);
275#else
276 ::operator delete(__args...);
277#endif
278}
279
280inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_allocate(size_t __size, size_t __align) {
281#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
282 if (__is_overaligned_for_new(__align)) {
283 const align_val_t __align_val = static_cast<align_val_t>(__align);
284 return __libcpp_operator_new(__size, __align_val);
285 }
286#endif
287
288 (void)__align;
289 return __libcpp_operator_new(__size);
290}
291
292template <class... _Args>
293_LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __size, _Args... __args) {
294#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
295 (void)__size;
296 return std::__libcpp_operator_delete(__ptr, __args...);
297#else
298 return std::__libcpp_operator_delete(__ptr, __size, __args...);
299#endif
300}
301
302inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) {
303#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
304 (void)__align;
305 return __do_deallocate_handle_size(__ptr, __size);
306#else
307 if (__is_overaligned_for_new(__align)) {
308 const align_val_t __align_val = static_cast<align_val_t>(__align);
309 return __do_deallocate_handle_size(__ptr, __size, __align_val);
310 } else {
311 return __do_deallocate_handle_size(__ptr, __size);
312 }
313#endif
314}
315
316inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_t __align) {
317#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
318 (void)__align;
319 return __libcpp_operator_delete(__ptr);
320#else
321 if (__is_overaligned_for_new(__align)) {
322 const align_val_t __align_val = static_cast<align_val_t>(__align);
323 return __libcpp_operator_delete(__ptr, __align_val);
324 } else {
325 return __libcpp_operator_delete(__ptr);
326 }
327#endif
328}
329
330template <class _Tp>
331_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT {
332 static_assert(!(is_function<_Tp>::value), "can't launder functions");
333 static_assert(!(is_same<void, __remove_cv_t<_Tp> >::value), "can't launder cv-void");
334 return __builtin_launder(__p);
335}
336
337#if _LIBCPP_STD_VER >= 17
338template <class _Tp>
339[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept {
340 return std::__launder(__p);
341}
342#endif
343
344#if _LIBCPP_STD_VER >= 17
345
346# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
347
348inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE;
349inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE;
350
351# endif // defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE)
352
353#endif // _LIBCPP_STD_VER >= 17
354
355_LIBCPP_END_NAMESPACE_STD
356
357#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
358# include <cstdlib>
359# include <type_traits>
360#endif
361123
362#endif // _LIBCPP_NEW124#endif // _LIBCPP_NEW
lib/libcxx/include/numbers+17-12
...@@ -58,15 +58,18 @@ namespace std::numbers {...@@ -58,15 +58,18 @@ namespace std::numbers {
58}58}
59*/59*/
6060
61#include <__concepts/arithmetic.h>61#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
62#include <__config>62# include <__cxx03/numbers>
63#include <version>63#else
64# include <__concepts/arithmetic.h>
65# include <__config>
66# include <version>
6467
65#if _LIBCPP_STD_VER >= 2068# if _LIBCPP_STD_VER >= 20
6669
67# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)70# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
68# pragma GCC system_header71# pragma GCC system_header
69# endif72# endif
7073
71_LIBCPP_BEGIN_NAMESPACE_STD74_LIBCPP_BEGIN_NAMESPACE_STD
7275
...@@ -154,11 +157,13 @@ inline constexpr double phi = phi_v<double>;...@@ -154,11 +157,13 @@ inline constexpr double phi = phi_v<double>;
154157
155_LIBCPP_END_NAMESPACE_STD158_LIBCPP_END_NAMESPACE_STD
156159
157#endif // _LIBCPP_STD_VER >= 20160# endif // _LIBCPP_STD_VER >= 20
158161
159#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20162# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
160# include <concepts>163# include <concepts>
161# include <type_traits>164# include <cstddef>
162#endif165# include <type_traits>
166# endif
167#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
163168
164#endif // _LIBCPP_NUMBERS169#endif // _LIBCPP_NUMBERS
lib/libcxx/include/numeric+51-47
...@@ -156,52 +156,56 @@ constexpr T saturate_cast(U x) noexcept; // freestanding, Sin...@@ -156,52 +156,56 @@ constexpr T saturate_cast(U x) noexcept; // freestanding, Sin
156156
157*/157*/
158158
159#include <__config>159#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
160160# include <__cxx03/numeric>
161#include <__numeric/accumulate.h>161#else
162#include <__numeric/adjacent_difference.h>162# include <__config>
163#include <__numeric/inner_product.h>163
164#include <__numeric/iota.h>164# include <__numeric/accumulate.h>
165#include <__numeric/partial_sum.h>165# include <__numeric/adjacent_difference.h>
166166# include <__numeric/inner_product.h>
167#if _LIBCPP_STD_VER >= 17167# include <__numeric/iota.h>
168# include <__numeric/exclusive_scan.h>168# include <__numeric/partial_sum.h>
169# include <__numeric/gcd_lcm.h>169
170# include <__numeric/inclusive_scan.h>170# if _LIBCPP_STD_VER >= 17
171# include <__numeric/pstl.h>171# include <__numeric/exclusive_scan.h>
172# include <__numeric/reduce.h>172# include <__numeric/gcd_lcm.h>
173# include <__numeric/transform_exclusive_scan.h>173# include <__numeric/inclusive_scan.h>
174# include <__numeric/transform_inclusive_scan.h>174# include <__numeric/pstl.h>
175# include <__numeric/transform_reduce.h>175# include <__numeric/reduce.h>
176#endif176# include <__numeric/transform_exclusive_scan.h>
177177# include <__numeric/transform_inclusive_scan.h>
178#if _LIBCPP_STD_VER >= 20178# include <__numeric/transform_reduce.h>
179# include <__numeric/midpoint.h>179# endif
180# include <__numeric/saturation_arithmetic.h>180
181#endif181# if _LIBCPP_STD_VER >= 20
182182# include <__numeric/midpoint.h>
183#include <version>183# include <__numeric/saturation_arithmetic.h>
184184# endif
185#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)185
186# pragma GCC system_header186# include <version>
187#endif187
188188# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
189#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14189# pragma GCC system_header
190# include <initializer_list>190# endif
191# include <limits>191
192#endif192# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14
193193# include <initializer_list>
194#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20194# include <limits>
195# include <climits>195# endif
196# include <cmath>196
197# include <concepts>197# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
198# include <cstdint>198# include <climits>
199# include <execution>199# include <cmath>
200# include <functional>200# include <concepts>
201# include <iterator>201# include <cstdint>
202# include <new>202# include <execution>
203# include <optional>203# include <functional>
204# include <type_traits>204# include <iterator>
205#endif205# include <new>
206# include <optional>
207# include <type_traits>
208# endif
209#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
206210
207#endif // _LIBCPP_NUMERIC211#endif // _LIBCPP_NUMERIC
lib/libcxx/include/optional+119-110
...@@ -177,64 +177,71 @@ namespace std {...@@ -177,64 +177,71 @@ namespace std {
177177
178*/178*/
179179
180#include <__assert>180#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
181#include <__compare/compare_three_way_result.h>181# include <__cxx03/optional>
182#include <__compare/three_way_comparable.h>182#else
183#include <__concepts/invocable.h>183# include <__assert>
184#include <__config>184# include <__compare/compare_three_way_result.h>
185#include <__exception/exception.h>185# include <__compare/ordering.h>
186#include <__functional/hash.h>186# include <__compare/three_way_comparable.h>
187#include <__functional/invoke.h>187# include <__concepts/invocable.h>
188#include <__functional/unary_function.h>188# include <__config>
189#include <__fwd/functional.h>189# include <__exception/exception.h>
190#include <__memory/addressof.h>190# include <__functional/hash.h>
191#include <__memory/construct_at.h>191# include <__functional/invoke.h>
192#include <__tuple/sfinae_helpers.h>192# include <__functional/unary_function.h>
193#include <__type_traits/add_pointer.h>193# include <__fwd/functional.h>
194#include <__type_traits/conditional.h>194# include <__memory/addressof.h>
195#include <__type_traits/conjunction.h>195# include <__memory/construct_at.h>
196#include <__type_traits/decay.h>196# include <__tuple/sfinae_helpers.h>
197#include <__type_traits/disjunction.h>197# include <__type_traits/add_pointer.h>
198#include <__type_traits/is_array.h>198# include <__type_traits/conditional.h>
199#include <__type_traits/is_assignable.h>199# include <__type_traits/conjunction.h>
200#include <__type_traits/is_constructible.h>200# include <__type_traits/decay.h>
201#include <__type_traits/is_convertible.h>201# include <__type_traits/disjunction.h>
202#include <__type_traits/is_destructible.h>202# include <__type_traits/enable_if.h>
203#include <__type_traits/is_nothrow_assignable.h>203# include <__type_traits/invoke.h>
204#include <__type_traits/is_nothrow_constructible.h>204# include <__type_traits/is_array.h>
205#include <__type_traits/is_object.h>205# include <__type_traits/is_assignable.h>
206#include <__type_traits/is_reference.h>206# include <__type_traits/is_constructible.h>
207#include <__type_traits/is_scalar.h>207# include <__type_traits/is_convertible.h>
208#include <__type_traits/is_swappable.h>208# include <__type_traits/is_destructible.h>
209#include <__type_traits/is_trivially_assignable.h>209# include <__type_traits/is_nothrow_assignable.h>
210#include <__type_traits/is_trivially_constructible.h>210# include <__type_traits/is_nothrow_constructible.h>
211#include <__type_traits/is_trivially_destructible.h>211# include <__type_traits/is_object.h>
212#include <__type_traits/is_trivially_relocatable.h>212# include <__type_traits/is_reference.h>
213#include <__type_traits/negation.h>213# include <__type_traits/is_same.h>
214#include <__type_traits/remove_const.h>214# include <__type_traits/is_scalar.h>
215#include <__type_traits/remove_cvref.h>215# include <__type_traits/is_swappable.h>
216#include <__type_traits/remove_reference.h>216# include <__type_traits/is_trivially_assignable.h>
217#include <__utility/declval.h>217# include <__type_traits/is_trivially_constructible.h>
218#include <__utility/forward.h>218# include <__type_traits/is_trivially_destructible.h>
219#include <__utility/in_place.h>219# include <__type_traits/is_trivially_relocatable.h>
220#include <__utility/move.h>220# include <__type_traits/negation.h>
221#include <__utility/swap.h>221# include <__type_traits/remove_const.h>
222#include <__verbose_abort>222# include <__type_traits/remove_cv.h>
223#include <initializer_list>223# include <__type_traits/remove_cvref.h>
224#include <new>224# include <__type_traits/remove_reference.h>
225#include <version>225# include <__utility/declval.h>
226# include <__utility/forward.h>
227# include <__utility/in_place.h>
228# include <__utility/move.h>
229# include <__utility/swap.h>
230# include <__verbose_abort>
231# include <initializer_list>
232# include <version>
226233
227// standard-mandated includes234// standard-mandated includes
228235
229// [optional.syn]236// [optional.syn]
230#include <compare>237# include <compare>
231238
232#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)239# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
233# pragma GCC system_header240# pragma GCC system_header
234#endif241# endif
235242
236_LIBCPP_PUSH_MACROS243_LIBCPP_PUSH_MACROS
237#include <__undef_macros>244# include <__undef_macros>
238245
239namespace std // purposefully not using versioning namespace246namespace std // purposefully not using versioning namespace
240{247{
...@@ -251,17 +258,17 @@ public:...@@ -251,17 +258,17 @@ public:
251258
252} // namespace std259} // namespace std
253260
254#if _LIBCPP_STD_VER >= 17261# if _LIBCPP_STD_VER >= 17
255262
256_LIBCPP_BEGIN_NAMESPACE_STD263_LIBCPP_BEGIN_NAMESPACE_STD
257264
258_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS void265[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS void
259__throw_bad_optional_access() {266__throw_bad_optional_access() {
260# ifndef _LIBCPP_HAS_NO_EXCEPTIONS267# if _LIBCPP_HAS_EXCEPTIONS
261 throw bad_optional_access();268 throw bad_optional_access();
262# else269# else
263 _LIBCPP_VERBOSE_ABORT("bad_optional_access was thrown in -fno-exceptions mode");270 _LIBCPP_VERBOSE_ABORT("bad_optional_access was thrown in -fno-exceptions mode");
264# endif271# endif
265}272}
266273
267struct nullopt_t {274struct nullopt_t {
...@@ -284,7 +291,7 @@ struct __optional_destruct_base<_Tp, false> {...@@ -284,7 +291,7 @@ struct __optional_destruct_base<_Tp, false> {
284 static_assert(is_object_v<value_type>, "instantiation of optional with a non-object type is undefined behavior");291 static_assert(is_object_v<value_type>, "instantiation of optional with a non-object type is undefined behavior");
285 union {292 union {
286 char __null_state_;293 char __null_state_;
287 value_type __val_;294 remove_cv_t<value_type> __val_;
288 };295 };
289 bool __engaged_;296 bool __engaged_;
290297
...@@ -299,12 +306,12 @@ struct __optional_destruct_base<_Tp, false> {...@@ -299,12 +306,12 @@ struct __optional_destruct_base<_Tp, false> {
299 _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(in_place_t, _Args&&... __args)306 _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(in_place_t, _Args&&... __args)
300 : __val_(std::forward<_Args>(__args)...), __engaged_(true) {}307 : __val_(std::forward<_Args>(__args)...), __engaged_(true) {}
301308
302# if _LIBCPP_STD_VER >= 23309# if _LIBCPP_STD_VER >= 23
303 template <class _Fp, class... _Args>310 template <class _Fp, class... _Args>
304 _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(311 _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(
305 __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)312 __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)
306 : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {}313 : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {}
307# endif314# endif
308315
309 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept {316 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept {
310 if (__engaged_) {317 if (__engaged_) {
...@@ -320,7 +327,7 @@ struct __optional_destruct_base<_Tp, true> {...@@ -320,7 +327,7 @@ struct __optional_destruct_base<_Tp, true> {
320 static_assert(is_object_v<value_type>, "instantiation of optional with a non-object type is undefined behavior");327 static_assert(is_object_v<value_type>, "instantiation of optional with a non-object type is undefined behavior");
321 union {328 union {
322 char __null_state_;329 char __null_state_;
323 value_type __val_;330 remove_cv_t<value_type> __val_;
324 };331 };
325 bool __engaged_;332 bool __engaged_;
326333
...@@ -330,12 +337,12 @@ struct __optional_destruct_base<_Tp, true> {...@@ -330,12 +337,12 @@ struct __optional_destruct_base<_Tp, true> {
330 _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(in_place_t, _Args&&... __args)337 _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(in_place_t, _Args&&... __args)
331 : __val_(std::forward<_Args>(__args)...), __engaged_(true) {}338 : __val_(std::forward<_Args>(__args)...), __engaged_(true) {}
332339
333# if _LIBCPP_STD_VER >= 23340# if _LIBCPP_STD_VER >= 23
334 template <class _Fp, class... _Args>341 template <class _Fp, class... _Args>
335 _LIBCPP_HIDE_FROM_ABI constexpr __optional_destruct_base(342 _LIBCPP_HIDE_FROM_ABI constexpr __optional_destruct_base(
336 __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)343 __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)
337 : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {}344 : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {}
338# endif345# endif
339346
340 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept {347 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept {
341 if (__engaged_) {348 if (__engaged_) {
...@@ -346,8 +353,8 @@ struct __optional_destruct_base<_Tp, true> {...@@ -346,8 +353,8 @@ struct __optional_destruct_base<_Tp, true> {
346353
347template <class _Tp, bool = is_reference<_Tp>::value>354template <class _Tp, bool = is_reference<_Tp>::value>
348struct __optional_storage_base : __optional_destruct_base<_Tp> {355struct __optional_storage_base : __optional_destruct_base<_Tp> {
349 using __base = __optional_destruct_base<_Tp>;356 using __base _LIBCPP_NODEBUG = __optional_destruct_base<_Tp>;
350 using value_type = _Tp;357 using value_type = _Tp;
351 using __base::__base;358 using __base::__base;
352359
353 _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return this->__engaged_; }360 _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return this->__engaged_; }
...@@ -374,7 +381,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp> {...@@ -374,7 +381,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp> {
374 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_from(_That&& __opt) {381 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_from(_That&& __opt) {
375 if (this->__engaged_ == __opt.has_value()) {382 if (this->__engaged_ == __opt.has_value()) {
376 if (this->__engaged_)383 if (this->__engaged_)
377 this->__val_ = std::forward<_That>(__opt).__get();384 static_cast<_Tp&>(this->__val_) = std::forward<_That>(__opt).__get();
378 } else {385 } else {
379 if (this->__engaged_)386 if (this->__engaged_)
380 this->reset();387 this->reset();
...@@ -389,8 +396,8 @@ struct __optional_storage_base : __optional_destruct_base<_Tp> {...@@ -389,8 +396,8 @@ struct __optional_storage_base : __optional_destruct_base<_Tp> {
389// to ensure we can make the change in an ABI-compatible manner.396// to ensure we can make the change in an ABI-compatible manner.
390template <class _Tp>397template <class _Tp>
391struct __optional_storage_base<_Tp, true> {398struct __optional_storage_base<_Tp, true> {
392 using value_type = _Tp;399 using value_type = _Tp;
393 using __raw_type = remove_reference_t<_Tp>;400 using __raw_type _LIBCPP_NODEBUG = remove_reference_t<_Tp>;
394 __raw_type* __value_;401 __raw_type* __value_;
395402
396 template <class _Up>403 template <class _Up>
...@@ -548,23 +555,23 @@ struct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp...@@ -548,23 +555,23 @@ struct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp
548};555};
549556
550template <class _Tp>557template <class _Tp>
551using __optional_sfinae_ctor_base_t =558using __optional_sfinae_ctor_base_t _LIBCPP_NODEBUG =
552 __sfinae_ctor_base< is_copy_constructible<_Tp>::value, is_move_constructible<_Tp>::value >;559 __sfinae_ctor_base< is_copy_constructible<_Tp>::value, is_move_constructible<_Tp>::value >;
553560
554template <class _Tp>561template <class _Tp>
555using __optional_sfinae_assign_base_t =562using __optional_sfinae_assign_base_t _LIBCPP_NODEBUG =
556 __sfinae_assign_base< (is_copy_constructible<_Tp>::value && is_copy_assignable<_Tp>::value),563 __sfinae_assign_base< (is_copy_constructible<_Tp>::value && is_copy_assignable<_Tp>::value),
557 (is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value) >;564 (is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value) >;
558565
559template <class _Tp>566template <class _Tp>
560class optional;567class optional;
561568
562# if _LIBCPP_STD_VER >= 20569# if _LIBCPP_STD_VER >= 20
563570
564template <class _Tp>571template <class _Tp>
565concept __is_derived_from_optional = requires(const _Tp& __t) { []<class _Up>(const optional<_Up>&) {}(__t); };572concept __is_derived_from_optional = requires(const _Tp& __t) { []<class _Up>(const optional<_Up>&) {}(__t); };
566573
567# endif // _LIBCPP_STD_VER >= 20574# endif // _LIBCPP_STD_VER >= 20
568575
569template <class _Tp>576template <class _Tp>
570struct __is_std_optional : false_type {};577struct __is_std_optional : false_type {};
...@@ -576,12 +583,13 @@ class _LIBCPP_DECLSPEC_EMPTY_BASES optional...@@ -576,12 +583,13 @@ class _LIBCPP_DECLSPEC_EMPTY_BASES optional
576 : private __optional_move_assign_base<_Tp>,583 : private __optional_move_assign_base<_Tp>,
577 private __optional_sfinae_ctor_base_t<_Tp>,584 private __optional_sfinae_ctor_base_t<_Tp>,
578 private __optional_sfinae_assign_base_t<_Tp> {585 private __optional_sfinae_assign_base_t<_Tp> {
579 using __base = __optional_move_assign_base<_Tp>;586 using __base _LIBCPP_NODEBUG = __optional_move_assign_base<_Tp>;
580587
581public:588public:
582 using value_type = _Tp;589 using value_type = _Tp;
583590
584 using __trivially_relocatable = conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>;591 using __trivially_relocatable _LIBCPP_NODEBUG =
592 conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>;
585593
586private:594private:
587 // Disable the reference extension using this static assert.595 // Disable the reference extension using this static assert.
...@@ -606,7 +614,7 @@ private:...@@ -606,7 +614,7 @@ private:
606 }614 }
607 };615 };
608 template <class _Up>616 template <class _Up>
609 using _CheckOptionalArgsCtor =617 using _CheckOptionalArgsCtor _LIBCPP_NODEBUG =
610 _If< _IsNotSame<__remove_cvref_t<_Up>, in_place_t>::value && _IsNotSame<__remove_cvref_t<_Up>, optional>::value &&618 _If< _IsNotSame<__remove_cvref_t<_Up>, in_place_t>::value && _IsNotSame<__remove_cvref_t<_Up>, optional>::value &&
611 (!is_same_v<remove_cv_t<_Tp>, bool> || !__is_std_optional<__remove_cvref_t<_Up>>::value),619 (!is_same_v<remove_cv_t<_Tp>, bool> || !__is_std_optional<__remove_cvref_t<_Up>>::value),
612 _CheckOptionalArgsConstructor,620 _CheckOptionalArgsConstructor,
...@@ -614,7 +622,7 @@ private:...@@ -614,7 +622,7 @@ private:
614 template <class _QualUp>622 template <class _QualUp>
615 struct _CheckOptionalLikeConstructor {623 struct _CheckOptionalLikeConstructor {
616 template <class _Up, class _Opt = optional<_Up>>624 template <class _Up, class _Opt = optional<_Up>>
617 using __check_constructible_from_opt =625 using __check_constructible_from_opt _LIBCPP_NODEBUG =
618 _Or< is_constructible<_Tp, _Opt&>,626 _Or< is_constructible<_Tp, _Opt&>,
619 is_constructible<_Tp, _Opt const&>,627 is_constructible<_Tp, _Opt const&>,
620 is_constructible<_Tp, _Opt&&>,628 is_constructible<_Tp, _Opt&&>,
...@@ -624,7 +632,7 @@ private:...@@ -624,7 +632,7 @@ private:
624 is_convertible<_Opt&&, _Tp>,632 is_convertible<_Opt&&, _Tp>,
625 is_convertible<_Opt const&&, _Tp> >;633 is_convertible<_Opt const&&, _Tp> >;
626 template <class _Up, class _Opt = optional<_Up>>634 template <class _Up, class _Opt = optional<_Up>>
627 using __check_assignable_from_opt =635 using __check_assignable_from_opt _LIBCPP_NODEBUG =
628 _Or< is_assignable<_Tp&, _Opt&>,636 _Or< is_assignable<_Tp&, _Opt&>,
629 is_assignable<_Tp&, _Opt const&>,637 is_assignable<_Tp&, _Opt const&>,
630 is_assignable<_Tp&, _Opt&&>,638 is_assignable<_Tp&, _Opt&&>,
...@@ -648,12 +656,12 @@ private:...@@ -648,12 +656,12 @@ private:
648 };656 };
649657
650 template <class _Up, class _QualUp>658 template <class _Up, class _QualUp>
651 using _CheckOptionalLikeCtor =659 using _CheckOptionalLikeCtor _LIBCPP_NODEBUG =
652 _If< _And< _IsNotSame<_Up, _Tp>, is_constructible<_Tp, _QualUp> >::value,660 _If< _And< _IsNotSame<_Up, _Tp>, is_constructible<_Tp, _QualUp> >::value,
653 _CheckOptionalLikeConstructor<_QualUp>,661 _CheckOptionalLikeConstructor<_QualUp>,
654 __check_tuple_constructor_fail >;662 __check_tuple_constructor_fail >;
655 template <class _Up, class _QualUp>663 template <class _Up, class _QualUp>
656 using _CheckOptionalLikeAssign =664 using _CheckOptionalLikeAssign _LIBCPP_NODEBUG =
657 _If< _And< _IsNotSame<_Up, _Tp>, is_constructible<_Tp, _QualUp>, is_assignable<_Tp&, _QualUp> >::value,665 _If< _And< _IsNotSame<_Up, _Tp>, is_constructible<_Tp, _QualUp>, is_assignable<_Tp&, _QualUp> >::value,
658 _CheckOptionalLikeConstructor<_QualUp>,666 _CheckOptionalLikeConstructor<_QualUp>,
659 __check_tuple_constructor_fail >;667 __check_tuple_constructor_fail >;
...@@ -706,14 +714,14 @@ public:...@@ -706,14 +714,14 @@ public:
706 this->__construct_from(std::move(__v));714 this->__construct_from(std::move(__v));
707 }715 }
708716
709# if _LIBCPP_STD_VER >= 23717# if _LIBCPP_STD_VER >= 23
710 template <class _Tag,718 template <class _Tag,
711 class _Fp,719 class _Fp,
712 class... _Args,720 class... _Args,
713 __enable_if_t<_IsSame<_Tag, __optional_construct_from_invoke_tag>::value, int> = 0>721 __enable_if_t<_IsSame<_Tag, __optional_construct_from_invoke_tag>::value, int> = 0>
714 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args)722 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args)
715 : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {}723 : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {}
716# endif724# endif
717725
718 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(nullopt_t) noexcept {726 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(nullopt_t) noexcept {
719 reset();727 reset();
...@@ -859,7 +867,7 @@ public:...@@ -859,7 +867,7 @@ public:
859 return this->has_value() ? std::move(this->__get()) : static_cast<value_type>(std::forward<_Up>(__v));867 return this->has_value() ? std::move(this->__get()) : static_cast<value_type>(std::forward<_Up>(__v));
860 }868 }
861869
862# if _LIBCPP_STD_VER >= 23870# if _LIBCPP_STD_VER >= 23
863 template <class _Func>871 template <class _Func>
864 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) & {872 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) & {
865 using _Up = invoke_result_t<_Func, value_type&>;873 using _Up = invoke_result_t<_Func, value_type&>;
...@@ -969,15 +977,15 @@ public:...@@ -969,15 +977,15 @@ public:
969 return std::move(*this);977 return std::move(*this);
970 return std::forward<_Func>(__f)();978 return std::forward<_Func>(__f)();
971 }979 }
972# endif // _LIBCPP_STD_VER >= 23980# endif // _LIBCPP_STD_VER >= 23
973981
974 using __base::reset;982 using __base::reset;
975};983};
976984
977# if _LIBCPP_STD_VER >= 17985# if _LIBCPP_STD_VER >= 17
978template <class _Tp>986template <class _Tp>
979optional(_Tp) -> optional<_Tp>;987optional(_Tp) -> optional<_Tp>;
980# endif988# endif
981989
982// Comparisons between optionals990// Comparisons between optionals
983template <class _Tp, class _Up>991template <class _Tp, class _Up>
...@@ -1052,7 +1060,7 @@ operator>=(const optional<_Tp>& __x, const optional<_Up>& __y) {...@@ -1052,7 +1060,7 @@ operator>=(const optional<_Tp>& __x, const optional<_Up>& __y) {
1052 return *__x >= *__y;1060 return *__x >= *__y;
1053}1061}
10541062
1055# if _LIBCPP_STD_VER >= 201063# if _LIBCPP_STD_VER >= 20
10561064
1057template <class _Tp, three_way_comparable_with<_Tp> _Up>1065template <class _Tp, three_way_comparable_with<_Tp> _Up>
1058_LIBCPP_HIDE_FROM_ABI constexpr compare_three_way_result_t<_Tp, _Up>1066_LIBCPP_HIDE_FROM_ABI constexpr compare_three_way_result_t<_Tp, _Up>
...@@ -1062,7 +1070,7 @@ operator<=>(const optional<_Tp>& __x, const optional<_Up>& __y) {...@@ -1062,7 +1070,7 @@ operator<=>(const optional<_Tp>& __x, const optional<_Up>& __y) {
1062 return __x.has_value() <=> __y.has_value();1070 return __x.has_value() <=> __y.has_value();
1063}1071}
10641072
1065# endif // _LIBCPP_STD_VER >= 201073# endif // _LIBCPP_STD_VER >= 20
10661074
1067// Comparisons with nullopt1075// Comparisons with nullopt
1068template <class _Tp>1076template <class _Tp>
...@@ -1070,7 +1078,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, nullop...@@ -1070,7 +1078,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, nullop
1070 return !static_cast<bool>(__x);1078 return !static_cast<bool>(__x);
1071}1079}
10721080
1073# if _LIBCPP_STD_VER <= 171081# if _LIBCPP_STD_VER <= 17
10741082
1075template <class _Tp>1083template <class _Tp>
1076_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(nullopt_t, const optional<_Tp>& __x) noexcept {1084_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(nullopt_t, const optional<_Tp>& __x) noexcept {
...@@ -1127,14 +1135,14 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(nullopt_t, const optional<_Tp>&...@@ -1127,14 +1135,14 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(nullopt_t, const optional<_Tp>&
1127 return !static_cast<bool>(__x);1135 return !static_cast<bool>(__x);
1128}1136}
11291137
1130# else // _LIBCPP_STD_VER <= 171138# else // _LIBCPP_STD_VER <= 17
11311139
1132template <class _Tp>1140template <class _Tp>
1133_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const optional<_Tp>& __x, nullopt_t) noexcept {1141_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const optional<_Tp>& __x, nullopt_t) noexcept {
1134 return __x.has_value() <=> false;1142 return __x.has_value() <=> false;
1135}1143}
11361144
1137# endif // _LIBCPP_STD_VER <= 171145# endif // _LIBCPP_STD_VER <= 17
11381146
1139// Comparisons with T1147// Comparisons with T
1140template <class _Tp, class _Up>1148template <class _Tp, class _Up>
...@@ -1233,7 +1241,7 @@ operator>=(const _Tp& __v, const optional<_Up>& __x) {...@@ -1233,7 +1241,7 @@ operator>=(const _Tp& __v, const optional<_Up>& __x) {
1233 return static_cast<bool>(__x) ? __v >= *__x : true;1241 return static_cast<bool>(__x) ? __v >= *__x : true;
1234}1242}
12351243
1236# if _LIBCPP_STD_VER >= 201244# if _LIBCPP_STD_VER >= 20
12371245
1238template <class _Tp, class _Up>1246template <class _Tp, class _Up>
1239 requires(!__is_derived_from_optional<_Up>) && three_way_comparable_with<_Tp, _Up>1247 requires(!__is_derived_from_optional<_Up>) && three_way_comparable_with<_Tp, _Up>
...@@ -1242,7 +1250,7 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) {...@@ -1242,7 +1250,7 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) {
1242 return __x.has_value() ? *__x <=> __v : strong_ordering::less;1250 return __x.has_value() ? *__x <=> __v : strong_ordering::less;
1243}1251}
12441252
1245# endif // _LIBCPP_STD_VER >= 201253# endif // _LIBCPP_STD_VER >= 20
12461254
1247template <class _Tp>1255template <class _Tp>
1248inline _LIBCPP_HIDE_FROM_ABI1256inline _LIBCPP_HIDE_FROM_ABI
...@@ -1268,10 +1276,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> make_optional(initializer_list<_Up...@@ -1268,10 +1276,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> make_optional(initializer_list<_Up
12681276
1269template <class _Tp>1277template <class _Tp>
1270struct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>> > {1278struct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>> > {
1271# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)1279# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
1272 _LIBCPP_DEPRECATED_IN_CXX17 typedef optional<_Tp> argument_type;1280 _LIBCPP_DEPRECATED_IN_CXX17 typedef optional<_Tp> argument_type;
1273 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;1281 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
1274# endif1282# endif
12751283
1276 _LIBCPP_HIDE_FROM_ABI size_t operator()(const optional<_Tp>& __opt) const {1284 _LIBCPP_HIDE_FROM_ABI size_t operator()(const optional<_Tp>& __opt) const {
1277 return static_cast<bool>(__opt) ? hash<remove_const_t<_Tp>>()(*__opt) : 0;1285 return static_cast<bool>(__opt) ? hash<remove_const_t<_Tp>>()(*__opt) : 0;
...@@ -1280,25 +1288,26 @@ struct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper<optional<_Tp>, remove_con...@@ -1280,25 +1288,26 @@ struct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper<optional<_Tp>, remove_con
12801288
1281_LIBCPP_END_NAMESPACE_STD1289_LIBCPP_END_NAMESPACE_STD
12821290
1283#endif // _LIBCPP_STD_VER >= 171291# endif // _LIBCPP_STD_VER >= 17
12841292
1285_LIBCPP_POP_MACROS1293_LIBCPP_POP_MACROS
12861294
1287#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 201295# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1288# include <atomic>1296# include <atomic>
1289# include <climits>1297# include <climits>
1290# include <concepts>1298# include <concepts>
1291# include <ctime>1299# include <ctime>
1292# include <iterator>1300# include <iterator>
1293# include <limits>1301# include <limits>
1294# include <memory>1302# include <memory>
1295# include <ratio>1303# include <ratio>
1296# include <stdexcept>1304# include <stdexcept>
1297# include <tuple>1305# include <tuple>
1298# include <type_traits>1306# include <type_traits>
1299# include <typeinfo>1307# include <typeinfo>
1300# include <utility>1308# include <utility>
1301# include <variant>1309# include <variant>
1302#endif1310# endif
1311#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
13031312
1304#endif // _LIBCPP_OPTIONAL1313#endif // _LIBCPP_OPTIONAL
lib/libcxx/include/ostream+34-26
...@@ -172,31 +172,39 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);...@@ -172,31 +172,39 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
172172
173*/173*/
174174
175#include <__config>175#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
176176# include <__cxx03/ostream>
177#include <__ostream/basic_ostream.h>177#else
178178# include <__config>
179#if _LIBCPP_STD_VER >= 23179
180# include <__ostream/print.h>180# if _LIBCPP_HAS_LOCALIZATION
181#endif181
182182# include <__ostream/basic_ostream.h>
183#include <version>183
184184# if _LIBCPP_STD_VER >= 23
185#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)185# include <__ostream/print.h>
186# pragma GCC system_header186# endif
187#endif187
188188# include <version>
189#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20189
190# include <atomic>190# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
191# include <concepts>191# pragma GCC system_header
192# include <cstdio>192# endif
193# include <cstdlib>193
194# include <format>194# endif // _LIBCPP_HAS_LOCALIZATION
195# include <iosfwd>195
196# include <iterator>196# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
197# include <print>197# include <atomic>
198# include <stdexcept>198# include <concepts>
199# include <type_traits>199# include <cstdio>
200#endif200# include <cstdlib>
201# include <format>
202# include <iosfwd>
203# include <iterator>
204# include <print>
205# include <stdexcept>
206# include <type_traits>
207# endif
208#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
201209
202#endif // _LIBCPP_OSTREAM210#endif // _LIBCPP_OSTREAM
lib/libcxx/include/print+68-63
...@@ -33,28 +33,31 @@ namespace std {...@@ -33,28 +33,31 @@ namespace std {
33}33}
34*/34*/
3535
36#include <__assert>36#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
37#include <__concepts/same_as.h>37# include <__cxx03/print>
38#include <__config>38#else
39#include <__system_error/system_error.h>39# include <__assert>
40#include <__utility/forward.h>40# include <__concepts/same_as.h>
41#include <cerrno>41# include <__config>
42#include <cstdio>42# include <__system_error/throw_system_error.h>
43#include <format>43# include <__utility/forward.h>
44#include <string>44# include <cerrno>
45#include <string_view>45# include <cstdio>
46#include <version>46# include <format>
4747# include <string>
48#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)48# include <string_view>
49# pragma GCC system_header49# include <version>
50#endif50
51# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
52# pragma GCC system_header
53# endif
5154
52_LIBCPP_BEGIN_NAMESPACE_STD55_LIBCPP_BEGIN_NAMESPACE_STD
5356
54#ifdef _LIBCPP_WIN32API57# ifdef _LIBCPP_WIN32API
55_LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream);58_LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream);
5659
57# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS60# if _LIBCPP_HAS_WIDE_CHARACTERS
58// A wrapper for WriteConsoleW which is used to write to the Windows61// A wrapper for WriteConsoleW which is used to write to the Windows
59// console. This function is in the dylib to avoid pulling in windows.h62// console. This function is in the dylib to avoid pulling in windows.h
60// in the library headers. The function itself uses some private parts63// in the library headers. The function itself uses some private parts
...@@ -65,14 +68,14 @@ _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream);...@@ -65,14 +68,14 @@ _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream);
65//68//
66// Note the function is only implemented on the Windows platform.69// Note the function is only implemented on the Windows platform.
67_LIBCPP_EXPORTED_FROM_ABI void __write_to_windows_console(FILE* __stream, wstring_view __view);70_LIBCPP_EXPORTED_FROM_ABI void __write_to_windows_console(FILE* __stream, wstring_view __view);
68# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS71# endif // _LIBCPP_HAS_WIDE_CHARACTERS
69#elif __has_include(<unistd.h>)72# elif __has_include(<unistd.h>)
70_LIBCPP_EXPORTED_FROM_ABI bool __is_posix_terminal(FILE* __stream);73_LIBCPP_EXPORTED_FROM_ABI bool __is_posix_terminal(FILE* __stream);
71#endif // _LIBCPP_WIN32API74# endif // _LIBCPP_WIN32API
7275
73#if _LIBCPP_STD_VER >= 2376# if _LIBCPP_STD_VER >= 23
7477
75# ifndef _LIBCPP_HAS_NO_UNICODE78# if _LIBCPP_HAS_UNICODE
76// This is the code to transcode UTF-8 to UTF-16. This is used on79// This is the code to transcode UTF-8 to UTF-16. This is used on
77// Windows for the native Unicode API. The code is modeled to make it80// Windows for the native Unicode API. The code is modeled to make it
78// easier to extend to81// easier to extend to
...@@ -86,27 +89,27 @@ namespace __unicode {...@@ -86,27 +89,27 @@ namespace __unicode {
86// The names of these concepts are modelled after P2728R0, but the89// The names of these concepts are modelled after P2728R0, but the
87// implementation is not. char16_t may contain 32-bits so depending on the90// implementation is not. char16_t may contain 32-bits so depending on the
88// number of bits is an issue.91// number of bits is an issue.
89# ifdef _LIBCPP_SHORT_WCHAR92# ifdef _LIBCPP_SHORT_WCHAR
90template <class _Tp>93template <class _Tp>
91concept __utf16_code_unit =94concept __utf16_code_unit =
92 same_as<_Tp, char16_t>95 same_as<_Tp, char16_t>
93# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS96# if _LIBCPP_HAS_WIDE_CHARACTERS
94 || same_as<_Tp, wchar_t>97 || same_as<_Tp, wchar_t>
95# endif98# endif
96 ;99 ;
97template <class _Tp>100template <class _Tp>
98concept __utf32_code_unit = same_as<_Tp, char32_t>;101concept __utf32_code_unit = same_as<_Tp, char32_t>;
99# else // _LIBCPP_SHORT_WCHAR102# else // _LIBCPP_SHORT_WCHAR
100template <class _Tp>103template <class _Tp>
101concept __utf16_code_unit = same_as<_Tp, char16_t>;104concept __utf16_code_unit = same_as<_Tp, char16_t>;
102template <class _Tp>105template <class _Tp>
103concept __utf32_code_unit =106concept __utf32_code_unit =
104 same_as<_Tp, char32_t>107 same_as<_Tp, char32_t>
105# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS108# if _LIBCPP_HAS_WIDE_CHARACTERS
106 || same_as<_Tp, wchar_t>109 || same_as<_Tp, wchar_t>
107# endif110# endif
108 ;111 ;
109# endif // _LIBCPP_SHORT_WCHAR112# endif // _LIBCPP_SHORT_WCHAR
110113
111// Pass by reference since an output_iterator may not be copyable.114// Pass by reference since an output_iterator may not be copyable.
112template <class _OutIt>115template <class _OutIt>
...@@ -164,7 +167,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _OutIt __transcode(_InIt __first, _InIt __last,...@@ -164,7 +167,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _OutIt __transcode(_InIt __first, _InIt __last,
164167
165} // namespace __unicode168} // namespace __unicode
166169
167# endif // _LIBCPP_HAS_NO_UNICODE170# endif // _LIBCPP_HAS_UNICODE
168171
169namespace __print {172namespace __print {
170173
...@@ -184,30 +187,30 @@ namespace __print {...@@ -184,30 +187,30 @@ namespace __print {
184// (note at the time of writing Clang is hard-coded to UTF-8.)187// (note at the time of writing Clang is hard-coded to UTF-8.)
185//188//
186189
187# ifdef _LIBCPP_HAS_NO_UNICODE190# if !_LIBCPP_HAS_UNICODE
188inline constexpr bool __use_unicode_execution_charset = false;191inline constexpr bool __use_unicode_execution_charset = false;
189# elif defined(_MSVC_EXECUTION_CHARACTER_SET)192# elif defined(_MSVC_EXECUTION_CHARACTER_SET)
190// This is the same test MSVC STL uses in their implementation of <print>193// This is the same test MSVC STL uses in their implementation of <print>
191// See: https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers194// See: https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
192inline constexpr bool __use_unicode_execution_charset = _MSVC_EXECUTION_CHARACTER_SET == 65001;195inline constexpr bool __use_unicode_execution_charset = _MSVC_EXECUTION_CHARACTER_SET == 65001;
193# else196# else
194inline constexpr bool __use_unicode_execution_charset = true;197inline constexpr bool __use_unicode_execution_charset = true;
195# endif198# endif
196199
197_LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream) {200_LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream) {
198 // The macro _LIBCPP_TESTING_PRINT_IS_TERMINAL is used to change201 // The macro _LIBCPP_TESTING_PRINT_IS_TERMINAL is used to change
199 // the behavior in the test. This is not part of the public API.202 // the behavior in the test. This is not part of the public API.
200# ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL203# ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL
201 return _LIBCPP_TESTING_PRINT_IS_TERMINAL(__stream);204 return _LIBCPP_TESTING_PRINT_IS_TERMINAL(__stream);
202# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0205# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0 || !_LIBCPP_HAS_TERMINAL
203 return false;206 return false;
204# elif defined(_LIBCPP_WIN32API)207# elif defined(_LIBCPP_WIN32API)
205 return std::__is_windows_terminal(__stream);208 return std::__is_windows_terminal(__stream);
206# elif __has_include(<unistd.h>)209# elif __has_include(<unistd.h>)
207 return std::__is_posix_terminal(__stream);210 return std::__is_posix_terminal(__stream);
208# else211# else
209# error "Provide a way to determine whether a FILE* is a terminal"212# error "Provide a way to determine whether a FILE* is a terminal"
210# endif213# endif
211}214}
212215
213template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).216template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
...@@ -226,7 +229,7 @@ __vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args, bool...@@ -226,7 +229,7 @@ __vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args, bool
226 }229 }
227}230}
228231
229# ifndef _LIBCPP_HAS_NO_UNICODE232# if _LIBCPP_HAS_UNICODE
230233
231// Note these helper functions are mainly used to aid testing.234// Note these helper functions are mainly used to aid testing.
232// On POSIX systems and Windows the output is no longer considered a235// On POSIX systems and Windows the output is no longer considered a
...@@ -243,7 +246,7 @@ __vprint_unicode_posix(FILE* __stream, string_view __fmt, format_args __args, bo...@@ -243,7 +246,7 @@ __vprint_unicode_posix(FILE* __stream, string_view __fmt, format_args __args, bo
243 __print::__vprint_nonunicode(__stream, __fmt, __args, __write_nl);246 __print::__vprint_nonunicode(__stream, __fmt, __args, __write_nl);
244}247}
245248
246# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS249# if _LIBCPP_HAS_WIDE_CHARACTERS
247template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).250template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
248_LIBCPP_HIDE_FROM_ABI inline void251_LIBCPP_HIDE_FROM_ABI inline void
249__vprint_unicode_windows(FILE* __stream, string_view __fmt, format_args __args, bool __write_nl, bool __is_terminal) {252__vprint_unicode_windows(FILE* __stream, string_view __fmt, format_args __args, bool __write_nl, bool __is_terminal) {
...@@ -272,16 +275,16 @@ __vprint_unicode_windows(FILE* __stream, string_view __fmt, format_args __args,...@@ -272,16 +275,16 @@ __vprint_unicode_windows(FILE* __stream, string_view __fmt, format_args __args,
272275
273 // The macro _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION is used to change276 // The macro _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION is used to change
274 // the behavior in the test. This is not part of the public API.277 // the behavior in the test. This is not part of the public API.
275# ifdef _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION278# ifdef _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION
276 _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION(__stream, __view);279 _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION(__stream, __view);
277# elif defined(_LIBCPP_WIN32API)280# elif defined(_LIBCPP_WIN32API)
278 std::__write_to_windows_console(__stream, __view);281 std::__write_to_windows_console(__stream, __view);
279# else282# else
280 std::__throw_runtime_error("No defintion of _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION and "283 std::__throw_runtime_error("No defintion of _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION and "
281 "__write_to_windows_console is not available.");284 "__write_to_windows_console is not available.");
282# endif285# endif
283}286}
284# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS287# endif // _LIBCPP_HAS_WIDE_CHARACTERS
285288
286template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).289template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
287_LIBCPP_HIDE_FROM_ABI inline void290_LIBCPP_HIDE_FROM_ABI inline void
...@@ -312,29 +315,29 @@ __vprint_unicode([[maybe_unused]] FILE* __stream,...@@ -312,29 +315,29 @@ __vprint_unicode([[maybe_unused]] FILE* __stream,
312 // so there the call can be forwarded to the non_unicode API. On315 // so there the call can be forwarded to the non_unicode API. On
313 // Windows there is a different API. This API requires transcoding.316 // Windows there is a different API. This API requires transcoding.
314317
315# ifndef _LIBCPP_WIN32API318# ifndef _LIBCPP_WIN32API
316 __print::__vprint_unicode_posix(__stream, __fmt, __args, __write_nl, __print::__is_terminal(__stream));319 __print::__vprint_unicode_posix(__stream, __fmt, __args, __write_nl, __print::__is_terminal(__stream));
317# elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)320# elif _LIBCPP_HAS_WIDE_CHARACTERS
318 __print::__vprint_unicode_windows(__stream, __fmt, __args, __write_nl, __print::__is_terminal(__stream));321 __print::__vprint_unicode_windows(__stream, __fmt, __args, __write_nl, __print::__is_terminal(__stream));
319# else322# else
320# error "Windows builds with wchar_t disabled are not supported."323# error "Windows builds with wchar_t disabled are not supported."
321# endif324# endif
322}325}
323326
324# endif // _LIBCPP_HAS_NO_UNICODE327# endif // _LIBCPP_HAS_UNICODE
325328
326} // namespace __print329} // namespace __print
327330
328template <class... _Args>331template <class... _Args>
329_LIBCPP_HIDE_FROM_ABI void print(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) {332_LIBCPP_HIDE_FROM_ABI void print(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) {
330# ifndef _LIBCPP_HAS_NO_UNICODE333# if _LIBCPP_HAS_UNICODE
331 if constexpr (__print::__use_unicode_execution_charset)334 if constexpr (__print::__use_unicode_execution_charset)
332 __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), false);335 __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), false);
333 else336 else
334 __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), false);337 __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), false);
335# else // _LIBCPP_HAS_NO_UNICODE338# else // _LIBCPP_HAS_UNICODE
336 __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), false);339 __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), false);
337# endif // _LIBCPP_HAS_NO_UNICODE340# endif // _LIBCPP_HAS_UNICODE
338}341}
339342
340template <class... _Args>343template <class... _Args>
...@@ -344,7 +347,7 @@ _LIBCPP_HIDE_FROM_ABI void print(format_string<_Args...> __fmt, _Args&&... __arg...@@ -344,7 +347,7 @@ _LIBCPP_HIDE_FROM_ABI void print(format_string<_Args...> __fmt, _Args&&... __arg
344347
345template <class... _Args>348template <class... _Args>
346_LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) {349_LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) {
347# ifndef _LIBCPP_HAS_NO_UNICODE350# if _LIBCPP_HAS_UNICODE
348 // Note the wording in the Standard is inefficient. The output of351 // Note the wording in the Standard is inefficient. The output of
349 // std::format is a std::string which is then copied. This solution352 // std::format is a std::string which is then copied. This solution
350 // just appends a newline at the end of the output.353 // just appends a newline at the end of the output.
...@@ -352,9 +355,9 @@ _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt...@@ -352,9 +355,9 @@ _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt
352 __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), true);355 __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), true);
353 else356 else
354 __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), true);357 __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), true);
355# else // _LIBCPP_HAS_NO_UNICODE358# else // _LIBCPP_HAS_UNICODE
356 __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), true);359 __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), true);
357# endif // _LIBCPP_HAS_NO_UNICODE360# endif // _LIBCPP_HAS_UNICODE
358}361}
359362
360template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).363template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
...@@ -372,7 +375,7 @@ _LIBCPP_HIDE_FROM_ABI void println(format_string<_Args...> __fmt, _Args&&... __a...@@ -372,7 +375,7 @@ _LIBCPP_HIDE_FROM_ABI void println(format_string<_Args...> __fmt, _Args&&... __a
372 std::println(stdout, __fmt, std::forward<_Args>(__args)...);375 std::println(stdout, __fmt, std::forward<_Args>(__args)...);
373}376}
374377
375# ifndef _LIBCPP_HAS_NO_UNICODE378# if _LIBCPP_HAS_UNICODE
376template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).379template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
377_LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(FILE* __stream, string_view __fmt, format_args __args) {380_LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(FILE* __stream, string_view __fmt, format_args __args) {
378 __print::__vprint_unicode(__stream, __fmt, __args, false);381 __print::__vprint_unicode(__stream, __fmt, __args, false);
...@@ -383,7 +386,7 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(string_view __fmt, format_args...@@ -383,7 +386,7 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(string_view __fmt, format_args
383 std::vprint_unicode(stdout, __fmt, __args);386 std::vprint_unicode(stdout, __fmt, __args);
384}387}
385388
386# endif // _LIBCPP_HAS_NO_UNICODE389# endif // _LIBCPP_HAS_UNICODE
387390
388template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).391template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
389_LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args) {392_LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args) {
...@@ -395,8 +398,10 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(string_view __fmt, format_ar...@@ -395,8 +398,10 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(string_view __fmt, format_ar
395 std::vprint_nonunicode(stdout, __fmt, __args);398 std::vprint_nonunicode(stdout, __fmt, __args);
396}399}
397400
398#endif // _LIBCPP_STD_VER >= 23401# endif // _LIBCPP_STD_VER >= 23
399402
400_LIBCPP_END_NAMESPACE_STD403_LIBCPP_END_NAMESPACE_STD
401404
405#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
406
402#endif // _LIBCPP_PRINT407#endif // _LIBCPP_PRINT
lib/libcxx/include/queue+92-88
...@@ -254,38 +254,41 @@ template <class T, class Container, class Compare>...@@ -254,38 +254,41 @@ template <class T, class Container, class Compare>
254254
255*/255*/
256256
257#include <__algorithm/make_heap.h>257#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
258#include <__algorithm/pop_heap.h>258# include <__cxx03/queue>
259#include <__algorithm/push_heap.h>259#else
260#include <__algorithm/ranges_copy.h>260# include <__algorithm/make_heap.h>
261#include <__config>261# include <__algorithm/pop_heap.h>
262#include <__functional/operations.h>262# include <__algorithm/push_heap.h>
263#include <__fwd/deque.h>263# include <__algorithm/ranges_copy.h>
264#include <__fwd/queue.h>264# include <__config>
265#include <__iterator/back_insert_iterator.h>265# include <__functional/operations.h>
266#include <__iterator/iterator_traits.h>266# include <__fwd/deque.h>
267#include <__memory/uses_allocator.h>267# include <__fwd/queue.h>
268#include <__ranges/access.h>268# include <__iterator/back_insert_iterator.h>
269#include <__ranges/concepts.h>269# include <__iterator/iterator_traits.h>
270#include <__ranges/container_compatible_range.h>270# include <__memory/uses_allocator.h>
271#include <__ranges/from_range.h>271# include <__ranges/access.h>
272#include <__utility/forward.h>272# include <__ranges/concepts.h>
273#include <deque>273# include <__ranges/container_compatible_range.h>
274#include <vector>274# include <__ranges/from_range.h>
275#include <version>275# include <__utility/forward.h>
276# include <deque>
277# include <vector>
278# include <version>
276279
277// standard-mandated includes280// standard-mandated includes
278281
279// [queue.syn]282// [queue.syn]
280#include <compare>283# include <compare>
281#include <initializer_list>284# include <initializer_list>
282285
283#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)286# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
284# pragma GCC system_header287# pragma GCC system_header
285#endif288# endif
286289
287_LIBCPP_PUSH_MACROS290_LIBCPP_PUSH_MACROS
288#include <__undef_macros>291# include <__undef_macros>
289292
290_LIBCPP_BEGIN_NAMESPACE_STD293_LIBCPP_BEGIN_NAMESPACE_STD
291294
...@@ -313,7 +316,7 @@ public:...@@ -313,7 +316,7 @@ public:
313316
314 _LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {}317 _LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {}
315318
316#if _LIBCPP_STD_VER >= 23319# if _LIBCPP_STD_VER >= 23
317 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>320 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
318 _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}321 _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
319322
...@@ -333,14 +336,14 @@ public:...@@ -333,14 +336,14 @@ public:
333 _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range, const _Alloc& __alloc)336 _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range, const _Alloc& __alloc)
334 : c(from_range, std::forward<_Range>(__range), __alloc) {}337 : c(from_range, std::forward<_Range>(__range), __alloc) {}
335338
336#endif339# endif
337340
338 _LIBCPP_HIDE_FROM_ABI queue& operator=(const queue& __q) {341 _LIBCPP_HIDE_FROM_ABI queue& operator=(const queue& __q) {
339 c = __q.c;342 c = __q.c;
340 return *this;343 return *this;
341 }344 }
342345
343#ifndef _LIBCPP_CXX03_LANG346# ifndef _LIBCPP_CXX03_LANG
344 _LIBCPP_HIDE_FROM_ABI queue(queue&& __q) noexcept(is_nothrow_move_constructible<container_type>::value)347 _LIBCPP_HIDE_FROM_ABI queue(queue&& __q) noexcept(is_nothrow_move_constructible<container_type>::value)
345 : c(std::move(__q.c)) {}348 : c(std::move(__q.c)) {}
346349
...@@ -348,12 +351,12 @@ public:...@@ -348,12 +351,12 @@ public:
348 c = std::move(__q.c);351 c = std::move(__q.c);
349 return *this;352 return *this;
350 }353 }
351#endif // _LIBCPP_CXX03_LANG354# endif // _LIBCPP_CXX03_LANG
352355
353 _LIBCPP_HIDE_FROM_ABI explicit queue(const container_type& __c) : c(__c) {}356 _LIBCPP_HIDE_FROM_ABI explicit queue(const container_type& __c) : c(__c) {}
354#ifndef _LIBCPP_CXX03_LANG357# ifndef _LIBCPP_CXX03_LANG
355 _LIBCPP_HIDE_FROM_ABI explicit queue(container_type&& __c) : c(std::move(__c)) {}358 _LIBCPP_HIDE_FROM_ABI explicit queue(container_type&& __c) : c(std::move(__c)) {}
356#endif // _LIBCPP_CXX03_LANG359# endif // _LIBCPP_CXX03_LANG
357360
358 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>361 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
359 _LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a) : c(__a) {}362 _LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a) : c(__a) {}
...@@ -364,15 +367,15 @@ public:...@@ -364,15 +367,15 @@ public:
364 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>367 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
365 _LIBCPP_HIDE_FROM_ABI queue(const container_type& __c, const _Alloc& __a) : c(__c, __a) {}368 _LIBCPP_HIDE_FROM_ABI queue(const container_type& __c, const _Alloc& __a) : c(__c, __a) {}
366369
367#ifndef _LIBCPP_CXX03_LANG370# ifndef _LIBCPP_CXX03_LANG
368 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>371 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
369 _LIBCPP_HIDE_FROM_ABI queue(container_type&& __c, const _Alloc& __a) : c(std::move(__c), __a) {}372 _LIBCPP_HIDE_FROM_ABI queue(container_type&& __c, const _Alloc& __a) : c(std::move(__c), __a) {}
370373
371 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>374 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
372 _LIBCPP_HIDE_FROM_ABI queue(queue&& __q, const _Alloc& __a) : c(std::move(__q.c), __a) {}375 _LIBCPP_HIDE_FROM_ABI queue(queue&& __q, const _Alloc& __a) : c(std::move(__q.c), __a) {}
373#endif // _LIBCPP_CXX03_LANG376# endif // _LIBCPP_CXX03_LANG
374377
375 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }378 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
376 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }379 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
377380
378 _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); }381 _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); }
...@@ -381,10 +384,10 @@ public:...@@ -381,10 +384,10 @@ public:
381 _LIBCPP_HIDE_FROM_ABI const_reference back() const { return c.back(); }384 _LIBCPP_HIDE_FROM_ABI const_reference back() const { return c.back(); }
382385
383 _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); }386 _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); }
384#ifndef _LIBCPP_CXX03_LANG387# ifndef _LIBCPP_CXX03_LANG
385 _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); }388 _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); }
386389
387# if _LIBCPP_STD_VER >= 23390# if _LIBCPP_STD_VER >= 23
388 template <_ContainerCompatibleRange<_Tp> _Range>391 template <_ContainerCompatibleRange<_Tp> _Range>
389 _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {392 _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {
390 if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {393 if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {
...@@ -393,22 +396,22 @@ public:...@@ -393,22 +396,22 @@ public:
393 ranges::copy(std::forward<_Range>(__range), std::back_inserter(c));396 ranges::copy(std::forward<_Range>(__range), std::back_inserter(c));
394 }397 }
395 }398 }
396# endif399# endif
397400
398 template <class... _Args>401 template <class... _Args>
399 _LIBCPP_HIDE_FROM_ABI402 _LIBCPP_HIDE_FROM_ABI
400# if _LIBCPP_STD_VER >= 17403# if _LIBCPP_STD_VER >= 17
401 decltype(auto)404 decltype(auto)
402 emplace(_Args&&... __args) {405 emplace(_Args&&... __args) {
403 return c.emplace_back(std::forward<_Args>(__args)...);406 return c.emplace_back(std::forward<_Args>(__args)...);
404 }407 }
405# else408# else
406 void409 void
407 emplace(_Args&&... __args) {410 emplace(_Args&&... __args) {
408 c.emplace_back(std::forward<_Args>(__args)...);411 c.emplace_back(std::forward<_Args>(__args)...);
409 }412 }
410# endif413# endif
411#endif // _LIBCPP_CXX03_LANG414# endif // _LIBCPP_CXX03_LANG
412 _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); }415 _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); }
413416
414 _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) _NOEXCEPT_(__is_nothrow_swappable_v<container_type>) {417 _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) _NOEXCEPT_(__is_nothrow_swappable_v<container_type>) {
...@@ -416,7 +419,7 @@ public:...@@ -416,7 +419,7 @@ public:
416 swap(c, __q.c);419 swap(c, __q.c);
417 }420 }
418421
419 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }422 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
420423
421 template <class _T1, class _OtherContainer>424 template <class _T1, class _OtherContainer>
422 friend _LIBCPP_HIDE_FROM_ABI bool425 friend _LIBCPP_HIDE_FROM_ABI bool
...@@ -427,7 +430,7 @@ public:...@@ -427,7 +430,7 @@ public:
427 operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y);430 operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y);
428};431};
429432
430#if _LIBCPP_STD_VER >= 17433# if _LIBCPP_STD_VER >= 17
431template <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> >434template <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> >
432queue(_Container) -> queue<typename _Container::value_type, _Container>;435queue(_Container) -> queue<typename _Container::value_type, _Container>;
433436
...@@ -436,9 +439,9 @@ template <class _Container,...@@ -436,9 +439,9 @@ template <class _Container,
436 class = enable_if_t<!__is_allocator<_Container>::value>,439 class = enable_if_t<!__is_allocator<_Container>::value>,
437 class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >440 class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >
438queue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>;441queue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>;
439#endif442# endif
440443
441#if _LIBCPP_STD_VER >= 23444# if _LIBCPP_STD_VER >= 23
442template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>445template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
443queue(_InputIterator, _InputIterator) -> queue<__iter_value_type<_InputIterator>>;446queue(_InputIterator, _InputIterator) -> queue<__iter_value_type<_InputIterator>>;
444447
...@@ -457,7 +460,7 @@ template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator...@@ -457,7 +460,7 @@ template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator
457queue(from_range_t,460queue(from_range_t,
458 _Range&&,461 _Range&&,
459 _Alloc) -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;462 _Alloc) -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
460#endif463# endif
461464
462template <class _Tp, class _Container>465template <class _Tp, class _Container>
463inline _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {466inline _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
...@@ -489,7 +492,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x,...@@ -489,7 +492,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x,
489 return !(__y < __x);492 return !(__y < __x);
490}493}
491494
492#if _LIBCPP_STD_VER >= 20495# if _LIBCPP_STD_VER >= 20
493496
494template <class _Tp, three_way_comparable _Container>497template <class _Tp, three_way_comparable _Container>
495_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container>498_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container>
...@@ -498,7 +501,7 @@ operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y...@@ -498,7 +501,7 @@ operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y
498 return __x.__get_container() <=> __y.__get_container();501 return __x.__get_container() <=> __y.__get_container();
499}502}
500503
501#endif504# endif
502505
503template <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0>506template <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0>
504inline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)507inline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
...@@ -538,7 +541,7 @@ public:...@@ -538,7 +541,7 @@ public:
538 return *this;541 return *this;
539 }542 }
540543
541#ifndef _LIBCPP_CXX03_LANG544# ifndef _LIBCPP_CXX03_LANG
542 _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) noexcept(545 _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) noexcept(
543 is_nothrow_move_constructible<container_type>::value && is_nothrow_move_constructible<value_compare>::value)546 is_nothrow_move_constructible<container_type>::value && is_nothrow_move_constructible<value_compare>::value)
544 : c(std::move(__q.c)), comp(std::move(__q.comp)) {}547 : c(std::move(__q.c)), comp(std::move(__q.comp)) {}
...@@ -549,13 +552,13 @@ public:...@@ -549,13 +552,13 @@ public:
549 comp = std::move(__q.comp);552 comp = std::move(__q.comp);
550 return *this;553 return *this;
551 }554 }
552#endif // _LIBCPP_CXX03_LANG555# endif // _LIBCPP_CXX03_LANG
553556
554 _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) : c(), comp(__comp) {}557 _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) : c(), comp(__comp) {}
555 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c);558 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c);
556#ifndef _LIBCPP_CXX03_LANG559# ifndef _LIBCPP_CXX03_LANG
557 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c);560 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c);
558#endif561# endif
559 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>562 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
560 _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare());563 _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare());
561564
...@@ -563,19 +566,19 @@ public:...@@ -563,19 +566,19 @@ public:
563 _LIBCPP_HIDE_FROM_ABI566 _LIBCPP_HIDE_FROM_ABI
564 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c);567 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c);
565568
566#ifndef _LIBCPP_CXX03_LANG569# ifndef _LIBCPP_CXX03_LANG
567 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>570 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
568 _LIBCPP_HIDE_FROM_ABI571 _LIBCPP_HIDE_FROM_ABI
569 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c);572 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c);
570#endif // _LIBCPP_CXX03_LANG573# endif // _LIBCPP_CXX03_LANG
571574
572#if _LIBCPP_STD_VER >= 23575# if _LIBCPP_STD_VER >= 23
573 template <_ContainerCompatibleRange<_Tp> _Range>576 template <_ContainerCompatibleRange<_Tp> _Range>
574 _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare())577 _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare())
575 : c(from_range, std::forward<_Range>(__range)), comp(__comp) {578 : c(from_range, std::forward<_Range>(__range)), comp(__comp) {
576 std::make_heap(c.begin(), c.end(), comp);579 std::make_heap(c.begin(), c.end(), comp);
577 }580 }
578#endif581# endif
579582
580 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>583 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
581 _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a);584 _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a);
...@@ -589,13 +592,13 @@ public:...@@ -589,13 +592,13 @@ public:
589 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>592 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
590 _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a);593 _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a);
591594
592#ifndef _LIBCPP_CXX03_LANG595# ifndef _LIBCPP_CXX03_LANG
593 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>596 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
594 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a);597 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a);
595598
596 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>599 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
597 _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q, const _Alloc& __a);600 _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q, const _Alloc& __a);
598#endif // _LIBCPP_CXX03_LANG601# endif // _LIBCPP_CXX03_LANG
599602
600 template <603 template <
601 class _InputIter,604 class _InputIter,
...@@ -619,7 +622,7 @@ public:...@@ -619,7 +622,7 @@ public:
619 _LIBCPP_HIDE_FROM_ABI priority_queue(622 _LIBCPP_HIDE_FROM_ABI priority_queue(
620 _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a);623 _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a);
621624
622#ifndef _LIBCPP_CXX03_LANG625# ifndef _LIBCPP_CXX03_LANG
623 template <626 template <
624 class _InputIter,627 class _InputIter,
625 class _Alloc,628 class _Alloc,
...@@ -627,9 +630,9 @@ public:...@@ -627,9 +630,9 @@ public:
627 int> = 0>630 int> = 0>
628 _LIBCPP_HIDE_FROM_ABI631 _LIBCPP_HIDE_FROM_ABI
629 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a);632 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a);
630#endif // _LIBCPP_CXX03_LANG633# endif // _LIBCPP_CXX03_LANG
631634
632#if _LIBCPP_STD_VER >= 23635# if _LIBCPP_STD_VER >= 23
633636
634 template <_ContainerCompatibleRange<_Tp> _Range,637 template <_ContainerCompatibleRange<_Tp> _Range,
635 class _Alloc,638 class _Alloc,
...@@ -647,17 +650,17 @@ public:...@@ -647,17 +650,17 @@ public:
647 std::make_heap(c.begin(), c.end(), comp);650 std::make_heap(c.begin(), c.end(), comp);
648 }651 }
649652
650#endif653# endif
651654
652 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }655 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
653 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }656 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
654 _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); }657 _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); }
655658
656 _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v);659 _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v);
657#ifndef _LIBCPP_CXX03_LANG660# ifndef _LIBCPP_CXX03_LANG
658 _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v);661 _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v);
659662
660# if _LIBCPP_STD_VER >= 23663# if _LIBCPP_STD_VER >= 23
661 template <_ContainerCompatibleRange<_Tp> _Range>664 template <_ContainerCompatibleRange<_Tp> _Range>
662 _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {665 _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {
663 if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {666 if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {
...@@ -668,20 +671,20 @@ public:...@@ -668,20 +671,20 @@ public:
668671
669 std::make_heap(c.begin(), c.end(), comp);672 std::make_heap(c.begin(), c.end(), comp);
670 }673 }
671# endif674# endif
672675
673 template <class... _Args>676 template <class... _Args>
674 _LIBCPP_HIDE_FROM_ABI void emplace(_Args&&... __args);677 _LIBCPP_HIDE_FROM_ABI void emplace(_Args&&... __args);
675#endif // _LIBCPP_CXX03_LANG678# endif // _LIBCPP_CXX03_LANG
676 _LIBCPP_HIDE_FROM_ABI void pop();679 _LIBCPP_HIDE_FROM_ABI void pop();
677680
678 _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q)681 _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q)
679 _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>);682 _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>);
680683
681 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }684 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
682};685};
683686
684#if _LIBCPP_STD_VER >= 17687# if _LIBCPP_STD_VER >= 17
685template <class _Compare,688template <class _Compare,
686 class _Container,689 class _Container,
687 class = enable_if_t<!__is_allocator<_Compare>::value>,690 class = enable_if_t<!__is_allocator<_Compare>::value>,
...@@ -735,9 +738,9 @@ template <class _InputIterator,...@@ -735,9 +738,9 @@ template <class _InputIterator,
735 class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >738 class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >
736priority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc)739priority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc)
737 -> priority_queue<typename _Container::value_type, _Container, _Compare>;740 -> priority_queue<typename _Container::value_type, _Container, _Compare>;
738#endif741# endif
739742
740#if _LIBCPP_STD_VER >= 23743# if _LIBCPP_STD_VER >= 23
741744
742template <ranges::input_range _Range,745template <ranges::input_range _Range,
743 class _Compare = less<ranges::range_value_t<_Range>>,746 class _Compare = less<ranges::range_value_t<_Range>>,
...@@ -757,7 +760,7 @@ template <ranges::input_range _Range, class _Alloc, class = enable_if_t<__is_all...@@ -757,7 +760,7 @@ template <ranges::input_range _Range, class _Alloc, class = enable_if_t<__is_all
757priority_queue(from_range_t, _Range&&, _Alloc)760priority_queue(from_range_t, _Range&&, _Alloc)
758 -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>>;761 -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>>;
759762
760#endif763# endif
761764
762template <class _Tp, class _Container, class _Compare>765template <class _Tp, class _Container, class _Compare>
763inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, const container_type& __c)766inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, const container_type& __c)
...@@ -765,7 +768,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare&...@@ -765,7 +768,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare&
765 std::make_heap(c.begin(), c.end(), comp);768 std::make_heap(c.begin(), c.end(), comp);
766}769}
767770
768#ifndef _LIBCPP_CXX03_LANG771# ifndef _LIBCPP_CXX03_LANG
769772
770template <class _Tp, class _Container, class _Compare>773template <class _Tp, class _Container, class _Compare>
771inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, container_type&& __c)774inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, container_type&& __c)
...@@ -773,7 +776,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_com...@@ -773,7 +776,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_com
773 std::make_heap(c.begin(), c.end(), comp);776 std::make_heap(c.begin(), c.end(), comp);
774}777}
775778
776#endif // _LIBCPP_CXX03_LANG779# endif // _LIBCPP_CXX03_LANG
777780
778template <class _Tp, class _Container, class _Compare>781template <class _Tp, class _Container, class _Compare>
779template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >782template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
...@@ -792,7 +795,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(...@@ -792,7 +795,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
792 std::make_heap(c.begin(), c.end(), comp);795 std::make_heap(c.begin(), c.end(), comp);
793}796}
794797
795#ifndef _LIBCPP_CXX03_LANG798# ifndef _LIBCPP_CXX03_LANG
796799
797template <class _Tp, class _Container, class _Compare>800template <class _Tp, class _Container, class _Compare>
798template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >801template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
...@@ -803,7 +806,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(...@@ -803,7 +806,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
803 std::make_heap(c.begin(), c.end(), comp);806 std::make_heap(c.begin(), c.end(), comp);
804}807}
805808
806#endif // _LIBCPP_CXX03_LANG809# endif // _LIBCPP_CXX03_LANG
807810
808template <class _Tp, class _Container, class _Compare>811template <class _Tp, class _Container, class _Compare>
809template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >812template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
...@@ -827,7 +830,7 @@ template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value,...@@ -827,7 +830,7 @@ template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value,
827inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, const _Alloc& __a)830inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, const _Alloc& __a)
828 : c(__q.c, __a), comp(__q.comp) {}831 : c(__q.c, __a), comp(__q.comp) {}
829832
830#ifndef _LIBCPP_CXX03_LANG833# ifndef _LIBCPP_CXX03_LANG
831834
832template <class _Tp, class _Container, class _Compare>835template <class _Tp, class _Container, class _Compare>
833template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >836template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
...@@ -842,7 +845,7 @@ template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value,...@@ -842,7 +845,7 @@ template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value,
842inline priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, const _Alloc& __a)845inline priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, const _Alloc& __a)
843 : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {}846 : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {}
844847
845#endif // _LIBCPP_CXX03_LANG848# endif // _LIBCPP_CXX03_LANG
846849
847template <class _Tp, class _Container, class _Compare>850template <class _Tp, class _Container, class _Compare>
848template <851template <
...@@ -877,7 +880,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(...@@ -877,7 +880,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
877 std::make_heap(c.begin(), c.end(), comp);880 std::make_heap(c.begin(), c.end(), comp);
878}881}
879882
880#ifndef _LIBCPP_CXX03_LANG883# ifndef _LIBCPP_CXX03_LANG
881template <class _Tp, class _Container, class _Compare>884template <class _Tp, class _Container, class _Compare>
882template <885template <
883 class _InputIter,886 class _InputIter,
...@@ -889,7 +892,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(...@@ -889,7 +892,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
889 c.insert(c.end(), __f, __l);892 c.insert(c.end(), __f, __l);
890 std::make_heap(c.begin(), c.end(), comp);893 std::make_heap(c.begin(), c.end(), comp);
891}894}
892#endif // _LIBCPP_CXX03_LANG895# endif // _LIBCPP_CXX03_LANG
893896
894template <class _Tp, class _Container, class _Compare>897template <class _Tp, class _Container, class _Compare>
895inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) {898inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) {
...@@ -897,7 +900,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __...@@ -897,7 +900,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __
897 std::push_heap(c.begin(), c.end(), comp);900 std::push_heap(c.begin(), c.end(), comp);
898}901}
899902
900#ifndef _LIBCPP_CXX03_LANG903# ifndef _LIBCPP_CXX03_LANG
901904
902template <class _Tp, class _Container, class _Compare>905template <class _Tp, class _Container, class _Compare>
903inline void priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) {906inline void priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) {
...@@ -912,7 +915,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args...@@ -912,7 +915,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args
912 std::push_heap(c.begin(), c.end(), comp);915 std::push_heap(c.begin(), c.end(), comp);
913}916}
914917
915#endif // _LIBCPP_CXX03_LANG918# endif // _LIBCPP_CXX03_LANG
916919
917template <class _Tp, class _Container, class _Compare>920template <class _Tp, class _Container, class _Compare>
918inline void priority_queue<_Tp, _Container, _Compare>::pop() {921inline void priority_queue<_Tp, _Container, _Compare>::pop() {
...@@ -946,11 +949,12 @@ _LIBCPP_END_NAMESPACE_STD...@@ -946,11 +949,12 @@ _LIBCPP_END_NAMESPACE_STD
946949
947_LIBCPP_POP_MACROS950_LIBCPP_POP_MACROS
948951
949#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20952# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
950# include <concepts>953# include <concepts>
951# include <cstdlib>954# include <cstdlib>
952# include <functional>955# include <functional>
953# include <type_traits>956# include <type_traits>
954#endif957# endif
958#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
955959
956#endif // _LIBCPP_QUEUE960#endif // _LIBCPP_QUEUE
lib/libcxx/include/random+61-57
...@@ -1677,66 +1677,70 @@ class piecewise_linear_distribution...@@ -1677,66 +1677,70 @@ class piecewise_linear_distribution
1677} // std1677} // std
1678*/1678*/
16791679
1680#include <__config>1680#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
1681#include <__random/bernoulli_distribution.h>1681# include <__cxx03/random>
1682#include <__random/binomial_distribution.h>1682#else
1683#include <__random/cauchy_distribution.h>1683# include <__config>
1684#include <__random/chi_squared_distribution.h>1684# include <__random/bernoulli_distribution.h>
1685#include <__random/default_random_engine.h>1685# include <__random/binomial_distribution.h>
1686#include <__random/discard_block_engine.h>1686# include <__random/cauchy_distribution.h>
1687#include <__random/discrete_distribution.h>1687# include <__random/chi_squared_distribution.h>
1688#include <__random/exponential_distribution.h>1688# include <__random/default_random_engine.h>
1689#include <__random/extreme_value_distribution.h>1689# include <__random/discard_block_engine.h>
1690#include <__random/fisher_f_distribution.h>1690# include <__random/discrete_distribution.h>
1691#include <__random/gamma_distribution.h>1691# include <__random/exponential_distribution.h>
1692#include <__random/generate_canonical.h>1692# include <__random/extreme_value_distribution.h>
1693#include <__random/geometric_distribution.h>1693# include <__random/fisher_f_distribution.h>
1694#include <__random/independent_bits_engine.h>1694# include <__random/gamma_distribution.h>
1695#include <__random/is_seed_sequence.h>1695# include <__random/generate_canonical.h>
1696#include <__random/knuth_b.h>1696# include <__random/geometric_distribution.h>
1697#include <__random/linear_congruential_engine.h>1697# include <__random/independent_bits_engine.h>
1698#include <__random/lognormal_distribution.h>1698# include <__random/is_seed_sequence.h>
1699#include <__random/mersenne_twister_engine.h>1699# include <__random/knuth_b.h>
1700#include <__random/negative_binomial_distribution.h>1700# include <__random/linear_congruential_engine.h>
1701#include <__random/normal_distribution.h>1701# include <__random/lognormal_distribution.h>
1702#include <__random/piecewise_constant_distribution.h>1702# include <__random/mersenne_twister_engine.h>
1703#include <__random/piecewise_linear_distribution.h>1703# include <__random/negative_binomial_distribution.h>
1704#include <__random/poisson_distribution.h>1704# include <__random/normal_distribution.h>
1705#include <__random/random_device.h>1705# include <__random/piecewise_constant_distribution.h>
1706#include <__random/ranlux.h>1706# include <__random/piecewise_linear_distribution.h>
1707#include <__random/seed_seq.h>1707# include <__random/poisson_distribution.h>
1708#include <__random/shuffle_order_engine.h>1708# include <__random/random_device.h>
1709#include <__random/student_t_distribution.h>1709# include <__random/ranlux.h>
1710#include <__random/subtract_with_carry_engine.h>1710# include <__random/seed_seq.h>
1711#include <__random/uniform_int_distribution.h>1711# include <__random/shuffle_order_engine.h>
1712#include <__random/uniform_random_bit_generator.h>1712# include <__random/student_t_distribution.h>
1713#include <__random/uniform_real_distribution.h>1713# include <__random/subtract_with_carry_engine.h>
1714#include <__random/weibull_distribution.h>1714# include <__random/uniform_int_distribution.h>
1715#include <version>1715# include <__random/uniform_random_bit_generator.h>
1716# include <__random/uniform_real_distribution.h>
1717# include <__random/weibull_distribution.h>
1718# include <version>
17161719
1717// standard-mandated includes1720// standard-mandated includes
17181721
1719// [rand.synopsis]1722// [rand.synopsis]
1720#include <initializer_list>1723# include <initializer_list>
17211724
1722#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)1725# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1723# pragma GCC system_header1726# pragma GCC system_header
1724#endif1727# endif
17251728
1726#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 201729# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1727# include <algorithm>1730# include <algorithm>
1728# include <climits>1731# include <climits>
1729# include <cmath>1732# include <cmath>
1730# include <concepts>1733# include <concepts>
1731# include <cstddef>1734# include <cstddef>
1732# include <cstdint>1735# include <cstdint>
1733# include <cstdlib>1736# include <cstdlib>
1734# include <iosfwd>1737# include <iosfwd>
1735# include <limits>1738# include <limits>
1736# include <numeric>1739# include <numeric>
1737# include <string>1740# include <string>
1738# include <type_traits>1741# include <type_traits>
1739# include <vector>1742# include <vector>
1740#endif1743# endif
1744#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
17411745
1742#endif // _LIBCPP_RANDOM1746#endif // _LIBCPP_RANDOM
lib/libcxx/include/ranges+66-70
...@@ -380,84 +380,80 @@ namespace std {...@@ -380,84 +380,80 @@ namespace std {
380}380}
381*/381*/
382382
383#include <__config>383#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
384384# include <__cxx03/ranges>
385#if _LIBCPP_STD_VER >= 20385#else
386# include <__ranges/access.h>386# include <__config>
387# include <__ranges/all.h>387
388# include <__ranges/common_view.h>388# if _LIBCPP_STD_VER >= 20
389# include <__ranges/concepts.h>389# include <__ranges/access.h>
390# include <__ranges/counted.h>390# include <__ranges/all.h>
391# include <__ranges/dangling.h>391# include <__ranges/common_view.h>
392# include <__ranges/data.h>392# include <__ranges/concepts.h>
393# include <__ranges/drop_view.h>393# include <__ranges/counted.h>
394# include <__ranges/drop_while_view.h>394# include <__ranges/dangling.h>
395# include <__ranges/elements_view.h>395# include <__ranges/data.h>
396# include <__ranges/empty.h>396# include <__ranges/drop_view.h>
397# include <__ranges/empty_view.h>397# include <__ranges/drop_while_view.h>
398# include <__ranges/enable_borrowed_range.h>398# include <__ranges/elements_view.h>
399# include <__ranges/enable_view.h>399# include <__ranges/empty.h>
400# include <__ranges/filter_view.h>400# include <__ranges/empty_view.h>
401# include <__ranges/iota_view.h>401# include <__ranges/enable_borrowed_range.h>
402# include <__ranges/join_view.h>402# include <__ranges/enable_view.h>
403# include <__ranges/lazy_split_view.h>403# include <__ranges/filter_view.h>
404# include <__ranges/rbegin.h>404# include <__ranges/iota_view.h>
405# include <__ranges/ref_view.h>405# include <__ranges/join_view.h>
406# include <__ranges/rend.h>406# include <__ranges/lazy_split_view.h>
407# include <__ranges/reverse_view.h>407# include <__ranges/rbegin.h>
408# include <__ranges/single_view.h>408# include <__ranges/ref_view.h>
409# include <__ranges/size.h>409# include <__ranges/rend.h>
410# include <__ranges/split_view.h>410# include <__ranges/reverse_view.h>
411# include <__ranges/subrange.h>411# include <__ranges/single_view.h>
412# include <__ranges/take_view.h>412# include <__ranges/size.h>
413# include <__ranges/take_while_view.h>413# include <__ranges/split_view.h>
414# include <__ranges/transform_view.h>414# include <__ranges/subrange.h>
415# include <__ranges/view_interface.h>415# include <__ranges/take_view.h>
416# include <__ranges/views.h>416# include <__ranges/take_while_view.h>
417417# include <__ranges/transform_view.h>
418# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)418# include <__ranges/view_interface.h>
419# include <__ranges/istream_view.h>419# include <__ranges/views.h>
420
421# if _LIBCPP_HAS_LOCALIZATION
422# include <__ranges/istream_view.h>
423# endif
420# endif424# endif
421#endif
422425
423#if _LIBCPP_STD_VER >= 23426# if _LIBCPP_STD_VER >= 23
424# include <__ranges/as_rvalue_view.h>427# include <__ranges/as_rvalue_view.h>
425# include <__ranges/chunk_by_view.h>428# include <__ranges/chunk_by_view.h>
426# include <__ranges/from_range.h>429# include <__ranges/from_range.h>
427# include <__ranges/repeat_view.h>430# include <__ranges/repeat_view.h>
428# include <__ranges/to.h>431# include <__ranges/to.h>
429# include <__ranges/zip_view.h>432# include <__ranges/zip_view.h>
430#endif433# endif
431434
432#include <version>435# include <version>
433436
434// standard-mandated includes437// standard-mandated includes
435438
436// [ranges.syn]439// [ranges.syn]
437#include <compare>440# include <compare>
438#include <initializer_list>441# include <initializer_list>
439#include <iterator>442# include <iterator>
440443
441// [tuple.helper]444// [tuple.helper]
442#include <__tuple/tuple_element.h>445# include <__tuple/tuple_element.h>
443#include <__tuple/tuple_size.h>446# include <__tuple/tuple_size.h>
444447
445#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)448# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
446# pragma GCC system_header449# pragma GCC system_header
447#endif450# endif
448451
449#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17452# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
450# include <cstddef>453# include <cstdlib>
451# include <limits>454# include <iosfwd>
452# include <optional>455# include <type_traits>
453# include <span>456# endif
454# include <tuple>457#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
455#endif
456
457#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
458# include <cstdlib>
459# include <iosfwd>
460# include <type_traits>
461#endif
462458
463#endif // _LIBCPP_RANGES459#endif // _LIBCPP_RANGES
lib/libcxx/include/ratio+82-100
...@@ -81,56 +81,47 @@ using quetta = ratio <1'000'000'000'000'000'000'000'000'000'000, 1>; // Since C+...@@ -81,56 +81,47 @@ using quetta = ratio <1'000'000'000'000'000'000'000'000'000'000, 1>; // Since C+
81}81}
82*/82*/
8383
84#include <__config>84#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
85#include <__type_traits/integral_constant.h>85# include <__cxx03/ratio>
86#include <climits>86#else
87#include <cstdint>87# include <__config>
88#include <version>88# include <__type_traits/integral_constant.h>
8989# include <climits>
90#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)90# include <cstdint>
91# pragma GCC system_header91# include <version>
92#endif92
93# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
94# pragma GCC system_header
95# endif
9396
94_LIBCPP_PUSH_MACROS97_LIBCPP_PUSH_MACROS
95#include <__undef_macros>98# include <__undef_macros>
9699
97_LIBCPP_BEGIN_NAMESPACE_STD100_LIBCPP_BEGIN_NAMESPACE_STD
98101
99// __static_gcd102// __static_gcd
100103
101template <intmax_t _Xp, intmax_t _Yp>104template <intmax_t _Xp, intmax_t _Yp>
102struct __static_gcd {105inline const intmax_t __static_gcd = __static_gcd<_Yp, _Xp % _Yp>;
103 static const intmax_t value = __static_gcd<_Yp, _Xp % _Yp>::value;
104};
105106
106template <intmax_t _Xp>107template <intmax_t _Xp>
107struct __static_gcd<_Xp, 0> {108inline const intmax_t __static_gcd<_Xp, 0> = _Xp;
108 static const intmax_t value = _Xp;
109};
110109
111template <>110template <>
112struct __static_gcd<0, 0> {111inline const intmax_t __static_gcd<0, 0> = 1;
113 static const intmax_t value = 1;
114};
115112
116// __static_lcm113// __static_lcm
117114
118template <intmax_t _Xp, intmax_t _Yp>115template <intmax_t _Xp, intmax_t _Yp>
119struct __static_lcm {116inline const intmax_t __static_lcm = _Xp / __static_gcd<_Xp, _Yp> * _Yp;
120 static const intmax_t value = _Xp / __static_gcd<_Xp, _Yp>::value * _Yp;
121};
122117
123template <intmax_t _Xp>118template <intmax_t _Xp>
124struct __static_abs {119inline const intmax_t __static_abs = _Xp < 0 ? -_Xp : _Xp;
125 static const intmax_t value = _Xp < 0 ? -_Xp : _Xp;
126};
127120
128template <intmax_t _Xp>121template <intmax_t _Xp>
129struct __static_sign {122inline const intmax_t __static_sign = _Xp == 0 ? 0 : (_Xp < 0 ? -1 : 1);
130 static const intmax_t value = _Xp == 0 ? 0 : (_Xp < 0 ? -1 : 1);
131};
132123
133template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp>::value>124template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp> >
134class __ll_add;125class __ll_add;
135126
136template <intmax_t _Xp, intmax_t _Yp>127template <intmax_t _Xp, intmax_t _Yp>
...@@ -161,7 +152,7 @@ public:...@@ -161,7 +152,7 @@ public:
161 static const intmax_t value = _Xp + _Yp;152 static const intmax_t value = _Xp + _Yp;
162};153};
163154
164template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp>::value>155template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp> >
165class __ll_sub;156class __ll_sub;
166157
167template <intmax_t _Xp, intmax_t _Yp>158template <intmax_t _Xp, intmax_t _Yp>
...@@ -197,8 +188,8 @@ class __ll_mul {...@@ -197,8 +188,8 @@ class __ll_mul {
197 static const intmax_t nan = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1));188 static const intmax_t nan = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1));
198 static const intmax_t min = nan + 1;189 static const intmax_t min = nan + 1;
199 static const intmax_t max = -min;190 static const intmax_t max = -min;
200 static const intmax_t __a_x = __static_abs<_Xp>::value;191 static const intmax_t __a_x = __static_abs<_Xp>;
201 static const intmax_t __a_y = __static_abs<_Yp>::value;192 static const intmax_t __a_y = __static_abs<_Yp>;
202193
203 static_assert(_Xp != nan && _Yp != nan && __a_x <= max / __a_y, "overflow in __ll_mul");194 static_assert(_Xp != nan && _Yp != nan && __a_x <= max / __a_y, "overflow in __ll_mul");
204195
...@@ -239,31 +230,26 @@ public:...@@ -239,31 +230,26 @@ public:
239230
240template <intmax_t _Num, intmax_t _Den = 1>231template <intmax_t _Num, intmax_t _Den = 1>
241class _LIBCPP_TEMPLATE_VIS ratio {232class _LIBCPP_TEMPLATE_VIS ratio {
242 static_assert(__static_abs<_Num>::value >= 0, "ratio numerator is out of range");233 static_assert(__static_abs<_Num> >= 0, "ratio numerator is out of range");
243 static_assert(_Den != 0, "ratio divide by 0");234 static_assert(_Den != 0, "ratio divide by 0");
244 static_assert(__static_abs<_Den>::value > 0, "ratio denominator is out of range");235 static_assert(__static_abs<_Den> > 0, "ratio denominator is out of range");
245 static _LIBCPP_CONSTEXPR const intmax_t __na = __static_abs<_Num>::value;236 static _LIBCPP_CONSTEXPR const intmax_t __na = __static_abs<_Num>;
246 static _LIBCPP_CONSTEXPR const intmax_t __da = __static_abs<_Den>::value;237 static _LIBCPP_CONSTEXPR const intmax_t __da = __static_abs<_Den>;
247 static _LIBCPP_CONSTEXPR const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value;238 static _LIBCPP_CONSTEXPR const intmax_t __s = __static_sign<_Num> * __static_sign<_Den>;
248 static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>::value;239 static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>;
249240
250public:241public:
251 static _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd;242 static inline _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd;
252 static _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd;243 static inline _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd;
253244
254 typedef ratio<num, den> type;245 typedef ratio<num, den> type;
255};246};
256247
257template <intmax_t _Num, intmax_t _Den>
258_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::num;
259
260template <intmax_t _Num, intmax_t _Den>
261_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::den;
262
263template <class _Tp>248template <class _Tp>
264struct __is_ratio : false_type {};249inline const bool __is_ratio_v = false;
250
265template <intmax_t _Num, intmax_t _Den>251template <intmax_t _Num, intmax_t _Den>
266struct __is_ratio<ratio<_Num, _Den> > : true_type {};252inline const bool __is_ratio_v<ratio<_Num, _Den> > = true;
267253
268typedef ratio<1LL, 1000000000000000000LL> atto;254typedef ratio<1LL, 1000000000000000000LL> atto;
269typedef ratio<1LL, 1000000000000000LL> femto;255typedef ratio<1LL, 1000000000000000LL> femto;
...@@ -285,63 +271,63 @@ typedef ratio<1000000000000000000LL, 1LL> exa;...@@ -285,63 +271,63 @@ typedef ratio<1000000000000000000LL, 1LL> exa;
285template <class _R1, class _R2>271template <class _R1, class _R2>
286struct __ratio_multiply {272struct __ratio_multiply {
287private:273private:
288 static const intmax_t __gcd_n1_d2 = __static_gcd<_R1::num, _R2::den>::value;274 static const intmax_t __gcd_n1_d2 = __static_gcd<_R1::num, _R2::den>;
289 static const intmax_t __gcd_d1_n2 = __static_gcd<_R1::den, _R2::num>::value;275 static const intmax_t __gcd_d1_n2 = __static_gcd<_R1::den, _R2::num>;
290276
291 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");277 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
292 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");278 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
293279
294public:280public:
295 typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_d2, _R2::num / __gcd_d1_n2>::value,281 typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_d2, _R2::num / __gcd_d1_n2>::value,
296 __ll_mul<_R2::den / __gcd_n1_d2, _R1::den / __gcd_d1_n2>::value >::type type;282 __ll_mul<_R2::den / __gcd_n1_d2, _R1::den / __gcd_d1_n2>::value >::type type;
297};283};
298284
299#ifndef _LIBCPP_CXX03_LANG285# ifndef _LIBCPP_CXX03_LANG
300286
301template <class _R1, class _R2>287template <class _R1, class _R2>
302using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type;288using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type;
303289
304#else // _LIBCPP_CXX03_LANG290# else // _LIBCPP_CXX03_LANG
305291
306template <class _R1, class _R2>292template <class _R1, class _R2>
307struct _LIBCPP_TEMPLATE_VIS ratio_multiply : public __ratio_multiply<_R1, _R2>::type {};293struct _LIBCPP_TEMPLATE_VIS ratio_multiply : public __ratio_multiply<_R1, _R2>::type {};
308294
309#endif // _LIBCPP_CXX03_LANG295# endif // _LIBCPP_CXX03_LANG
310296
311template <class _R1, class _R2>297template <class _R1, class _R2>
312struct __ratio_divide {298struct __ratio_divide {
313private:299private:
314 static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;300 static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>;
315 static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;301 static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>;
316302
317 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");303 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
318 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");304 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
319305
320public:306public:
321 typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,307 typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
322 __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value >::type type;308 __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value >::type type;
323};309};
324310
325#ifndef _LIBCPP_CXX03_LANG311# ifndef _LIBCPP_CXX03_LANG
326312
327template <class _R1, class _R2>313template <class _R1, class _R2>
328using ratio_divide = typename __ratio_divide<_R1, _R2>::type;314using ratio_divide = typename __ratio_divide<_R1, _R2>::type;
329315
330#else // _LIBCPP_CXX03_LANG316# else // _LIBCPP_CXX03_LANG
331317
332template <class _R1, class _R2>318template <class _R1, class _R2>
333struct _LIBCPP_TEMPLATE_VIS ratio_divide : public __ratio_divide<_R1, _R2>::type {};319struct _LIBCPP_TEMPLATE_VIS ratio_divide : public __ratio_divide<_R1, _R2>::type {};
334320
335#endif // _LIBCPP_CXX03_LANG321# endif // _LIBCPP_CXX03_LANG
336322
337template <class _R1, class _R2>323template <class _R1, class _R2>
338struct __ratio_add {324struct __ratio_add {
339private:325private:
340 static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;326 static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>;
341 static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;327 static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>;
342328
343 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");329 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
344 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");330 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
345331
346public:332public:
347 typedef typename ratio_multiply<333 typedef typename ratio_multiply<
...@@ -351,26 +337,26 @@ public:...@@ -351,26 +337,26 @@ public:
351 _R2::den > >::type type;337 _R2::den > >::type type;
352};338};
353339
354#ifndef _LIBCPP_CXX03_LANG340# ifndef _LIBCPP_CXX03_LANG
355341
356template <class _R1, class _R2>342template <class _R1, class _R2>
357using ratio_add = typename __ratio_add<_R1, _R2>::type;343using ratio_add = typename __ratio_add<_R1, _R2>::type;
358344
359#else // _LIBCPP_CXX03_LANG345# else // _LIBCPP_CXX03_LANG
360346
361template <class _R1, class _R2>347template <class _R1, class _R2>
362struct _LIBCPP_TEMPLATE_VIS ratio_add : public __ratio_add<_R1, _R2>::type {};348struct _LIBCPP_TEMPLATE_VIS ratio_add : public __ratio_add<_R1, _R2>::type {};
363349
364#endif // _LIBCPP_CXX03_LANG350# endif // _LIBCPP_CXX03_LANG
365351
366template <class _R1, class _R2>352template <class _R1, class _R2>
367struct __ratio_subtract {353struct __ratio_subtract {
368private:354private:
369 static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;355 static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>;
370 static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;356 static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>;
371357
372 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");358 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
373 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");359 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
374360
375public:361public:
376 typedef typename ratio_multiply<362 typedef typename ratio_multiply<
...@@ -380,30 +366,30 @@ public:...@@ -380,30 +366,30 @@ public:
380 _R2::den > >::type type;366 _R2::den > >::type type;
381};367};
382368
383#ifndef _LIBCPP_CXX03_LANG369# ifndef _LIBCPP_CXX03_LANG
384370
385template <class _R1, class _R2>371template <class _R1, class _R2>
386using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type;372using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type;
387373
388#else // _LIBCPP_CXX03_LANG374# else // _LIBCPP_CXX03_LANG
389375
390template <class _R1, class _R2>376template <class _R1, class _R2>
391struct _LIBCPP_TEMPLATE_VIS ratio_subtract : public __ratio_subtract<_R1, _R2>::type {};377struct _LIBCPP_TEMPLATE_VIS ratio_subtract : public __ratio_subtract<_R1, _R2>::type {};
392378
393#endif // _LIBCPP_CXX03_LANG379# endif // _LIBCPP_CXX03_LANG
394380
395// ratio_equal381// ratio_equal
396382
397template <class _R1, class _R2>383template <class _R1, class _R2>
398struct _LIBCPP_TEMPLATE_VIS ratio_equal : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> {384struct _LIBCPP_TEMPLATE_VIS ratio_equal : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> {
399 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");385 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
400 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");386 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
401};387};
402388
403template <class _R1, class _R2>389template <class _R1, class _R2>
404struct _LIBCPP_TEMPLATE_VIS ratio_not_equal : _BoolConstant<!ratio_equal<_R1, _R2>::value> {390struct _LIBCPP_TEMPLATE_VIS ratio_not_equal : _BoolConstant<!ratio_equal<_R1, _R2>::value> {
405 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");391 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
406 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");392 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
407};393};
408394
409// ratio_less395// ratio_less
...@@ -439,10 +425,7 @@ struct __ratio_less1<_R1, _R2, _Odd, _Qp, _M1, _Qp, _M2> {...@@ -439,10 +425,7 @@ struct __ratio_less1<_R1, _R2, _Odd, _Qp, _M1, _Qp, _M2> {
439 static const bool value = __ratio_less1<ratio<_R1::den, _M1>, ratio<_R2::den, _M2>, !_Odd>::value;425 static const bool value = __ratio_less1<ratio<_R1::den, _M1>, ratio<_R2::den, _M2>, !_Odd>::value;
440};426};
441427
442template <class _R1,428template <class _R1, class _R2, intmax_t _S1 = __static_sign<_R1::num>, intmax_t _S2 = __static_sign<_R2::num> >
443 class _R2,
444 intmax_t _S1 = __static_sign<_R1::num>::value,
445 intmax_t _S2 = __static_sign<_R2::num>::value>
446struct __ratio_less {429struct __ratio_less {
447 static const bool value = _S1 < _S2;430 static const bool value = _S1 < _S2;
448};431};
...@@ -459,34 +442,32 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> {...@@ -459,34 +442,32 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> {
459442
460template <class _R1, class _R2>443template <class _R1, class _R2>
461struct _LIBCPP_TEMPLATE_VIS ratio_less : _BoolConstant<__ratio_less<_R1, _R2>::value> {444struct _LIBCPP_TEMPLATE_VIS ratio_less : _BoolConstant<__ratio_less<_R1, _R2>::value> {
462 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");445 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
463 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");446 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
464};447};
465448
466template <class _R1, class _R2>449template <class _R1, class _R2>
467struct _LIBCPP_TEMPLATE_VIS ratio_less_equal : _BoolConstant<!ratio_less<_R2, _R1>::value> {450struct _LIBCPP_TEMPLATE_VIS ratio_less_equal : _BoolConstant<!ratio_less<_R2, _R1>::value> {
468 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");451 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
469 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");452 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
470};453};
471454
472template <class _R1, class _R2>455template <class _R1, class _R2>
473struct _LIBCPP_TEMPLATE_VIS ratio_greater : _BoolConstant<ratio_less<_R2, _R1>::value> {456struct _LIBCPP_TEMPLATE_VIS ratio_greater : _BoolConstant<ratio_less<_R2, _R1>::value> {
474 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");457 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
475 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");458 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
476};459};
477460
478template <class _R1, class _R2>461template <class _R1, class _R2>
479struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal : _BoolConstant<!ratio_less<_R1, _R2>::value> {462struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal : _BoolConstant<!ratio_less<_R1, _R2>::value> {
480 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");463 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
481 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");464 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
482};465};
483466
484template <class _R1, class _R2>467template <class _R1, class _R2>
485struct __ratio_gcd {468using __ratio_gcd _LIBCPP_NODEBUG = ratio<__static_gcd<_R1::num, _R2::num>, __static_lcm<_R1::den, _R2::den> >;
486 typedef ratio<__static_gcd<_R1::num, _R2::num>::value, __static_lcm<_R1::den, _R2::den>::value> type;
487};
488469
489#if _LIBCPP_STD_VER >= 17470# if _LIBCPP_STD_VER >= 17
490template <class _R1, class _R2>471template <class _R1, class _R2>
491inline constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value;472inline constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value;
492473
...@@ -504,14 +485,15 @@ inline constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value;...@@ -504,14 +485,15 @@ inline constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value;
504485
505template <class _R1, class _R2>486template <class _R1, class _R2>
506inline constexpr bool ratio_greater_equal_v = ratio_greater_equal<_R1, _R2>::value;487inline constexpr bool ratio_greater_equal_v = ratio_greater_equal<_R1, _R2>::value;
507#endif488# endif
508489
509_LIBCPP_END_NAMESPACE_STD490_LIBCPP_END_NAMESPACE_STD
510491
511_LIBCPP_POP_MACROS492_LIBCPP_POP_MACROS
512493
513#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20494# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
514# include <type_traits>495# include <type_traits>
515#endif496# endif
497#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
516498
517#endif // _LIBCPP_RATIO499#endif // _LIBCPP_RATIO
lib/libcxx/include/regex+164-161
...@@ -789,48 +789,51 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;...@@ -789,48 +789,51 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
789} // std789} // std
790*/790*/
791791
792#include <__algorithm/find.h>792#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
793#include <__algorithm/search.h>793# include <__cxx03/regex>
794#include <__assert>794#else
795#include <__config>795# include <__algorithm/find.h>
796#include <__iterator/back_insert_iterator.h>796# include <__algorithm/search.h>
797#include <__iterator/default_sentinel.h>797# include <__assert>
798#include <__iterator/wrap_iter.h>798# include <__config>
799#include <__locale>799# include <__iterator/back_insert_iterator.h>
800#include <__memory/shared_ptr.h>800# include <__iterator/default_sentinel.h>
801#include <__memory_resource/polymorphic_allocator.h>801# include <__iterator/wrap_iter.h>
802#include <__type_traits/is_swappable.h>802# include <__locale>
803#include <__utility/move.h>803# include <__memory/shared_ptr.h>
804#include <__utility/pair.h>804# include <__memory_resource/polymorphic_allocator.h>
805#include <__utility/swap.h>805# include <__type_traits/is_swappable.h>
806#include <__verbose_abort>806# include <__utility/move.h>
807#include <deque>807# include <__utility/pair.h>
808#include <stdexcept>808# include <__utility/swap.h>
809#include <string>809# include <__verbose_abort>
810#include <vector>810# include <deque>
811#include <version>811# include <stdexcept>
812# include <string>
813# include <vector>
814# include <version>
812815
813// standard-mandated includes816// standard-mandated includes
814817
815// [iterator.range]818// [iterator.range]
816#include <__iterator/access.h>819# include <__iterator/access.h>
817#include <__iterator/data.h>820# include <__iterator/data.h>
818#include <__iterator/empty.h>821# include <__iterator/empty.h>
819#include <__iterator/reverse_access.h>822# include <__iterator/reverse_access.h>
820#include <__iterator/size.h>823# include <__iterator/size.h>
821824
822// [re.syn]825// [re.syn]
823#include <compare>826# include <compare>
824#include <initializer_list>827# include <initializer_list>
825828
826#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)829# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
827# pragma GCC system_header830# pragma GCC system_header
828#endif831# endif
829832
830_LIBCPP_PUSH_MACROS833_LIBCPP_PUSH_MACROS
831#include <__undef_macros>834# include <__undef_macros>
832835
833#define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096836# define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096
834837
835_LIBCPP_BEGIN_NAMESPACE_STD838_LIBCPP_BEGIN_NAMESPACE_STD
836839
...@@ -843,11 +846,11 @@ enum syntax_option_type {...@@ -843,11 +846,11 @@ enum syntax_option_type {
843 nosubs = 1 << 1,846 nosubs = 1 << 1,
844 optimize = 1 << 2,847 optimize = 1 << 2,
845 collate = 1 << 3,848 collate = 1 << 3,
846#ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO849# ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
847 ECMAScript = 1 << 9,850 ECMAScript = 1 << 9,
848#else851# else
849 ECMAScript = 0,852 ECMAScript = 0,
850#endif853# endif
851 basic = 1 << 4,854 basic = 1 << 4,
852 extended = 1 << 5,855 extended = 1 << 5,
853 awk = 1 << 6,856 awk = 1 << 6,
...@@ -858,11 +861,11 @@ enum syntax_option_type {...@@ -858,11 +861,11 @@ enum syntax_option_type {
858};861};
859862
860_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR syntax_option_type __get_grammar(syntax_option_type __g) {863_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR syntax_option_type __get_grammar(syntax_option_type __g) {
861#ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO864# ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
862 return static_cast<syntax_option_type>(__g & 0x3F0);865 return static_cast<syntax_option_type>(__g & 0x3F0);
863#else866# else
864 return static_cast<syntax_option_type>(__g & 0x1F0);867 return static_cast<syntax_option_type>(__g & 0x1F0);
865#endif868# endif
866}869}
867870
868inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR syntax_option_type operator~(syntax_option_type __x) {871inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR syntax_option_type operator~(syntax_option_type __x) {
...@@ -983,12 +986,12 @@ public:...@@ -983,12 +986,12 @@ public:
983};986};
984987
985template <regex_constants::error_type _Ev>988template <regex_constants::error_type _Ev>
986_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_regex_error() {989[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_regex_error() {
987#ifndef _LIBCPP_HAS_NO_EXCEPTIONS990# if _LIBCPP_HAS_EXCEPTIONS
988 throw regex_error(_Ev);991 throw regex_error(_Ev);
989#else992# else
990 _LIBCPP_VERBOSE_ABORT("regex_error was thrown in -fno-exceptions mode");993 _LIBCPP_VERBOSE_ABORT("regex_error was thrown in -fno-exceptions mode");
991#endif994# endif
992}995}
993996
994template <class _CharT>997template <class _CharT>
...@@ -997,7 +1000,7 @@ public:...@@ -997,7 +1000,7 @@ public:
997 typedef _CharT char_type;1000 typedef _CharT char_type;
998 typedef basic_string<char_type> string_type;1001 typedef basic_string<char_type> string_type;
999 typedef locale locale_type;1002 typedef locale locale_type;
1000#if defined(__BIONIC__) || defined(_NEWLIB_VERSION)1003# if defined(__BIONIC__) || defined(_NEWLIB_VERSION)
1001 // Originally bionic's ctype_base used its own ctype masks because the1004 // Originally bionic's ctype_base used its own ctype masks because the
1002 // builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask1005 // builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask
1003 // was only 8 bits wide and already saturated, so it used a wider type here1006 // was only 8 bits wide and already saturated, so it used a wider type here
...@@ -1012,9 +1015,9 @@ public:...@@ -1012,9 +1015,9 @@ public:
1012 // often used for space constrained environments, so it makes sense not to1015 // often used for space constrained environments, so it makes sense not to
1013 // duplicate the ctype table.1016 // duplicate the ctype table.
1014 typedef uint16_t char_class_type;1017 typedef uint16_t char_class_type;
1015#else1018# else
1016 typedef ctype_base::mask char_class_type;1019 typedef ctype_base::mask char_class_type;
1017#endif1020# endif
10181021
1019 static const char_class_type __regex_word = ctype_base::__regex_word;1022 static const char_class_type __regex_word = ctype_base::__regex_word;
10201023
...@@ -1054,30 +1057,30 @@ private:...@@ -1054,30 +1057,30 @@ private:
10541057
1055 template <class _ForwardIterator>1058 template <class _ForwardIterator>
1056 string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const;1059 string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const;
1057#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1060# if _LIBCPP_HAS_WIDE_CHARACTERS
1058 template <class _ForwardIterator>1061 template <class _ForwardIterator>
1059 string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;1062 string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
1060#endif1063# endif
1061 template <class _ForwardIterator>1064 template <class _ForwardIterator>
1062 string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const;1065 string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const;
1063#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1066# if _LIBCPP_HAS_WIDE_CHARACTERS
1064 template <class _ForwardIterator>1067 template <class _ForwardIterator>
1065 string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;1068 string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
1066#endif1069# endif
1067 template <class _ForwardIterator>1070 template <class _ForwardIterator>
1068 char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, char) const;1071 char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, char) const;
1069#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1072# if _LIBCPP_HAS_WIDE_CHARACTERS
1070 template <class _ForwardIterator>1073 template <class _ForwardIterator>
1071 char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const;1074 char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const;
1072#endif1075# endif
10731076
1074 static int __regex_traits_value(unsigned char __ch, int __radix);1077 static int __regex_traits_value(unsigned char __ch, int __radix);
1075 _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(char __ch, int __radix) const {1078 _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(char __ch, int __radix) const {
1076 return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);1079 return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);
1077 }1080 }
1078#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1081# if _LIBCPP_HAS_WIDE_CHARACTERS
1079 _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(wchar_t __ch, int __radix) const;1082 _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(wchar_t __ch, int __radix) const;
1080#endif1083# endif
1081};1084};
10821085
1083template <class _CharT>1086template <class _CharT>
...@@ -1136,7 +1139,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator...@@ -1136,7 +1139,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator
1136 return __d;1139 return __d;
1137}1140}
11381141
1139#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1142# if _LIBCPP_HAS_WIDE_CHARACTERS
1140template <class _CharT>1143template <class _CharT>
1141template <class _ForwardIterator>1144template <class _ForwardIterator>
1142typename regex_traits<_CharT>::string_type1145typename regex_traits<_CharT>::string_type
...@@ -1155,7 +1158,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator...@@ -1155,7 +1158,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator
1155 }1158 }
1156 return __d;1159 return __d;
1157}1160}
1158#endif1161# endif
11591162
1160// lookup_collatename is very FreeBSD-specific1163// lookup_collatename is very FreeBSD-specific
11611164
...@@ -1180,7 +1183,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato...@@ -1180,7 +1183,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato
1180 return __r;1183 return __r;
1181}1184}
11821185
1183#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1186# if _LIBCPP_HAS_WIDE_CHARACTERS
1184template <class _CharT>1187template <class _CharT>
1185template <class _ForwardIterator>1188template <class _ForwardIterator>
1186typename regex_traits<_CharT>::string_type1189typename regex_traits<_CharT>::string_type
...@@ -1208,7 +1211,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato...@@ -1208,7 +1211,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato
1208 }1211 }
1209 return __r;1212 return __r;
1210}1213}
1211#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS1214# endif // _LIBCPP_HAS_WIDE_CHARACTERS
12121215
1213// lookup_classname1216// lookup_classname
12141217
...@@ -1223,7 +1226,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator...@@ -1223,7 +1226,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator
1223 return std::__get_classname(__s.c_str(), __icase);1226 return std::__get_classname(__s.c_str(), __icase);
1224}1227}
12251228
1226#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1229# if _LIBCPP_HAS_WIDE_CHARACTERS
1227template <class _CharT>1230template <class _CharT>
1228template <class _ForwardIterator>1231template <class _ForwardIterator>
1229typename regex_traits<_CharT>::char_class_type1232typename regex_traits<_CharT>::char_class_type
...@@ -1239,7 +1242,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator...@@ -1239,7 +1242,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator
1239 }1242 }
1240 return __get_classname(__n.c_str(), __icase);1243 return __get_classname(__n.c_str(), __icase);
1241}1244}
1242#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS1245# endif // _LIBCPP_HAS_WIDE_CHARACTERS
12431246
1244template <class _CharT>1247template <class _CharT>
1245bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const {1248bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const {
...@@ -1250,28 +1253,28 @@ bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const {...@@ -1250,28 +1253,28 @@ bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const {
12501253
1251inline _LIBCPP_HIDE_FROM_ABI bool __is_07(unsigned char __c) {1254inline _LIBCPP_HIDE_FROM_ABI bool __is_07(unsigned char __c) {
1252 return (__c & 0xF8u) ==1255 return (__c & 0xF8u) ==
1253#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)1256# if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
1254 0xF0;1257 0xF0;
1255#else1258# else
1256 0x30;1259 0x30;
1257#endif1260# endif
1258}1261}
12591262
1260inline _LIBCPP_HIDE_FROM_ABI bool __is_89(unsigned char __c) {1263inline _LIBCPP_HIDE_FROM_ABI bool __is_89(unsigned char __c) {
1261 return (__c & 0xFEu) ==1264 return (__c & 0xFEu) ==
1262#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)1265# if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
1263 0xF8;1266 0xF8;
1264#else1267# else
1265 0x38;1268 0x38;
1266#endif1269# endif
1267}1270}
12681271
1269inline _LIBCPP_HIDE_FROM_ABI unsigned char __to_lower(unsigned char __c) {1272inline _LIBCPP_HIDE_FROM_ABI unsigned char __to_lower(unsigned char __c) {
1270#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)1273# if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
1271 return __c & 0xBF;1274 return __c & 0xBF;
1272#else1275# else
1273 return __c | 0x20;1276 return __c | 0x20;
1274#endif1277# endif
1275}1278}
12761279
1277template <class _CharT>1280template <class _CharT>
...@@ -1290,12 +1293,12 @@ int regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix)...@@ -1290,12 +1293,12 @@ int regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix)
1290 return -1;1293 return -1;
1291}1294}
12921295
1293#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1296# if _LIBCPP_HAS_WIDE_CHARACTERS
1294template <class _CharT>1297template <class _CharT>
1295inline int regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const {1298inline int regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const {
1296 return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix);1299 return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix);
1297}1300}
1298#endif1301# endif
12991302
1300template <class _CharT>1303template <class _CharT>
1301class __node;1304class __node;
...@@ -1938,10 +1941,10 @@ public:...@@ -1938,10 +1941,10 @@ public:
19381941
1939template <>1942template <>
1940_LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<char>::__exec(__state&) const;1943_LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<char>::__exec(__state&) const;
1941#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1944# if _LIBCPP_HAS_WIDE_CHARACTERS
1942template <>1945template <>
1943_LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<wchar_t>::__exec(__state&) const;1946_LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<wchar_t>::__exec(__state&) const;
1944#endif1947# endif
19451948
1946// __match_char1949// __match_char
19471950
...@@ -2262,9 +2265,9 @@ template <class _CharT, class _Traits = regex_traits<_CharT> >...@@ -2262,9 +2265,9 @@ template <class _CharT, class _Traits = regex_traits<_CharT> >
2262class _LIBCPP_TEMPLATE_VIS basic_regex;2265class _LIBCPP_TEMPLATE_VIS basic_regex;
22632266
2264typedef basic_regex<char> regex;2267typedef basic_regex<char> regex;
2265#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2268# if _LIBCPP_HAS_WIDE_CHARACTERS
2266typedef basic_regex<wchar_t> wregex;2269typedef basic_regex<wchar_t> wregex;
2267#endif2270# endif
22682271
2269template <class _CharT, class _Traits>2272template <class _CharT, class _Traits>
2270class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(regex)2273class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(regex)
...@@ -2335,21 +2338,21 @@ public:...@@ -2335,21 +2338,21 @@ public:
2335 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) {2338 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) {
2336 __init(__first, __last);2339 __init(__first, __last);
2337 }2340 }
2338#ifndef _LIBCPP_CXX03_LANG2341# ifndef _LIBCPP_CXX03_LANG
2339 _LIBCPP_HIDE_FROM_ABI basic_regex(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript)2342 _LIBCPP_HIDE_FROM_ABI basic_regex(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript)
2340 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) {2343 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) {
2341 __init(__il.begin(), __il.end());2344 __init(__il.begin(), __il.end());
2342 }2345 }
2343#endif // _LIBCPP_CXX03_LANG2346# endif // _LIBCPP_CXX03_LANG
23442347
2345 // ~basic_regex() = default;2348 // ~basic_regex() = default;
23462349
2347 // basic_regex& operator=(const basic_regex&) = default;2350 // basic_regex& operator=(const basic_regex&) = default;
2348 // basic_regex& operator=(basic_regex&&) = default;2351 // basic_regex& operator=(basic_regex&&) = default;
2349 _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const value_type* __p) { return assign(__p); }2352 _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const value_type* __p) { return assign(__p); }
2350#ifndef _LIBCPP_CXX03_LANG2353# ifndef _LIBCPP_CXX03_LANG
2351 _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(initializer_list<value_type> __il) { return assign(__il); }2354 _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(initializer_list<value_type> __il) { return assign(__il); }
2352#endif // _LIBCPP_CXX03_LANG2355# endif // _LIBCPP_CXX03_LANG
2353 template <class _ST, class _SA>2356 template <class _ST, class _SA>
2354 _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p) {2357 _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p) {
2355 return assign(__p);2358 return assign(__p);
...@@ -2357,9 +2360,9 @@ public:...@@ -2357,9 +2360,9 @@ public:
23572360
2358 // assign:2361 // assign:
2359 _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const basic_regex& __that) { return *this = __that; }2362 _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const basic_regex& __that) { return *this = __that; }
2360#ifndef _LIBCPP_CXX03_LANG2363# ifndef _LIBCPP_CXX03_LANG
2361 _LIBCPP_HIDE_FROM_ABI basic_regex& assign(basic_regex&& __that) _NOEXCEPT { return *this = std::move(__that); }2364 _LIBCPP_HIDE_FROM_ABI basic_regex& assign(basic_regex&& __that) _NOEXCEPT { return *this = std::move(__that); }
2362#endif2365# endif
2363 _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript) {2366 _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript) {
2364 return assign(__p, __p + __traits_.length(__p), __f);2367 return assign(__p, __p + __traits_.length(__p), __f);
2365 }2368 }
...@@ -2396,14 +2399,14 @@ public:...@@ -2396,14 +2399,14 @@ public:
2396 return assign(basic_regex(__first, __last, __f));2399 return assign(basic_regex(__first, __last, __f));
2397 }2400 }
23982401
2399#ifndef _LIBCPP_CXX03_LANG2402# ifndef _LIBCPP_CXX03_LANG
24002403
2401 _LIBCPP_HIDE_FROM_ABI basic_regex&2404 _LIBCPP_HIDE_FROM_ABI basic_regex&
2402 assign(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript) {2405 assign(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript) {
2403 return assign(__il.begin(), __il.end(), __f);2406 return assign(__il.begin(), __il.end(), __f);
2404 }2407 }
24052408
2406#endif // _LIBCPP_CXX03_LANG2409# endif // _LIBCPP_CXX03_LANG
24072410
2408 // const operations:2411 // const operations:
2409 _LIBCPP_HIDE_FROM_ABI unsigned mark_count() const { return __marked_count_; }2412 _LIBCPP_HIDE_FROM_ABI unsigned mark_count() const { return __marked_count_; }
...@@ -2644,11 +2647,11 @@ private:...@@ -2644,11 +2647,11 @@ private:
2644 friend class __lookahead;2647 friend class __lookahead;
2645};2648};
26462649
2647#if _LIBCPP_STD_VER >= 172650# if _LIBCPP_STD_VER >= 17
2648template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>2651template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
2649basic_regex(_ForwardIterator, _ForwardIterator, regex_constants::syntax_option_type = regex_constants::ECMAScript)2652basic_regex(_ForwardIterator, _ForwardIterator, regex_constants::syntax_option_type = regex_constants::ECMAScript)
2650 -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>;2653 -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>;
2651#endif2654# endif
26522655
2653template <class _CharT, class _Traits>2656template <class _CharT, class _Traits>
2654const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase;2657const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase;
...@@ -3921,7 +3924,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape(...@@ -3921,7 +3924,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape(
3921 if (__hd == -1)3924 if (__hd == -1)
3922 __throw_regex_error<regex_constants::error_escape>();3925 __throw_regex_error<regex_constants::error_escape>();
3923 __sum = 16 * __sum + static_cast<unsigned>(__hd);3926 __sum = 16 * __sum + static_cast<unsigned>(__hd);
3924 // fallthrough3927 _LIBCPP_FALLTHROUGH();
3925 case 'x':3928 case 'x':
3926 ++__first;3929 ++__first;
3927 if (__first == __last)3930 if (__first == __last)
...@@ -4181,10 +4184,10 @@ void basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, bo...@@ -4181,10 +4184,10 @@ void basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, bo
41814184
4182typedef sub_match<const char*> csub_match;4185typedef sub_match<const char*> csub_match;
4183typedef sub_match<string::const_iterator> ssub_match;4186typedef sub_match<string::const_iterator> ssub_match;
4184#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4187# if _LIBCPP_HAS_WIDE_CHARACTERS
4185typedef sub_match<const wchar_t*> wcsub_match;4188typedef sub_match<const wchar_t*> wcsub_match;
4186typedef sub_match<wstring::const_iterator> wssub_match;4189typedef sub_match<wstring::const_iterator> wssub_match;
4187#endif4190# endif
41884191
4189template <class _BidirectionalIterator>4192template <class _BidirectionalIterator>
4190class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(csub_match)4193class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(csub_match)
...@@ -4224,15 +4227,16 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const sub_match<_BiIter>& __x, cons...@@ -4224,15 +4227,16 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const sub_match<_BiIter>& __x, cons
4224 return __x.compare(__y) == 0;4227 return __x.compare(__y) == 0;
4225}4228}
42264229
4227#if _LIBCPP_STD_VER >= 204230# if _LIBCPP_STD_VER >= 20
4228template <class _BiIter>4231template <class _BiIter>
4229using __sub_match_cat = compare_three_way_result_t<basic_string<typename iterator_traits<_BiIter>::value_type>>;4232using __sub_match_cat _LIBCPP_NODEBUG =
4233 compare_three_way_result_t<basic_string<typename iterator_traits<_BiIter>::value_type>>;
42304234
4231template <class _BiIter>4235template <class _BiIter>
4232_LIBCPP_HIDE_FROM_ABI auto operator<=>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {4236_LIBCPP_HIDE_FROM_ABI auto operator<=>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {
4233 return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0);4237 return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0);
4234}4238}
4235#else // _LIBCPP_STD_VER >= 204239# else // _LIBCPP_STD_VER >= 20
4236template <class _BiIter>4240template <class _BiIter>
4237inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {4241inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {
4238 return !(__x == __y);4242 return !(__x == __y);
...@@ -4299,7 +4303,7 @@ operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST...@@ -4299,7 +4303,7 @@ operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST
4299 const sub_match<_BiIter>& __y) {4303 const sub_match<_BiIter>& __y) {
4300 return !(__y < __x);4304 return !(__y < __x);
4301}4305}
4302#endif // _LIBCPP_STD_VER >= 204306# endif // _LIBCPP_STD_VER >= 20
43034307
4304template <class _BiIter, class _ST, class _SA>4308template <class _BiIter, class _ST, class _SA>
4305inline _LIBCPP_HIDE_FROM_ABI bool4309inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -4308,7 +4312,7 @@ operator==(const sub_match<_BiIter>& __x,...@@ -4308,7 +4312,7 @@ operator==(const sub_match<_BiIter>& __x,
4308 return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0;4312 return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0;
4309}4313}
43104314
4311#if _LIBCPP_STD_VER >= 204315# if _LIBCPP_STD_VER >= 20
4312template <class _BiIter, class _ST, class _SA>4316template <class _BiIter, class _ST, class _SA>
4313_LIBCPP_HIDE_FROM_ABI auto4317_LIBCPP_HIDE_FROM_ABI auto
4314operator<=>(const sub_match<_BiIter>& __x,4318operator<=>(const sub_match<_BiIter>& __x,
...@@ -4316,7 +4320,7 @@ operator<=>(const sub_match<_BiIter>& __x,...@@ -4316,7 +4320,7 @@ operator<=>(const sub_match<_BiIter>& __x,
4316 return static_cast<__sub_match_cat<_BiIter>>(4320 return static_cast<__sub_match_cat<_BiIter>>(
4317 __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) <=> 0);4321 __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) <=> 0);
4318}4322}
4319#else // _LIBCPP_STD_VER >= 204323# else // _LIBCPP_STD_VER >= 20
4320template <class _BiIter, class _ST, class _SA>4324template <class _BiIter, class _ST, class _SA>
4321inline _LIBCPP_HIDE_FROM_ABI bool4325inline _LIBCPP_HIDE_FROM_ABI bool
4322operator!=(const sub_match<_BiIter>& __x,4326operator!=(const sub_match<_BiIter>& __x,
...@@ -4387,7 +4391,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool...@@ -4387,7 +4391,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool
4387operator<=(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) {4391operator<=(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) {
4388 return !(__y < __x);4392 return !(__y < __x);
4389}4393}
4390#endif // _LIBCPP_STD_VER >= 204394# endif // _LIBCPP_STD_VER >= 20
43914395
4392template <class _BiIter>4396template <class _BiIter>
4393inline _LIBCPP_HIDE_FROM_ABI bool4397inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -4395,13 +4399,13 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val...@@ -4395,13 +4399,13 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val
4395 return __x.compare(__y) == 0;4399 return __x.compare(__y) == 0;
4396}4400}
43974401
4398#if _LIBCPP_STD_VER >= 204402# if _LIBCPP_STD_VER >= 20
4399template <class _BiIter>4403template <class _BiIter>
4400_LIBCPP_HIDE_FROM_ABI auto4404_LIBCPP_HIDE_FROM_ABI auto
4401operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {4405operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {
4402 return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0);4406 return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0);
4403}4407}
4404#else // _LIBCPP_STD_VER >= 204408# else // _LIBCPP_STD_VER >= 20
4405template <class _BiIter>4409template <class _BiIter>
4406inline _LIBCPP_HIDE_FROM_ABI bool4410inline _LIBCPP_HIDE_FROM_ABI bool
4407operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {4411operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {
...@@ -4469,7 +4473,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool...@@ -4469,7 +4473,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool
4469operator<=(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) {4473operator<=(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) {
4470 return !(__y < __x);4474 return !(__y < __x);
4471}4475}
4472#endif // _LIBCPP_STD_VER >= 204476# endif // _LIBCPP_STD_VER >= 20
44734477
4474template <class _BiIter>4478template <class _BiIter>
4475inline _LIBCPP_HIDE_FROM_ABI bool4479inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -4478,14 +4482,14 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val...@@ -4478,14 +4482,14 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val
4478 return __x.compare(string_type(1, __y)) == 0;4482 return __x.compare(string_type(1, __y)) == 0;
4479}4483}
44804484
4481#if _LIBCPP_STD_VER >= 204485# if _LIBCPP_STD_VER >= 20
4482template <class _BiIter>4486template <class _BiIter>
4483_LIBCPP_HIDE_FROM_ABI auto4487_LIBCPP_HIDE_FROM_ABI auto
4484operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {4488operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {
4485 using string_type = basic_string<typename iterator_traits<_BiIter>::value_type>;4489 using string_type = basic_string<typename iterator_traits<_BiIter>::value_type>;
4486 return static_cast<__sub_match_cat<_BiIter>>(__x.compare(string_type(1, __y)) <=> 0);4490 return static_cast<__sub_match_cat<_BiIter>>(__x.compare(string_type(1, __y)) <=> 0);
4487}4491}
4488#else // _LIBCPP_STD_VER >= 204492# else // _LIBCPP_STD_VER >= 20
4489template <class _BiIter>4493template <class _BiIter>
4490inline _LIBCPP_HIDE_FROM_ABI bool4494inline _LIBCPP_HIDE_FROM_ABI bool
4491operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {4495operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {
...@@ -4516,7 +4520,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool...@@ -4516,7 +4520,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool
4516operator<=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {4520operator<=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {
4517 return !(__y < __x);4521 return !(__y < __x);
4518}4522}
4519#endif // _LIBCPP_STD_VER >= 204523# endif // _LIBCPP_STD_VER >= 20
45204524
4521template <class _CharT, class _ST, class _BiIter>4525template <class _CharT, class _ST, class _BiIter>
4522inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _ST>&4526inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _ST>&
...@@ -4526,10 +4530,10 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) {...@@ -4526,10 +4530,10 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) {
45264530
4527typedef match_results<const char*> cmatch;4531typedef match_results<const char*> cmatch;
4528typedef match_results<string::const_iterator> smatch;4532typedef match_results<string::const_iterator> smatch;
4529#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4533# if _LIBCPP_HAS_WIDE_CHARACTERS
4530typedef match_results<const wchar_t*> wcmatch;4534typedef match_results<const wchar_t*> wcmatch;
4531typedef match_results<wstring::const_iterator> wsmatch;4535typedef match_results<wstring::const_iterator> wsmatch;
4532#endif4536# endif
45334537
4534template <class _BidirectionalIterator, class _Allocator>4538template <class _BidirectionalIterator, class _Allocator>
4535class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cmatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcmatch))4539class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cmatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcmatch))
...@@ -4559,12 +4563,12 @@ public:...@@ -4559,12 +4563,12 @@ public:
4559 typedef basic_string<char_type> string_type;4563 typedef basic_string<char_type> string_type;
45604564
4561 // construct/copy/destroy:4565 // construct/copy/destroy:
4562#ifndef _LIBCPP_CXX03_LANG4566# ifndef _LIBCPP_CXX03_LANG
4563 match_results() : match_results(allocator_type()) {}4567 match_results() : match_results(allocator_type()) {}
4564 explicit match_results(const allocator_type& __a);4568 explicit match_results(const allocator_type& __a);
4565#else4569# else
4566 explicit match_results(const allocator_type& __a = allocator_type());4570 explicit match_results(const allocator_type& __a = allocator_type());
4567#endif4571# endif
45684572
4569 // match_results(const match_results&) = default;4573 // match_results(const match_results&) = default;
4570 // match_results& operator=(const match_results&) = default;4574 // match_results& operator=(const match_results&) = default;
...@@ -4577,7 +4581,7 @@ public:...@@ -4577,7 +4581,7 @@ public:
4577 // size:4581 // size:
4578 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __matches_.size(); }4582 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __matches_.size(); }
4579 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __matches_.max_size(); }4583 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __matches_.max_size(); }
4580 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; }4584 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; }
45814585
4582 // element access:4586 // element access:
4583 _LIBCPP_HIDE_FROM_ABI difference_type length(size_type __sub = 0) const {4587 _LIBCPP_HIDE_FROM_ABI difference_type length(size_type __sub = 0) const {
...@@ -4814,13 +4818,13 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const match_results<_BidirectionalIterator...@@ -4814,13 +4818,13 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const match_results<_BidirectionalIterator
4814 return __x.__matches_ == __y.__matches_ && __x.__prefix_ == __y.__prefix_ && __x.__suffix_ == __y.__suffix_;4818 return __x.__matches_ == __y.__matches_ && __x.__prefix_ == __y.__prefix_ && __x.__suffix_ == __y.__suffix_;
4815}4819}
48164820
4817#if _LIBCPP_STD_VER < 204821# if _LIBCPP_STD_VER < 20
4818template <class _BidirectionalIterator, class _Allocator>4822template <class _BidirectionalIterator, class _Allocator>
4819inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x,4823inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x,
4820 const match_results<_BidirectionalIterator, _Allocator>& __y) {4824 const match_results<_BidirectionalIterator, _Allocator>& __y) {
4821 return !(__x == __y);4825 return !(__x == __y);
4822}4826}
4823#endif4827# endif
48244828
4825template <class _BidirectionalIterator, class _Allocator>4829template <class _BidirectionalIterator, class _Allocator>
4826inline _LIBCPP_HIDE_FROM_ABI void4830inline _LIBCPP_HIDE_FROM_ABI void
...@@ -5232,13 +5236,13 @@ regex_search(const basic_string<_CharT, _ST, _SA>& __s,...@@ -5232,13 +5236,13 @@ regex_search(const basic_string<_CharT, _ST, _SA>& __s,
5232 return __r;5236 return __r;
5233}5237}
52345238
5235#if _LIBCPP_STD_VER >= 145239# if _LIBCPP_STD_VER >= 14
5236template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>5240template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
5237bool regex_search(const basic_string<_Cp, _ST, _SA>&& __s,5241bool regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
5238 match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,5242 match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
5239 const basic_regex<_Cp, _Tp>& __e,5243 const basic_regex<_Cp, _Tp>& __e,
5240 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;5244 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
5241#endif5245# endif
52425246
5243// regex_match5247// regex_match
52445248
...@@ -5287,14 +5291,14 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s,...@@ -5287,14 +5291,14 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s,
5287 return std::regex_match(__s.begin(), __s.end(), __m, __e, __flags);5291 return std::regex_match(__s.begin(), __s.end(), __m, __e, __flags);
5288}5292}
52895293
5290#if _LIBCPP_STD_VER >= 145294# if _LIBCPP_STD_VER >= 14
5291template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>5295template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
5292inline _LIBCPP_HIDE_FROM_ABI bool5296inline _LIBCPP_HIDE_FROM_ABI bool
5293regex_match(const basic_string<_CharT, _ST, _SA>&& __s,5297regex_match(const basic_string<_CharT, _ST, _SA>&& __s,
5294 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,5298 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
5295 const basic_regex<_CharT, _Traits>& __e,5299 const basic_regex<_CharT, _Traits>& __e,
5296 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;5300 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
5297#endif5301# endif
52985302
5299template <class _CharT, class _Traits>5303template <class _CharT, class _Traits>
5300inline _LIBCPP_HIDE_FROM_ABI bool5304inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -5321,10 +5325,10 @@ class _LIBCPP_TEMPLATE_VIS regex_iterator;...@@ -5321,10 +5325,10 @@ class _LIBCPP_TEMPLATE_VIS regex_iterator;
53215325
5322typedef regex_iterator<const char*> cregex_iterator;5326typedef regex_iterator<const char*> cregex_iterator;
5323typedef regex_iterator<string::const_iterator> sregex_iterator;5327typedef regex_iterator<string::const_iterator> sregex_iterator;
5324#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS5328# if _LIBCPP_HAS_WIDE_CHARACTERS
5325typedef regex_iterator<const wchar_t*> wcregex_iterator;5329typedef regex_iterator<const wchar_t*> wcregex_iterator;
5326typedef regex_iterator<wstring::const_iterator> wsregex_iterator;5330typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
5327#endif5331# endif
53285332
5329template <class _BidirectionalIterator, class _CharT, class _Traits>5333template <class _BidirectionalIterator, class _CharT, class _Traits>
5330class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_iterator)5334class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_iterator)
...@@ -5337,9 +5341,9 @@ public:...@@ -5337,9 +5341,9 @@ public:
5337 typedef const value_type* pointer;5341 typedef const value_type* pointer;
5338 typedef const value_type& reference;5342 typedef const value_type& reference;
5339 typedef forward_iterator_tag iterator_category;5343 typedef forward_iterator_tag iterator_category;
5340#if _LIBCPP_STD_VER >= 205344# if _LIBCPP_STD_VER >= 20
5341 typedef input_iterator_tag iterator_concept;5345 typedef input_iterator_tag iterator_concept;
5342#endif5346# endif
53435347
5344private:5348private:
5345 _BidirectionalIterator __begin_;5349 _BidirectionalIterator __begin_;
...@@ -5354,20 +5358,20 @@ public:...@@ -5354,20 +5358,20 @@ public:
5354 _BidirectionalIterator __b,5358 _BidirectionalIterator __b,
5355 const regex_type& __re,5359 const regex_type& __re,
5356 regex_constants::match_flag_type __m = regex_constants::match_default);5360 regex_constants::match_flag_type __m = regex_constants::match_default);
5357#if _LIBCPP_STD_VER >= 145361# if _LIBCPP_STD_VER >= 14
5358 regex_iterator(_BidirectionalIterator __a,5362 regex_iterator(_BidirectionalIterator __a,
5359 _BidirectionalIterator __b,5363 _BidirectionalIterator __b,
5360 const regex_type&& __re,5364 const regex_type&& __re,
5361 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;5365 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;
5362#endif5366# endif
53635367
5364 _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_iterator& __x) const;5368 _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_iterator& __x) const;
5365#if _LIBCPP_STD_VER >= 205369# if _LIBCPP_STD_VER >= 20
5366 _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_iterator(); }5370 _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_iterator(); }
5367#endif5371# endif
5368#if _LIBCPP_STD_VER < 205372# if _LIBCPP_STD_VER < 20
5369 _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_iterator& __x) const { return !(*this == __x); }5373 _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_iterator& __x) const { return !(*this == __x); }
5370#endif5374# endif
53715375
5372 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __match_; }5376 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __match_; }
5373 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return std::addressof(__match_); }5377 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return std::addressof(__match_); }
...@@ -5451,10 +5455,10 @@ class _LIBCPP_TEMPLATE_VIS regex_token_iterator;...@@ -5451,10 +5455,10 @@ class _LIBCPP_TEMPLATE_VIS regex_token_iterator;
54515455
5452typedef regex_token_iterator<const char*> cregex_token_iterator;5456typedef regex_token_iterator<const char*> cregex_token_iterator;
5453typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;5457typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
5454#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS5458# if _LIBCPP_HAS_WIDE_CHARACTERS
5455typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;5459typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
5456typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;5460typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
5457#endif5461# endif
54585462
5459template <class _BidirectionalIterator, class _CharT, class _Traits>5463template <class _BidirectionalIterator, class _CharT, class _Traits>
5460class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_token_iterator)5464class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_token_iterator)
...@@ -5468,9 +5472,9 @@ public:...@@ -5468,9 +5472,9 @@ public:
5468 typedef const value_type* pointer;5472 typedef const value_type* pointer;
5469 typedef const value_type& reference;5473 typedef const value_type& reference;
5470 typedef forward_iterator_tag iterator_category;5474 typedef forward_iterator_tag iterator_category;
5471#if _LIBCPP_STD_VER >= 205475# if _LIBCPP_STD_VER >= 20
5472 typedef input_iterator_tag iterator_concept;5476 typedef input_iterator_tag iterator_concept;
5473#endif5477# endif
54745478
5475private:5479private:
5476 typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position;5480 typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position;
...@@ -5488,69 +5492,67 @@ public:...@@ -5488,69 +5492,67 @@ public:
5488 const regex_type& __re,5492 const regex_type& __re,
5489 int __submatch = 0,5493 int __submatch = 0,
5490 regex_constants::match_flag_type __m = regex_constants::match_default);5494 regex_constants::match_flag_type __m = regex_constants::match_default);
5491#if _LIBCPP_STD_VER >= 145495# if _LIBCPP_STD_VER >= 14
5492 regex_token_iterator(_BidirectionalIterator __a,5496 regex_token_iterator(_BidirectionalIterator __a,
5493 _BidirectionalIterator __b,5497 _BidirectionalIterator __b,
5494 const regex_type&& __re,5498 const regex_type&& __re,
5495 int __submatch = 0,5499 int __submatch = 0,
5496 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;5500 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;
5497#endif5501# endif
54985502
5499 regex_token_iterator(_BidirectionalIterator __a,5503 regex_token_iterator(_BidirectionalIterator __a,
5500 _BidirectionalIterator __b,5504 _BidirectionalIterator __b,
5501 const regex_type& __re,5505 const regex_type& __re,
5502 const vector<int>& __submatches,5506 const vector<int>& __submatches,
5503 regex_constants::match_flag_type __m = regex_constants::match_default);5507 regex_constants::match_flag_type __m = regex_constants::match_default);
5504#if _LIBCPP_STD_VER >= 145508# if _LIBCPP_STD_VER >= 14
5505 regex_token_iterator(_BidirectionalIterator __a,5509 regex_token_iterator(_BidirectionalIterator __a,
5506 _BidirectionalIterator __b,5510 _BidirectionalIterator __b,
5507 const regex_type&& __re,5511 const regex_type&& __re,
5508 const vector<int>& __submatches,5512 const vector<int>& __submatches,
5509 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;5513 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;
5510#endif5514# endif
55115515
5512#ifndef _LIBCPP_CXX03_LANG5516# ifndef _LIBCPP_CXX03_LANG
5513 regex_token_iterator(_BidirectionalIterator __a,5517 regex_token_iterator(_BidirectionalIterator __a,
5514 _BidirectionalIterator __b,5518 _BidirectionalIterator __b,
5515 const regex_type& __re,5519 const regex_type& __re,
5516 initializer_list<int> __submatches,5520 initializer_list<int> __submatches,
5517 regex_constants::match_flag_type __m = regex_constants::match_default);5521 regex_constants::match_flag_type __m = regex_constants::match_default);
55185522
5519# if _LIBCPP_STD_VER >= 145523# if _LIBCPP_STD_VER >= 14
5520 regex_token_iterator(_BidirectionalIterator __a,5524 regex_token_iterator(_BidirectionalIterator __a,
5521 _BidirectionalIterator __b,5525 _BidirectionalIterator __b,
5522 const regex_type&& __re,5526 const regex_type&& __re,
5523 initializer_list<int> __submatches,5527 initializer_list<int> __submatches,
5524 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;5528 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;
5525# endif5529# endif
5526#endif // _LIBCPP_CXX03_LANG5530# endif // _LIBCPP_CXX03_LANG
5527 template <size_t _Np>5531 template <size_t _Np>
5528 regex_token_iterator(_BidirectionalIterator __a,5532 regex_token_iterator(_BidirectionalIterator __a,
5529 _BidirectionalIterator __b,5533 _BidirectionalIterator __b,
5530 const regex_type& __re,5534 const regex_type& __re,
5531 const int (&__submatches)[_Np],5535 const int (&__submatches)[_Np],
5532 regex_constants::match_flag_type __m = regex_constants::match_default);5536 regex_constants::match_flag_type __m = regex_constants::match_default);
5533#if _LIBCPP_STD_VER >= 145537# if _LIBCPP_STD_VER >= 14
5534 template <size_t _Np>5538 template <size_t _Np>
5535 regex_token_iterator(_BidirectionalIterator __a,5539 regex_token_iterator(_BidirectionalIterator __a,
5536 _BidirectionalIterator __b,5540 _BidirectionalIterator __b,
5537 const regex_type&& __re,5541 const regex_type&& __re,
5538 const int (&__submatches)[_Np],5542 const int (&__submatches)[_Np],
5539 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;5543 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;
5540#endif5544# endif
55415545
5542 regex_token_iterator(const regex_token_iterator&);5546 regex_token_iterator(const regex_token_iterator&);
5543 regex_token_iterator& operator=(const regex_token_iterator&);5547 regex_token_iterator& operator=(const regex_token_iterator&);
55445548
5545 _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_token_iterator& __x) const;5549 _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_token_iterator& __x) const;
5546#if _LIBCPP_STD_VER >= 205550# if _LIBCPP_STD_VER >= 20
5547 _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const {5551 _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_token_iterator(); }
5548 return *this == regex_token_iterator();5552# endif
5549 }5553# if _LIBCPP_STD_VER < 20
5550#endif
5551#if _LIBCPP_STD_VER < 20
5552 _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_token_iterator& __x) const { return !(*this == __x); }5554 _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_token_iterator& __x) const { return !(*this == __x); }
5553#endif5555# endif
55545556
5555 _LIBCPP_HIDE_FROM_ABI const value_type& operator*() const { return *__result_; }5557 _LIBCPP_HIDE_FROM_ABI const value_type& operator*() const { return *__result_; }
5556 _LIBCPP_HIDE_FROM_ABI const value_type* operator->() const { return __result_; }5558 _LIBCPP_HIDE_FROM_ABI const value_type* operator->() const { return __result_; }
...@@ -5612,7 +5614,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera...@@ -5612,7 +5614,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera
5612 __init(__a, __b);5614 __init(__a, __b);
5613}5615}
56145616
5615#ifndef _LIBCPP_CXX03_LANG5617# ifndef _LIBCPP_CXX03_LANG
56165618
5617template <class _BidirectionalIterator, class _CharT, class _Traits>5619template <class _BidirectionalIterator, class _CharT, class _Traits>
5618regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator(5620regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator(
...@@ -5625,7 +5627,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera...@@ -5625,7 +5627,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera
5625 __init(__a, __b);5627 __init(__a, __b);
5626}5628}
56275629
5628#endif // _LIBCPP_CXX03_LANG5630# endif // _LIBCPP_CXX03_LANG
56295631
5630template <class _BidirectionalIterator, class _CharT, class _Traits>5632template <class _BidirectionalIterator, class _CharT, class _Traits>
5631template <size_t _Np>5633template <size_t _Np>
...@@ -5800,7 +5802,7 @@ regex_replace(const _CharT* __s,...@@ -5800,7 +5802,7 @@ regex_replace(const _CharT* __s,
58005802
5801_LIBCPP_END_NAMESPACE_STD5803_LIBCPP_END_NAMESPACE_STD
58025804
5803#if _LIBCPP_STD_VER >= 175805# if _LIBCPP_STD_VER >= 17
5804_LIBCPP_BEGIN_NAMESPACE_STD5806_LIBCPP_BEGIN_NAMESPACE_STD
5805namespace pmr {5807namespace pmr {
5806template <class _BidirT>5808template <class _BidirT>
...@@ -5810,27 +5812,28 @@ using match_results _LIBCPP_AVAILABILITY_PMR =...@@ -5810,27 +5812,28 @@ using match_results _LIBCPP_AVAILABILITY_PMR =
5810using cmatch _LIBCPP_AVAILABILITY_PMR = match_results<const char*>;5812using cmatch _LIBCPP_AVAILABILITY_PMR = match_results<const char*>;
5811using smatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::string::const_iterator>;5813using smatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::string::const_iterator>;
58125814
5813# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS5815# if _LIBCPP_HAS_WIDE_CHARACTERS
5814using wcmatch _LIBCPP_AVAILABILITY_PMR = match_results<const wchar_t*>;5816using wcmatch _LIBCPP_AVAILABILITY_PMR = match_results<const wchar_t*>;
5815using wsmatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::wstring::const_iterator>;5817using wsmatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::wstring::const_iterator>;
5816# endif5818# endif
5817} // namespace pmr5819} // namespace pmr
5818_LIBCPP_END_NAMESPACE_STD5820_LIBCPP_END_NAMESPACE_STD
5819#endif5821# endif
58205822
5821_LIBCPP_POP_MACROS5823_LIBCPP_POP_MACROS
58225824
5823#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 205825# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
5824# include <atomic>5826# include <atomic>
5825# include <concepts>5827# include <concepts>
5826# include <cstdlib>5828# include <cstdlib>
5827# include <iosfwd>5829# include <iosfwd>
5828# include <iterator>5830# include <iterator>
5829# include <mutex>5831# include <mutex>
5830# include <new>5832# include <new>
5831# include <type_traits>5833# include <type_traits>
5832# include <typeinfo>5834# include <typeinfo>
5833# include <utility>5835# include <utility>
5834#endif5836# endif
5837#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
58355838
5836#endif // _LIBCPP_REGEX5839#endif // _LIBCPP_REGEX
lib/libcxx/include/scoped_allocator+48-44
...@@ -109,32 +109,35 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>...@@ -109,32 +109,35 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
109109
110*/110*/
111111
112#include <__config>112#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
113#include <__memory/allocator_traits.h>113# include <__cxx03/scoped_allocator>
114#include <__memory/uses_allocator_construction.h>114#else
115#include <__type_traits/common_type.h>115# include <__config>
116#include <__type_traits/enable_if.h>116# include <__memory/allocator_traits.h>
117#include <__type_traits/integral_constant.h>117# include <__memory/uses_allocator_construction.h>
118#include <__type_traits/is_constructible.h>118# include <__type_traits/common_type.h>
119#include <__type_traits/remove_reference.h>119# include <__type_traits/enable_if.h>
120#include <__utility/declval.h>120# include <__type_traits/integral_constant.h>
121#include <__utility/forward.h>121# include <__type_traits/is_constructible.h>
122#include <__utility/move.h>122# include <__type_traits/remove_reference.h>
123#include <__utility/pair.h>123# include <__utility/declval.h>
124#include <__utility/piecewise_construct.h>124# include <__utility/forward.h>
125#include <tuple>125# include <__utility/move.h>
126#include <version>126# include <__utility/pair.h>
127127# include <__utility/piecewise_construct.h>
128#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)128# include <tuple>
129# pragma GCC system_header129# include <version>
130#endif130
131# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
132# pragma GCC system_header
133# endif
131134
132_LIBCPP_PUSH_MACROS135_LIBCPP_PUSH_MACROS
133#include <__undef_macros>136# include <__undef_macros>
134137
135_LIBCPP_BEGIN_NAMESPACE_STD138_LIBCPP_BEGIN_NAMESPACE_STD
136139
137#if !defined(_LIBCPP_CXX03_LANG)140# if !defined(_LIBCPP_CXX03_LANG)
138141
139// scoped_allocator_adaptor142// scoped_allocator_adaptor
140143
...@@ -389,10 +392,10 @@ public:...@@ -389,10 +392,10 @@ public:
389 return _Base::outer_allocator();392 return _Base::outer_allocator();
390 }393 }
391394
392 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n) {395 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n) {
393 return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n);396 return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n);
394 }397 }
395 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, const_void_pointer __hint) {398 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, const_void_pointer __hint) {
396 return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n, __hint);399 return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n, __hint);
397 }400 }
398401
...@@ -404,7 +407,7 @@ public:...@@ -404,7 +407,7 @@ public:
404 return allocator_traits<outer_allocator_type>::max_size(outer_allocator());407 return allocator_traits<outer_allocator_type>::max_size(outer_allocator());
405 }408 }
406409
407# if _LIBCPP_STD_VER >= 20410# if _LIBCPP_STD_VER >= 20
408 template <class _Type, class... _Args>411 template <class _Type, class... _Args>
409 _LIBCPP_HIDE_FROM_ABI void construct(_Type* __ptr, _Args&&... __args) {412 _LIBCPP_HIDE_FROM_ABI void construct(_Type* __ptr, _Args&&... __args) {
410 using _OM = __outermost<outer_allocator_type>;413 using _OM = __outermost<outer_allocator_type>;
...@@ -415,7 +418,7 @@ public:...@@ -415,7 +418,7 @@ public:
415 },418 },
416 std::uses_allocator_construction_args<_Type>(inner_allocator(), std::forward<_Args>(__args)...));419 std::uses_allocator_construction_args<_Type>(inner_allocator(), std::forward<_Args>(__args)...));
417 }420 }
418# else421# else
419 template <class _Tp, class... _Args>422 template <class _Tp, class... _Args>
420 _LIBCPP_HIDE_FROM_ABI void construct(_Tp* __p, _Args&&... __args) {423 _LIBCPP_HIDE_FROM_ABI void construct(_Tp* __p, _Args&&... __args) {
421 __construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(), __p, std::forward<_Args>(__args)...);424 __construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(), __p, std::forward<_Args>(__args)...);
...@@ -462,7 +465,7 @@ public:...@@ -462,7 +465,7 @@ public:
462 std::forward_as_tuple(std::forward<_Up>(__x.first)),465 std::forward_as_tuple(std::forward<_Up>(__x.first)),
463 std::forward_as_tuple(std::forward<_Vp>(__x.second)));466 std::forward_as_tuple(std::forward<_Vp>(__x.second)));
464 }467 }
465# endif468# endif
466469
467 template <class _Tp>470 template <class _Tp>
468 _LIBCPP_HIDE_FROM_ABI void destroy(_Tp* __p) {471 _LIBCPP_HIDE_FROM_ABI void destroy(_Tp* __p) {
...@@ -522,10 +525,10 @@ private:...@@ -522,10 +525,10 @@ private:
522 friend class __scoped_allocator_storage;525 friend class __scoped_allocator_storage;
523};526};
524527
525# if _LIBCPP_STD_VER >= 17528# if _LIBCPP_STD_VER >= 17
526template <class _OuterAlloc, class... _InnerAllocs>529template <class _OuterAlloc, class... _InnerAllocs>
527scoped_allocator_adaptor(_OuterAlloc, _InnerAllocs...) -> scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>;530scoped_allocator_adaptor(_OuterAlloc, _InnerAllocs...) -> scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>;
528# endif531# endif
529532
530template <class _OuterA1, class _OuterA2>533template <class _OuterA1, class _OuterA2>
531inline _LIBCPP_HIDE_FROM_ABI bool534inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -540,7 +543,7 @@ operator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>&...@@ -540,7 +543,7 @@ operator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>&
540 return __a.outer_allocator() == __b.outer_allocator() && __a.inner_allocator() == __b.inner_allocator();543 return __a.outer_allocator() == __b.outer_allocator() && __a.inner_allocator() == __b.inner_allocator();
541}544}
542545
543# if _LIBCPP_STD_VER <= 17546# if _LIBCPP_STD_VER <= 17
544547
545template <class _OuterA1, class _OuterA2, class... _InnerAllocs>548template <class _OuterA1, class _OuterA2, class... _InnerAllocs>
546inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,549inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
...@@ -548,26 +551,27 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const scoped_allocator_adaptor<_Out...@@ -548,26 +551,27 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const scoped_allocator_adaptor<_Out
548 return !(__a == __b);551 return !(__a == __b);
549}552}
550553
551# endif // _LIBCPP_STD_VER <= 17554# endif // _LIBCPP_STD_VER <= 17
552555
553#endif // !defined(_LIBCPP_CXX03_LANG)556# endif // !defined(_LIBCPP_CXX03_LANG)
554557
555_LIBCPP_END_NAMESPACE_STD558_LIBCPP_END_NAMESPACE_STD
556559
557_LIBCPP_POP_MACROS560_LIBCPP_POP_MACROS
558561
559#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20562# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
560# include <atomic>563# include <atomic>
561# include <climits>564# include <climits>
562# include <concepts>565# include <concepts>
563# include <cstring>566# include <cstring>
564# include <ctime>567# include <ctime>
565# include <iterator>568# include <iterator>
566# include <memory>569# include <memory>
567# include <ratio>570# include <ratio>
568# include <stdexcept>571# include <stdexcept>
569# include <type_traits>572# include <type_traits>
570# include <variant>573# include <variant>
571#endif574# endif
575#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
572576
573#endif // _LIBCPP_SCOPED_ALLOCATOR577#endif // _LIBCPP_SCOPED_ALLOCATOR
lib/libcxx/include/semaphore+41-37
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16namespace std {16namespace std {
1717
18template<ptrdiff_t least_max_value = implementation-defined>18template<ptrdiff_t least_max_value = implementation-defined>
19class counting_semaphore19class counting_semaphore // since C++20
20{20{
21public:21public:
22static constexpr ptrdiff_t max() noexcept;22static constexpr ptrdiff_t max() noexcept;
...@@ -39,36 +39,39 @@ private:...@@ -39,36 +39,39 @@ private:
39ptrdiff_t counter; // exposition only39ptrdiff_t counter; // exposition only
40};40};
4141
42using binary_semaphore = counting_semaphore<1>;42using binary_semaphore = counting_semaphore<1>; // since C++20
4343
44}44}
4545
46*/46*/
4747
48#include <__config>48#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
4949# include <__cxx03/semaphore>
50#if !defined(_LIBCPP_HAS_NO_THREADS)50#else
5151# include <__config>
52# include <__assert>52
53# include <__atomic/atomic_base.h>53# if _LIBCPP_HAS_THREADS
54# include <__atomic/atomic_sync.h>54
55# include <__atomic/memory_order.h>55# include <__assert>
56# include <__chrono/time_point.h>56# include <__atomic/atomic.h>
57# include <__thread/poll_with_backoff.h>57# include <__atomic/atomic_sync.h>
58# include <__thread/support.h>58# include <__atomic/memory_order.h>
59# include <__thread/timed_backoff_policy.h>59# include <__chrono/time_point.h>
60# include <cstddef>60# include <__cstddef/ptrdiff_t.h>
61# include <limits>61# include <__thread/poll_with_backoff.h>
62# include <version>62# include <__thread/support.h>
6363# include <__thread/timed_backoff_policy.h>
64# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)64# include <limits>
65# pragma GCC system_header65# include <version>
66# endif66
67# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
68# pragma GCC system_header
69# endif
6770
68_LIBCPP_PUSH_MACROS71_LIBCPP_PUSH_MACROS
69# include <__undef_macros>72# include <__undef_macros>
7073
71# if _LIBCPP_STD_VER >= 1474# if _LIBCPP_STD_VER >= 20
7275
73_LIBCPP_BEGIN_NAMESPACE_STD76_LIBCPP_BEGIN_NAMESPACE_STD
7477
...@@ -80,10 +83,10 @@ functions. It avoids contention against users' own use of those facilities....@@ -80,10 +83,10 @@ functions. It avoids contention against users' own use of those facilities.
8083
81*/84*/
8285
83# define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max())86# define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max())
8487
85class __atomic_semaphore_base {88class __atomic_semaphore_base {
86 __atomic_base<ptrdiff_t> __a_;89 atomic<ptrdiff_t> __a_;
8790
88public:91public:
89 _LIBCPP_HIDE_FROM_ABI constexpr explicit __atomic_semaphore_base(ptrdiff_t __count) : __a_(__count) {}92 _LIBCPP_HIDE_FROM_ABI constexpr explicit __atomic_semaphore_base(ptrdiff_t __count) : __a_(__count) {}
...@@ -96,8 +99,9 @@ public:...@@ -96,8 +99,9 @@ public:
96 }99 }
97 }100 }
98 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void acquire() {101 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void acquire() {
99 std::__atomic_wait_unless(102 std::__atomic_wait_unless(__a_, memory_order_relaxed, [this](ptrdiff_t& __old) {
100 __a_, [this](ptrdiff_t& __old) { return __try_acquire_impl(__old); }, memory_order_relaxed);103 return __try_acquire_impl(__old);
104 });
101 }105 }
102 template <class _Rep, class _Period>106 template <class _Rep, class _Period>
103 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool107 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool
...@@ -124,7 +128,7 @@ private:...@@ -124,7 +128,7 @@ private:
124};128};
125129
126template <ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX>130template <ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX>
127class _LIBCPP_DEPRECATED_ATOMIC_SYNC counting_semaphore {131class counting_semaphore {
128 __atomic_semaphore_base __semaphore_;132 __atomic_semaphore_base __semaphore_;
129133
130public:134public:
...@@ -169,20 +173,20 @@ public:...@@ -169,20 +173,20 @@ public:
169 }173 }
170};174};
171175
172_LIBCPP_SUPPRESS_DEPRECATED_PUSH176using binary_semaphore = counting_semaphore<1>;
173using binary_semaphore _LIBCPP_DEPRECATED_ATOMIC_SYNC = counting_semaphore<1>;
174_LIBCPP_SUPPRESS_DEPRECATED_POP
175177
176_LIBCPP_END_NAMESPACE_STD178_LIBCPP_END_NAMESPACE_STD
177179
178# endif // _LIBCPP_STD_VER >= 14180# endif // _LIBCPP_STD_VER >= 20
179181
180_LIBCPP_POP_MACROS182_LIBCPP_POP_MACROS
181183
182#endif // !defined(_LIBCPP_HAS_NO_THREADS)184# endif // _LIBCPP_HAS_THREADS
183185
184#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20186# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
185# include <atomic>187# include <atomic>
186#endif188# include <cstddef>
189# endif
190#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
187191
188#endif //_LIBCPP_SEMAPHORE192#endif // _LIBCPP_SEMAPHORE
lib/libcxx/include/set+167-138
...@@ -512,47 +512,60 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20...@@ -512,47 +512,60 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
512512
513*/513*/
514514
515#include <__algorithm/equal.h>515#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
516#include <__algorithm/lexicographical_compare.h>516# include <__cxx03/set>
517#include <__algorithm/lexicographical_compare_three_way.h>517#else
518#include <__assert>518# include <__algorithm/equal.h>
519#include <__config>519# include <__algorithm/lexicographical_compare.h>
520#include <__functional/is_transparent.h>520# include <__algorithm/lexicographical_compare_three_way.h>
521#include <__functional/operations.h>521# include <__assert>
522#include <__iterator/erase_if_container.h>522# include <__config>
523#include <__iterator/iterator_traits.h>523# include <__functional/is_transparent.h>
524#include <__iterator/ranges_iterator_traits.h>524# include <__functional/operations.h>
525#include <__iterator/reverse_iterator.h>525# include <__iterator/erase_if_container.h>
526#include <__memory/allocator.h>526# include <__iterator/iterator_traits.h>
527#include <__memory_resource/polymorphic_allocator.h>527# include <__iterator/ranges_iterator_traits.h>
528#include <__node_handle>528# include <__iterator/reverse_iterator.h>
529#include <__ranges/concepts.h>529# include <__memory/allocator.h>
530#include <__ranges/container_compatible_range.h>530# include <__memory/allocator_traits.h>
531#include <__ranges/from_range.h>531# include <__memory_resource/polymorphic_allocator.h>
532#include <__tree>532# include <__node_handle>
533#include <__type_traits/is_allocator.h>533# include <__ranges/concepts.h>
534#include <__utility/forward.h>534# include <__ranges/container_compatible_range.h>
535#include <version>535# include <__ranges/from_range.h>
536# include <__tree>
537# include <__type_traits/container_traits.h>
538# include <__type_traits/enable_if.h>
539# include <__type_traits/is_allocator.h>
540# include <__type_traits/is_nothrow_assignable.h>
541# include <__type_traits/is_nothrow_constructible.h>
542# include <__type_traits/is_same.h>
543# include <__type_traits/is_swappable.h>
544# include <__type_traits/type_identity.h>
545# include <__utility/forward.h>
546# include <__utility/move.h>
547# include <__utility/pair.h>
548# include <version>
536549
537// standard-mandated includes550// standard-mandated includes
538551
539// [iterator.range]552// [iterator.range]
540#include <__iterator/access.h>553# include <__iterator/access.h>
541#include <__iterator/data.h>554# include <__iterator/data.h>
542#include <__iterator/empty.h>555# include <__iterator/empty.h>
543#include <__iterator/reverse_access.h>556# include <__iterator/reverse_access.h>
544#include <__iterator/size.h>557# include <__iterator/size.h>
545558
546// [associative.set.syn]559// [associative.set.syn]
547#include <compare>560# include <compare>
548#include <initializer_list>561# include <initializer_list>
549562
550#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)563# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
551# pragma GCC system_header564# pragma GCC system_header
552#endif565# endif
553566
554_LIBCPP_PUSH_MACROS567_LIBCPP_PUSH_MACROS
555#include <__undef_macros>568# include <__undef_macros>
556569
557_LIBCPP_BEGIN_NAMESPACE_STD570_LIBCPP_BEGIN_NAMESPACE_STD
558571
...@@ -592,10 +605,10 @@ public:...@@ -592,10 +605,10 @@ public:
592 typedef std::reverse_iterator<iterator> reverse_iterator;605 typedef std::reverse_iterator<iterator> reverse_iterator;
593 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;606 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
594607
595#if _LIBCPP_STD_VER >= 17608# if _LIBCPP_STD_VER >= 17
596 typedef __set_node_handle<typename __base::__node, allocator_type> node_type;609 typedef __set_node_handle<typename __base::__node, allocator_type> node_type;
597 typedef __insert_return_type<iterator, node_type> insert_return_type;610 typedef __insert_return_type<iterator, node_type> insert_return_type;
598#endif611# endif
599612
600 template <class _Key2, class _Compare2, class _Alloc2>613 template <class _Key2, class _Compare2, class _Alloc2>
601 friend class _LIBCPP_TEMPLATE_VIS set;614 friend class _LIBCPP_TEMPLATE_VIS set;
...@@ -625,7 +638,7 @@ public:...@@ -625,7 +638,7 @@ public:
625 insert(__f, __l);638 insert(__f, __l);
626 }639 }
627640
628#if _LIBCPP_STD_VER >= 23641# if _LIBCPP_STD_VER >= 23
629 template <_ContainerCompatibleRange<value_type> _Range>642 template <_ContainerCompatibleRange<value_type> _Range>
630 _LIBCPP_HIDE_FROM_ABI643 _LIBCPP_HIDE_FROM_ABI
631 set(from_range_t,644 set(from_range_t,
...@@ -635,19 +648,19 @@ public:...@@ -635,19 +648,19 @@ public:
635 : __tree_(__comp, __a) {648 : __tree_(__comp, __a) {
636 insert_range(std::forward<_Range>(__range));649 insert_range(std::forward<_Range>(__range));
637 }650 }
638#endif651# endif
639652
640#if _LIBCPP_STD_VER >= 14653# if _LIBCPP_STD_VER >= 14
641 template <class _InputIterator>654 template <class _InputIterator>
642 _LIBCPP_HIDE_FROM_ABI set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)655 _LIBCPP_HIDE_FROM_ABI set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
643 : set(__f, __l, key_compare(), __a) {}656 : set(__f, __l, key_compare(), __a) {}
644#endif657# endif
645658
646#if _LIBCPP_STD_VER >= 23659# if _LIBCPP_STD_VER >= 23
647 template <_ContainerCompatibleRange<value_type> _Range>660 template <_ContainerCompatibleRange<value_type> _Range>
648 _LIBCPP_HIDE_FROM_ABI set(from_range_t, _Range&& __range, const allocator_type& __a)661 _LIBCPP_HIDE_FROM_ABI set(from_range_t, _Range&& __range, const allocator_type& __a)
649 : set(from_range, std::forward<_Range>(__range), key_compare(), __a) {}662 : set(from_range, std::forward<_Range>(__range), key_compare(), __a) {}
650#endif663# endif
651664
652 _LIBCPP_HIDE_FROM_ABI set(const set& __s) : __tree_(__s.__tree_) { insert(__s.begin(), __s.end()); }665 _LIBCPP_HIDE_FROM_ABI set(const set& __s) : __tree_(__s.__tree_) { insert(__s.begin(), __s.end()); }
653666
...@@ -656,10 +669,10 @@ public:...@@ -656,10 +669,10 @@ public:
656 return *this;669 return *this;
657 }670 }
658671
659#ifndef _LIBCPP_CXX03_LANG672# ifndef _LIBCPP_CXX03_LANG
660 _LIBCPP_HIDE_FROM_ABI set(set&& __s) noexcept(is_nothrow_move_constructible<__base>::value)673 _LIBCPP_HIDE_FROM_ABI set(set&& __s) noexcept(is_nothrow_move_constructible<__base>::value)
661 : __tree_(std::move(__s.__tree_)) {}674 : __tree_(std::move(__s.__tree_)) {}
662#endif // _LIBCPP_CXX03_LANG675# endif // _LIBCPP_CXX03_LANG
663676
664 _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {}677 _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {}
665678
...@@ -667,7 +680,7 @@ public:...@@ -667,7 +680,7 @@ public:
667 insert(__s.begin(), __s.end());680 insert(__s.begin(), __s.end());
668 }681 }
669682
670#ifndef _LIBCPP_CXX03_LANG683# ifndef _LIBCPP_CXX03_LANG
671 _LIBCPP_HIDE_FROM_ABI set(set&& __s, const allocator_type& __a);684 _LIBCPP_HIDE_FROM_ABI set(set&& __s, const allocator_type& __a);
672685
673 _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())686 _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
...@@ -680,10 +693,10 @@ public:...@@ -680,10 +693,10 @@ public:
680 insert(__il.begin(), __il.end());693 insert(__il.begin(), __il.end());
681 }694 }
682695
683# if _LIBCPP_STD_VER >= 14696# if _LIBCPP_STD_VER >= 14
684 _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const allocator_type& __a)697 _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const allocator_type& __a)
685 : set(__il, key_compare(), __a) {}698 : set(__il, key_compare(), __a) {}
686# endif699# endif
687700
688 _LIBCPP_HIDE_FROM_ABI set& operator=(initializer_list<value_type> __il) {701 _LIBCPP_HIDE_FROM_ABI set& operator=(initializer_list<value_type> __il) {
689 __tree_.__assign_unique(__il.begin(), __il.end());702 __tree_.__assign_unique(__il.begin(), __il.end());
...@@ -694,7 +707,7 @@ public:...@@ -694,7 +707,7 @@ public:
694 __tree_ = std::move(__s.__tree_);707 __tree_ = std::move(__s.__tree_);
695 return *this;708 return *this;
696 }709 }
697#endif // _LIBCPP_CXX03_LANG710# endif // _LIBCPP_CXX03_LANG
698711
699 _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); }712 _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); }
700713
...@@ -713,12 +726,12 @@ public:...@@ -713,12 +726,12 @@ public:
713 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }726 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
714 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }727 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
715728
716 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }729 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
717 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }730 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
718 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }731 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
719732
720 // modifiers:733 // modifiers:
721#ifndef _LIBCPP_CXX03_LANG734# ifndef _LIBCPP_CXX03_LANG
722 template <class... _Args>735 template <class... _Args>
723 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {736 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {
724 return __tree_.__emplace_unique(std::forward<_Args>(__args)...);737 return __tree_.__emplace_unique(std::forward<_Args>(__args)...);
...@@ -727,7 +740,7 @@ public:...@@ -727,7 +740,7 @@ public:
727 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {740 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {
728 return __tree_.__emplace_hint_unique(__p, std::forward<_Args>(__args)...);741 return __tree_.__emplace_hint_unique(__p, std::forward<_Args>(__args)...);
729 }742 }
730#endif // _LIBCPP_CXX03_LANG743# endif // _LIBCPP_CXX03_LANG
731744
732 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); }745 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); }
733 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {746 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {
...@@ -740,7 +753,7 @@ public:...@@ -740,7 +753,7 @@ public:
740 __tree_.__insert_unique(__e, *__f);753 __tree_.__insert_unique(__e, *__f);
741 }754 }
742755
743#if _LIBCPP_STD_VER >= 23756# if _LIBCPP_STD_VER >= 23
744 template <_ContainerCompatibleRange<value_type> _Range>757 template <_ContainerCompatibleRange<value_type> _Range>
745 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {758 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
746 const_iterator __end = cend();759 const_iterator __end = cend();
...@@ -748,9 +761,9 @@ public:...@@ -748,9 +761,9 @@ public:
748 __tree_.__insert_unique(__end, std::forward<decltype(__element)>(__element));761 __tree_.__insert_unique(__end, std::forward<decltype(__element)>(__element));
749 }762 }
750 }763 }
751#endif764# endif
752765
753#ifndef _LIBCPP_CXX03_LANG766# ifndef _LIBCPP_CXX03_LANG
754 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) {767 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) {
755 return __tree_.__insert_unique(std::move(__v));768 return __tree_.__insert_unique(std::move(__v));
756 }769 }
...@@ -760,14 +773,14 @@ public:...@@ -760,14 +773,14 @@ public:
760 }773 }
761774
762 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }775 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
763#endif // _LIBCPP_CXX03_LANG776# endif // _LIBCPP_CXX03_LANG
764777
765 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); }778 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); }
766 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_unique(__k); }779 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_unique(__k); }
767 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); }780 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); }
768 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }781 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }
769782
770#if _LIBCPP_STD_VER >= 17783# if _LIBCPP_STD_VER >= 17
771 _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {784 _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {
772 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),785 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
773 "node_type with incompatible allocator passed to set::insert()");786 "node_type with incompatible allocator passed to set::insert()");
...@@ -808,7 +821,7 @@ public:...@@ -808,7 +821,7 @@ public:
808 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");821 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
809 __tree_.__node_handle_merge_unique(__source.__tree_);822 __tree_.__node_handle_merge_unique(__source.__tree_);
810 }823 }
811#endif824# endif
812825
813 _LIBCPP_HIDE_FROM_ABI void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__s.__tree_); }826 _LIBCPP_HIDE_FROM_ABI void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__s.__tree_); }
814827
...@@ -819,7 +832,7 @@ public:...@@ -819,7 +832,7 @@ public:
819 // set operations:832 // set operations:
820 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }833 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
821 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }834 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
822#if _LIBCPP_STD_VER >= 14835# if _LIBCPP_STD_VER >= 14
823 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>836 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
824 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {837 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
825 return __tree_.find(__k);838 return __tree_.find(__k);
...@@ -828,27 +841,27 @@ public:...@@ -828,27 +841,27 @@ public:
828 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {841 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
829 return __tree_.find(__k);842 return __tree_.find(__k);
830 }843 }
831#endif844# endif
832845
833 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); }846 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); }
834#if _LIBCPP_STD_VER >= 14847# if _LIBCPP_STD_VER >= 14
835 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>848 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
836 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {849 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
837 return __tree_.__count_multi(__k);850 return __tree_.__count_multi(__k);
838 }851 }
839#endif852# endif
840853
841#if _LIBCPP_STD_VER >= 20854# if _LIBCPP_STD_VER >= 20
842 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }855 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
843 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>856 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
844 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {857 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
845 return find(__k) != end();858 return find(__k) != end();
846 }859 }
847#endif // _LIBCPP_STD_VER >= 20860# endif // _LIBCPP_STD_VER >= 20
848861
849 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }862 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
850 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }863 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
851#if _LIBCPP_STD_VER >= 14864# if _LIBCPP_STD_VER >= 14
852 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>865 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
853 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {866 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
854 return __tree_.lower_bound(__k);867 return __tree_.lower_bound(__k);
...@@ -858,11 +871,11 @@ public:...@@ -858,11 +871,11 @@ public:
858 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {871 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
859 return __tree_.lower_bound(__k);872 return __tree_.lower_bound(__k);
860 }873 }
861#endif874# endif
862875
863 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }876 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
864 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }877 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
865#if _LIBCPP_STD_VER >= 14878# if _LIBCPP_STD_VER >= 14
866 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>879 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
867 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {880 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
868 return __tree_.upper_bound(__k);881 return __tree_.upper_bound(__k);
...@@ -871,7 +884,7 @@ public:...@@ -871,7 +884,7 @@ public:
871 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {884 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
872 return __tree_.upper_bound(__k);885 return __tree_.upper_bound(__k);
873 }886 }
874#endif887# endif
875888
876 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {889 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
877 return __tree_.__equal_range_unique(__k);890 return __tree_.__equal_range_unique(__k);
...@@ -879,7 +892,7 @@ public:...@@ -879,7 +892,7 @@ public:
879 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {892 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
880 return __tree_.__equal_range_unique(__k);893 return __tree_.__equal_range_unique(__k);
881 }894 }
882#if _LIBCPP_STD_VER >= 14895# if _LIBCPP_STD_VER >= 14
883 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>896 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
884 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {897 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
885 return __tree_.__equal_range_multi(__k);898 return __tree_.__equal_range_multi(__k);
...@@ -888,10 +901,10 @@ public:...@@ -888,10 +901,10 @@ public:
888 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {901 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
889 return __tree_.__equal_range_multi(__k);902 return __tree_.__equal_range_multi(__k);
890 }903 }
891#endif904# endif
892};905};
893906
894#if _LIBCPP_STD_VER >= 17907# if _LIBCPP_STD_VER >= 17
895template <class _InputIterator,908template <class _InputIterator,
896 class _Compare = less<__iter_value_type<_InputIterator>>,909 class _Compare = less<__iter_value_type<_InputIterator>>,
897 class _Allocator = allocator<__iter_value_type<_InputIterator>>,910 class _Allocator = allocator<__iter_value_type<_InputIterator>>,
...@@ -901,7 +914,7 @@ template <class _InputIterator,...@@ -901,7 +914,7 @@ template <class _InputIterator,
901set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())914set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
902 -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>;915 -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
903916
904# if _LIBCPP_STD_VER >= 23917# if _LIBCPP_STD_VER >= 23
905template <ranges::input_range _Range,918template <ranges::input_range _Range,
906 class _Compare = less<ranges::range_value_t<_Range>>,919 class _Compare = less<ranges::range_value_t<_Range>>,
907 class _Allocator = allocator<ranges::range_value_t<_Range>>,920 class _Allocator = allocator<ranges::range_value_t<_Range>>,
...@@ -909,7 +922,7 @@ template <ranges::input_range _Range,...@@ -909,7 +922,7 @@ template <ranges::input_range _Range,
909 class = enable_if_t<!__is_allocator<_Compare>::value, void>>922 class = enable_if_t<!__is_allocator<_Compare>::value, void>>
910set(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator())923set(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator())
911 -> set<ranges::range_value_t<_Range>, _Compare, _Allocator>;924 -> set<ranges::range_value_t<_Range>, _Compare, _Allocator>;
912# endif925# endif
913926
914template <class _Key,927template <class _Key,
915 class _Compare = less<_Key>,928 class _Compare = less<_Key>,
...@@ -926,18 +939,18 @@ set(_InputIterator,...@@ -926,18 +939,18 @@ set(_InputIterator,
926 _InputIterator,939 _InputIterator,
927 _Allocator) -> set<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>;940 _Allocator) -> set<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>;
928941
929# if _LIBCPP_STD_VER >= 23942# if _LIBCPP_STD_VER >= 23
930template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>943template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
931set(from_range_t,944set(from_range_t,
932 _Range&&,945 _Range&&,
933 _Allocator) -> set<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;946 _Allocator) -> set<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;
934# endif947# endif
935948
936template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>949template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
937set(initializer_list<_Key>, _Allocator) -> set<_Key, less<_Key>, _Allocator>;950set(initializer_list<_Key>, _Allocator) -> set<_Key, less<_Key>, _Allocator>;
938#endif951# endif
939952
940#ifndef _LIBCPP_CXX03_LANG953# ifndef _LIBCPP_CXX03_LANG
941954
942template <class _Key, class _Compare, class _Allocator>955template <class _Key, class _Compare, class _Allocator>
943set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) : __tree_(std::move(__s.__tree_), __a) {956set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) : __tree_(std::move(__s.__tree_), __a) {
...@@ -948,7 +961,7 @@ set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) : __t...@@ -948,7 +961,7 @@ set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) : __t
948 }961 }
949}962}
950963
951#endif // _LIBCPP_CXX03_LANG964# endif // _LIBCPP_CXX03_LANG
952965
953template <class _Key, class _Compare, class _Allocator>966template <class _Key, class _Compare, class _Allocator>
954inline _LIBCPP_HIDE_FROM_ABI bool967inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -956,7 +969,7 @@ operator==(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,...@@ -956,7 +969,7 @@ operator==(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,
956 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());969 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
957}970}
958971
959#if _LIBCPP_STD_VER <= 17972# if _LIBCPP_STD_VER <= 17
960973
961template <class _Key, class _Compare, class _Allocator>974template <class _Key, class _Compare, class _Allocator>
962inline _LIBCPP_HIDE_FROM_ABI bool975inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -988,7 +1001,7 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,...@@ -988,7 +1001,7 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,
988 return !(__y < __x);1001 return !(__y < __x);
989}1002}
9901003
991#else // _LIBCPP_STD_VER <= 171004# else // _LIBCPP_STD_VER <= 17
9921005
993template <class _Key, class _Allocator>1006template <class _Key, class _Allocator>
994_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>1007_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
...@@ -996,7 +1009,7 @@ operator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y)...@@ -996,7 +1009,7 @@ operator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y)
996 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);1009 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
997}1010}
9981011
999#endif // _LIBCPP_STD_VER <= 171012# endif // _LIBCPP_STD_VER <= 17
10001013
1001// specialized algorithms:1014// specialized algorithms:
1002template <class _Key, class _Compare, class _Allocator>1015template <class _Key, class _Compare, class _Allocator>
...@@ -1005,13 +1018,21 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(set<_Key, _Compare, _Allocator>& __x, set...@@ -1005,13 +1018,21 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(set<_Key, _Compare, _Allocator>& __x, set
1005 __x.swap(__y);1018 __x.swap(__y);
1006}1019}
10071020
1008#if _LIBCPP_STD_VER >= 201021# if _LIBCPP_STD_VER >= 20
1009template <class _Key, class _Compare, class _Allocator, class _Predicate>1022template <class _Key, class _Compare, class _Allocator, class _Predicate>
1010inline _LIBCPP_HIDE_FROM_ABI typename set<_Key, _Compare, _Allocator>::size_type1023inline _LIBCPP_HIDE_FROM_ABI typename set<_Key, _Compare, _Allocator>::size_type
1011erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {1024erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
1012 return std::__libcpp_erase_if_container(__c, __pred);1025 return std::__libcpp_erase_if_container(__c, __pred);
1013}1026}
1014#endif1027# endif
1028
1029template <class _Key, class _Compare, class _Allocator>
1030struct __container_traits<set<_Key, _Compare, _Allocator> > {
1031 // http://eel.is/c++draft/associative.reqmts.except#2
1032 // For associative containers, if an exception is thrown by any operation from within
1033 // an insert or emplace function inserting a single element, the insertion has no effect.
1034 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;
1035};
10151036
1016template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> >1037template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> >
1017class _LIBCPP_TEMPLATE_VIS multiset {1038class _LIBCPP_TEMPLATE_VIS multiset {
...@@ -1046,9 +1067,9 @@ public:...@@ -1046,9 +1067,9 @@ public:
1046 typedef std::reverse_iterator<iterator> reverse_iterator;1067 typedef std::reverse_iterator<iterator> reverse_iterator;
1047 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;1068 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
10481069
1049#if _LIBCPP_STD_VER >= 171070# if _LIBCPP_STD_VER >= 17
1050 typedef __set_node_handle<typename __base::__node, allocator_type> node_type;1071 typedef __set_node_handle<typename __base::__node, allocator_type> node_type;
1051#endif1072# endif
10521073
1053 template <class _Key2, class _Compare2, class _Alloc2>1074 template <class _Key2, class _Compare2, class _Alloc2>
1054 friend class _LIBCPP_TEMPLATE_VIS set;1075 friend class _LIBCPP_TEMPLATE_VIS set;
...@@ -1073,11 +1094,11 @@ public:...@@ -1073,11 +1094,11 @@ public:
1073 insert(__f, __l);1094 insert(__f, __l);
1074 }1095 }
10751096
1076#if _LIBCPP_STD_VER >= 141097# if _LIBCPP_STD_VER >= 14
1077 template <class _InputIterator>1098 template <class _InputIterator>
1078 _LIBCPP_HIDE_FROM_ABI multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)1099 _LIBCPP_HIDE_FROM_ABI multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
1079 : multiset(__f, __l, key_compare(), __a) {}1100 : multiset(__f, __l, key_compare(), __a) {}
1080#endif1101# endif
10811102
1082 template <class _InputIterator>1103 template <class _InputIterator>
1083 _LIBCPP_HIDE_FROM_ABI1104 _LIBCPP_HIDE_FROM_ABI
...@@ -1086,7 +1107,7 @@ public:...@@ -1086,7 +1107,7 @@ public:
1086 insert(__f, __l);1107 insert(__f, __l);
1087 }1108 }
10881109
1089#if _LIBCPP_STD_VER >= 231110# if _LIBCPP_STD_VER >= 23
1090 template <_ContainerCompatibleRange<value_type> _Range>1111 template <_ContainerCompatibleRange<value_type> _Range>
1091 _LIBCPP_HIDE_FROM_ABI1112 _LIBCPP_HIDE_FROM_ABI
1092 multiset(from_range_t,1113 multiset(from_range_t,
...@@ -1100,7 +1121,7 @@ public:...@@ -1100,7 +1121,7 @@ public:
1100 template <_ContainerCompatibleRange<value_type> _Range>1121 template <_ContainerCompatibleRange<value_type> _Range>
1101 _LIBCPP_HIDE_FROM_ABI multiset(from_range_t, _Range&& __range, const allocator_type& __a)1122 _LIBCPP_HIDE_FROM_ABI multiset(from_range_t, _Range&& __range, const allocator_type& __a)
1102 : multiset(from_range, std::forward<_Range>(__range), key_compare(), __a) {}1123 : multiset(from_range, std::forward<_Range>(__range), key_compare(), __a) {}
1103#endif1124# endif
11041125
1105 _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s)1126 _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s)
1106 : __tree_(__s.__tree_.value_comp(),1127 : __tree_(__s.__tree_.value_comp(),
...@@ -1113,19 +1134,19 @@ public:...@@ -1113,19 +1134,19 @@ public:
1113 return *this;1134 return *this;
1114 }1135 }
11151136
1116#ifndef _LIBCPP_CXX03_LANG1137# ifndef _LIBCPP_CXX03_LANG
1117 _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) noexcept(is_nothrow_move_constructible<__base>::value)1138 _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) noexcept(is_nothrow_move_constructible<__base>::value)
1118 : __tree_(std::move(__s.__tree_)) {}1139 : __tree_(std::move(__s.__tree_)) {}
11191140
1120 _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a);1141 _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a);
1121#endif // _LIBCPP_CXX03_LANG1142# endif // _LIBCPP_CXX03_LANG
1122 _LIBCPP_HIDE_FROM_ABI explicit multiset(const allocator_type& __a) : __tree_(__a) {}1143 _LIBCPP_HIDE_FROM_ABI explicit multiset(const allocator_type& __a) : __tree_(__a) {}
1123 _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s, const allocator_type& __a)1144 _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s, const allocator_type& __a)
1124 : __tree_(__s.__tree_.value_comp(), __a) {1145 : __tree_(__s.__tree_.value_comp(), __a) {
1125 insert(__s.begin(), __s.end());1146 insert(__s.begin(), __s.end());
1126 }1147 }
11271148
1128#ifndef _LIBCPP_CXX03_LANG1149# ifndef _LIBCPP_CXX03_LANG
1129 _LIBCPP_HIDE_FROM_ABI multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())1150 _LIBCPP_HIDE_FROM_ABI multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
1130 : __tree_(__comp) {1151 : __tree_(__comp) {
1131 insert(__il.begin(), __il.end());1152 insert(__il.begin(), __il.end());
...@@ -1137,10 +1158,10 @@ public:...@@ -1137,10 +1158,10 @@ public:
1137 insert(__il.begin(), __il.end());1158 insert(__il.begin(), __il.end());
1138 }1159 }
11391160
1140# if _LIBCPP_STD_VER >= 141161# if _LIBCPP_STD_VER >= 14
1141 _LIBCPP_HIDE_FROM_ABI multiset(initializer_list<value_type> __il, const allocator_type& __a)1162 _LIBCPP_HIDE_FROM_ABI multiset(initializer_list<value_type> __il, const allocator_type& __a)
1142 : multiset(__il, key_compare(), __a) {}1163 : multiset(__il, key_compare(), __a) {}
1143# endif1164# endif
11441165
1145 _LIBCPP_HIDE_FROM_ABI multiset& operator=(initializer_list<value_type> __il) {1166 _LIBCPP_HIDE_FROM_ABI multiset& operator=(initializer_list<value_type> __il) {
1146 __tree_.__assign_multi(__il.begin(), __il.end());1167 __tree_.__assign_multi(__il.begin(), __il.end());
...@@ -1151,7 +1172,7 @@ public:...@@ -1151,7 +1172,7 @@ public:
1151 __tree_ = std::move(__s.__tree_);1172 __tree_ = std::move(__s.__tree_);
1152 return *this;1173 return *this;
1153 }1174 }
1154#endif // _LIBCPP_CXX03_LANG1175# endif // _LIBCPP_CXX03_LANG
11551176
1156 _LIBCPP_HIDE_FROM_ABI ~multiset() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); }1177 _LIBCPP_HIDE_FROM_ABI ~multiset() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); }
11571178
...@@ -1170,12 +1191,12 @@ public:...@@ -1170,12 +1191,12 @@ public:
1170 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }1191 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
1171 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }1192 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
11721193
1173 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }1194 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
1174 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }1195 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
1175 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }1196 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
11761197
1177 // modifiers:1198 // modifiers:
1178#ifndef _LIBCPP_CXX03_LANG1199# ifndef _LIBCPP_CXX03_LANG
1179 template <class... _Args>1200 template <class... _Args>
1180 _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {1201 _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {
1181 return __tree_.__emplace_multi(std::forward<_Args>(__args)...);1202 return __tree_.__emplace_multi(std::forward<_Args>(__args)...);
...@@ -1184,7 +1205,7 @@ public:...@@ -1184,7 +1205,7 @@ public:
1184 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {1205 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {
1185 return __tree_.__emplace_hint_multi(__p, std::forward<_Args>(__args)...);1206 return __tree_.__emplace_hint_multi(__p, std::forward<_Args>(__args)...);
1186 }1207 }
1187#endif // _LIBCPP_CXX03_LANG1208# endif // _LIBCPP_CXX03_LANG
11881209
1189 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); }1210 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); }
1190 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {1211 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {
...@@ -1197,7 +1218,7 @@ public:...@@ -1197,7 +1218,7 @@ public:
1197 __tree_.__insert_multi(__e, *__f);1218 __tree_.__insert_multi(__e, *__f);
1198 }1219 }
11991220
1200#if _LIBCPP_STD_VER >= 231221# if _LIBCPP_STD_VER >= 23
1201 template <_ContainerCompatibleRange<value_type> _Range>1222 template <_ContainerCompatibleRange<value_type> _Range>
1202 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {1223 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
1203 const_iterator __end = cend();1224 const_iterator __end = cend();
...@@ -1205,9 +1226,9 @@ public:...@@ -1205,9 +1226,9 @@ public:
1205 __tree_.__insert_multi(__end, std::forward<decltype(__element)>(__element));1226 __tree_.__insert_multi(__end, std::forward<decltype(__element)>(__element));
1206 }1227 }
1207 }1228 }
1208#endif1229# endif
12091230
1210#ifndef _LIBCPP_CXX03_LANG1231# ifndef _LIBCPP_CXX03_LANG
1211 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__insert_multi(std::move(__v)); }1232 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__insert_multi(std::move(__v)); }
12121233
1213 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {1234 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {
...@@ -1215,14 +1236,14 @@ public:...@@ -1215,14 +1236,14 @@ public:
1215 }1236 }
12161237
1217 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }1238 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
1218#endif // _LIBCPP_CXX03_LANG1239# endif // _LIBCPP_CXX03_LANG
12191240
1220 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); }1241 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); }
1221 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_multi(__k); }1242 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_multi(__k); }
1222 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); }1243 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); }
1223 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }1244 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }
12241245
1225#if _LIBCPP_STD_VER >= 171246# if _LIBCPP_STD_VER >= 17
1226 _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {1247 _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {
1227 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),1248 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
1228 "node_type with incompatible allocator passed to multiset::insert()");1249 "node_type with incompatible allocator passed to multiset::insert()");
...@@ -1263,7 +1284,7 @@ public:...@@ -1263,7 +1284,7 @@ public:
1263 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");1284 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
1264 __tree_.__node_handle_merge_multi(__source.__tree_);1285 __tree_.__node_handle_merge_multi(__source.__tree_);
1265 }1286 }
1266#endif1287# endif
12671288
1268 _LIBCPP_HIDE_FROM_ABI void swap(multiset& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) {1289 _LIBCPP_HIDE_FROM_ABI void swap(multiset& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) {
1269 __tree_.swap(__s.__tree_);1290 __tree_.swap(__s.__tree_);
...@@ -1276,7 +1297,7 @@ public:...@@ -1276,7 +1297,7 @@ public:
1276 // set operations:1297 // set operations:
1277 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }1298 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
1278 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }1299 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
1279#if _LIBCPP_STD_VER >= 141300# if _LIBCPP_STD_VER >= 14
1280 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1301 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1281 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {1302 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
1282 return __tree_.find(__k);1303 return __tree_.find(__k);
...@@ -1285,27 +1306,27 @@ public:...@@ -1285,27 +1306,27 @@ public:
1285 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {1306 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
1286 return __tree_.find(__k);1307 return __tree_.find(__k);
1287 }1308 }
1288#endif1309# endif
12891310
1290 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); }1311 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); }
1291#if _LIBCPP_STD_VER >= 141312# if _LIBCPP_STD_VER >= 14
1292 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1313 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1293 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {1314 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
1294 return __tree_.__count_multi(__k);1315 return __tree_.__count_multi(__k);
1295 }1316 }
1296#endif1317# endif
12971318
1298#if _LIBCPP_STD_VER >= 201319# if _LIBCPP_STD_VER >= 20
1299 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }1320 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1300 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1321 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1301 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {1322 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
1302 return find(__k) != end();1323 return find(__k) != end();
1303 }1324 }
1304#endif // _LIBCPP_STD_VER >= 201325# endif // _LIBCPP_STD_VER >= 20
13051326
1306 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }1327 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
1307 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }1328 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
1308#if _LIBCPP_STD_VER >= 141329# if _LIBCPP_STD_VER >= 14
1309 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1330 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1310 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {1331 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
1311 return __tree_.lower_bound(__k);1332 return __tree_.lower_bound(__k);
...@@ -1315,11 +1336,11 @@ public:...@@ -1315,11 +1336,11 @@ public:
1315 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {1336 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
1316 return __tree_.lower_bound(__k);1337 return __tree_.lower_bound(__k);
1317 }1338 }
1318#endif1339# endif
13191340
1320 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }1341 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
1321 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }1342 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
1322#if _LIBCPP_STD_VER >= 141343# if _LIBCPP_STD_VER >= 14
1323 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1344 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1324 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {1345 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
1325 return __tree_.upper_bound(__k);1346 return __tree_.upper_bound(__k);
...@@ -1328,7 +1349,7 @@ public:...@@ -1328,7 +1349,7 @@ public:
1328 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {1349 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
1329 return __tree_.upper_bound(__k);1350 return __tree_.upper_bound(__k);
1330 }1351 }
1331#endif1352# endif
13321353
1333 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {1354 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
1334 return __tree_.__equal_range_multi(__k);1355 return __tree_.__equal_range_multi(__k);
...@@ -1336,7 +1357,7 @@ public:...@@ -1336,7 +1357,7 @@ public:
1336 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {1357 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
1337 return __tree_.__equal_range_multi(__k);1358 return __tree_.__equal_range_multi(__k);
1338 }1359 }
1339#if _LIBCPP_STD_VER >= 141360# if _LIBCPP_STD_VER >= 14
1340 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>1361 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1341 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {1362 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
1342 return __tree_.__equal_range_multi(__k);1363 return __tree_.__equal_range_multi(__k);
...@@ -1345,10 +1366,10 @@ public:...@@ -1345,10 +1366,10 @@ public:
1345 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {1366 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
1346 return __tree_.__equal_range_multi(__k);1367 return __tree_.__equal_range_multi(__k);
1347 }1368 }
1348#endif1369# endif
1349};1370};
13501371
1351#if _LIBCPP_STD_VER >= 171372# if _LIBCPP_STD_VER >= 17
1352template <class _InputIterator,1373template <class _InputIterator,
1353 class _Compare = less<__iter_value_type<_InputIterator>>,1374 class _Compare = less<__iter_value_type<_InputIterator>>,
1354 class _Allocator = allocator<__iter_value_type<_InputIterator>>,1375 class _Allocator = allocator<__iter_value_type<_InputIterator>>,
...@@ -1358,7 +1379,7 @@ template <class _InputIterator,...@@ -1358,7 +1379,7 @@ template <class _InputIterator,
1358multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())1379multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
1359 -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>;1380 -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
13601381
1361# if _LIBCPP_STD_VER >= 231382# if _LIBCPP_STD_VER >= 23
1362template <ranges::input_range _Range,1383template <ranges::input_range _Range,
1363 class _Compare = less<ranges::range_value_t<_Range>>,1384 class _Compare = less<ranges::range_value_t<_Range>>,
1364 class _Allocator = allocator<ranges::range_value_t<_Range>>,1385 class _Allocator = allocator<ranges::range_value_t<_Range>>,
...@@ -1366,7 +1387,7 @@ template <ranges::input_range _Range,...@@ -1366,7 +1387,7 @@ template <ranges::input_range _Range,
1366 class = enable_if_t<!__is_allocator<_Compare>::value, void>>1387 class = enable_if_t<!__is_allocator<_Compare>::value, void>>
1367multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator())1388multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator())
1368 -> multiset<ranges::range_value_t<_Range>, _Compare, _Allocator>;1389 -> multiset<ranges::range_value_t<_Range>, _Compare, _Allocator>;
1369# endif1390# endif
13701391
1371template <class _Key,1392template <class _Key,
1372 class _Compare = less<_Key>,1393 class _Compare = less<_Key>,
...@@ -1384,18 +1405,18 @@ template <class _InputIterator,...@@ -1384,18 +1405,18 @@ template <class _InputIterator,
1384multiset(_InputIterator, _InputIterator, _Allocator)1405multiset(_InputIterator, _InputIterator, _Allocator)
1385 -> multiset<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>;1406 -> multiset<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>;
13861407
1387# if _LIBCPP_STD_VER >= 231408# if _LIBCPP_STD_VER >= 23
1388template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>1409template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
1389multiset(from_range_t,1410multiset(from_range_t,
1390 _Range&&,1411 _Range&&,
1391 _Allocator) -> multiset<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;1412 _Allocator) -> multiset<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;
1392# endif1413# endif
13931414
1394template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>1415template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
1395multiset(initializer_list<_Key>, _Allocator) -> multiset<_Key, less<_Key>, _Allocator>;1416multiset(initializer_list<_Key>, _Allocator) -> multiset<_Key, less<_Key>, _Allocator>;
1396#endif1417# endif
13971418
1398#ifndef _LIBCPP_CXX03_LANG1419# ifndef _LIBCPP_CXX03_LANG
13991420
1400template <class _Key, class _Compare, class _Allocator>1421template <class _Key, class _Compare, class _Allocator>
1401multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a)1422multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a)
...@@ -1407,7 +1428,7 @@ multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_t...@@ -1407,7 +1428,7 @@ multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_t
1407 }1428 }
1408}1429}
14091430
1410#endif // _LIBCPP_CXX03_LANG1431# endif // _LIBCPP_CXX03_LANG
14111432
1412template <class _Key, class _Compare, class _Allocator>1433template <class _Key, class _Compare, class _Allocator>
1413inline _LIBCPP_HIDE_FROM_ABI bool1434inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -1415,7 +1436,7 @@ operator==(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key,...@@ -1415,7 +1436,7 @@ operator==(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key,
1415 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());1436 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
1416}1437}
14171438
1418#if _LIBCPP_STD_VER <= 171439# if _LIBCPP_STD_VER <= 17
14191440
1420template <class _Key, class _Compare, class _Allocator>1441template <class _Key, class _Compare, class _Allocator>
1421inline _LIBCPP_HIDE_FROM_ABI bool1442inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -1447,16 +1468,15 @@ operator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key,...@@ -1447,16 +1468,15 @@ operator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key,
1447 return !(__y < __x);1468 return !(__y < __x);
1448}1469}
14491470
1450#else // _LIBCPP_STD_VER <= 171471# else // _LIBCPP_STD_VER <= 17
14511472
1452template <class _Key, class _Allocator>1473template <class _Key, class _Allocator>
1453_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>1474_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
1454operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) {1475operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) {
1455 return std::lexicographical_compare_three_way(1476 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
1456 __x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
1457}1477}
14581478
1459#endif // _LIBCPP_STD_VER <= 171479# endif // _LIBCPP_STD_VER <= 17
14601480
1461template <class _Key, class _Compare, class _Allocator>1481template <class _Key, class _Compare, class _Allocator>
1462inline _LIBCPP_HIDE_FROM_ABI void1482inline _LIBCPP_HIDE_FROM_ABI void
...@@ -1465,17 +1485,25 @@ swap(multiset<_Key, _Compare, _Allocator>& __x, multiset<_Key, _Compare, _Alloca...@@ -1465,17 +1485,25 @@ swap(multiset<_Key, _Compare, _Allocator>& __x, multiset<_Key, _Compare, _Alloca
1465 __x.swap(__y);1485 __x.swap(__y);
1466}1486}
14671487
1468#if _LIBCPP_STD_VER >= 201488# if _LIBCPP_STD_VER >= 20
1469template <class _Key, class _Compare, class _Allocator, class _Predicate>1489template <class _Key, class _Compare, class _Allocator, class _Predicate>
1470inline _LIBCPP_HIDE_FROM_ABI typename multiset<_Key, _Compare, _Allocator>::size_type1490inline _LIBCPP_HIDE_FROM_ABI typename multiset<_Key, _Compare, _Allocator>::size_type
1471erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {1491erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
1472 return std::__libcpp_erase_if_container(__c, __pred);1492 return std::__libcpp_erase_if_container(__c, __pred);
1473}1493}
1474#endif1494# endif
1495
1496template <class _Key, class _Compare, class _Allocator>
1497struct __container_traits<multiset<_Key, _Compare, _Allocator> > {
1498 // http://eel.is/c++draft/associative.reqmts.except#2
1499 // For associative containers, if an exception is thrown by any operation from within
1500 // an insert or emplace function inserting a single element, the insertion has no effect.
1501 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;
1502};
14751503
1476_LIBCPP_END_NAMESPACE_STD1504_LIBCPP_END_NAMESPACE_STD
14771505
1478#if _LIBCPP_STD_VER >= 171506# if _LIBCPP_STD_VER >= 17
1479_LIBCPP_BEGIN_NAMESPACE_STD1507_LIBCPP_BEGIN_NAMESPACE_STD
1480namespace pmr {1508namespace pmr {
1481template <class _KeyT, class _CompareT = std::less<_KeyT>>1509template <class _KeyT, class _CompareT = std::less<_KeyT>>
...@@ -1485,17 +1513,18 @@ template <class _KeyT, class _CompareT = std::less<_KeyT>>...@@ -1485,17 +1513,18 @@ template <class _KeyT, class _CompareT = std::less<_KeyT>>
1485using multiset _LIBCPP_AVAILABILITY_PMR = std::multiset<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>;1513using multiset _LIBCPP_AVAILABILITY_PMR = std::multiset<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>;
1486} // namespace pmr1514} // namespace pmr
1487_LIBCPP_END_NAMESPACE_STD1515_LIBCPP_END_NAMESPACE_STD
1488#endif1516# endif
14891517
1490_LIBCPP_POP_MACROS1518_LIBCPP_POP_MACROS
14911519
1492#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 201520# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1493# include <concepts>1521# include <concepts>
1494# include <cstdlib>1522# include <cstdlib>
1495# include <functional>1523# include <functional>
1496# include <iterator>1524# include <iterator>
1497# include <stdexcept>1525# include <stdexcept>
1498# include <type_traits>1526# include <type_traits>
1499#endif1527# endif
1528#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
15001529
1501#endif // _LIBCPP_SET1530#endif // _LIBCPP_SET
lib/libcxx/include/shared_mutex+32-28
...@@ -122,31 +122,34 @@ template <class Mutex>...@@ -122,31 +122,34 @@ template <class Mutex>
122122
123*/123*/
124124
125#include <__config>125#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
126126# include <__cxx03/shared_mutex>
127#if !defined(_LIBCPP_HAS_NO_THREADS)127#else
128128# include <__config>
129# include <__chrono/duration.h>129
130# include <__chrono/steady_clock.h>130# if _LIBCPP_HAS_THREADS
131# include <__chrono/time_point.h>131
132# include <__condition_variable/condition_variable.h>132# include <__chrono/duration.h>
133# include <__memory/addressof.h>133# include <__chrono/steady_clock.h>
134# include <__mutex/mutex.h>134# include <__chrono/time_point.h>
135# include <__mutex/tag_types.h>135# include <__condition_variable/condition_variable.h>
136# include <__mutex/unique_lock.h>136# include <__memory/addressof.h>
137# include <__system_error/system_error.h>137# include <__mutex/mutex.h>
138# include <__utility/swap.h>138# include <__mutex/tag_types.h>
139# include <cerrno>139# include <__mutex/unique_lock.h>
140# include <version>140# include <__system_error/throw_system_error.h>
141# include <__utility/swap.h>
142# include <cerrno>
143# include <version>
141144
142_LIBCPP_PUSH_MACROS145_LIBCPP_PUSH_MACROS
143# include <__undef_macros>146# include <__undef_macros>
144147
145# if _LIBCPP_STD_VER >= 14148# if _LIBCPP_STD_VER >= 14
146149
147# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)150# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
148# pragma GCC system_header151# pragma GCC system_header
149# endif152# endif
150153
151_LIBCPP_BEGIN_NAMESPACE_STD154_LIBCPP_BEGIN_NAMESPACE_STD
152155
...@@ -179,7 +182,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base {...@@ -179,7 +182,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base {
179 // native_handle_type native_handle(); // See 30.2.3182 // native_handle_type native_handle(); // See 30.2.3
180};183};
181184
182# if _LIBCPP_STD_VER >= 17185# if _LIBCPP_STD_VER >= 17
183class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_mutex")) shared_mutex {186class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_mutex")) shared_mutex {
184 __shared_mutex_base __base_;187 __shared_mutex_base __base_;
185188
...@@ -216,7 +219,7 @@ public:...@@ -216,7 +219,7 @@ public:
216 // typedef __shared_mutex_base::native_handle_type native_handle_type;219 // typedef __shared_mutex_base::native_handle_type native_handle_type;
217 // _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __base::unlock_shared(); }220 // _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __base::unlock_shared(); }
218};221};
219# endif222# endif
220223
221class _LIBCPP_EXPORTED_FROM_ABI224class _LIBCPP_EXPORTED_FROM_ABI
222_LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_timed_mutex")) shared_timed_mutex {225_LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_timed_mutex")) shared_timed_mutex {
...@@ -451,14 +454,15 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(shared_lock<_Mutex>& __x, shared_lock<_Mu...@@ -451,14 +454,15 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(shared_lock<_Mutex>& __x, shared_lock<_Mu
451454
452_LIBCPP_END_NAMESPACE_STD455_LIBCPP_END_NAMESPACE_STD
453456
454# endif // _LIBCPP_STD_VER >= 14457# endif // _LIBCPP_STD_VER >= 14
455458
456_LIBCPP_POP_MACROS459_LIBCPP_POP_MACROS
457460
458#endif // !defined(_LIBCPP_HAS_NO_THREADS)461# endif // _LIBCPP_HAS_THREADS
459462
460#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20463# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
461# include <system_error>464# include <system_error>
462#endif465# endif
466#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
463467
464#endif // _LIBCPP_SHARED_MUTEX468#endif // _LIBCPP_SHARED_MUTEX
lib/libcxx/include/source_location+14-9
...@@ -25,17 +25,20 @@ namespace std {...@@ -25,17 +25,20 @@ namespace std {
25}25}
26*/26*/
2727
28#include <__config>28#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
29#include <cstdint>29# include <__cxx03/source_location>
30#include <version>30#else
31# include <__config>
32# include <cstdint>
33# include <version>
3134
32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)35# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
33# pragma GCC system_header36# pragma GCC system_header
34#endif37# endif
3538
36_LIBCPP_BEGIN_NAMESPACE_STD39_LIBCPP_BEGIN_NAMESPACE_STD
3740
38#if _LIBCPP_STD_VER >= 2041# if _LIBCPP_STD_VER >= 20
3942
40class source_location {43class source_location {
41 // The names source_location::__impl, _M_file_name, _M_function_name, _M_line, and _M_column44 // The names source_location::__impl, _M_file_name, _M_function_name, _M_line, and _M_column
...@@ -52,7 +55,7 @@ class source_location {...@@ -52,7 +55,7 @@ class source_location {
52 // in constant evaluation, so we don't want to use `void*` as the argument55 // 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 is56 // type unless the builtin returned that, anyhow, and the invalid cast is
54 // unavoidable.57 // unavoidable.
55 using __bsl_ty = decltype(__builtin_source_location());58 using __bsl_ty _LIBCPP_NODEBUG = decltype(__builtin_source_location());
5659
57public:60public:
58 // The defaulted __ptr argument is necessary so that the builtin is evaluated61 // The defaulted __ptr argument is necessary so that the builtin is evaluated
...@@ -78,8 +81,10 @@ public:...@@ -78,8 +81,10 @@ public:
78 }81 }
79};82};
8083
81#endif // _LIBCPP_STD_VER >= 2084# endif // _LIBCPP_STD_VER >= 20
8285
83_LIBCPP_END_NAMESPACE_STD86_LIBCPP_END_NAMESPACE_STD
8487
88#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
89
85#endif // _LIBCPP_SOURCE_LOCATION90#endif // _LIBCPP_SOURCE_LOCATION
lib/libcxx/include/span+93-83
...@@ -144,59 +144,63 @@ template<class R>...@@ -144,59 +144,63 @@ template<class R>
144144
145*/145*/
146146
147#include <__assert>147#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
148#include <__concepts/convertible_to.h>148# include <__cxx03/span>
149#include <__concepts/equality_comparable.h>149#else
150#include <__config>150# include <__assert>
151#include <__fwd/array.h>151# include <__concepts/convertible_to.h>
152#include <__fwd/span.h>152# include <__concepts/equality_comparable.h>
153#include <__iterator/bounded_iter.h>153# include <__config>
154#include <__iterator/concepts.h>154# include <__cstddef/byte.h>
155#include <__iterator/iterator_traits.h>155# include <__cstddef/ptrdiff_t.h>
156#include <__iterator/reverse_iterator.h>156# include <__fwd/array.h>
157#include <__iterator/wrap_iter.h>157# include <__fwd/span.h>
158#include <__memory/pointer_traits.h>158# include <__iterator/bounded_iter.h>
159#include <__ranges/concepts.h>159# include <__iterator/concepts.h>
160#include <__ranges/data.h>160# include <__iterator/iterator_traits.h>
161#include <__ranges/enable_borrowed_range.h>161# include <__iterator/reverse_iterator.h>
162#include <__ranges/enable_view.h>162# include <__iterator/wrap_iter.h>
163#include <__ranges/size.h>163# include <__memory/pointer_traits.h>
164#include <__type_traits/integral_constant.h>164# include <__ranges/concepts.h>
165#include <__type_traits/is_array.h>165# include <__ranges/data.h>
166#include <__type_traits/is_const.h>166# include <__ranges/enable_borrowed_range.h>
167#include <__type_traits/is_convertible.h>167# include <__ranges/enable_view.h>
168#include <__type_traits/is_integral.h>168# include <__ranges/size.h>
169#include <__type_traits/is_same.h>169# include <__type_traits/integral_constant.h>
170#include <__type_traits/remove_const.h>170# include <__type_traits/is_array.h>
171#include <__type_traits/remove_cv.h>171# include <__type_traits/is_const.h>
172#include <__type_traits/remove_cvref.h>172# include <__type_traits/is_convertible.h>
173#include <__type_traits/remove_reference.h>173# include <__type_traits/is_integral.h>
174#include <__type_traits/type_identity.h>174# include <__type_traits/is_same.h>
175#include <__utility/forward.h>175# include <__type_traits/remove_const.h>
176#include <cstddef> // for byte176# include <__type_traits/remove_cv.h>
177#include <initializer_list>177# include <__type_traits/remove_cvref.h>
178#include <stdexcept>178# include <__type_traits/remove_reference.h>
179#include <version>179# include <__type_traits/type_identity.h>
180# include <__utility/forward.h>
181# include <initializer_list>
182# include <stdexcept>
183# include <version>
180184
181// standard-mandated includes185// standard-mandated includes
182186
183// [iterator.range]187// [iterator.range]
184#include <__iterator/access.h>188# include <__iterator/access.h>
185#include <__iterator/data.h>189# include <__iterator/data.h>
186#include <__iterator/empty.h>190# include <__iterator/empty.h>
187#include <__iterator/reverse_access.h>191# include <__iterator/reverse_access.h>
188#include <__iterator/size.h>192# include <__iterator/size.h>
189193
190#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)194# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
191# pragma GCC system_header195# pragma GCC system_header
192#endif196# endif
193197
194_LIBCPP_PUSH_MACROS198_LIBCPP_PUSH_MACROS
195#include <__undef_macros>199# include <__undef_macros>
196200
197_LIBCPP_BEGIN_NAMESPACE_STD201_LIBCPP_BEGIN_NAMESPACE_STD
198202
199#if _LIBCPP_STD_VER >= 20203# if _LIBCPP_STD_VER >= 20
200204
201template <class _Tp>205template <class _Tp>
202struct __is_std_span : false_type {};206struct __is_std_span : false_type {};
...@@ -210,7 +214,7 @@ concept __span_compatible_range =...@@ -210,7 +214,7 @@ concept __span_compatible_range =
210 ranges::contiguous_range<_Range> && //214 ranges::contiguous_range<_Range> && //
211 ranges::sized_range<_Range> && //215 ranges::sized_range<_Range> && //
212 (ranges::borrowed_range<_Range> || is_const_v<_ElementType>) && //216 (ranges::borrowed_range<_Range> || is_const_v<_ElementType>) && //
213 !__is_std_array<remove_cvref_t<_Range>>::value && //217 !__is_std_array_v<remove_cvref_t<_Range>> && //
214 !is_array_v<remove_cvref_t<_Range>> && //218 !is_array_v<remove_cvref_t<_Range>> && //
215 is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>> (*)[], _ElementType (*)[]>;219 is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>> (*)[], _ElementType (*)[]>;
216220
...@@ -236,11 +240,11 @@ public:...@@ -236,11 +240,11 @@ public:
236 using const_pointer = const _Tp*;240 using const_pointer = const _Tp*;
237 using reference = _Tp&;241 using reference = _Tp&;
238 using const_reference = const _Tp&;242 using const_reference = const _Tp&;
239# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS243# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
240 using iterator = __bounded_iter<pointer>;244 using iterator = __bounded_iter<pointer>;
241# else245# else
242 using iterator = __wrap_iter<pointer>;246 using iterator = __wrap_iter<pointer>;
243# endif247# endif
244 using reverse_iterator = std::reverse_iterator<iterator>;248 using reverse_iterator = std::reverse_iterator<iterator>;
245249
246 static constexpr size_type extent = _Extent;250 static constexpr size_type extent = _Extent;
...@@ -250,14 +254,14 @@ public:...@@ -250,14 +254,14 @@ public:
250 requires(_Sz == 0)254 requires(_Sz == 0)
251 _LIBCPP_HIDE_FROM_ABI constexpr span() noexcept : __data_{nullptr} {}255 _LIBCPP_HIDE_FROM_ABI constexpr span() noexcept : __data_{nullptr} {}
252256
253# if _LIBCPP_STD_VER >= 26257# if _LIBCPP_STD_VER >= 26
254 _LIBCPP_HIDE_FROM_ABI constexpr explicit span(std::initializer_list<value_type> __il)258 _LIBCPP_HIDE_FROM_ABI constexpr explicit span(std::initializer_list<value_type> __il)
255 requires is_const_v<element_type>259 requires is_const_v<element_type>
256 : __data_{__il.begin()} {260 : __data_{__il.begin()} {
257 _LIBCPP_ASSERT_VALID_INPUT_RANGE(261 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
258 _Extent == __il.size(), "Size mismatch in span's constructor _Extent != __il.size().");262 _Extent == __il.size(), "Size mismatch in span's constructor _Extent != __il.size().");
259 }263 }
260# endif264# endif
261265
262 constexpr span(const span&) noexcept = default;266 constexpr span(const span&) noexcept = default;
263 constexpr span& operator=(const span&) noexcept = default;267 constexpr span& operator=(const span&) noexcept = default;
...@@ -266,6 +270,8 @@ public:...@@ -266,6 +270,8 @@ public:
266 _LIBCPP_HIDE_FROM_ABI constexpr explicit span(_It __first, size_type __count) : __data_{std::to_address(__first)} {270 _LIBCPP_HIDE_FROM_ABI constexpr explicit span(_It __first, size_type __count) : __data_{std::to_address(__first)} {
267 (void)__count;271 (void)__count;
268 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(_Extent == __count, "size mismatch in span's constructor (iterator, len)");272 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(_Extent == __count, "size mismatch in span's constructor (iterator, len)");
273 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__count == 0 || std::to_address(__first) != nullptr,
274 "passed nullptr with non-zero length in span's constructor (iterator, len)");
269 }275 }
270276
271 template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>277 template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
...@@ -355,13 +361,13 @@ public:...@@ -355,13 +361,13 @@ public:
355 return __data_[__idx];361 return __data_[__idx];
356 }362 }
357363
358# if _LIBCPP_STD_VER >= 26364# if _LIBCPP_STD_VER >= 26
359 _LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __index) const {365 _LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __index) const {
360 if (__index >= size())366 if (__index >= size())
361 std::__throw_out_of_range("span");367 std::__throw_out_of_range("span");
362 return __data_[__index];368 return __data_[__index];
363 }369 }
364# endif370# endif
365371
366 _LIBCPP_HIDE_FROM_ABI constexpr reference front() const noexcept {372 _LIBCPP_HIDE_FROM_ABI constexpr reference front() const noexcept {
367 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T, N>::front() on empty span");373 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T, N>::front() on empty span");
...@@ -377,18 +383,18 @@ public:...@@ -377,18 +383,18 @@ public:
377383
378 // [span.iter], span iterator support384 // [span.iter], span iterator support
379 _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() const noexcept {385 _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() const noexcept {
380# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS386# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
381 return std::__make_bounded_iter(data(), data(), data() + size());387 return std::__make_bounded_iter(data(), data(), data() + size());
382# else388# else
383 return iterator(data());389 return iterator(data());
384# endif390# endif
385 }391 }
386 _LIBCPP_HIDE_FROM_ABI constexpr iterator end() const noexcept {392 _LIBCPP_HIDE_FROM_ABI constexpr iterator end() const noexcept {
387# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS393# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
388 return std::__make_bounded_iter(data() + size(), data(), data() + size());394 return std::__make_bounded_iter(data() + size(), data(), data() + size());
389# else395# else
390 return iterator(data() + size());396 return iterator(data() + size());
391# endif397# endif
392 }398 }
393 _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }399 _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
394 _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }400 _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
...@@ -417,11 +423,11 @@ public:...@@ -417,11 +423,11 @@ public:
417 using const_pointer = const _Tp*;423 using const_pointer = const _Tp*;
418 using reference = _Tp&;424 using reference = _Tp&;
419 using const_reference = const _Tp&;425 using const_reference = const _Tp&;
420# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS426# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
421 using iterator = __bounded_iter<pointer>;427 using iterator = __bounded_iter<pointer>;
422# else428# else
423 using iterator = __wrap_iter<pointer>;429 using iterator = __wrap_iter<pointer>;
424# endif430# endif
425 using reverse_iterator = std::reverse_iterator<iterator>;431 using reverse_iterator = std::reverse_iterator<iterator>;
426432
427 static constexpr size_type extent = dynamic_extent;433 static constexpr size_type extent = dynamic_extent;
...@@ -429,18 +435,21 @@ public:...@@ -429,18 +435,21 @@ public:
429 // [span.cons], span constructors, copy, assignment, and destructor435 // [span.cons], span constructors, copy, assignment, and destructor
430 _LIBCPP_HIDE_FROM_ABI constexpr span() noexcept : __data_{nullptr}, __size_{0} {}436 _LIBCPP_HIDE_FROM_ABI constexpr span() noexcept : __data_{nullptr}, __size_{0} {}
431437
432# if _LIBCPP_STD_VER >= 26438# if _LIBCPP_STD_VER >= 26
433 _LIBCPP_HIDE_FROM_ABI constexpr span(std::initializer_list<value_type> __il)439 _LIBCPP_HIDE_FROM_ABI constexpr span(std::initializer_list<value_type> __il)
434 requires is_const_v<element_type>440 requires is_const_v<element_type>
435 : __data_{__il.begin()}, __size_{__il.size()} {}441 : __data_{__il.begin()}, __size_{__il.size()} {}
436# endif442# endif
437443
438 constexpr span(const span&) noexcept = default;444 constexpr span(const span&) noexcept = default;
439 constexpr span& operator=(const span&) noexcept = default;445 constexpr span& operator=(const span&) noexcept = default;
440446
441 template <__span_compatible_iterator<element_type> _It>447 template <__span_compatible_iterator<element_type> _It>
442 _LIBCPP_HIDE_FROM_ABI constexpr span(_It __first, size_type __count)448 _LIBCPP_HIDE_FROM_ABI constexpr span(_It __first, size_type __count)
443 : __data_{std::to_address(__first)}, __size_{__count} {}449 : __data_{std::to_address(__first)}, __size_{__count} {
450 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__count == 0 || std::to_address(__first) != nullptr,
451 "passed nullptr with non-zero length in span's constructor (iterator, len)");
452 }
444453
445 template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>454 template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
446 _LIBCPP_HIDE_FROM_ABI constexpr span(_It __first, _End __last)455 _LIBCPP_HIDE_FROM_ABI constexpr span(_It __first, _End __last)
...@@ -517,13 +526,13 @@ public:...@@ -517,13 +526,13 @@ public:
517 return __data_[__idx];526 return __data_[__idx];
518 }527 }
519528
520# if _LIBCPP_STD_VER >= 26529# if _LIBCPP_STD_VER >= 26
521 _LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __index) const {530 _LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __index) const {
522 if (__index >= size())531 if (__index >= size())
523 std::__throw_out_of_range("span");532 std::__throw_out_of_range("span");
524 return __data_[__index];533 return __data_[__index];
525 }534 }
526# endif535# endif
527536
528 _LIBCPP_HIDE_FROM_ABI constexpr reference front() const noexcept {537 _LIBCPP_HIDE_FROM_ABI constexpr reference front() const noexcept {
529 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T>::front() on empty span");538 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T>::front() on empty span");
...@@ -539,18 +548,18 @@ public:...@@ -539,18 +548,18 @@ public:
539548
540 // [span.iter], span iterator support549 // [span.iter], span iterator support
541 _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() const noexcept {550 _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() const noexcept {
542# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS551# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
543 return std::__make_bounded_iter(data(), data(), data() + size());552 return std::__make_bounded_iter(data(), data(), data() + size());
544# else553# else
545 return iterator(data());554 return iterator(data());
546# endif555# endif
547 }556 }
548 _LIBCPP_HIDE_FROM_ABI constexpr iterator end() const noexcept {557 _LIBCPP_HIDE_FROM_ABI constexpr iterator end() const noexcept {
549# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS558# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
550 return std::__make_bounded_iter(data() + size(), data(), data() + size());559 return std::__make_bounded_iter(data() + size(), data(), data() + size());
551# else560# else
552 return iterator(data() + size());561 return iterator(data() + size());
553# endif562# endif
554 }563 }
555 _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }564 _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); }
556 _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }565 _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); }
...@@ -586,7 +595,7 @@ _LIBCPP_HIDE_FROM_ABI auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept {...@@ -586,7 +595,7 @@ _LIBCPP_HIDE_FROM_ABI auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept {
586 return __s.__as_writable_bytes();595 return __s.__as_writable_bytes();
587}596}
588597
589# if _LIBCPP_STD_VER >= 26598# if _LIBCPP_STD_VER >= 26
590template <class _Tp>599template <class _Tp>
591concept __integral_constant_like =600concept __integral_constant_like =
592 is_integral_v<decltype(_Tp::value)> && !is_same_v<bool, remove_const_t<decltype(_Tp::value)>> &&601 is_integral_v<decltype(_Tp::value)> && !is_same_v<bool, remove_const_t<decltype(_Tp::value)>> &&
...@@ -602,10 +611,10 @@ inline constexpr size_t __maybe_static_ext<_Tp> = {_Tp::value};...@@ -602,10 +611,10 @@ inline constexpr size_t __maybe_static_ext<_Tp> = {_Tp::value};
602611
603template <contiguous_iterator _It, class _EndOrSize>612template <contiguous_iterator _It, class _EndOrSize>
604span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>, __maybe_static_ext<_EndOrSize>>;613span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>, __maybe_static_ext<_EndOrSize>>;
605# else614# else
606template <contiguous_iterator _It, class _EndOrSize>615template <contiguous_iterator _It, class _EndOrSize>
607span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>;616span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>;
608# endif617# endif
609618
610template <class _Tp, size_t _Sz>619template <class _Tp, size_t _Sz>
611span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>;620span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>;
...@@ -619,18 +628,19 @@ span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;...@@ -619,18 +628,19 @@ span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;
619template <ranges::contiguous_range _Range>628template <ranges::contiguous_range _Range>
620span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>;629span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>;
621630
622#endif // _LIBCPP_STD_VER >= 20631# endif // _LIBCPP_STD_VER >= 20
623632
624_LIBCPP_END_NAMESPACE_STD633_LIBCPP_END_NAMESPACE_STD
625634
626_LIBCPP_POP_MACROS635_LIBCPP_POP_MACROS
627636
628#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20637# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
629# include <array>638# include <array>
630# include <concepts>639# include <concepts>
631# include <functional>640# include <functional>
632# include <iterator>641# include <iterator>
633# include <type_traits>642# include <type_traits>
634#endif643# endif
644#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
635645
636#endif // _LIBCPP_SPAN646#endif // _LIBCPP_SPAN
lib/libcxx/include/sstream+129-108
...@@ -312,22 +312,30 @@ typedef basic_stringstream<wchar_t> wstringstream;...@@ -312,22 +312,30 @@ typedef basic_stringstream<wchar_t> wstringstream;
312312
313// clang-format on313// clang-format on
314314
315#include <__config>315#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
316#include <__fwd/sstream.h>316# include <__cxx03/sstream>
317#include <__ostream/basic_ostream.h>317#else
318#include <__type_traits/is_convertible.h>318# include <__config>
319#include <__utility/swap.h>319
320#include <istream>320# if _LIBCPP_HAS_LOCALIZATION
321#include <string>321
322#include <string_view>322# include <__fwd/sstream.h>
323#include <version>323# include <__ostream/basic_ostream.h>
324324# include <__type_traits/is_convertible.h>
325#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)325# include <__utility/swap.h>
326# pragma GCC system_header326# include <ios>
327#endif327# include <istream>
328# include <locale>
329# include <string>
330# include <string_view>
331# include <version>
332
333# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
334# pragma GCC system_header
335# endif
328336
329_LIBCPP_PUSH_MACROS337_LIBCPP_PUSH_MACROS
330#include <__undef_macros>338# include <__undef_macros>
331339
332_LIBCPP_BEGIN_NAMESPACE_STD340_LIBCPP_BEGIN_NAMESPACE_STD
333341
...@@ -354,9 +362,15 @@ private:...@@ -354,9 +362,15 @@ private:
354362
355public:363public:
356 // [stringbuf.cons] constructors:364 // [stringbuf.cons] constructors:
357 _LIBCPP_HIDE_FROM_ABI basic_stringbuf() : __hm_(nullptr), __mode_(ios_base::in | ios_base::out) {}365 _LIBCPP_HIDE_FROM_ABI basic_stringbuf() : __hm_(nullptr), __mode_(ios_base::in | ios_base::out) {
366 // it is implementation-defined whether we initialize eback() & friends to nullptr, and libc++ doesn't
367 __init_buf_ptrs();
368 }
358369
359 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(ios_base::openmode __wch) : __hm_(nullptr), __mode_(__wch) {}370 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(ios_base::openmode __wch) : __hm_(nullptr), __mode_(__wch) {
371 // it is implementation-defined whether we initialize eback() & friends to nullptr, and libc++ doesn't
372 __init_buf_ptrs();
373 }
360374
361 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const string_type& __s,375 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const string_type& __s,
362 ios_base::openmode __wch = ios_base::in | ios_base::out)376 ios_base::openmode __wch = ios_base::in | ios_base::out)
...@@ -364,12 +378,14 @@ public:...@@ -364,12 +378,14 @@ public:
364 str(__s);378 str(__s);
365 }379 }
366380
367#if _LIBCPP_STD_VER >= 20381# if _LIBCPP_STD_VER >= 20
368 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const allocator_type& __a)382 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const allocator_type& __a)
369 : basic_stringbuf(ios_base::in | ios_base::out, __a) {}383 : basic_stringbuf(ios_base::in | ios_base::out, __a) {}
370384
371 _LIBCPP_HIDE_FROM_ABI basic_stringbuf(ios_base::openmode __wch, const allocator_type& __a)385 _LIBCPP_HIDE_FROM_ABI basic_stringbuf(ios_base::openmode __wch, const allocator_type& __a)
372 : __str_(__a), __hm_(nullptr), __mode_(__wch) {}386 : __str_(__a), __hm_(nullptr), __mode_(__wch) {
387 __init_buf_ptrs();
388 }
373389
374 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(string_type&& __s,390 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(string_type&& __s,
375 ios_base::openmode __wch = ios_base::in | ios_base::out)391 ios_base::openmode __wch = ios_base::in | ios_base::out)
...@@ -396,9 +412,9 @@ public:...@@ -396,9 +412,9 @@ public:
396 : __str_(__s), __hm_(nullptr), __mode_(__wch) {412 : __str_(__s), __hm_(nullptr), __mode_(__wch) {
397 __init_buf_ptrs();413 __init_buf_ptrs();
398 }414 }
399#endif // _LIBCPP_STD_VER >= 20415# endif // _LIBCPP_STD_VER >= 20
400416
401#if _LIBCPP_STD_VER >= 26417# if _LIBCPP_STD_VER >= 26
402418
403 template <class _Tp>419 template <class _Tp>
404 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>420 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
...@@ -420,37 +436,37 @@ public:...@@ -420,37 +436,37 @@ public:
420 __init_buf_ptrs();436 __init_buf_ptrs();
421 }437 }
422438
423#endif // _LIBCPP_STD_VER >= 26439# endif // _LIBCPP_STD_VER >= 26
424440
425 basic_stringbuf(const basic_stringbuf&) = delete;441 basic_stringbuf(const basic_stringbuf&) = delete;
426 basic_stringbuf(basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { __move_init(std::move(__rhs)); }442 basic_stringbuf(basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { __move_init(std::move(__rhs)); }
427443
428#if _LIBCPP_STD_VER >= 20444# if _LIBCPP_STD_VER >= 20
429 _LIBCPP_HIDE_FROM_ABI basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a)445 _LIBCPP_HIDE_FROM_ABI basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a)
430 : basic_stringbuf(__rhs.__mode_, __a) {446 : basic_stringbuf(__rhs.__mode_, __a) {
431 __move_init(std::move(__rhs));447 __move_init(std::move(__rhs));
432 }448 }
433#endif449# endif
434450
435 // [stringbuf.assign] Assign and swap:451 // [stringbuf.assign] Assign and swap:
436 basic_stringbuf& operator=(const basic_stringbuf&) = delete;452 basic_stringbuf& operator=(const basic_stringbuf&) = delete;
437 basic_stringbuf& operator=(basic_stringbuf&& __rhs);453 basic_stringbuf& operator=(basic_stringbuf&& __rhs);
438 void swap(basic_stringbuf& __rhs)454 void swap(basic_stringbuf& __rhs)
439#if _LIBCPP_STD_VER >= 20455# if _LIBCPP_STD_VER >= 20
440 noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||456 noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
441 allocator_traits<allocator_type>::is_always_equal::value)457 allocator_traits<allocator_type>::is_always_equal::value)
442#endif458# endif
443 ;459 ;
444460
445 // [stringbuf.members] Member functions:461 // [stringbuf.members] Member functions:
446462
447#if _LIBCPP_STD_VER >= 20463# if _LIBCPP_STD_VER >= 20
448 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const noexcept { return __str_.get_allocator(); }464 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const noexcept { return __str_.get_allocator(); }
449#endif465# endif
450466
451#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)467# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
452 string_type str() const;468 string_type str() const;
453#else469# else
454 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return str(__str_.get_allocator()); }470 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return str(__str_.get_allocator()); }
455471
456 _LIBCPP_HIDE_FROM_ABI string_type str() && {472 _LIBCPP_HIDE_FROM_ABI string_type str() && {
...@@ -464,9 +480,9 @@ public:...@@ -464,9 +480,9 @@ public:
464 __init_buf_ptrs();480 __init_buf_ptrs();
465 return __result;481 return __result;
466 }482 }
467#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)483# endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
468484
469#if _LIBCPP_STD_VER >= 20485# if _LIBCPP_STD_VER >= 20
470 template <class _SAlloc>486 template <class _SAlloc>
471 requires __is_allocator<_SAlloc>::value487 requires __is_allocator<_SAlloc>::value
472 _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {488 _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
...@@ -474,14 +490,14 @@ public:...@@ -474,14 +490,14 @@ public:
474 }490 }
475491
476 _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept;492 _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept;
477#endif // _LIBCPP_STD_VER >= 20493# endif // _LIBCPP_STD_VER >= 20
478494
479 void str(const string_type& __s) {495 void str(const string_type& __s) {
480 __str_ = __s;496 __str_ = __s;
481 __init_buf_ptrs();497 __init_buf_ptrs();
482 }498 }
483499
484#if _LIBCPP_STD_VER >= 20500# if _LIBCPP_STD_VER >= 20
485 template <class _SAlloc>501 template <class _SAlloc>
486 requires(!is_same_v<_SAlloc, allocator_type>)502 requires(!is_same_v<_SAlloc, allocator_type>)
487 _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {503 _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {
...@@ -493,9 +509,9 @@ public:...@@ -493,9 +509,9 @@ public:
493 __str_ = std::move(__s);509 __str_ = std::move(__s);
494 __init_buf_ptrs();510 __init_buf_ptrs();
495 }511 }
496#endif // _LIBCPP_STD_VER >= 20512# endif // _LIBCPP_STD_VER >= 20
497513
498#if _LIBCPP_STD_VER >= 26514# if _LIBCPP_STD_VER >= 26
499515
500 template <class _Tp>516 template <class _Tp>
501 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>517 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
...@@ -505,7 +521,7 @@ public:...@@ -505,7 +521,7 @@ public:
505 __init_buf_ptrs();521 __init_buf_ptrs();
506 }522 }
507523
508#endif // _LIBCPP_STD_VER >= 26524# endif // _LIBCPP_STD_VER >= 26
509525
510protected:526protected:
511 // [stringbuf.virtuals] Overridden virtual functions:527 // [stringbuf.virtuals] Overridden virtual functions:
...@@ -601,10 +617,10 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)...@@ -601,10 +617,10 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
601617
602template <class _CharT, class _Traits, class _Allocator>618template <class _CharT, class _Traits, class _Allocator>
603void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)619void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
604#if _LIBCPP_STD_VER >= 20620# if _LIBCPP_STD_VER >= 20
605 noexcept(allocator_traits<_Allocator>::propagate_on_container_swap::value ||621 noexcept(allocator_traits<_Allocator>::propagate_on_container_swap::value ||
606 allocator_traits<_Allocator>::is_always_equal::value)622 allocator_traits<_Allocator>::is_always_equal::value)
607#endif623# endif
608{624{
609 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());625 char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
610 ptrdiff_t __rbinp = -1;626 ptrdiff_t __rbinp = -1;
...@@ -674,14 +690,14 @@ void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)...@@ -674,14 +690,14 @@ void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
674template <class _CharT, class _Traits, class _Allocator>690template <class _CharT, class _Traits, class _Allocator>
675inline _LIBCPP_HIDE_FROM_ABI void691inline _LIBCPP_HIDE_FROM_ABI void
676swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, basic_stringbuf<_CharT, _Traits, _Allocator>& __y)692swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, basic_stringbuf<_CharT, _Traits, _Allocator>& __y)
677#if _LIBCPP_STD_VER >= 20693# if _LIBCPP_STD_VER >= 20
678 noexcept(noexcept(__x.swap(__y)))694 noexcept(noexcept(__x.swap(__y)))
679#endif695# endif
680{696{
681 __x.swap(__y);697 __x.swap(__y);
682}698}
683699
684#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)700# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
685template <class _CharT, class _Traits, class _Allocator>701template <class _CharT, class _Traits, class _Allocator>
686basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allocator>::str() const {702basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allocator>::str() const {
687 if (__mode_ & ios_base::out) {703 if (__mode_ & ios_base::out) {
...@@ -692,7 +708,7 @@ basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allo...@@ -692,7 +708,7 @@ basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allo
692 return string_type(this->eback(), this->egptr(), __str_.get_allocator());708 return string_type(this->eback(), this->egptr(), __str_.get_allocator());
693 return string_type(__str_.get_allocator());709 return string_type(__str_.get_allocator());
694}710}
695#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)711# endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
696712
697template <class _CharT, class _Traits, class _Allocator>713template <class _CharT, class _Traits, class _Allocator>
698_LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__init_buf_ptrs() {714_LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__init_buf_ptrs() {
...@@ -718,7 +734,7 @@ _LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__init_...@@ -718,7 +734,7 @@ _LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__init_
718 }734 }
719}735}
720736
721#if _LIBCPP_STD_VER >= 20737# if _LIBCPP_STD_VER >= 20
722template <class _CharT, class _Traits, class _Allocator>738template <class _CharT, class _Traits, class _Allocator>
723_LIBCPP_HIDE_FROM_ABI basic_string_view<_CharT, _Traits>739_LIBCPP_HIDE_FROM_ABI basic_string_view<_CharT, _Traits>
724basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept {740basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept {
...@@ -730,7 +746,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept {...@@ -730,7 +746,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept {
730 return basic_string_view<_CharT, _Traits>(this->eback(), this->egptr());746 return basic_string_view<_CharT, _Traits>(this->eback(), this->egptr());
731 return basic_string_view<_CharT, _Traits>();747 return basic_string_view<_CharT, _Traits>();
732}748}
733#endif // _LIBCPP_STD_VER >= 20749# endif // _LIBCPP_STD_VER >= 20
734750
735template <class _CharT, class _Traits, class _Allocator>751template <class _CharT, class _Traits, class _Allocator>
736typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type752typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
...@@ -773,9 +789,9 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) {...@@ -773,9 +789,9 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) {
773 if (this->pptr() == this->epptr()) {789 if (this->pptr() == this->epptr()) {
774 if (!(__mode_ & ios_base::out))790 if (!(__mode_ & ios_base::out))
775 return traits_type::eof();791 return traits_type::eof();
776#ifndef _LIBCPP_HAS_NO_EXCEPTIONS792# if _LIBCPP_HAS_EXCEPTIONS
777 try {793 try {
778#endif // _LIBCPP_HAS_NO_EXCEPTIONS794# endif // _LIBCPP_HAS_EXCEPTIONS
779 ptrdiff_t __nout = this->pptr() - this->pbase();795 ptrdiff_t __nout = this->pptr() - this->pbase();
780 ptrdiff_t __hm = __hm_ - this->pbase();796 ptrdiff_t __hm = __hm_ - this->pbase();
781 __str_.push_back(char_type());797 __str_.push_back(char_type());
...@@ -784,11 +800,11 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) {...@@ -784,11 +800,11 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) {
784 this->setp(__p, __p + __str_.size());800 this->setp(__p, __p + __str_.size());
785 this->__pbump(__nout);801 this->__pbump(__nout);
786 __hm_ = this->pbase() + __hm;802 __hm_ = this->pbase() + __hm;
787#ifndef _LIBCPP_HAS_NO_EXCEPTIONS803# if _LIBCPP_HAS_EXCEPTIONS
788 } catch (...) {804 } catch (...) {
789 return traits_type::eof();805 return traits_type::eof();
790 }806 }
791#endif // _LIBCPP_HAS_NO_EXCEPTIONS807# endif // _LIBCPP_HAS_EXCEPTIONS
792 }808 }
793 __hm_ = std::max(this->pptr() + 1, __hm_);809 __hm_ = std::max(this->pptr() + 1, __hm_);
794 if (__mode_ & ios_base::in) {810 if (__mode_ & ios_base::in) {
...@@ -864,15 +880,16 @@ private:...@@ -864,15 +880,16 @@ private:
864880
865public:881public:
866 // [istringstream.cons] Constructors:882 // [istringstream.cons] Constructors:
867 _LIBCPP_HIDE_FROM_ABI basic_istringstream() : basic_istream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in) {}883 _LIBCPP_HIDE_FROM_ABI basic_istringstream()
884 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(ios_base::in) {}
868885
869 _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(ios_base::openmode __wch)886 _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(ios_base::openmode __wch)
870 : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) {}887 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::in) {}
871888
872 _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const string_type& __s, ios_base::openmode __wch = ios_base::in)889 _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const string_type& __s, ios_base::openmode __wch = ios_base::in)
873 : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch | ios_base::in) {}890 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {}
874891
875#if _LIBCPP_STD_VER >= 20892# if _LIBCPP_STD_VER >= 20
876 _LIBCPP_HIDE_FROM_ABI basic_istringstream(ios_base::openmode __wch, const _Allocator& __a)893 _LIBCPP_HIDE_FROM_ABI basic_istringstream(ios_base::openmode __wch, const _Allocator& __a)
877 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::in, __a) {}894 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::in, __a) {}
878895
...@@ -892,9 +909,9 @@ public:...@@ -892,9 +909,9 @@ public:
892 _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s,909 _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s,
893 ios_base::openmode __wch = ios_base::in)910 ios_base::openmode __wch = ios_base::in)
894 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {}911 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {}
895#endif // _LIBCPP_STD_VER >= 20912# endif // _LIBCPP_STD_VER >= 20
896913
897#if _LIBCPP_STD_VER >= 26914# if _LIBCPP_STD_VER >= 26
898915
899 template <class _Tp>916 template <class _Tp>
900 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>917 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
...@@ -911,12 +928,12 @@ public:...@@ -911,12 +928,12 @@ public:
911 _LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)928 _LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
912 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::in, __a) {}929 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::in, __a) {}
913930
914#endif // _LIBCPP_STD_VER >= 26931# endif // _LIBCPP_STD_VER >= 26
915932
916 basic_istringstream(const basic_istringstream&) = delete;933 basic_istringstream(const basic_istringstream&) = delete;
917 _LIBCPP_HIDE_FROM_ABI basic_istringstream(basic_istringstream&& __rhs)934 _LIBCPP_HIDE_FROM_ABI basic_istringstream(basic_istringstream&& __rhs)
918 : basic_istream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {935 : basic_istream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
919 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);936 basic_istream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_));
920 }937 }
921938
922 // [istringstream.assign] Assign and swap:939 // [istringstream.assign] Assign and swap:
...@@ -933,18 +950,18 @@ public:...@@ -933,18 +950,18 @@ public:
933950
934 // [istringstream.members] Member functions:951 // [istringstream.members] Member functions:
935 _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {952 _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
936 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);953 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_));
937 }954 }
938955
939#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)956# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
940 _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }957 _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
941#else958# else
942 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }959 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }
943960
944 _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }961 _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
945#endif962# endif
946963
947#if _LIBCPP_STD_VER >= 20964# if _LIBCPP_STD_VER >= 20
948 template <class _SAlloc>965 template <class _SAlloc>
949 requires __is_allocator<_SAlloc>::value966 requires __is_allocator<_SAlloc>::value
950 _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {967 _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
...@@ -952,26 +969,26 @@ public:...@@ -952,26 +969,26 @@ public:
952 }969 }
953970
954 _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }971 _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
955#endif // _LIBCPP_STD_VER >= 20972# endif // _LIBCPP_STD_VER >= 20
956973
957 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }974 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }
958975
959#if _LIBCPP_STD_VER >= 20976# if _LIBCPP_STD_VER >= 20
960 template <class _SAlloc>977 template <class _SAlloc>
961 _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {978 _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {
962 __sb_.str(__s);979 __sb_.str(__s);
963 }980 }
964981
965 _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }982 _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
966#endif // _LIBCPP_STD_VER >= 20983# endif // _LIBCPP_STD_VER >= 20
967984
968#if _LIBCPP_STD_VER >= 26985# if _LIBCPP_STD_VER >= 26
969 template <class _Tp>986 template <class _Tp>
970 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>987 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
971 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {988 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
972 rdbuf()->str(__t);989 rdbuf()->str(__t);
973 }990 }
974#endif // _LIBCPP_STD_VER >= 26991# endif // _LIBCPP_STD_VER >= 26
975};992};
976993
977template <class _CharT, class _Traits, class _Allocator>994template <class _CharT, class _Traits, class _Allocator>
...@@ -999,15 +1016,16 @@ private:...@@ -999,15 +1016,16 @@ private:
9991016
1000public:1017public:
1001 // [ostringstream.cons] Constructors:1018 // [ostringstream.cons] Constructors:
1002 _LIBCPP_HIDE_FROM_ABI basic_ostringstream() : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::out) {}1019 _LIBCPP_HIDE_FROM_ABI basic_ostringstream()
1020 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(ios_base::out) {}
10031021
1004 _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(ios_base::openmode __wch)1022 _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(ios_base::openmode __wch)
1005 : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::out) {}1023 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::out) {}
10061024
1007 _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const string_type& __s, ios_base::openmode __wch = ios_base::out)1025 _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const string_type& __s, ios_base::openmode __wch = ios_base::out)
1008 : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch | ios_base::out) {}1026 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {}
10091027
1010#if _LIBCPP_STD_VER >= 201028# if _LIBCPP_STD_VER >= 20
1011 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(ios_base::openmode __wch, const _Allocator& __a)1029 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(ios_base::openmode __wch, const _Allocator& __a)
1012 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::out, __a) {}1030 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::out, __a) {}
10131031
...@@ -1028,9 +1046,9 @@ public:...@@ -1028,9 +1046,9 @@ public:
1028 _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s,1046 _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s,
1029 ios_base::openmode __wch = ios_base::out)1047 ios_base::openmode __wch = ios_base::out)
1030 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {}1048 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {}
1031#endif // _LIBCPP_STD_VER >= 201049# endif // _LIBCPP_STD_VER >= 20
10321050
1033#if _LIBCPP_STD_VER >= 261051# if _LIBCPP_STD_VER >= 26
10341052
1035 template <class _Tp>1053 template <class _Tp>
1036 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>1054 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
...@@ -1047,12 +1065,12 @@ public:...@@ -1047,12 +1065,12 @@ public:
1047 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)1065 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
1048 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::out, __a) {}1066 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::out, __a) {}
10491067
1050#endif // _LIBCPP_STD_VER >= 261068# endif // _LIBCPP_STD_VER >= 26
10511069
1052 basic_ostringstream(const basic_ostringstream&) = delete;1070 basic_ostringstream(const basic_ostringstream&) = delete;
1053 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(basic_ostringstream&& __rhs)1071 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(basic_ostringstream&& __rhs)
1054 : basic_ostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {1072 : basic_ostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
1055 basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);1073 basic_ostream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_));
1056 }1074 }
10571075
1058 // [ostringstream.assign] Assign and swap:1076 // [ostringstream.assign] Assign and swap:
...@@ -1070,18 +1088,18 @@ public:...@@ -1070,18 +1088,18 @@ public:
10701088
1071 // [ostringstream.members] Member functions:1089 // [ostringstream.members] Member functions:
1072 _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {1090 _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
1073 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);1091 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_));
1074 }1092 }
10751093
1076#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)1094# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
1077 _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }1095 _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
1078#else1096# else
1079 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }1097 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }
10801098
1081 _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }1099 _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
1082#endif1100# endif
10831101
1084#if _LIBCPP_STD_VER >= 201102# if _LIBCPP_STD_VER >= 20
1085 template <class _SAlloc>1103 template <class _SAlloc>
1086 requires __is_allocator<_SAlloc>::value1104 requires __is_allocator<_SAlloc>::value
1087 _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {1105 _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
...@@ -1089,26 +1107,26 @@ public:...@@ -1089,26 +1107,26 @@ public:
1089 }1107 }
10901108
1091 _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }1109 _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
1092#endif // _LIBCPP_STD_VER >= 201110# endif // _LIBCPP_STD_VER >= 20
10931111
1094 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }1112 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }
10951113
1096#if _LIBCPP_STD_VER >= 201114# if _LIBCPP_STD_VER >= 20
1097 template <class _SAlloc>1115 template <class _SAlloc>
1098 _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {1116 _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {
1099 __sb_.str(__s);1117 __sb_.str(__s);
1100 }1118 }
11011119
1102 _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }1120 _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
1103#endif // _LIBCPP_STD_VER >= 201121# endif // _LIBCPP_STD_VER >= 20
11041122
1105#if _LIBCPP_STD_VER >= 261123# if _LIBCPP_STD_VER >= 26
1106 template <class _Tp>1124 template <class _Tp>
1107 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>1125 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1108 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {1126 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
1109 rdbuf()->str(__t);1127 rdbuf()->str(__t);
1110 }1128 }
1111#endif // _LIBCPP_STD_VER >= 261129# endif // _LIBCPP_STD_VER >= 26
1112};1130};
11131131
1114template <class _CharT, class _Traits, class _Allocator>1132template <class _CharT, class _Traits, class _Allocator>
...@@ -1137,16 +1155,16 @@ private:...@@ -1137,16 +1155,16 @@ private:
1137public:1155public:
1138 // [stringstream.cons] constructors1156 // [stringstream.cons] constructors
1139 _LIBCPP_HIDE_FROM_ABI basic_stringstream()1157 _LIBCPP_HIDE_FROM_ABI basic_stringstream()
1140 : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in | ios_base::out) {}1158 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(ios_base::in | ios_base::out) {}
11411159
1142 _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(ios_base::openmode __wch)1160 _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(ios_base::openmode __wch)
1143 : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) {}1161 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch) {}
11441162
1145 _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const string_type& __s,1163 _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const string_type& __s,
1146 ios_base::openmode __wch = ios_base::in | ios_base::out)1164 ios_base::openmode __wch = ios_base::in | ios_base::out)
1147 : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch) {}1165 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {}
11481166
1149#if _LIBCPP_STD_VER >= 201167# if _LIBCPP_STD_VER >= 20
1150 _LIBCPP_HIDE_FROM_ABI basic_stringstream(ios_base::openmode __wch, const _Allocator& __a)1168 _LIBCPP_HIDE_FROM_ABI basic_stringstream(ios_base::openmode __wch, const _Allocator& __a)
1151 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch, __a) {}1169 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch, __a) {}
11521170
...@@ -1168,9 +1186,9 @@ public:...@@ -1168,9 +1186,9 @@ public:
1168 _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s,1186 _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s,
1169 ios_base::openmode __wch = ios_base::out | ios_base::in)1187 ios_base::openmode __wch = ios_base::out | ios_base::in)
1170 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {}1188 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {}
1171#endif // _LIBCPP_STD_VER >= 201189# endif // _LIBCPP_STD_VER >= 20
11721190
1173#if _LIBCPP_STD_VER >= 261191# if _LIBCPP_STD_VER >= 26
11741192
1175 template <class _Tp>1193 template <class _Tp>
1176 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>1194 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
...@@ -1188,12 +1206,12 @@ public:...@@ -1188,12 +1206,12 @@ public:
1188 _LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)1206 _LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
1189 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which, __a) {}1207 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which, __a) {}
11901208
1191#endif // _LIBCPP_STD_VER >= 261209# endif // _LIBCPP_STD_VER >= 26
11921210
1193 basic_stringstream(const basic_stringstream&) = delete;1211 basic_stringstream(const basic_stringstream&) = delete;
1194 _LIBCPP_HIDE_FROM_ABI basic_stringstream(basic_stringstream&& __rhs)1212 _LIBCPP_HIDE_FROM_ABI basic_stringstream(basic_stringstream&& __rhs)
1195 : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {1213 : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
1196 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);1214 basic_istream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_));
1197 }1215 }
11981216
1199 // [stringstream.assign] Assign and swap:1217 // [stringstream.assign] Assign and swap:
...@@ -1210,18 +1228,18 @@ public:...@@ -1210,18 +1228,18 @@ public:
12101228
1211 // [stringstream.members] Member functions:1229 // [stringstream.members] Member functions:
1212 _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {1230 _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
1213 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);1231 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_));
1214 }1232 }
12151233
1216#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)1234# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
1217 _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }1235 _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
1218#else1236# else
1219 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }1237 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }
12201238
1221 _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }1239 _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
1222#endif1240# endif
12231241
1224#if _LIBCPP_STD_VER >= 201242# if _LIBCPP_STD_VER >= 20
1225 template <class _SAlloc>1243 template <class _SAlloc>
1226 requires __is_allocator<_SAlloc>::value1244 requires __is_allocator<_SAlloc>::value
1227 _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {1245 _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
...@@ -1229,26 +1247,26 @@ public:...@@ -1229,26 +1247,26 @@ public:
1229 }1247 }
12301248
1231 _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }1249 _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
1232#endif // _LIBCPP_STD_VER >= 201250# endif // _LIBCPP_STD_VER >= 20
12331251
1234 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }1252 _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }
12351253
1236#if _LIBCPP_STD_VER >= 201254# if _LIBCPP_STD_VER >= 20
1237 template <class _SAlloc>1255 template <class _SAlloc>
1238 _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {1256 _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {
1239 __sb_.str(__s);1257 __sb_.str(__s);
1240 }1258 }
12411259
1242 _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }1260 _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
1243#endif // _LIBCPP_STD_VER >= 201261# endif // _LIBCPP_STD_VER >= 20
12441262
1245#if _LIBCPP_STD_VER >= 261263# if _LIBCPP_STD_VER >= 26
1246 template <class _Tp>1264 template <class _Tp>
1247 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>1265 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1248 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {1266 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
1249 rdbuf()->str(__t);1267 rdbuf()->str(__t);
1250 }1268 }
1251#endif // _LIBCPP_STD_VER >= 261269# endif // _LIBCPP_STD_VER >= 26
1252};1270};
12531271
1254template <class _CharT, class _Traits, class _Allocator>1272template <class _CharT, class _Traits, class _Allocator>
...@@ -1257,20 +1275,23 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, basic_stringstream<_C...@@ -1257,20 +1275,23 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, basic_stringstream<_C
1257 __x.swap(__y);1275 __x.swap(__y);
1258}1276}
12591277
1260#if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_11278# if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
1261extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>;1279extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>;
1262extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>;1280extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>;
1263extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>;1281extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>;
1264extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>;1282extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>;
1265#endif1283# endif
12661284
1267_LIBCPP_END_NAMESPACE_STD1285_LIBCPP_END_NAMESPACE_STD
12681286
1269_LIBCPP_POP_MACROS1287_LIBCPP_POP_MACROS
12701288
1271#if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)1289# endif // _LIBCPP_HAS_LOCALIZATION
1272# include <ostream>1290
1273# include <type_traits>1291# if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
1274#endif1292# include <ostream>
1293# include <type_traits>
1294# endif
1295#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
12751296
1276#endif // _LIBCPP_SSTREAM1297#endif // _LIBCPP_SSTREAM
lib/libcxx/include/stack+50-46
...@@ -113,33 +113,36 @@ template <class T, class Container>...@@ -113,33 +113,36 @@ template <class T, class Container>
113113
114*/114*/
115115
116#include <__algorithm/ranges_copy.h>116#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
117#include <__config>117# include <__cxx03/stack>
118#include <__fwd/stack.h>118#else
119#include <__iterator/back_insert_iterator.h>119# include <__algorithm/ranges_copy.h>
120#include <__iterator/iterator_traits.h>120# include <__config>
121#include <__memory/uses_allocator.h>121# include <__fwd/stack.h>
122#include <__ranges/access.h>122# include <__iterator/back_insert_iterator.h>
123#include <__ranges/concepts.h>123# include <__iterator/iterator_traits.h>
124#include <__ranges/container_compatible_range.h>124# include <__memory/uses_allocator.h>
125#include <__ranges/from_range.h>125# include <__ranges/access.h>
126#include <__type_traits/is_same.h>126# include <__ranges/concepts.h>
127#include <__utility/forward.h>127# include <__ranges/container_compatible_range.h>
128#include <deque>128# include <__ranges/from_range.h>
129#include <version>129# include <__type_traits/is_same.h>
130# include <__utility/forward.h>
131# include <deque>
132# include <version>
130133
131// standard-mandated includes134// standard-mandated includes
132135
133// [stack.syn]136// [stack.syn]
134#include <compare>137# include <compare>
135#include <initializer_list>138# include <initializer_list>
136139
137#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)140# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
138# pragma GCC system_header141# pragma GCC system_header
139#endif142# endif
140143
141_LIBCPP_PUSH_MACROS144_LIBCPP_PUSH_MACROS
142#include <__undef_macros>145# include <__undef_macros>
143146
144_LIBCPP_BEGIN_NAMESPACE_STD147_LIBCPP_BEGIN_NAMESPACE_STD
145148
...@@ -172,7 +175,7 @@ public:...@@ -172,7 +175,7 @@ public:
172 return *this;175 return *this;
173 }176 }
174177
175#ifndef _LIBCPP_CXX03_LANG178# ifndef _LIBCPP_CXX03_LANG
176 _LIBCPP_HIDE_FROM_ABI stack(stack&& __q) noexcept(is_nothrow_move_constructible<container_type>::value)179 _LIBCPP_HIDE_FROM_ABI stack(stack&& __q) noexcept(is_nothrow_move_constructible<container_type>::value)
177 : c(std::move(__q.c)) {}180 : c(std::move(__q.c)) {}
178181
...@@ -182,7 +185,7 @@ public:...@@ -182,7 +185,7 @@ public:
182 }185 }
183186
184 _LIBCPP_HIDE_FROM_ABI explicit stack(container_type&& __c) : c(std::move(__c)) {}187 _LIBCPP_HIDE_FROM_ABI explicit stack(container_type&& __c) : c(std::move(__c)) {}
185#endif // _LIBCPP_CXX03_LANG188# endif // _LIBCPP_CXX03_LANG
186189
187 _LIBCPP_HIDE_FROM_ABI explicit stack(const container_type& __c) : c(__c) {}190 _LIBCPP_HIDE_FROM_ABI explicit stack(const container_type& __c) : c(__c) {}
188191
...@@ -198,7 +201,7 @@ public:...@@ -198,7 +201,7 @@ public:
198 _LIBCPP_HIDE_FROM_ABI201 _LIBCPP_HIDE_FROM_ABI
199 stack(const stack& __s, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)202 stack(const stack& __s, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
200 : c(__s.c, __a) {}203 : c(__s.c, __a) {}
201#ifndef _LIBCPP_CXX03_LANG204# ifndef _LIBCPP_CXX03_LANG
202 template <class _Alloc>205 template <class _Alloc>
203 _LIBCPP_HIDE_FROM_ABI206 _LIBCPP_HIDE_FROM_ABI
204 stack(container_type&& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)207 stack(container_type&& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
...@@ -207,9 +210,9 @@ public:...@@ -207,9 +210,9 @@ public:
207 _LIBCPP_HIDE_FROM_ABI210 _LIBCPP_HIDE_FROM_ABI
208 stack(stack&& __s, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)211 stack(stack&& __s, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
209 : c(std::move(__s.c), __a) {}212 : c(std::move(__s.c), __a) {}
210#endif // _LIBCPP_CXX03_LANG213# endif // _LIBCPP_CXX03_LANG
211214
212#if _LIBCPP_STD_VER >= 23215# if _LIBCPP_STD_VER >= 23
213 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>216 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
214 _LIBCPP_HIDE_FROM_ABI stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}217 _LIBCPP_HIDE_FROM_ABI stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
215218
...@@ -229,18 +232,18 @@ public:...@@ -229,18 +232,18 @@ public:
229 _LIBCPP_HIDE_FROM_ABI stack(from_range_t, _Range&& __range, const _Alloc& __alloc)232 _LIBCPP_HIDE_FROM_ABI stack(from_range_t, _Range&& __range, const _Alloc& __alloc)
230 : c(from_range, std::forward<_Range>(__range), __alloc) {}233 : c(from_range, std::forward<_Range>(__range), __alloc) {}
231234
232#endif235# endif
233236
234 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }237 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
235 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }238 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
236 _LIBCPP_HIDE_FROM_ABI reference top() { return c.back(); }239 _LIBCPP_HIDE_FROM_ABI reference top() { return c.back(); }
237 _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.back(); }240 _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.back(); }
238241
239 _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); }242 _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); }
240#ifndef _LIBCPP_CXX03_LANG243# ifndef _LIBCPP_CXX03_LANG
241 _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); }244 _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); }
242245
243# if _LIBCPP_STD_VER >= 23246# if _LIBCPP_STD_VER >= 23
244 template <_ContainerCompatibleRange<_Tp> _Range>247 template <_ContainerCompatibleRange<_Tp> _Range>
245 _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {248 _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {
246 if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {249 if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {
...@@ -249,22 +252,22 @@ public:...@@ -249,22 +252,22 @@ public:
249 ranges::copy(std::forward<_Range>(__range), std::back_inserter(c));252 ranges::copy(std::forward<_Range>(__range), std::back_inserter(c));
250 }253 }
251 }254 }
252# endif255# endif
253256
254 template <class... _Args>257 template <class... _Args>
255 _LIBCPP_HIDE_FROM_ABI258 _LIBCPP_HIDE_FROM_ABI
256# if _LIBCPP_STD_VER >= 17259# if _LIBCPP_STD_VER >= 17
257 decltype(auto)260 decltype(auto)
258 emplace(_Args&&... __args) {261 emplace(_Args&&... __args) {
259 return c.emplace_back(std::forward<_Args>(__args)...);262 return c.emplace_back(std::forward<_Args>(__args)...);
260 }263 }
261# else264# else
262 void265 void
263 emplace(_Args&&... __args) {266 emplace(_Args&&... __args) {
264 c.emplace_back(std::forward<_Args>(__args)...);267 c.emplace_back(std::forward<_Args>(__args)...);
265 }268 }
266# endif269# endif
267#endif // _LIBCPP_CXX03_LANG270# endif // _LIBCPP_CXX03_LANG
268271
269 _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_back(); }272 _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_back(); }
270273
...@@ -273,7 +276,7 @@ public:...@@ -273,7 +276,7 @@ public:
273 swap(c, __s.c);276 swap(c, __s.c);
274 }277 }
275278
276 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }279 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
277280
278 template <class _T1, class _OtherContainer>281 template <class _T1, class _OtherContainer>
279 friend bool operator==(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y);282 friend bool operator==(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y);
...@@ -282,7 +285,7 @@ public:...@@ -282,7 +285,7 @@ public:
282 friend bool operator<(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y);285 friend bool operator<(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y);
283};286};
284287
285#if _LIBCPP_STD_VER >= 17288# if _LIBCPP_STD_VER >= 17
286template <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> >289template <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> >
287stack(_Container) -> stack<typename _Container::value_type, _Container>;290stack(_Container) -> stack<typename _Container::value_type, _Container>;
288291
...@@ -291,9 +294,9 @@ template <class _Container,...@@ -291,9 +294,9 @@ template <class _Container,
291 class = enable_if_t<!__is_allocator<_Container>::value>,294 class = enable_if_t<!__is_allocator<_Container>::value>,
292 class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >295 class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >
293stack(_Container, _Alloc) -> stack<typename _Container::value_type, _Container>;296stack(_Container, _Alloc) -> stack<typename _Container::value_type, _Container>;
294#endif297# endif
295298
296#if _LIBCPP_STD_VER >= 23299# if _LIBCPP_STD_VER >= 23
297template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>300template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
298stack(_InputIterator, _InputIterator) -> stack<__iter_value_type<_InputIterator>>;301stack(_InputIterator, _InputIterator) -> stack<__iter_value_type<_InputIterator>>;
299302
...@@ -313,7 +316,7 @@ stack(from_range_t,...@@ -313,7 +316,7 @@ stack(from_range_t,
313 _Range&&,316 _Range&&,
314 _Alloc) -> stack<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;317 _Alloc) -> stack<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
315318
316#endif319# endif
317320
318template <class _Tp, class _Container>321template <class _Tp, class _Container>
319inline _LIBCPP_HIDE_FROM_ABI bool operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) {322inline _LIBCPP_HIDE_FROM_ABI bool operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) {
...@@ -345,7 +348,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const stack<_Tp, _Container>& __x,...@@ -345,7 +348,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const stack<_Tp, _Container>& __x,
345 return !(__y < __x);348 return !(__y < __x);
346}349}
347350
348#if _LIBCPP_STD_VER >= 20351# if _LIBCPP_STD_VER >= 20
349352
350template <class _Tp, three_way_comparable _Container>353template <class _Tp, three_way_comparable _Container>
351_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container>354_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container>
...@@ -354,7 +357,7 @@ operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y...@@ -354,7 +357,7 @@ operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y
354 return __x.__get_container() <=> __y.__get_container();357 return __x.__get_container() <=> __y.__get_container();
355}358}
356359
357#endif360# endif
358361
359template <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0>362template <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0>
360inline _LIBCPP_HIDE_FROM_ABI void swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)363inline _LIBCPP_HIDE_FROM_ABI void swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
...@@ -370,10 +373,11 @@ _LIBCPP_END_NAMESPACE_STD...@@ -370,10 +373,11 @@ _LIBCPP_END_NAMESPACE_STD
370373
371_LIBCPP_POP_MACROS374_LIBCPP_POP_MACROS
372375
373#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20376# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
374# include <concepts>377# include <concepts>
375# include <functional>378# include <functional>
376# include <type_traits>379# include <type_traits>
377#endif380# endif
381#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
378382
379#endif // _LIBCPP_STACK383#endif // _LIBCPP_STACK
lib/libcxx/include/stdatomic.h+28-16
...@@ -103,6 +103,8 @@ using std::atomic_fetch_sub // see below...@@ -103,6 +103,8 @@ using std::atomic_fetch_sub // see below
103using std::atomic_fetch_sub_explicit // see below103using std::atomic_fetch_sub_explicit // see below
104using std::atomic_fetch_or // see below104using std::atomic_fetch_or // see below
105using std::atomic_fetch_or_explicit // see below105using std::atomic_fetch_or_explicit // see below
106using std::atomic_fetch_xor // see below
107using std::atomic_fetch_xor_explicit // see below
106using std::atomic_fetch_and // see below108using std::atomic_fetch_and // see below
107using std::atomic_fetch_and_explicit // see below109using std::atomic_fetch_and_explicit // see below
108using std::atomic_flag_test_and_set // see below110using std::atomic_flag_test_and_set // see below
...@@ -115,22 +117,25 @@ using std::atomic_signal_fence // see below...@@ -115,22 +117,25 @@ using std::atomic_signal_fence // see below
115117
116*/118*/
117119
118#include <__config>120#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
121# include <__cxx03/stdatomic.h>
122#else
123# include <__config>
119124
120#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)125# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
121# pragma GCC system_header126# pragma GCC system_header
122#endif127# endif
123128
124#if defined(__cplusplus) && _LIBCPP_STD_VER >= 23129# if defined(__cplusplus) && _LIBCPP_STD_VER >= 23
125130
126# include <atomic>131# include <atomic>
127# include <version>132# include <version>
128133
129# ifdef _Atomic134# ifdef _Atomic
130# undef _Atomic135# undef _Atomic
131# endif136# endif
132137
133# define _Atomic(_Tp) ::std::atomic<_Tp>138# define _Atomic(_Tp) ::std::atomic<_Tp>
134139
135using std::memory_order _LIBCPP_USING_IF_EXISTS;140using std::memory_order _LIBCPP_USING_IF_EXISTS;
136using std::memory_order_relaxed _LIBCPP_USING_IF_EXISTS;141using std::memory_order_relaxed _LIBCPP_USING_IF_EXISTS;
...@@ -154,10 +159,14 @@ using std::atomic_long _LIBCPP_USING_IF_EXISTS;...@@ -154,10 +159,14 @@ using std::atomic_long _LIBCPP_USING_IF_EXISTS;
154using std::atomic_ulong _LIBCPP_USING_IF_EXISTS;159using std::atomic_ulong _LIBCPP_USING_IF_EXISTS;
155using std::atomic_llong _LIBCPP_USING_IF_EXISTS;160using std::atomic_llong _LIBCPP_USING_IF_EXISTS;
156using std::atomic_ullong _LIBCPP_USING_IF_EXISTS;161using std::atomic_ullong _LIBCPP_USING_IF_EXISTS;
162# if _LIBCPP_HAS_CHAR8_T
157using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS;163using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS;
164# endif
158using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS;165using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS;
159using std::atomic_char32_t _LIBCPP_USING_IF_EXISTS;166using std::atomic_char32_t _LIBCPP_USING_IF_EXISTS;
167# if _LIBCPP_HAS_WIDE_CHARACTERS
160using std::atomic_wchar_t _LIBCPP_USING_IF_EXISTS;168using std::atomic_wchar_t _LIBCPP_USING_IF_EXISTS;
169# endif
161170
162using std::atomic_int8_t _LIBCPP_USING_IF_EXISTS;171using std::atomic_int8_t _LIBCPP_USING_IF_EXISTS;
163using std::atomic_uint8_t _LIBCPP_USING_IF_EXISTS;172using std::atomic_uint8_t _LIBCPP_USING_IF_EXISTS;
...@@ -204,6 +213,8 @@ using std::atomic_fetch_add_explicit _LIBCPP_USING_IF_EXISTS;...@@ -204,6 +213,8 @@ using std::atomic_fetch_add_explicit _LIBCPP_USING_IF_EXISTS;
204using std::atomic_fetch_and _LIBCPP_USING_IF_EXISTS;213using std::atomic_fetch_and _LIBCPP_USING_IF_EXISTS;
205using std::atomic_fetch_and_explicit _LIBCPP_USING_IF_EXISTS;214using std::atomic_fetch_and_explicit _LIBCPP_USING_IF_EXISTS;
206using std::atomic_fetch_or _LIBCPP_USING_IF_EXISTS;215using std::atomic_fetch_or _LIBCPP_USING_IF_EXISTS;
216using std::atomic_fetch_xor_explicit _LIBCPP_USING_IF_EXISTS;
217using std::atomic_fetch_xor _LIBCPP_USING_IF_EXISTS;
207using std::atomic_fetch_or_explicit _LIBCPP_USING_IF_EXISTS;218using std::atomic_fetch_or_explicit _LIBCPP_USING_IF_EXISTS;
208using std::atomic_fetch_sub _LIBCPP_USING_IF_EXISTS;219using std::atomic_fetch_sub _LIBCPP_USING_IF_EXISTS;
209using std::atomic_fetch_sub_explicit _LIBCPP_USING_IF_EXISTS;220using std::atomic_fetch_sub_explicit _LIBCPP_USING_IF_EXISTS;
...@@ -220,16 +231,17 @@ using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS;...@@ -220,16 +231,17 @@ using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS;
220using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS;231using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS;
221using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS;232using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS;
222233
223#elif defined(_LIBCPP_COMPILER_CLANG_BASED)234# elif defined(_LIBCPP_COMPILER_CLANG_BASED)
224235
225// Before C++23, we include the next <stdatomic.h> on the path to avoid hijacking236// Before C++23, we include the next <stdatomic.h> on the path to avoid hijacking
226// the header. We do this because Clang has historically shipped a <stdatomic.h>237// the header. We do this because Clang has historically shipped a <stdatomic.h>
227// header that would be available in all Standard modes, and we don't want to238// header that would be available in all Standard modes, and we don't want to
228// break that use case.239// break that use case.
229# if __has_include_next(<stdatomic.h>)240# if __has_include_next(<stdatomic.h>)
230# include_next <stdatomic.h>241# include_next <stdatomic.h>
231# endif242# endif
232243
233#endif // defined(__cplusplus) && _LIBCPP_STD_VER >= 23244# endif // defined(__cplusplus) && _LIBCPP_STD_VER >= 23
245#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
234246
235#endif // _LIBCPP_STDATOMIC_H247#endif // _LIBCPP_STDATOMIC_H
lib/libcxx/include/stdbool.h+21-17
...@@ -19,22 +19,26 @@ Macros:...@@ -19,22 +19,26 @@ Macros:
1919
20*/20*/
2121
22#include <__config>22#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
2323# include <__cxx03/stdbool.h>
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#else
25# pragma GCC system_header25# include <__config>
26#endif26
2727# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28#if __has_include_next(<stdbool.h>)28# pragma GCC system_header
29# include_next <stdbool.h>29# endif
30#endif30
3131# if __has_include_next(<stdbool.h>)
32#ifdef __cplusplus32# include_next <stdbool.h>
33# undef bool33# endif
34# undef true34
35# undef false35# ifdef __cplusplus
36# undef __bool_true_false_are_defined36# undef bool
37# define __bool_true_false_are_defined 137# undef true
38#endif38# undef false
39# undef __bool_true_false_are_defined
40# define __bool_true_false_are_defined 1
41# endif
42#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
3943
40#endif // _LIBCPP_STDBOOL_H44#endif // _LIBCPP_STDBOOL_H
lib/libcxx/include/stddef.h+13-9
...@@ -24,21 +24,25 @@ Types:...@@ -24,21 +24,25 @@ Types:
2424
25*/25*/
2626
27#include <__config>27#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
28# include <__cxx03/stddef.h>
29#else
30# include <__config>
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
31#endif34# endif
3235
33// Note: This include is outside of header guards because we sometimes get included multiple times36// Note: This include is outside of header guards because we sometimes get included multiple times
34// with different defines and the underlying <stddef.h> will know how to deal with that.37// with different defines and the underlying <stddef.h> will know how to deal with that.
35#include_next <stddef.h>38# include_next <stddef.h>
3639
37#ifndef _LIBCPP_STDDEF_H40# ifndef _LIBCPP_STDDEF_H
38# define _LIBCPP_STDDEF_H41# define _LIBCPP_STDDEF_H
3942
40# ifdef __cplusplus43# ifdef __cplusplus
41typedef decltype(nullptr) nullptr_t;44typedef decltype(nullptr) nullptr_t;
42# endif45# endif
46# endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
4347
44#endif // _LIBCPP_STDDEF_H48#endif // _LIBCPP_STDDEF_H
lib/libcxx/include/stdexcept+73-67
...@@ -41,18 +41,21 @@ public:...@@ -41,18 +41,21 @@ public:
4141
42*/42*/
4343
44#include <__config>44#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
45#include <__exception/exception.h>45# include <__cxx03/stdexcept>
46#include <__fwd/string.h>46#else
47#include <__verbose_abort>47# include <__config>
48# include <__exception/exception.h>
49# include <__fwd/string.h>
50# include <__verbose_abort>
4851
49#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)52# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
50# pragma GCC system_header53# pragma GCC system_header
51#endif54# endif
5255
53_LIBCPP_BEGIN_NAMESPACE_STD56_LIBCPP_BEGIN_NAMESPACE_STD
5457
55#ifndef _LIBCPP_ABI_VCRUNTIME58# ifndef _LIBCPP_ABI_VCRUNTIME
56class _LIBCPP_HIDDEN __libcpp_refstring {59class _LIBCPP_HIDDEN __libcpp_refstring {
57 const char* __imp_;60 const char* __imp_;
5861
...@@ -66,7 +69,7 @@ public:...@@ -66,7 +69,7 @@ public:
6669
67 _LIBCPP_HIDE_FROM_ABI const char* c_str() const _NOEXCEPT { return __imp_; }70 _LIBCPP_HIDE_FROM_ABI const char* c_str() const _NOEXCEPT { return __imp_; }
68};71};
69#endif // !_LIBCPP_ABI_VCRUNTIME72# endif // !_LIBCPP_ABI_VCRUNTIME
7073
71_LIBCPP_END_NAMESPACE_STD74_LIBCPP_END_NAMESPACE_STD
7275
...@@ -74,7 +77,7 @@ namespace std // purposefully not using versioning namespace...@@ -74,7 +77,7 @@ namespace std // purposefully not using versioning namespace
74{77{
7578
76class _LIBCPP_EXPORTED_FROM_ABI logic_error : public exception {79class _LIBCPP_EXPORTED_FROM_ABI logic_error : public exception {
77#ifndef _LIBCPP_ABI_VCRUNTIME80# ifndef _LIBCPP_ABI_VCRUNTIME
7881
79private:82private:
80 std::__libcpp_refstring __imp_;83 std::__libcpp_refstring __imp_;
...@@ -89,16 +92,16 @@ public:...@@ -89,16 +92,16 @@ public:
89 ~logic_error() _NOEXCEPT override;92 ~logic_error() _NOEXCEPT override;
9093
91 const char* what() const _NOEXCEPT override;94 const char* what() const _NOEXCEPT override;
92#else95# else
9396
94public:97public:
95 explicit logic_error(const std::string&); // Symbol uses versioned std::string98 explicit logic_error(const std::string&); // Symbol uses versioned std::string
96 _LIBCPP_HIDE_FROM_ABI explicit logic_error(const char* __s) : exception(__s) {}99 _LIBCPP_HIDE_FROM_ABI explicit logic_error(const char* __s) : exception(__s) {}
97#endif100# endif
98};101};
99102
100class _LIBCPP_EXPORTED_FROM_ABI runtime_error : public exception {103class _LIBCPP_EXPORTED_FROM_ABI runtime_error : public exception {
101#ifndef _LIBCPP_ABI_VCRUNTIME104# ifndef _LIBCPP_ABI_VCRUNTIME
102105
103private:106private:
104 std::__libcpp_refstring __imp_;107 std::__libcpp_refstring __imp_;
...@@ -113,12 +116,12 @@ public:...@@ -113,12 +116,12 @@ public:
113 ~runtime_error() _NOEXCEPT override;116 ~runtime_error() _NOEXCEPT override;
114117
115 const char* what() const _NOEXCEPT override;118 const char* what() const _NOEXCEPT override;
116#else119# else
117120
118public:121public:
119 explicit runtime_error(const std::string&); // Symbol uses versioned std::string122 explicit runtime_error(const std::string&); // Symbol uses versioned std::string
120 _LIBCPP_HIDE_FROM_ABI explicit runtime_error(const char* __s) : exception(__s) {}123 _LIBCPP_HIDE_FROM_ABI explicit runtime_error(const char* __s) : exception(__s) {}
121#endif // _LIBCPP_ABI_VCRUNTIME124# endif // _LIBCPP_ABI_VCRUNTIME
122};125};
123126
124class _LIBCPP_EXPORTED_FROM_ABI domain_error : public logic_error {127class _LIBCPP_EXPORTED_FROM_ABI domain_error : public logic_error {
...@@ -126,11 +129,11 @@ public:...@@ -126,11 +129,11 @@ public:
126 _LIBCPP_HIDE_FROM_ABI explicit domain_error(const string& __s) : logic_error(__s) {}129 _LIBCPP_HIDE_FROM_ABI explicit domain_error(const string& __s) : logic_error(__s) {}
127 _LIBCPP_HIDE_FROM_ABI explicit domain_error(const char* __s) : logic_error(__s) {}130 _LIBCPP_HIDE_FROM_ABI explicit domain_error(const char* __s) : logic_error(__s) {}
128131
129#ifndef _LIBCPP_ABI_VCRUNTIME132# ifndef _LIBCPP_ABI_VCRUNTIME
130 _LIBCPP_HIDE_FROM_ABI domain_error(const domain_error&) _NOEXCEPT = default;133 _LIBCPP_HIDE_FROM_ABI domain_error(const domain_error&) _NOEXCEPT = default;
131 _LIBCPP_HIDE_FROM_ABI domain_error& operator=(const domain_error&) _NOEXCEPT = default;134 _LIBCPP_HIDE_FROM_ABI domain_error& operator=(const domain_error&) _NOEXCEPT = default;
132 ~domain_error() _NOEXCEPT override;135 ~domain_error() _NOEXCEPT override;
133#endif136# endif
134};137};
135138
136class _LIBCPP_EXPORTED_FROM_ABI invalid_argument : public logic_error {139class _LIBCPP_EXPORTED_FROM_ABI invalid_argument : public logic_error {
...@@ -138,22 +141,22 @@ public:...@@ -138,22 +141,22 @@ public:
138 _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const string& __s) : logic_error(__s) {}141 _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const string& __s) : logic_error(__s) {}
139 _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const char* __s) : logic_error(__s) {}142 _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const char* __s) : logic_error(__s) {}
140143
141#ifndef _LIBCPP_ABI_VCRUNTIME144# ifndef _LIBCPP_ABI_VCRUNTIME
142 _LIBCPP_HIDE_FROM_ABI invalid_argument(const invalid_argument&) _NOEXCEPT = default;145 _LIBCPP_HIDE_FROM_ABI invalid_argument(const invalid_argument&) _NOEXCEPT = default;
143 _LIBCPP_HIDE_FROM_ABI invalid_argument& operator=(const invalid_argument&) _NOEXCEPT = default;146 _LIBCPP_HIDE_FROM_ABI invalid_argument& operator=(const invalid_argument&) _NOEXCEPT = default;
144 ~invalid_argument() _NOEXCEPT override;147 ~invalid_argument() _NOEXCEPT override;
145#endif148# endif
146};149};
147150
148class _LIBCPP_EXPORTED_FROM_ABI length_error : public logic_error {151class _LIBCPP_EXPORTED_FROM_ABI length_error : public logic_error {
149public:152public:
150 _LIBCPP_HIDE_FROM_ABI explicit length_error(const string& __s) : logic_error(__s) {}153 _LIBCPP_HIDE_FROM_ABI explicit length_error(const string& __s) : logic_error(__s) {}
151 _LIBCPP_HIDE_FROM_ABI explicit length_error(const char* __s) : logic_error(__s) {}154 _LIBCPP_HIDE_FROM_ABI explicit length_error(const char* __s) : logic_error(__s) {}
152#ifndef _LIBCPP_ABI_VCRUNTIME155# ifndef _LIBCPP_ABI_VCRUNTIME
153 _LIBCPP_HIDE_FROM_ABI length_error(const length_error&) _NOEXCEPT = default;156 _LIBCPP_HIDE_FROM_ABI length_error(const length_error&) _NOEXCEPT = default;
154 _LIBCPP_HIDE_FROM_ABI length_error& operator=(const length_error&) _NOEXCEPT = default;157 _LIBCPP_HIDE_FROM_ABI length_error& operator=(const length_error&) _NOEXCEPT = default;
155 ~length_error() _NOEXCEPT override;158 ~length_error() _NOEXCEPT override;
156#endif159# endif
157};160};
158161
159class _LIBCPP_EXPORTED_FROM_ABI out_of_range : public logic_error {162class _LIBCPP_EXPORTED_FROM_ABI out_of_range : public logic_error {
...@@ -161,11 +164,11 @@ public:...@@ -161,11 +164,11 @@ public:
161 _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const string& __s) : logic_error(__s) {}164 _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const string& __s) : logic_error(__s) {}
162 _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const char* __s) : logic_error(__s) {}165 _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const char* __s) : logic_error(__s) {}
163166
164#ifndef _LIBCPP_ABI_VCRUNTIME167# ifndef _LIBCPP_ABI_VCRUNTIME
165 _LIBCPP_HIDE_FROM_ABI out_of_range(const out_of_range&) _NOEXCEPT = default;168 _LIBCPP_HIDE_FROM_ABI out_of_range(const out_of_range&) _NOEXCEPT = default;
166 _LIBCPP_HIDE_FROM_ABI out_of_range& operator=(const out_of_range&) _NOEXCEPT = default;169 _LIBCPP_HIDE_FROM_ABI out_of_range& operator=(const out_of_range&) _NOEXCEPT = default;
167 ~out_of_range() _NOEXCEPT override;170 ~out_of_range() _NOEXCEPT override;
168#endif171# endif
169};172};
170173
171class _LIBCPP_EXPORTED_FROM_ABI range_error : public runtime_error {174class _LIBCPP_EXPORTED_FROM_ABI range_error : public runtime_error {
...@@ -173,11 +176,11 @@ public:...@@ -173,11 +176,11 @@ public:
173 _LIBCPP_HIDE_FROM_ABI explicit range_error(const string& __s) : runtime_error(__s) {}176 _LIBCPP_HIDE_FROM_ABI explicit range_error(const string& __s) : runtime_error(__s) {}
174 _LIBCPP_HIDE_FROM_ABI explicit range_error(const char* __s) : runtime_error(__s) {}177 _LIBCPP_HIDE_FROM_ABI explicit range_error(const char* __s) : runtime_error(__s) {}
175178
176#ifndef _LIBCPP_ABI_VCRUNTIME179# ifndef _LIBCPP_ABI_VCRUNTIME
177 _LIBCPP_HIDE_FROM_ABI range_error(const range_error&) _NOEXCEPT = default;180 _LIBCPP_HIDE_FROM_ABI range_error(const range_error&) _NOEXCEPT = default;
178 _LIBCPP_HIDE_FROM_ABI range_error& operator=(const range_error&) _NOEXCEPT = default;181 _LIBCPP_HIDE_FROM_ABI range_error& operator=(const range_error&) _NOEXCEPT = default;
179 ~range_error() _NOEXCEPT override;182 ~range_error() _NOEXCEPT override;
180#endif183# endif
181};184};
182185
183class _LIBCPP_EXPORTED_FROM_ABI overflow_error : public runtime_error {186class _LIBCPP_EXPORTED_FROM_ABI overflow_error : public runtime_error {
...@@ -185,11 +188,11 @@ public:...@@ -185,11 +188,11 @@ public:
185 _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const string& __s) : runtime_error(__s) {}188 _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const string& __s) : runtime_error(__s) {}
186 _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const char* __s) : runtime_error(__s) {}189 _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const char* __s) : runtime_error(__s) {}
187190
188#ifndef _LIBCPP_ABI_VCRUNTIME191# ifndef _LIBCPP_ABI_VCRUNTIME
189 _LIBCPP_HIDE_FROM_ABI overflow_error(const overflow_error&) _NOEXCEPT = default;192 _LIBCPP_HIDE_FROM_ABI overflow_error(const overflow_error&) _NOEXCEPT = default;
190 _LIBCPP_HIDE_FROM_ABI overflow_error& operator=(const overflow_error&) _NOEXCEPT = default;193 _LIBCPP_HIDE_FROM_ABI overflow_error& operator=(const overflow_error&) _NOEXCEPT = default;
191 ~overflow_error() _NOEXCEPT override;194 ~overflow_error() _NOEXCEPT override;
192#endif195# endif
193};196};
194197
195class _LIBCPP_EXPORTED_FROM_ABI underflow_error : public runtime_error {198class _LIBCPP_EXPORTED_FROM_ABI underflow_error : public runtime_error {
...@@ -197,11 +200,11 @@ public:...@@ -197,11 +200,11 @@ public:
197 _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const string& __s) : runtime_error(__s) {}200 _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const string& __s) : runtime_error(__s) {}
198 _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const char* __s) : runtime_error(__s) {}201 _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const char* __s) : runtime_error(__s) {}
199202
200#ifndef _LIBCPP_ABI_VCRUNTIME203# ifndef _LIBCPP_ABI_VCRUNTIME
201 _LIBCPP_HIDE_FROM_ABI underflow_error(const underflow_error&) _NOEXCEPT = default;204 _LIBCPP_HIDE_FROM_ABI underflow_error(const underflow_error&) _NOEXCEPT = default;
202 _LIBCPP_HIDE_FROM_ABI underflow_error& operator=(const underflow_error&) _NOEXCEPT = default;205 _LIBCPP_HIDE_FROM_ABI underflow_error& operator=(const underflow_error&) _NOEXCEPT = default;
203 ~underflow_error() _NOEXCEPT override;206 ~underflow_error() _NOEXCEPT override;
204#endif207# endif
205};208};
206209
207} // namespace std210} // namespace std
...@@ -209,78 +212,81 @@ public:...@@ -209,78 +212,81 @@ public:
209_LIBCPP_BEGIN_NAMESPACE_STD212_LIBCPP_BEGIN_NAMESPACE_STD
210213
211// in the dylib214// in the dylib
212_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_runtime_error(const char*);215[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_runtime_error(const char*);
213216
214_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_logic_error(const char* __msg) {217[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_logic_error(const char* __msg) {
215#ifndef _LIBCPP_HAS_NO_EXCEPTIONS218# if _LIBCPP_HAS_EXCEPTIONS
216 throw logic_error(__msg);219 throw logic_error(__msg);
217#else220# else
218 _LIBCPP_VERBOSE_ABORT("logic_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);221 _LIBCPP_VERBOSE_ABORT("logic_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
219#endif222# endif
220}223}
221224
222_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_domain_error(const char* __msg) {225[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_domain_error(const char* __msg) {
223#ifndef _LIBCPP_HAS_NO_EXCEPTIONS226# if _LIBCPP_HAS_EXCEPTIONS
224 throw domain_error(__msg);227 throw domain_error(__msg);
225#else228# else
226 _LIBCPP_VERBOSE_ABORT("domain_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);229 _LIBCPP_VERBOSE_ABORT("domain_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
227#endif230# endif
228}231}
229232
230_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_invalid_argument(const char* __msg) {233[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_invalid_argument(const char* __msg) {
231#ifndef _LIBCPP_HAS_NO_EXCEPTIONS234# if _LIBCPP_HAS_EXCEPTIONS
232 throw invalid_argument(__msg);235 throw invalid_argument(__msg);
233#else236# else
234 _LIBCPP_VERBOSE_ABORT("invalid_argument was thrown in -fno-exceptions mode with message \"%s\"", __msg);237 _LIBCPP_VERBOSE_ABORT("invalid_argument was thrown in -fno-exceptions mode with message \"%s\"", __msg);
235#endif238# endif
236}239}
237240
238_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_length_error(const char* __msg) {241[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_length_error(const char* __msg) {
239#ifndef _LIBCPP_HAS_NO_EXCEPTIONS242# if _LIBCPP_HAS_EXCEPTIONS
240 throw length_error(__msg);243 throw length_error(__msg);
241#else244# else
242 _LIBCPP_VERBOSE_ABORT("length_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);245 _LIBCPP_VERBOSE_ABORT("length_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
243#endif246# endif
244}247}
245248
246_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const char* __msg) {249[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const char* __msg) {
247#ifndef _LIBCPP_HAS_NO_EXCEPTIONS250# if _LIBCPP_HAS_EXCEPTIONS
248 throw out_of_range(__msg);251 throw out_of_range(__msg);
249#else252# else
250 _LIBCPP_VERBOSE_ABORT("out_of_range was thrown in -fno-exceptions mode with message \"%s\"", __msg);253 _LIBCPP_VERBOSE_ABORT("out_of_range was thrown in -fno-exceptions mode with message \"%s\"", __msg);
251#endif254# endif
252}255}
253256
254_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_range_error(const char* __msg) {257[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_range_error(const char* __msg) {
255#ifndef _LIBCPP_HAS_NO_EXCEPTIONS258# if _LIBCPP_HAS_EXCEPTIONS
256 throw range_error(__msg);259 throw range_error(__msg);
257#else260# else
258 _LIBCPP_VERBOSE_ABORT("range_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);261 _LIBCPP_VERBOSE_ABORT("range_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
259#endif262# endif
260}263}
261264
262_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_overflow_error(const char* __msg) {265[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_overflow_error(const char* __msg) {
263#ifndef _LIBCPP_HAS_NO_EXCEPTIONS266# if _LIBCPP_HAS_EXCEPTIONS
264 throw overflow_error(__msg);267 throw overflow_error(__msg);
265#else268# else
266 _LIBCPP_VERBOSE_ABORT("overflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);269 _LIBCPP_VERBOSE_ABORT("overflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
267#endif270# endif
268}271}
269272
270_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_underflow_error(const char* __msg) {273[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_underflow_error(const char* __msg) {
271#ifndef _LIBCPP_HAS_NO_EXCEPTIONS274# if _LIBCPP_HAS_EXCEPTIONS
272 throw underflow_error(__msg);275 throw underflow_error(__msg);
273#else276# else
274 _LIBCPP_VERBOSE_ABORT("underflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);277 _LIBCPP_VERBOSE_ABORT("underflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
275#endif278# endif
276}279}
277280
278_LIBCPP_END_NAMESPACE_STD281_LIBCPP_END_NAMESPACE_STD
279282
280#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20283# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
281# include <cstdlib>284# include <cstddef>
282# include <exception>285# include <cstdlib>
283# include <iosfwd>286# include <exception>
284#endif287# include <iosfwd>
288# include <new>
289# endif
290#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
285291
286#endif // _LIBCPP_STDEXCEPT292#endif // _LIBCPP_STDEXCEPT
lib/libcxx/include/stdint.h deleted-127
...@@ -1,127 +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_STDINT_H
11// AIX system headers need stdint.h to be re-enterable while _STD_TYPES_T
12// is defined until an inclusion of it without _STD_TYPES_T occurs, in which
13// case the header guard macro is defined.
14#if !defined(_AIX) || !defined(_STD_TYPES_T)
15# define _LIBCPP_STDINT_H
16#endif // _STD_TYPES_T
17
18/*
19 stdint.h synopsis
20
21Macros:
22
23 INT8_MIN
24 INT16_MIN
25 INT32_MIN
26 INT64_MIN
27
28 INT8_MAX
29 INT16_MAX
30 INT32_MAX
31 INT64_MAX
32
33 UINT8_MAX
34 UINT16_MAX
35 UINT32_MAX
36 UINT64_MAX
37
38 INT_LEAST8_MIN
39 INT_LEAST16_MIN
40 INT_LEAST32_MIN
41 INT_LEAST64_MIN
42
43 INT_LEAST8_MAX
44 INT_LEAST16_MAX
45 INT_LEAST32_MAX
46 INT_LEAST64_MAX
47
48 UINT_LEAST8_MAX
49 UINT_LEAST16_MAX
50 UINT_LEAST32_MAX
51 UINT_LEAST64_MAX
52
53 INT_FAST8_MIN
54 INT_FAST16_MIN
55 INT_FAST32_MIN
56 INT_FAST64_MIN
57
58 INT_FAST8_MAX
59 INT_FAST16_MAX
60 INT_FAST32_MAX
61 INT_FAST64_MAX
62
63 UINT_FAST8_MAX
64 UINT_FAST16_MAX
65 UINT_FAST32_MAX
66 UINT_FAST64_MAX
67
68 INTPTR_MIN
69 INTPTR_MAX
70 UINTPTR_MAX
71
72 INTMAX_MIN
73 INTMAX_MAX
74
75 UINTMAX_MAX
76
77 PTRDIFF_MIN
78 PTRDIFF_MAX
79
80 SIG_ATOMIC_MIN
81 SIG_ATOMIC_MAX
82
83 SIZE_MAX
84
85 WCHAR_MIN
86 WCHAR_MAX
87
88 WINT_MIN
89 WINT_MAX
90
91 INT8_C(value)
92 INT16_C(value)
93 INT32_C(value)
94 INT64_C(value)
95
96 UINT8_C(value)
97 UINT16_C(value)
98 UINT32_C(value)
99 UINT64_C(value)
100
101 INTMAX_C(value)
102 UINTMAX_C(value)
103
104*/
105
106#include <__config>
107
108#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
109# pragma GCC system_header
110#endif
111
112/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
113 for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
114 are defined
115*/
116#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
117# define __STDC_LIMIT_MACROS
118#endif
119#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
120# define __STDC_CONSTANT_MACROS
121#endif
122
123#if __has_include_next(<stdint.h>)
124# include_next <stdint.h>
125#endif
126
127#endif // _LIBCPP_STDINT_H
lib/libcxx/include/stdio.h+20-21
...@@ -7,17 +7,6 @@...@@ -7,17 +7,6 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#if defined(__need_FILE) || defined(__need___FILE)
11
12# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
13# pragma GCC system_header
14# endif
15
16# include_next <stdio.h>
17
18#elif !defined(_LIBCPP_STDIO_H)
19# define _LIBCPP_STDIO_H
20
21/*10/*
22 stdio.h synopsis11 stdio.h synopsis
2312
...@@ -98,26 +87,36 @@ int ferror(FILE* stream);...@@ -98,26 +87,36 @@ int ferror(FILE* stream);
98void perror(const char* s);87void perror(const char* s);
99*/88*/
10089
90#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
91# include <__cxx03/stdio.h>
92#else
101# include <__config>93# include <__config>
10294
103# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)95# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
104# pragma GCC system_header96# pragma GCC system_header
105# endif97# endif
10698
99// The inclusion of the system's <stdio.h> is intentionally done once outside of any include
100// guards because some code expects to be able to include the underlying system header multiple
101// times to get different definitions based on the macros that are set before inclusion.
107# if __has_include_next(<stdio.h>)102# if __has_include_next(<stdio.h>)
108# include_next <stdio.h>103# include_next <stdio.h>
109# endif104# endif
110105
111# ifdef __cplusplus106# ifndef _LIBCPP_STDIO_H
107# define _LIBCPP_STDIO_H
112108
113# undef getc109# ifdef __cplusplus
114# undef putc
115# undef clearerr
116# undef feof
117# undef ferror
118# undef putchar
119# undef getchar
120110
121# endif111# undef getc
112# undef putc
113# undef clearerr
114# undef feof
115# undef ferror
116# undef putchar
117# undef getchar
118
119# endif // __cplusplus
120# endif // _LIBCPP_STDIO_H
122121
123#endif // _LIBCPP_STDIO_H122#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/stdlib.h+42-43
...@@ -7,17 +7,6 @@...@@ -7,17 +7,6 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#if defined(__need_malloc_and_calloc)
11
12# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
13# pragma GCC system_header
14# endif
15
16# include_next <stdlib.h>
17
18#elif !defined(_LIBCPP_STDLIB_H)
19# define _LIBCPP_STDLIB_H
20
21/*10/*
22 stdlib.h synopsis11 stdlib.h synopsis
2312
...@@ -84,68 +73,78 @@ void *aligned_alloc(size_t alignment, size_t size); // C11...@@ -84,68 +73,78 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
8473
85*/74*/
8675
76#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
77# include <__cxx03/stdlib.h>
78#else
87# include <__config>79# include <__config>
8880
89# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)81# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
90# pragma GCC system_header82# pragma GCC system_header
91# endif83# endif
9284
85// The inclusion of the system's <stdlib.h> is intentionally done once outside of any include
86// guards because some code expects to be able to include the underlying system header multiple
87// times to get different definitions based on the macros that are set before inclusion.
93# if __has_include_next(<stdlib.h>)88# if __has_include_next(<stdlib.h>)
94# include_next <stdlib.h>89# include_next <stdlib.h>
95# endif90# endif
9691
97# ifdef __cplusplus92# if !defined(_LIBCPP_STDLIB_H)
93# define _LIBCPP_STDLIB_H
94
95# ifdef __cplusplus
98extern "C++" {96extern "C++" {
99// abs97// abs
10098
101# ifdef abs99# ifdef abs
102# undef abs100# undef abs
103# endif101# endif
104# ifdef labs102# ifdef labs
105# undef labs103# undef labs
106# endif104# endif
107# ifdef llabs105# ifdef llabs
108# undef llabs106# undef llabs
109# endif107# endif
110108
111// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined109// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
112# if !defined(_LIBCPP_MSVCRT)110# if !defined(_LIBCPP_MSVCRT)
113_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); }111[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); }
114_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); }112[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); }
115# endif // !defined(_LIBCPP_MSVCRT)113# endif // !defined(_LIBCPP_MSVCRT)
116114
117_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT {115[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT {
118 return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h116 return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h
119}117}
120118
121_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT {119[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT {
122 return __builtin_fabs(__lcpp_x);120 return __builtin_fabs(__lcpp_x);
123}121}
124122
125_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT {123[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT {
126 return __builtin_fabsl(__lcpp_x);124 return __builtin_fabsl(__lcpp_x);
127}125}
128126
129// div127// div
130128
131# ifdef div129# ifdef div
132# undef div130# undef div
133# endif131# endif
134# ifdef ldiv132# ifdef ldiv
135# undef ldiv133# undef ldiv
136# endif134# endif
137# ifdef lldiv135# ifdef lldiv
138# undef lldiv136# undef lldiv
139# endif137# endif
140138
141// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined139// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
142# if !defined(_LIBCPP_MSVCRT)140# if !defined(_LIBCPP_MSVCRT)
143inline _LIBCPP_HIDE_FROM_ABI ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); }141inline _LIBCPP_HIDE_FROM_ABI ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); }
144# if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED))142# if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED))
145inline _LIBCPP_HIDE_FROM_ABI lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); }143inline _LIBCPP_HIDE_FROM_ABI lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); }
146# endif144# endif
147# endif // _LIBCPP_MSVCRT145# endif // _LIBCPP_MSVCRT
148} // extern "C++"146} // extern "C++"
149# endif // __cplusplus147# endif // __cplusplus
148# endif // _LIBCPP_STDLIB_H
150149
151#endif // _LIBCPP_STDLIB_H150#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/stop_token+20-15
...@@ -31,26 +31,31 @@ namespace std {...@@ -31,26 +31,31 @@ namespace std {
3131
32*/32*/
3333
34#include <__config>34#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
35# include <__cxx03/stop_token>
36#else
37# include <__config>
3538
36#if !defined(_LIBCPP_HAS_NO_THREADS)39# if _LIBCPP_HAS_THREADS
3740
38# if _LIBCPP_STD_VER >= 2041# if _LIBCPP_STD_VER >= 20
39# include <__stop_token/stop_callback.h>42# include <__stop_token/stop_callback.h>
40# include <__stop_token/stop_source.h>43# include <__stop_token/stop_source.h>
41# include <__stop_token/stop_token.h>44# include <__stop_token/stop_token.h>
42# endif45# endif
4346
44# include <version>47# include <version>
4548
46# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)49# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
47# pragma GCC system_header50# pragma GCC system_header
48# endif51# endif
4952
50#endif // !defined(_LIBCPP_HAS_NO_THREADS)53# endif // _LIBCPP_HAS_THREADS
5154
52#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 2055# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
53# include <iosfwd>56# include <cstddef>
54#endif57# include <iosfwd>
58# endif
59#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
5560
56#endif // _LIBCPP_STOP_TOKEN61#endif // _LIBCPP_STOP_TOKEN
lib/libcxx/include/streambuf+126-179
...@@ -107,23 +107,29 @@ protected:...@@ -107,23 +107,29 @@ protected:
107107
108*/108*/
109109
110#include <__assert>110#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
111#include <__config>111# include <__cxx03/streambuf>
112#include <__fwd/streambuf.h>112#else
113#include <__locale>113# include <__config>
114#include <__type_traits/is_same.h>114
115#include <__utility/is_valid_range.h>115# if _LIBCPP_HAS_LOCALIZATION
116#include <climits>116
117#include <ios>117# include <__assert>
118#include <iosfwd>118# include <__fwd/streambuf.h>
119#include <version>119# include <__locale>
120120# include <__type_traits/is_same.h>
121#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)121# include <__utility/is_valid_range.h>
122# pragma GCC system_header122# include <climits>
123#endif123# include <ios>
124# include <iosfwd>
125# include <version>
126
127# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
128# pragma GCC system_header
129# endif
124130
125_LIBCPP_PUSH_MACROS131_LIBCPP_PUSH_MACROS
126#include <__undef_macros>132# include <__undef_macros>
127133
128_LIBCPP_BEGIN_NAMESPACE_STD134_LIBCPP_BEGIN_NAMESPACE_STD
129135
...@@ -140,7 +146,7 @@ public:...@@ -140,7 +146,7 @@ public:
140 static_assert(is_same<_CharT, typename traits_type::char_type>::value,146 static_assert(is_same<_CharT, typename traits_type::char_type>::value,
141 "traits_type::char_type must be the same type as CharT");147 "traits_type::char_type must be the same type as CharT");
142148
143 virtual ~basic_streambuf();149 virtual ~basic_streambuf() {}
144150
145 // 27.6.2.2.1 locales:151 // 27.6.2.2.1 locales:
146 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 locale pubimbue(const locale& __loc) {152 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 locale pubimbue(const locale& __loc) {
...@@ -223,10 +229,36 @@ public:...@@ -223,10 +229,36 @@ public:
223 }229 }
224230
225protected:231protected:
226 basic_streambuf();232 basic_streambuf() {}
227 basic_streambuf(const basic_streambuf& __rhs);233 basic_streambuf(const basic_streambuf& __sb)
228 basic_streambuf& operator=(const basic_streambuf& __rhs);234 : __loc_(__sb.__loc_),
229 void swap(basic_streambuf& __rhs);235 __binp_(__sb.__binp_),
236 __ninp_(__sb.__ninp_),
237 __einp_(__sb.__einp_),
238 __bout_(__sb.__bout_),
239 __nout_(__sb.__nout_),
240 __eout_(__sb.__eout_) {}
241
242 basic_streambuf& operator=(const basic_streambuf& __sb) {
243 __loc_ = __sb.__loc_;
244 __binp_ = __sb.__binp_;
245 __ninp_ = __sb.__ninp_;
246 __einp_ = __sb.__einp_;
247 __bout_ = __sb.__bout_;
248 __nout_ = __sb.__nout_;
249 __eout_ = __sb.__eout_;
250 return *this;
251 }
252
253 void swap(basic_streambuf& __sb) {
254 std::swap(__loc_, __sb.__loc_);
255 std::swap(__binp_, __sb.__binp_);
256 std::swap(__ninp_, __sb.__ninp_);
257 std::swap(__einp_, __sb.__einp_);
258 std::swap(__bout_, __sb.__bout_);
259 std::swap(__nout_, __sb.__nout_);
260 std::swap(__eout_, __sb.__eout_);
261 }
230262
231 // 27.6.2.3.2 Get area:263 // 27.6.2.3.2 Get area:
232 _LIBCPP_HIDE_FROM_ABI char_type* eback() const { return __binp_; }264 _LIBCPP_HIDE_FROM_ABI char_type* eback() const { return __binp_; }
...@@ -261,185 +293,100 @@ protected:...@@ -261,185 +293,100 @@ protected:
261293
262 // 27.6.2.4 virtual functions:294 // 27.6.2.4 virtual functions:
263 // 27.6.2.4.1 Locales:295 // 27.6.2.4.1 Locales:
264 virtual void imbue(const locale& __loc);296 virtual void imbue(const locale&) {}
265297
266 // 27.6.2.4.2 Buffer management and positioning:298 // 27.6.2.4.2 Buffer management and positioning:
267 virtual basic_streambuf* setbuf(char_type* __s, streamsize __n);299 virtual basic_streambuf* setbuf(char_type*, streamsize) { return this; }
268 virtual pos_type300 virtual pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode = ios_base::in | ios_base::out) {
269 seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which = ios_base::in | ios_base::out);301 return pos_type(off_type(-1));
270 virtual pos_type seekpos(pos_type __sp, ios_base::openmode __which = ios_base::in | ios_base::out);302 }
271 virtual int sync();303 virtual pos_type seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out) {
304 return pos_type(off_type(-1));
305 }
306 virtual int sync() { return 0; }
272307
273 // 27.6.2.4.3 Get area:308 // 27.6.2.4.3 Get area:
274 virtual streamsize showmanyc();309 virtual streamsize showmanyc() { return 0; }
275 virtual streamsize xsgetn(char_type* __s, streamsize __n);310
276 virtual int_type underflow();311 virtual streamsize xsgetn(char_type* __s, streamsize __n) {
277 virtual int_type uflow();312 const int_type __eof = traits_type::eof();
313 int_type __c;
314 streamsize __i = 0;
315 while (__i < __n) {
316 if (__ninp_ < __einp_) {
317 const streamsize __len = std::min(static_cast<streamsize>(INT_MAX), std::min(__einp_ - __ninp_, __n - __i));
318 traits_type::copy(__s, __ninp_, __len);
319 __s += __len;
320 __i += __len;
321 this->gbump(__len);
322 } else if ((__c = uflow()) != __eof) {
323 *__s = traits_type::to_char_type(__c);
324 ++__s;
325 ++__i;
326 } else
327 break;
328 }
329 return __i;
330 }
331
332 virtual int_type underflow() { return traits_type::eof(); }
333 virtual int_type uflow() {
334 if (underflow() == traits_type::eof())
335 return traits_type::eof();
336 return traits_type::to_int_type(*__ninp_++);
337 }
278338
279 // 27.6.2.4.4 Putback:339 // 27.6.2.4.4 Putback:
280 virtual int_type pbackfail(int_type __c = traits_type::eof());340 virtual int_type pbackfail(int_type = traits_type::eof()) { return traits_type::eof(); }
281341
282 // 27.6.2.4.5 Put area:342 // 27.6.2.4.5 Put area:
283 virtual streamsize xsputn(const char_type* __s, streamsize __n);343 virtual streamsize xsputn(const char_type* __s, streamsize __n) {
284 virtual int_type overflow(int_type __c = traits_type::eof());344 streamsize __i = 0;
345 int_type __eof = traits_type::eof();
346 while (__i < __n) {
347 if (__nout_ >= __eout_) {
348 if (overflow(traits_type::to_int_type(*__s)) == __eof)
349 break;
350 ++__s;
351 ++__i;
352 } else {
353 streamsize __chunk_size = std::min(__eout_ - __nout_, __n - __i);
354 traits_type::copy(__nout_, __s, __chunk_size);
355 __nout_ += __chunk_size;
356 __s += __chunk_size;
357 __i += __chunk_size;
358 }
359 }
360 return __i;
361 }
362
363 virtual int_type overflow(int_type = traits_type::eof()) { return traits_type::eof(); }
285364
286private:365private:
287 locale __loc_;366 locale __loc_;
288 char_type* __binp_;367 char_type* __binp_ = nullptr;
289 char_type* __ninp_;368 char_type* __ninp_ = nullptr;
290 char_type* __einp_;369 char_type* __einp_ = nullptr;
291 char_type* __bout_;370 char_type* __bout_ = nullptr;
292 char_type* __nout_;371 char_type* __nout_ = nullptr;
293 char_type* __eout_;372 char_type* __eout_ = nullptr;
294};373};
295374
296template <class _CharT, class _Traits>
297basic_streambuf<_CharT, _Traits>::~basic_streambuf() {}
298
299template <class _CharT, class _Traits>
300basic_streambuf<_CharT, _Traits>::basic_streambuf()
301 : __binp_(nullptr), __ninp_(nullptr), __einp_(nullptr), __bout_(nullptr), __nout_(nullptr), __eout_(nullptr) {}
302
303template <class _CharT, class _Traits>
304basic_streambuf<_CharT, _Traits>::basic_streambuf(const basic_streambuf& __sb)
305 : __loc_(__sb.__loc_),
306 __binp_(__sb.__binp_),
307 __ninp_(__sb.__ninp_),
308 __einp_(__sb.__einp_),
309 __bout_(__sb.__bout_),
310 __nout_(__sb.__nout_),
311 __eout_(__sb.__eout_) {}
312
313template <class _CharT, class _Traits>
314basic_streambuf<_CharT, _Traits>& basic_streambuf<_CharT, _Traits>::operator=(const basic_streambuf& __sb) {
315 __loc_ = __sb.__loc_;
316 __binp_ = __sb.__binp_;
317 __ninp_ = __sb.__ninp_;
318 __einp_ = __sb.__einp_;
319 __bout_ = __sb.__bout_;
320 __nout_ = __sb.__nout_;
321 __eout_ = __sb.__eout_;
322 return *this;
323}
324
325template <class _CharT, class _Traits>
326void basic_streambuf<_CharT, _Traits>::swap(basic_streambuf& __sb) {
327 std::swap(__loc_, __sb.__loc_);
328 std::swap(__binp_, __sb.__binp_);
329 std::swap(__ninp_, __sb.__ninp_);
330 std::swap(__einp_, __sb.__einp_);
331 std::swap(__bout_, __sb.__bout_);
332 std::swap(__nout_, __sb.__nout_);
333 std::swap(__eout_, __sb.__eout_);
334}
335
336template <class _CharT, class _Traits>
337void basic_streambuf<_CharT, _Traits>::imbue(const locale&) {}
338
339template <class _CharT, class _Traits>
340basic_streambuf<_CharT, _Traits>* basic_streambuf<_CharT, _Traits>::setbuf(char_type*, streamsize) {
341 return this;
342}
343
344template <class _CharT, class _Traits>
345typename basic_streambuf<_CharT, _Traits>::pos_type
346basic_streambuf<_CharT, _Traits>::seekoff(off_type, ios_base::seekdir, ios_base::openmode) {
347 return pos_type(off_type(-1));
348}
349
350template <class _CharT, class _Traits>
351typename basic_streambuf<_CharT, _Traits>::pos_type
352basic_streambuf<_CharT, _Traits>::seekpos(pos_type, ios_base::openmode) {
353 return pos_type(off_type(-1));
354}
355
356template <class _CharT, class _Traits>
357int basic_streambuf<_CharT, _Traits>::sync() {
358 return 0;
359}
360
361template <class _CharT, class _Traits>
362streamsize basic_streambuf<_CharT, _Traits>::showmanyc() {
363 return 0;
364}
365
366template <class _CharT, class _Traits>
367streamsize basic_streambuf<_CharT, _Traits>::xsgetn(char_type* __s, streamsize __n) {
368 const int_type __eof = traits_type::eof();
369 int_type __c;
370 streamsize __i = 0;
371 while (__i < __n) {
372 if (__ninp_ < __einp_) {
373 const streamsize __len = std::min(static_cast<streamsize>(INT_MAX), std::min(__einp_ - __ninp_, __n - __i));
374 traits_type::copy(__s, __ninp_, __len);
375 __s += __len;
376 __i += __len;
377 this->gbump(__len);
378 } else if ((__c = uflow()) != __eof) {
379 *__s = traits_type::to_char_type(__c);
380 ++__s;
381 ++__i;
382 } else
383 break;
384 }
385 return __i;
386}
387
388template <class _CharT, class _Traits>
389typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::underflow() {
390 return traits_type::eof();
391}
392
393template <class _CharT, class _Traits>
394typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::uflow() {
395 if (underflow() == traits_type::eof())
396 return traits_type::eof();
397 return traits_type::to_int_type(*__ninp_++);
398}
399
400template <class _CharT, class _Traits>
401typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::pbackfail(int_type) {
402 return traits_type::eof();
403}
404
405template <class _CharT, class _Traits>
406streamsize basic_streambuf<_CharT, _Traits>::xsputn(const char_type* __s, streamsize __n) {
407 streamsize __i = 0;
408 int_type __eof = traits_type::eof();
409 while (__i < __n) {
410 if (__nout_ >= __eout_) {
411 if (overflow(traits_type::to_int_type(*__s)) == __eof)
412 break;
413 ++__s;
414 ++__i;
415 } else {
416 streamsize __chunk_size = std::min(__eout_ - __nout_, __n - __i);
417 traits_type::copy(__nout_, __s, __chunk_size);
418 __nout_ += __chunk_size;
419 __s += __chunk_size;
420 __i += __chunk_size;
421 }
422 }
423 return __i;
424}
425
426template <class _CharT, class _Traits>
427typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::overflow(int_type) {
428 return traits_type::eof();
429}
430
431extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>;375extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>;
432376
433#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS377# if _LIBCPP_HAS_WIDE_CHARACTERS
434extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>;378extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>;
435#endif379# endif
436380
437_LIBCPP_END_NAMESPACE_STD381_LIBCPP_END_NAMESPACE_STD
438382
439_LIBCPP_POP_MACROS383_LIBCPP_POP_MACROS
440384
441#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20385# endif // _LIBCPP_HAS_LOCALIZATION
442# include <cstdint>386
443#endif387# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
388# include <cstdint>
389# endif
390#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
444391
445#endif // _LIBCPP_STREAMBUF392#endif // _LIBCPP_STREAMBUF
lib/libcxx/include/string+463-461
...@@ -586,101 +586,106 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );...@@ -586,101 +586,106 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
586586
587// clang-format on587// clang-format on
588588
589#include <__algorithm/max.h>589#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
590#include <__algorithm/min.h>590# include <__cxx03/string>
591#include <__algorithm/remove.h>591#else
592#include <__algorithm/remove_if.h>592# include <__algorithm/max.h>
593#include <__assert>593# include <__algorithm/min.h>
594#include <__config>594# include <__algorithm/remove.h>
595#include <__debug_utils/sanitizers.h>595# include <__algorithm/remove_if.h>
596#include <__format/enable_insertable.h>596# include <__assert>
597#include <__functional/hash.h>597# include <__config>
598#include <__functional/unary_function.h>598# include <__debug_utils/sanitizers.h>
599#include <__fwd/string.h>599# include <__format/enable_insertable.h>
600#include <__ios/fpos.h>600# include <__functional/hash.h>
601#include <__iterator/bounded_iter.h>601# include <__functional/unary_function.h>
602#include <__iterator/distance.h>602# include <__fwd/string.h>
603#include <__iterator/iterator_traits.h>603# include <__ios/fpos.h>
604#include <__iterator/reverse_iterator.h>604# include <__iterator/bounded_iter.h>
605#include <__iterator/wrap_iter.h>605# include <__iterator/distance.h>
606#include <__memory/addressof.h>606# include <__iterator/iterator_traits.h>
607#include <__memory/allocate_at_least.h>607# include <__iterator/reverse_iterator.h>
608#include <__memory/allocator.h>608# include <__iterator/wrap_iter.h>
609#include <__memory/allocator_traits.h>609# include <__memory/addressof.h>
610#include <__memory/compressed_pair.h>610# include <__memory/allocate_at_least.h>
611#include <__memory/construct_at.h>611# include <__memory/allocator.h>
612#include <__memory/pointer_traits.h>612# include <__memory/allocator_traits.h>
613#include <__memory/swap_allocator.h>613# include <__memory/compressed_pair.h>
614#include <__memory_resource/polymorphic_allocator.h>614# include <__memory/construct_at.h>
615#include <__ranges/access.h>615# include <__memory/noexcept_move_assign_container.h>
616#include <__ranges/concepts.h>616# include <__memory/pointer_traits.h>
617#include <__ranges/container_compatible_range.h>617# include <__memory/swap_allocator.h>
618#include <__ranges/from_range.h>618# include <__memory_resource/polymorphic_allocator.h>
619#include <__ranges/size.h>619# include <__ranges/access.h>
620#include <__string/char_traits.h>620# include <__ranges/concepts.h>
621#include <__string/extern_template_lists.h>621# include <__ranges/container_compatible_range.h>
622#include <__type_traits/conditional.h>622# include <__ranges/from_range.h>
623#include <__type_traits/is_allocator.h>623# include <__ranges/size.h>
624#include <__type_traits/is_array.h>624# include <__string/char_traits.h>
625#include <__type_traits/is_convertible.h>625# include <__string/extern_template_lists.h>
626#include <__type_traits/is_nothrow_assignable.h>626# include <__type_traits/conditional.h>
627#include <__type_traits/is_nothrow_constructible.h>627# include <__type_traits/enable_if.h>
628#include <__type_traits/is_same.h>628# include <__type_traits/is_allocator.h>
629#include <__type_traits/is_standard_layout.h>629# include <__type_traits/is_array.h>
630#include <__type_traits/is_trivial.h>630# include <__type_traits/is_convertible.h>
631#include <__type_traits/is_trivially_relocatable.h>631# include <__type_traits/is_nothrow_assignable.h>
632#include <__type_traits/noexcept_move_assign_container.h>632# include <__type_traits/is_nothrow_constructible.h>
633#include <__type_traits/remove_cvref.h>633# include <__type_traits/is_same.h>
634#include <__type_traits/void_t.h>634# include <__type_traits/is_standard_layout.h>
635#include <__utility/auto_cast.h>635# include <__type_traits/is_trivial.h>
636#include <__utility/declval.h>636# include <__type_traits/is_trivially_relocatable.h>
637#include <__utility/forward.h>637# include <__type_traits/remove_cvref.h>
638#include <__utility/is_pointer_in_range.h>638# include <__type_traits/void_t.h>
639#include <__utility/move.h>639# include <__utility/auto_cast.h>
640#include <__utility/swap.h>640# include <__utility/declval.h>
641#include <__utility/unreachable.h>641# include <__utility/forward.h>
642#include <climits>642# include <__utility/is_pointer_in_range.h>
643#include <cstdio> // EOF643# include <__utility/move.h>
644#include <cstring>644# include <__utility/scope_guard.h>
645#include <limits>645# include <__utility/swap.h>
646#include <stdexcept>646# include <__utility/unreachable.h>
647#include <string_view>647# include <climits>
648#include <version>648# include <cstdio> // EOF
649649# include <cstring>
650#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS650# include <limits>
651# include <cwchar>651# include <stdexcept>
652#endif652# include <string_view>
653# include <version>
654
655# if _LIBCPP_HAS_WIDE_CHARACTERS
656# include <cwchar>
657# endif
653658
654// standard-mandated includes659// standard-mandated includes
655660
656// [iterator.range]661// [iterator.range]
657#include <__iterator/access.h>662# include <__iterator/access.h>
658#include <__iterator/data.h>663# include <__iterator/data.h>
659#include <__iterator/empty.h>664# include <__iterator/empty.h>
660#include <__iterator/reverse_access.h>665# include <__iterator/reverse_access.h>
661#include <__iterator/size.h>666# include <__iterator/size.h>
662667
663// [string.syn]668// [string.syn]
664#include <compare>669# include <compare>
665#include <initializer_list>670# include <initializer_list>
666671
667#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)672# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
668# pragma GCC system_header673# pragma GCC system_header
669#endif674# endif
670675
671_LIBCPP_PUSH_MACROS676_LIBCPP_PUSH_MACROS
672#include <__undef_macros>677# include <__undef_macros>
673678
674#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)679# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
675# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__("address")))680# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__("address")))
676// This macro disables AddressSanitizer (ASan) instrumentation for a specific function,681// This macro disables AddressSanitizer (ASan) instrumentation for a specific function,
677// allowing memory accesses that would normally trigger ASan errors to proceed without crashing.682// allowing memory accesses that would normally trigger ASan errors to proceed without crashing.
678// This is useful for accessing parts of objects memory, which should not be accessed,683// This is useful for accessing parts of objects memory, which should not be accessed,
679// such as unused bytes in short strings, that should never be accessed684// such as unused bytes in short strings, that should never be accessed
680// by other parts of the program.685// by other parts of the program.
681#else686# else
682# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS687# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS
683#endif688# endif
684689
685_LIBCPP_BEGIN_NAMESPACE_STD690_LIBCPP_BEGIN_NAMESPACE_STD
686691
...@@ -706,7 +711,7 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -706,7 +711,7 @@ template <class _CharT, class _Traits, class _Allocator>
706_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>711_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>
707operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);712operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);
708713
709#if _LIBCPP_STD_VER >= 26714# if _LIBCPP_STD_VER >= 26
710715
711template <class _CharT, class _Traits, class _Allocator>716template <class _CharT, class _Traits, class _Allocator>
712_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>717_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
...@@ -726,7 +731,7 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -726,7 +731,7 @@ template <class _CharT, class _Traits, class _Allocator>
726_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>731_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
727operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs);732operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs);
728733
729#endif734# endif
730735
731extern template _LIBCPP_EXPORTED_FROM_ABI string operator+736extern template _LIBCPP_EXPORTED_FROM_ABI string operator+
732 <char, char_traits<char>, allocator<char> >(char const*, string const&);737 <char, char_traits<char>, allocator<char> >(char const*, string const&);
...@@ -748,10 +753,18 @@ struct __can_be_converted_to_string_view...@@ -748,10 +753,18 @@ struct __can_be_converted_to_string_view
748struct __uninitialized_size_tag {};753struct __uninitialized_size_tag {};
749struct __init_with_sentinel_tag {};754struct __init_with_sentinel_tag {};
750755
756template <size_t _PaddingSize>
757struct __padding {
758 char __padding_[_PaddingSize];
759};
760
761template <>
762struct __padding<0> {};
763
751template <class _CharT, class _Traits, class _Allocator>764template <class _CharT, class _Traits, class _Allocator>
752class basic_string {765class basic_string {
753private:766private:
754 using __default_allocator_type = allocator<_CharT>;767 using __default_allocator_type _LIBCPP_NODEBUG = allocator<_CharT>;
755768
756public:769public:
757 typedef basic_string __self;770 typedef basic_string __self;
...@@ -776,7 +789,7 @@ public:...@@ -776,7 +789,7 @@ public:
776 //789 //
777 // This string implementation doesn't contain any references into itself. It only contains a bit that says whether790 // This string implementation doesn't contain any references into itself. It only contains a bit that says whether
778 // it is in small or large string mode, so the entire structure is trivially relocatable if its members are.791 // it is in small or large string mode, so the entire structure is trivially relocatable if its members are.
779#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)792# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
780 // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially793 // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially
781 // relocatable. Because the object's memory might be poisoned when its content794 // relocatable. Because the object's memory might be poisoned when its content
782 // is kept inside objects memory (short string optimization), instead of in allocated795 // is kept inside objects memory (short string optimization), instead of in allocated
...@@ -784,13 +797,14 @@ public:...@@ -784,13 +797,14 @@ public:
784 // the memory to avoid triggering false positives.797 // the memory to avoid triggering false positives.
785 // Therefore it's crucial to ensure the destructor is called.798 // Therefore it's crucial to ensure the destructor is called.
786 using __trivially_relocatable = void;799 using __trivially_relocatable = void;
787#else800# else
788 using __trivially_relocatable = __conditional_t<801 using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<
789 __libcpp_is_trivially_relocatable<allocator_type>::value && __libcpp_is_trivially_relocatable<pointer>::value,802 __libcpp_is_trivially_relocatable<allocator_type>::value && __libcpp_is_trivially_relocatable<pointer>::value,
790 basic_string,803 basic_string,
791 void>;804 void>;
792#endif805# endif
793#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)806
807# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
794 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const {808 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const {
795 if (__libcpp_is_constant_evaluated())809 if (__libcpp_is_constant_evaluated())
796 return __ptr;810 return __ptr;
...@@ -809,10 +823,10 @@ public:...@@ -809,10 +823,10 @@ public:
809823
810 return const_cast<const_pointer&>(__copy_ptr);824 return const_cast<const_pointer&>(__copy_ptr);
811 }825 }
812# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) __asan_volatile_wrapper(PTR)826# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) __asan_volatile_wrapper(PTR)
813#else827# else
814# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) PTR828# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) PTR
815#endif829# endif
816830
817 static_assert(!is_array<value_type>::value, "Character type of basic_string must not be an array");831 static_assert(!is_array<value_type>::value, "Character type of basic_string must not be an array");
818 static_assert(is_standard_layout<value_type>::value, "Character type of basic_string must be standard-layout");832 static_assert(is_standard_layout<value_type>::value, "Character type of basic_string must be standard-layout");
...@@ -823,23 +837,23 @@ public:...@@ -823,23 +837,23 @@ public:
823 "Allocator::value_type must be same type as value_type");837 "Allocator::value_type must be same type as value_type");
824 static_assert(__check_valid_allocator<allocator_type>::value, "");838 static_assert(__check_valid_allocator<allocator_type>::value, "");
825839
826#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING840# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
827 // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's841 // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's
828 // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is842 // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is
829 // considered contiguous.843 // considered contiguous.
830 typedef __bounded_iter<__wrap_iter<pointer>> iterator;844 typedef __bounded_iter<__wrap_iter<pointer> > iterator;
831 typedef __bounded_iter<__wrap_iter<const_pointer>> const_iterator;845 typedef __bounded_iter<__wrap_iter<const_pointer> > const_iterator;
832#else846# else
833 typedef __wrap_iter<pointer> iterator;847 typedef __wrap_iter<pointer> iterator;
834 typedef __wrap_iter<const_pointer> const_iterator;848 typedef __wrap_iter<const_pointer> const_iterator;
835#endif849# endif
836 typedef std::reverse_iterator<iterator> reverse_iterator;850 typedef std::reverse_iterator<iterator> reverse_iterator;
837 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;851 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
838852
839private:853private:
840 static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits");854 static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits");
841855
842#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT856# ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
843857
844 struct __long {858 struct __long {
845 pointer __data_;859 pointer __data_;
...@@ -852,7 +866,7 @@ private:...@@ -852,7 +866,7 @@ private:
852866
853 struct __short {867 struct __short {
854 value_type __data_[__min_cap];868 value_type __data_[__min_cap];
855 unsigned char __padding_[sizeof(value_type) - 1];869 _LIBCPP_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_;
856 unsigned char __size_ : 7;870 unsigned char __size_ : 7;
857 unsigned char __is_long_ : 1;871 unsigned char __is_long_ : 1;
858 };872 };
...@@ -870,19 +884,19 @@ private:...@@ -870,19 +884,19 @@ private:
870 // This does not impact the short string representation, since we never need the MSB884 // This does not impact the short string representation, since we never need the MSB
871 // for representing the size of a short string anyway.885 // for representing the size of a short string anyway.
872886
873# ifdef _LIBCPP_BIG_ENDIAN887# ifdef _LIBCPP_BIG_ENDIAN
874 static const size_type __endian_factor = 2;888 static const size_type __endian_factor = 2;
875# else889# else
876 static const size_type __endian_factor = 1;890 static const size_type __endian_factor = 1;
877# endif891# endif
878892
879#else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT893# else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
880894
881# ifdef _LIBCPP_BIG_ENDIAN895# ifdef _LIBCPP_BIG_ENDIAN
882 static const size_type __endian_factor = 1;896 static const size_type __endian_factor = 1;
883# else897# else
884 static const size_type __endian_factor = 2;898 static const size_type __endian_factor = 2;
885# endif899# endif
886900
887 // Attribute 'packed' is used to keep the layout compatible with the901 // Attribute 'packed' is used to keep the layout compatible with the
888 // previous definition that did not use bit fields. This is because on902 // previous definition that did not use bit fields. This is because on
...@@ -904,11 +918,11 @@ private:...@@ -904,11 +918,11 @@ private:
904 unsigned char __is_long_ : 1;918 unsigned char __is_long_ : 1;
905 unsigned char __size_ : 7;919 unsigned char __size_ : 7;
906 };920 };
907 char __padding_[sizeof(value_type) - 1];921 _LIBCPP_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_;
908 value_type __data_[__min_cap];922 value_type __data_[__min_cap];
909 };923 };
910924
911#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT925# endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
912926
913 static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size.");927 static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size.");
914928
...@@ -917,22 +931,31 @@ private:...@@ -917,22 +931,31 @@ private:
917 __long __l;931 __long __l;
918 };932 };
919933
920 __compressed_pair<__rep, allocator_type> __r_;934 _LIBCPP_COMPRESSED_PAIR(__rep, __rep_, allocator_type, __alloc_);
935
936 // annotate the string with its size() at scope exit. The string has to be in a valid state at that point.
937 struct __annotate_new_size {
938 basic_string& __str_;
939
940 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __annotate_new_size(basic_string& __str) : __str_(__str) {}
941
942 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void operator()() { __str_.__annotate_new(__str_.size()); }
943 };
921944
922 // Construct a string with the given allocator and enough storage to hold `__size` characters, but945 // Construct a string with the given allocator and enough storage to hold `__size` characters, but
923 // don't initialize the characters. The contents of the string, including the null terminator, must be946 // don't initialize the characters. The contents of the string, including the null terminator, must be
924 // initialized separately.947 // initialized separately.
925 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(948 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(
926 __uninitialized_size_tag, size_type __size, const allocator_type& __a)949 __uninitialized_size_tag, size_type __size, const allocator_type& __a)
927 : __r_(__default_init_tag(), __a) {950 : __alloc_(__a) {
928 if (__size > max_size())951 if (__size > max_size())
929 __throw_length_error();952 __throw_length_error();
930 if (__fits_in_sso(__size)) {953 if (__fits_in_sso(__size)) {
931 __r_.first() = __rep();954 __rep_ = __rep();
932 __set_short_size(__size);955 __set_short_size(__size);
933 } else {956 } else {
934 auto __capacity = __recommend(__size) + 1;957 auto __capacity = __recommend(__size) + 1;
935 auto __allocation = __alloc_traits::allocate(__alloc(), __capacity);958 auto __allocation = __alloc_traits::allocate(__alloc_, __capacity);
936 __begin_lifetime(__allocation, __capacity);959 __begin_lifetime(__allocation, __capacity);
937 __set_long_cap(__capacity);960 __set_long_cap(__capacity);
938 __set_long_pointer(__allocation);961 __set_long_pointer(__allocation);
...@@ -944,12 +967,12 @@ private:...@@ -944,12 +967,12 @@ private:
944 template <class _Iter, class _Sent>967 template <class _Iter, class _Sent>
945 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20968 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
946 basic_string(__init_with_sentinel_tag, _Iter __first, _Sent __last, const allocator_type& __a)969 basic_string(__init_with_sentinel_tag, _Iter __first, _Sent __last, const allocator_type& __a)
947 : __r_(__default_init_tag(), __a) {970 : __alloc_(__a) {
948 __init_with_sentinel(std::move(__first), std::move(__last));971 __init_with_sentinel(std::move(__first), std::move(__last));
949 }972 }
950973
951 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) {974 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) {
952#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING975# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
953 // Bound the iterator according to the size (and not the capacity, unlike vector).976 // Bound the iterator according to the size (and not the capacity, unlike vector).
954 //977 //
955 // By the Standard, string iterators are generally not guaranteed to stay valid when the container is modified,978 // By the Standard, string iterators are generally not guaranteed to stay valid when the container is modified,
...@@ -960,21 +983,21 @@ private:...@@ -960,21 +983,21 @@ private:
960 std::__wrap_iter<pointer>(__p),983 std::__wrap_iter<pointer>(__p),
961 std::__wrap_iter<pointer>(__get_pointer()),984 std::__wrap_iter<pointer>(__get_pointer()),
962 std::__wrap_iter<pointer>(__get_pointer() + size()));985 std::__wrap_iter<pointer>(__get_pointer() + size()));
963#else986# else
964 return iterator(__p);987 return iterator(__p);
965#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING988# endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
966 }989 }
967990
968 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_const_iterator(const_pointer __p) const {991 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_const_iterator(const_pointer __p) const {
969#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING992# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
970 // Bound the iterator according to the size (and not the capacity, unlike vector).993 // Bound the iterator according to the size (and not the capacity, unlike vector).
971 return std::__make_bounded_iter(994 return std::__make_bounded_iter(
972 std::__wrap_iter<const_pointer>(__p),995 std::__wrap_iter<const_pointer>(__p),
973 std::__wrap_iter<const_pointer>(__get_pointer()),996 std::__wrap_iter<const_pointer>(__get_pointer()),
974 std::__wrap_iter<const_pointer>(__get_pointer() + size()));997 std::__wrap_iter<const_pointer>(__get_pointer() + size()));
975#else998# else
976 return const_iterator(__p);999 return const_iterator(__p);
977#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING1000# endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
978 }1001 }
9791002
980public:1003public:
...@@ -982,24 +1005,24 @@ public:...@@ -982,24 +1005,24 @@ public:
9821005
983 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string()1006 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string()
984 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)1007 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
985 : __r_(__value_init_tag(), __default_init_tag()) {1008 : __rep_() {
986 __annotate_new(0);1009 __annotate_new(0);
987 }1010 }
9881011
989 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const allocator_type& __a)1012 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const allocator_type& __a)
990#if _LIBCPP_STD_VER <= 141013# if _LIBCPP_STD_VER <= 14
991 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)1014 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
992#else1015# else
993 _NOEXCEPT1016 _NOEXCEPT
994#endif1017# endif
995 : __r_(__value_init_tag(), __a) {1018 : __rep_(), __alloc_(__a) {
996 __annotate_new(0);1019 __annotate_new(0);
997 }1020 }
9981021
999 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& __str)1022 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& __str)
1000 : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) {1023 : __alloc_(__alloc_traits::select_on_container_copy_construction(__str.__alloc_)) {
1001 if (!__str.__is_long()) {1024 if (!__str.__is_long()) {
1002 __r_.first() = __str.__r_.first();1025 __rep_ = __str.__rep_;
1003 __annotate_new(__get_short_size());1026 __annotate_new(__get_short_size());
1004 } else1027 } else
1005 __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());1028 __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
...@@ -1007,119 +1030,115 @@ public:...@@ -1007,119 +1030,115 @@ public:
10071030
1008 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS1031 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS
1009 basic_string(const basic_string& __str, const allocator_type& __a)1032 basic_string(const basic_string& __str, const allocator_type& __a)
1010 : __r_(__default_init_tag(), __a) {1033 : __alloc_(__a) {
1011 if (!__str.__is_long()) {1034 if (!__str.__is_long()) {
1012 __r_.first() = __str.__r_.first();1035 __rep_ = __str.__rep_;
1013 __annotate_new(__get_short_size());1036 __annotate_new(__get_short_size());
1014 } else1037 } else
1015 __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());1038 __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
1016 }1039 }
10171040
1018#ifndef _LIBCPP_CXX03_LANG1041# ifndef _LIBCPP_CXX03_LANG
1019 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str)1042 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str)
1020# if _LIBCPP_STD_VER <= 141043# if _LIBCPP_STD_VER <= 14
1021 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)1044 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
1022# else1045# else
1023 _NOEXCEPT1046 _NOEXCEPT
1024# endif1047# endif
1025 // Turning off ASan instrumentation for variable initialization with _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS1048 // Turning off ASan instrumentation for variable initialization with _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS
1026 // does not work consistently during initialization of __r_, so we instead unpoison __str's memory manually first.1049 // does not work consistently during initialization of __r_, so we instead unpoison __str's memory manually first.
1027 // __str's memory needs to be unpoisoned only in the case where it's a short string.1050 // __str's memory needs to be unpoisoned only in the case where it's a short string.
1028 : __r_([](basic_string& __s) -> decltype(__s.__r_)&& {1051 : __rep_([](basic_string& __s) -> decltype(__s.__rep_)&& {
1029 if (!__s.__is_long())1052 if (!__s.__is_long())
1030 __s.__annotate_delete();1053 __s.__annotate_delete();
1031 return std::move(__s.__r_);1054 return std::move(__s.__rep_);
1032 }(__str)) {1055 }(__str)),
1033 __str.__r_.first() = __rep();1056 __alloc_(std::move(__str.__alloc_)) {
1057 __str.__rep_ = __rep();
1034 __str.__annotate_new(0);1058 __str.__annotate_new(0);
1035 if (!__is_long())1059 if (!__is_long())
1036 __annotate_new(size());1060 __annotate_new(size());
1037 }1061 }
10381062
1039 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str, const allocator_type& __a)1063 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str, const allocator_type& __a)
1040 : __r_(__default_init_tag(), __a) {1064 : __alloc_(__a) {
1041 if (__str.__is_long() && __a != __str.__alloc()) // copy, not move1065 if (__str.__is_long() && __a != __str.__alloc_) // copy, not move
1042 __init(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());1066 __init(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
1043 else {1067 else {
1044 if (__libcpp_is_constant_evaluated())1068 if (__libcpp_is_constant_evaluated())
1045 __r_.first() = __rep();1069 __rep_ = __rep();
1046 if (!__str.__is_long())1070 if (!__str.__is_long())
1047 __str.__annotate_delete();1071 __str.__annotate_delete();
1048 __r_.first() = __str.__r_.first();1072 __rep_ = __str.__rep_;
1049 __str.__r_.first() = __rep();1073 __str.__rep_ = __rep();
1050 __str.__annotate_new(0);1074 __str.__annotate_new(0);
1051 if (!__is_long() && this != &__str)1075 if (!__is_long() && this != std::addressof(__str))
1052 __annotate_new(size());1076 __annotate_new(size());
1053 }1077 }
1054 }1078 }
1055#endif // _LIBCPP_CXX03_LANG1079# endif // _LIBCPP_CXX03_LANG
10561080
1057 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>1081 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>
1058 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s)1082 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s) {
1059 : __r_(__default_init_tag(), __default_init_tag()) {
1060 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*) detected nullptr");1083 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*) detected nullptr");
1061 __init(__s, traits_type::length(__s));1084 __init(__s, traits_type::length(__s));
1062 }1085 }
10631086
1064 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>1087 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>
1065 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, const _Allocator& __a)1088 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, const _Allocator& __a)
1066 : __r_(__default_init_tag(), __a) {1089 : __alloc_(__a) {
1067 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");1090 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
1068 __init(__s, traits_type::length(__s));1091 __init(__s, traits_type::length(__s));
1069 }1092 }
10701093
1071#if _LIBCPP_STD_VER >= 231094# if _LIBCPP_STD_VER >= 23
1072 basic_string(nullptr_t) = delete;1095 basic_string(nullptr_t) = delete;
1073#endif1096# endif
10741097
1075 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n)1098 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) {
1076 : __r_(__default_init_tag(), __default_init_tag()) {
1077 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");1099 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");
1078 __init(__s, __n);1100 __init(__s, __n);
1079 }1101 }
10801102
1081 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX201103 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1082 basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)1104 basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
1083 : __r_(__default_init_tag(), __a) {1105 : __alloc_(__a) {
1084 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");1106 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
1085 __init(__s, __n);1107 __init(__s, __n);
1086 }1108 }
10871109
1088 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c)1110 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c) { __init(__n, __c); }
1089 : __r_(__default_init_tag(), __default_init_tag()) {
1090 __init(__n, __c);
1091 }
10921111
1093#if _LIBCPP_STD_VER >= 231112# if _LIBCPP_STD_VER >= 23
1094 _LIBCPP_HIDE_FROM_ABI constexpr basic_string(1113 _LIBCPP_HIDE_FROM_ABI constexpr basic_string(
1095 basic_string&& __str, size_type __pos, const _Allocator& __alloc = _Allocator())1114 basic_string&& __str, size_type __pos, const _Allocator& __alloc = _Allocator())
1096 : basic_string(std::move(__str), __pos, npos, __alloc) {}1115 : basic_string(std::move(__str), __pos, npos, __alloc) {}
10971116
1098 _LIBCPP_HIDE_FROM_ABI constexpr basic_string(1117 _LIBCPP_HIDE_FROM_ABI constexpr basic_string(
1099 basic_string&& __str, size_type __pos, size_type __n, const _Allocator& __alloc = _Allocator())1118 basic_string&& __str, size_type __pos, size_type __n, const _Allocator& __alloc = _Allocator())
1100 : __r_(__default_init_tag(), __alloc) {1119 : __alloc_(__alloc) {
1101 if (__pos > __str.size())1120 if (__pos > __str.size())
1102 __throw_out_of_range();1121 __throw_out_of_range();
11031122
1104 auto __len = std::min<size_type>(__n, __str.size() - __pos);1123 auto __len = std::min<size_type>(__n, __str.size() - __pos);
1105 if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc()) {1124 if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc_) {
1106 __move_assign(std::move(__str), __pos, __len);1125 __move_assign(std::move(__str), __pos, __len);
1107 } else {1126 } else {
1108 // Perform a copy because the allocators are not compatible.1127 // Perform a copy because the allocators are not compatible.
1109 __init(__str.data() + __pos, __len);1128 __init(__str.data() + __pos, __len);
1110 }1129 }
1111 }1130 }
1112#endif1131# endif
11131132
1114 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>1133 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>
1115 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c, const _Allocator& __a)1134 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c, const _Allocator& __a)
1116 : __r_(__default_init_tag(), __a) {1135 : __alloc_(__a) {
1117 __init(__n, __c);1136 __init(__n, __c);
1118 }1137 }
11191138
1120 _LIBCPP_CONSTEXPR_SINCE_CXX201139 _LIBCPP_CONSTEXPR_SINCE_CXX20
1121 basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a = _Allocator())1140 basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a = _Allocator())
1122 : __r_(__default_init_tag(), __a) {1141 : __alloc_(__a) {
1123 size_type __str_sz = __str.size();1142 size_type __str_sz = __str.size();
1124 if (__pos > __str_sz)1143 if (__pos > __str_sz)
1125 __throw_out_of_range();1144 __throw_out_of_range();
...@@ -1128,7 +1147,7 @@ public:...@@ -1128,7 +1147,7 @@ public:
11281147
1129 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX201148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1130 basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a = _Allocator())1149 basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a = _Allocator())
1131 : __r_(__default_init_tag(), __a) {1150 : __alloc_(__a) {
1132 size_type __str_sz = __str.size();1151 size_type __str_sz = __str.size();
1133 if (__pos > __str_sz)1152 if (__pos > __str_sz)
1134 __throw_out_of_range();1153 __throw_out_of_range();
...@@ -1141,7 +1160,7 @@ public:...@@ -1141,7 +1160,7 @@ public:
1141 int> = 0>1160 int> = 0>
1142 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX201161 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1143 basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type())1162 basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type())
1144 : __r_(__default_init_tag(), __a) {1163 : __alloc_(__a) {
1145 __self_view __sv0 = __t;1164 __self_view __sv0 = __t;
1146 __self_view __sv = __sv0.substr(__pos, __n);1165 __self_view __sv = __sv0.substr(__pos, __n);
1147 __init(__sv.data(), __sv.size());1166 __init(__sv.data(), __sv.size());
...@@ -1151,8 +1170,8 @@ public:...@@ -1151,8 +1170,8 @@ public:
1151 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&1170 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1152 !__is_same_uncvref<_Tp, basic_string>::value,1171 !__is_same_uncvref<_Tp, basic_string>::value,
1153 int> = 0>1172 int> = 0>
1154 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t)1173 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1155 : __r_(__default_init_tag(), __default_init_tag()) {1174 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) {
1156 __self_view __sv = __t;1175 __self_view __sv = __t;
1157 __init(__sv.data(), __sv.size());1176 __init(__sv.data(), __sv.size());
1158 }1177 }
...@@ -1163,57 +1182,55 @@ public:...@@ -1163,57 +1182,55 @@ public:
1163 int> = 0>1182 int> = 0>
1164 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1183 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1165 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a)1184 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a)
1166 : __r_(__default_init_tag(), __a) {1185 : __alloc_(__a) {
1167 __self_view __sv = __t;1186 __self_view __sv = __t;
1168 __init(__sv.data(), __sv.size());1187 __init(__sv.data(), __sv.size());
1169 }1188 }
11701189
1171 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>1190 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
1172 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(_InputIterator __first, _InputIterator __last)1191 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(_InputIterator __first, _InputIterator __last) {
1173 : __r_(__default_init_tag(), __default_init_tag()) {
1174 __init(__first, __last);1192 __init(__first, __last);
1175 }1193 }
11761194
1177 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>1195 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
1178 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX201196 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1179 basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a)1197 basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
1180 : __r_(__default_init_tag(), __a) {1198 : __alloc_(__a) {
1181 __init(__first, __last);1199 __init(__first, __last);
1182 }1200 }
11831201
1184#if _LIBCPP_STD_VER >= 231202# if _LIBCPP_STD_VER >= 23
1185 template <_ContainerCompatibleRange<_CharT> _Range>1203 template <_ContainerCompatibleRange<_CharT> _Range>
1186 _LIBCPP_HIDE_FROM_ABI constexpr basic_string(1204 _LIBCPP_HIDE_FROM_ABI constexpr basic_string(
1187 from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())1205 from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())
1188 : __r_(__default_init_tag(), __a) {1206 : __alloc_(__a) {
1189 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {1207 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
1190 __init_with_size(ranges::begin(__range), ranges::end(__range), ranges::distance(__range));1208 __init_with_size(ranges::begin(__range), ranges::end(__range), ranges::distance(__range));
1191 } else {1209 } else {
1192 __init_with_sentinel(ranges::begin(__range), ranges::end(__range));1210 __init_with_sentinel(ranges::begin(__range), ranges::end(__range));
1193 }1211 }
1194 }1212 }
1195#endif1213# endif
11961214
1197#ifndef _LIBCPP_CXX03_LANG1215# ifndef _LIBCPP_CXX03_LANG
1198 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il)1216 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il) {
1199 : __r_(__default_init_tag(), __default_init_tag()) {
1200 __init(__il.begin(), __il.end());1217 __init(__il.begin(), __il.end());
1201 }1218 }
12021219
1203 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il, const _Allocator& __a)1220 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il, const _Allocator& __a)
1204 : __r_(__default_init_tag(), __a) {1221 : __alloc_(__a) {
1205 __init(__il.begin(), __il.end());1222 __init(__il.begin(), __il.end());
1206 }1223 }
1207#endif // _LIBCPP_CXX03_LANG1224# endif // _LIBCPP_CXX03_LANG
12081225
1209 inline _LIBCPP_CONSTEXPR_SINCE_CXX20 ~basic_string() {1226 inline _LIBCPP_CONSTEXPR_SINCE_CXX20 ~basic_string() {
1210 __annotate_delete();1227 __annotate_delete();
1211 if (__is_long())1228 if (__is_long())
1212 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());1229 __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());
1213 }1230 }
12141231
1215 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator __self_view() const _NOEXCEPT {1232 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator __self_view() const _NOEXCEPT {
1216 return __self_view(data(), size());1233 return __self_view(typename __self_view::__assume_valid(), data(), size());
1217 }1234 }
12181235
1219 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string&1236 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string&
...@@ -1228,7 +1245,7 @@ public:...@@ -1228,7 +1245,7 @@ public:
1228 return assign(__sv);1245 return assign(__sv);
1229 }1246 }
12301247
1231#ifndef _LIBCPP_CXX03_LANG1248# ifndef _LIBCPP_CXX03_LANG
1232 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1249 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1233 operator=(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {1250 operator=(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
1234 __move_assign(__str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());1251 __move_assign(__str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
...@@ -1238,13 +1255,13 @@ public:...@@ -1238,13 +1255,13 @@ public:
1238 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(initializer_list<value_type> __il) {1255 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(initializer_list<value_type> __il) {
1239 return assign(__il.begin(), __il.size());1256 return assign(__il.begin(), __il.size());
1240 }1257 }
1241#endif1258# endif
1242 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const value_type* __s) {1259 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const value_type* __s) {
1243 return assign(__s);1260 return assign(__s);
1244 }1261 }
1245#if _LIBCPP_STD_VER >= 231262# if _LIBCPP_STD_VER >= 23
1246 basic_string& operator=(nullptr_t) = delete;1263 basic_string& operator=(nullptr_t) = delete;
1247#endif1264# endif
1248 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c);1265 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c);
12491266
1250 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT {1267 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT {
...@@ -1286,7 +1303,7 @@ public:...@@ -1286,7 +1303,7 @@ public:
1286 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type length() const _NOEXCEPT { return size(); }1303 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type length() const _NOEXCEPT { return size(); }
12871304
1288 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT {1305 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT {
1289 size_type __m = __alloc_traits::max_size(__alloc());1306 size_type __m = __alloc_traits::max_size(__alloc_);
1290 if (__m <= std::numeric_limits<size_type>::max() / 2) {1307 if (__m <= std::numeric_limits<size_type>::max() / 2) {
1291 return __m - __alignment;1308 return __m - __alignment;
1292 } else {1309 } else {
...@@ -1304,23 +1321,23 @@ public:...@@ -1304,23 +1321,23 @@ public:
13041321
1305 _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __requested_capacity);1322 _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __requested_capacity);
13061323
1307#if _LIBCPP_STD_VER >= 231324# if _LIBCPP_STD_VER >= 23
1308 template <class _Op>1325 template <class _Op>
1309 _LIBCPP_HIDE_FROM_ABI constexpr void resize_and_overwrite(size_type __n, _Op __op) {1326 _LIBCPP_HIDE_FROM_ABI constexpr void resize_and_overwrite(size_type __n, _Op __op) {
1310 __resize_default_init(__n);1327 __resize_default_init(__n);
1311 __erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n)));1328 __erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n)));
1312 }1329 }
1313#endif1330# endif
13141331
1315 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __resize_default_init(size_type __n);1332 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __resize_default_init(size_type __n);
13161333
1317#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE)1334# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE)
1318 _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); }1335 _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); }
1319#endif1336# endif
1320 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;1337 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;
1321 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT;1338 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT;
13221339
1323 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT {1340 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT {
1324 return size() == 0;1341 return size() == 0;
1325 }1342 }
13261343
...@@ -1366,11 +1383,11 @@ public:...@@ -1366,11 +1383,11 @@ public:
1366 return *this;1383 return *this;
1367 }1384 }
13681385
1369#ifndef _LIBCPP_CXX03_LANG1386# ifndef _LIBCPP_CXX03_LANG
1370 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(initializer_list<value_type> __il) {1387 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(initializer_list<value_type> __il) {
1371 return append(__il);1388 return append(__il);
1372 }1389 }
1373#endif // _LIBCPP_CXX03_LANG1390# endif // _LIBCPP_CXX03_LANG
13741391
1375 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const basic_string& __str) {1392 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const basic_string& __str) {
1376 return append(__str.data(), __str.size());1393 return append(__str.data(), __str.size());
...@@ -1406,7 +1423,7 @@ public:...@@ -1406,7 +1423,7 @@ public:
1406 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>1423 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
1407 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1424 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1408 append(_InputIterator __first, _InputIterator __last) {1425 append(_InputIterator __first, _InputIterator __last) {
1409 const basic_string __temp(__first, __last, __alloc());1426 const basic_string __temp(__first, __last, __alloc_);
1410 append(__temp.data(), __temp.size());1427 append(__temp.data(), __temp.size());
1411 return *this;1428 return *this;
1412 }1429 }
...@@ -1415,19 +1432,19 @@ public:...@@ -1415,19 +1432,19 @@ public:
1415 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1432 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1416 append(_ForwardIterator __first, _ForwardIterator __last);1433 append(_ForwardIterator __first, _ForwardIterator __last);
14171434
1418#if _LIBCPP_STD_VER >= 231435# if _LIBCPP_STD_VER >= 23
1419 template <_ContainerCompatibleRange<_CharT> _Range>1436 template <_ContainerCompatibleRange<_CharT> _Range>
1420 _LIBCPP_HIDE_FROM_ABI constexpr basic_string& append_range(_Range&& __range) {1437 _LIBCPP_HIDE_FROM_ABI constexpr basic_string& append_range(_Range&& __range) {
1421 insert_range(end(), std::forward<_Range>(__range));1438 insert_range(end(), std::forward<_Range>(__range));
1422 return *this;1439 return *this;
1423 }1440 }
1424#endif1441# endif
14251442
1426#ifndef _LIBCPP_CXX03_LANG1443# ifndef _LIBCPP_CXX03_LANG
1427 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(initializer_list<value_type> __il) {1444 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(initializer_list<value_type> __il) {
1428 return append(__il.begin(), __il.size());1445 return append(__il.begin(), __il.size());
1429 }1446 }
1430#endif // _LIBCPP_CXX03_LANG1447# endif // _LIBCPP_CXX03_LANG
14311448
1432 _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(value_type __c);1449 _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(value_type __c);
1433 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back();1450 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back();
...@@ -1459,15 +1476,15 @@ public:...@@ -1459,15 +1476,15 @@ public:
1459 return assign(__sv.data(), __sv.size());1476 return assign(__sv.data(), __sv.size());
1460 }1477 }
14611478
1462#if _LIBCPP_STD_VER >= 201479# if _LIBCPP_STD_VER >= 20
1463 _LIBCPP_HIDE_FROM_ABI constexpr void __move_assign(basic_string&& __str, size_type __pos, size_type __len) {1480 _LIBCPP_HIDE_FROM_ABI constexpr void __move_assign(basic_string&& __str, size_type __pos, size_type __len) {
1464 // Pilfer the allocation from __str.1481 // Pilfer the allocation from __str.
1465 _LIBCPP_ASSERT_INTERNAL(__alloc() == __str.__alloc(), "__move_assign called with wrong allocator");1482 _LIBCPP_ASSERT_INTERNAL(__alloc_ == __str.__alloc_, "__move_assign called with wrong allocator");
1466 size_type __old_sz = __str.size();1483 size_type __old_sz = __str.size();
1467 if (!__str.__is_long())1484 if (!__str.__is_long())
1468 __str.__annotate_delete();1485 __str.__annotate_delete();
1469 __r_.first() = __str.__r_.first();1486 __rep_ = __str.__rep_;
1470 __str.__r_.first() = __rep();1487 __str.__rep_ = __rep();
1471 __str.__annotate_new(0);1488 __str.__annotate_new(0);
14721489
1473 _Traits::move(data(), data() + __pos, __len);1490 _Traits::move(data(), data() + __pos, __len);
...@@ -1480,18 +1497,18 @@ public:...@@ -1480,18 +1497,18 @@ public:
1480 __annotate_shrink(__old_sz);1497 __annotate_shrink(__old_sz);
1481 }1498 }
1482 }1499 }
1483#endif1500# endif
14841501
1485 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str) {1502 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str) {
1486 return *this = __str;1503 return *this = __str;
1487 }1504 }
1488#ifndef _LIBCPP_CXX03_LANG1505# ifndef _LIBCPP_CXX03_LANG
1489 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1506 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1490 assign(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {1507 assign(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
1491 *this = std::move(__str);1508 *this = std::move(__str);
1492 return *this;1509 return *this;
1493 }1510 }
1494#endif1511# endif
1495 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n = npos);1512 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n = npos);
14961513
1497 template <class _Tp,1514 template <class _Tp,
...@@ -1512,7 +1529,7 @@ public:...@@ -1512,7 +1529,7 @@ public:
1512 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1529 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1513 assign(_ForwardIterator __first, _ForwardIterator __last);1530 assign(_ForwardIterator __first, _ForwardIterator __last);
15141531
1515#if _LIBCPP_STD_VER >= 231532# if _LIBCPP_STD_VER >= 23
1516 template <_ContainerCompatibleRange<_CharT> _Range>1533 template <_ContainerCompatibleRange<_CharT> _Range>
1517 _LIBCPP_HIDE_FROM_ABI constexpr basic_string& assign_range(_Range&& __range) {1534 _LIBCPP_HIDE_FROM_ABI constexpr basic_string& assign_range(_Range&& __range) {
1518 if constexpr (__string_is_trivial_iterator<ranges::iterator_t<_Range>>::value &&1535 if constexpr (__string_is_trivial_iterator<ranges::iterator_t<_Range>>::value &&
...@@ -1526,13 +1543,13 @@ public:...@@ -1526,13 +1543,13 @@ public:
15261543
1527 return *this;1544 return *this;
1528 }1545 }
1529#endif1546# endif
15301547
1531#ifndef _LIBCPP_CXX03_LANG1548# ifndef _LIBCPP_CXX03_LANG
1532 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(initializer_list<value_type> __il) {1549 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(initializer_list<value_type> __il) {
1533 return assign(__il.begin(), __il.size());1550 return assign(__il.begin(), __il.size());
1534 }1551 }
1535#endif // _LIBCPP_CXX03_LANG1552# endif // _LIBCPP_CXX03_LANG
15361553
1537 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1554 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1538 insert(size_type __pos1, const basic_string& __str) {1555 insert(size_type __pos1, const basic_string& __str) {
...@@ -1560,7 +1577,7 @@ public:...@@ -1560,7 +1577,7 @@ public:
1560 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c);1577 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c);
1561 _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c);1578 _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c);
15621579
1563#if _LIBCPP_STD_VER >= 231580# if _LIBCPP_STD_VER >= 23
1564 template <_ContainerCompatibleRange<_CharT> _Range>1581 template <_ContainerCompatibleRange<_CharT> _Range>
1565 _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) {1582 _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) {
1566 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {1583 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
...@@ -1568,11 +1585,11 @@ public:...@@ -1568,11 +1585,11 @@ public:
1568 return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n);1585 return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n);
15691586
1570 } else {1587 } else {
1571 basic_string __temp(from_range, std::forward<_Range>(__range), __alloc());1588 basic_string __temp(from_range, std::forward<_Range>(__range), __alloc_);
1572 return insert(__position, __temp.data(), __temp.data() + __temp.size());1589 return insert(__position, __temp.data(), __temp.data() + __temp.size());
1573 }1590 }
1574 }1591 }
1575#endif1592# endif
15761593
1577 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator1594 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
1578 insert(const_iterator __pos, size_type __n, value_type __c) {1595 insert(const_iterator __pos, size_type __n, value_type __c) {
...@@ -1589,12 +1606,12 @@ public:...@@ -1589,12 +1606,12 @@ public:
1589 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator1606 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
1590 insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);1607 insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);
15911608
1592#ifndef _LIBCPP_CXX03_LANG1609# ifndef _LIBCPP_CXX03_LANG
1593 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator1610 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
1594 insert(const_iterator __pos, initializer_list<value_type> __il) {1611 insert(const_iterator __pos, initializer_list<value_type> __il) {
1595 return insert(__pos, __il.begin(), __il.end());1612 return insert(__pos, __il.begin(), __il.end());
1596 }1613 }
1597#endif // _LIBCPP_CXX03_LANG1614# endif // _LIBCPP_CXX03_LANG
15981615
1599 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& erase(size_type __pos = 0, size_type __n = npos);1616 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& erase(size_type __pos = 0, size_type __n = npos);
1600 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __pos);1617 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __pos);
...@@ -1659,30 +1676,30 @@ public:...@@ -1659,30 +1676,30 @@ public:
1659 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1676 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1660 replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);1677 replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);
16611678
1662#if _LIBCPP_STD_VER >= 231679# if _LIBCPP_STD_VER >= 23
1663 template <_ContainerCompatibleRange<_CharT> _Range>1680 template <_ContainerCompatibleRange<_CharT> _Range>
1664 _LIBCPP_HIDE_FROM_ABI constexpr basic_string&1681 _LIBCPP_HIDE_FROM_ABI constexpr basic_string&
1665 replace_with_range(const_iterator __i1, const_iterator __i2, _Range&& __range) {1682 replace_with_range(const_iterator __i1, const_iterator __i2, _Range&& __range) {
1666 basic_string __temp(from_range, std::forward<_Range>(__range), __alloc());1683 basic_string __temp(from_range, std::forward<_Range>(__range), __alloc_);
1667 return replace(__i1, __i2, __temp);1684 return replace(__i1, __i2, __temp);
1668 }1685 }
1669#endif1686# endif
16701687
1671#ifndef _LIBCPP_CXX03_LANG1688# ifndef _LIBCPP_CXX03_LANG
1672 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1689 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1673 replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il) {1690 replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il) {
1674 return replace(__i1, __i2, __il.begin(), __il.end());1691 return replace(__i1, __i2, __il.begin(), __il.end());
1675 }1692 }
1676#endif // _LIBCPP_CXX03_LANG1693# endif // _LIBCPP_CXX03_LANG
16771694
1678 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;1695 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;
16791696
1680#if _LIBCPP_STD_VER <= 201697# if _LIBCPP_STD_VER <= 20
1681 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string1698 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string
1682 substr(size_type __pos = 0, size_type __n = npos) const {1699 substr(size_type __pos = 0, size_type __n = npos) const {
1683 return basic_string(*this, __pos, __n);1700 return basic_string(*this, __pos, __n);
1684 }1701 }
1685#else1702# else
1686 _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) const& {1703 _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) const& {
1687 return basic_string(*this, __pos, __n);1704 return basic_string(*this, __pos, __n);
1688 }1705 }
...@@ -1690,27 +1707,27 @@ public:...@@ -1690,27 +1707,27 @@ public:
1690 _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) && {1707 _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) && {
1691 return basic_string(std::move(*this), __pos, __n);1708 return basic_string(std::move(*this), __pos, __n);
1692 }1709 }
1693#endif1710# endif
16941711
1695 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(basic_string& __str)1712 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(basic_string& __str)
1696#if _LIBCPP_STD_VER >= 141713# if _LIBCPP_STD_VER >= 14
1697 _NOEXCEPT;1714 _NOEXCEPT;
1698#else1715# else
1699 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);1716 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
1700#endif1717# endif
17011718
1702 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); }1719 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); }
1703 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* data() const _NOEXCEPT {1720 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* data() const _NOEXCEPT {
1704 return std::__to_address(__get_pointer());1721 return std::__to_address(__get_pointer());
1705 }1722 }
1706#if _LIBCPP_STD_VER >= 171723# if _LIBCPP_STD_VER >= 17
1707 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 value_type* data() _NOEXCEPT {1724 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 value_type* data() _NOEXCEPT {
1708 return std::__to_address(__get_pointer());1725 return std::__to_address(__get_pointer());
1709 }1726 }
1710#endif1727# endif
17111728
1712 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT {1729 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT {
1713 return __alloc();1730 return __alloc_;
1714 }1731 }
17151732
1716 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1733 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
...@@ -1820,9 +1837,9 @@ public:...@@ -1820,9 +1837,9 @@ public:
1820 _LIBCPP_CONSTEXPR_SINCE_CXX20 int1837 _LIBCPP_CONSTEXPR_SINCE_CXX20 int
1821 compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;1838 compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;
18221839
1823#if _LIBCPP_STD_VER >= 201840# if _LIBCPP_STD_VER >= 20
1824 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept {1841 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept {
1825 return __self_view(data(), size()).starts_with(__sv);1842 return __self_view(typename __self_view::__assume_valid(), data(), size()).starts_with(__sv);
1826 }1843 }
18271844
1828 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(value_type __c) const noexcept {1845 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(value_type __c) const noexcept {
...@@ -1834,7 +1851,7 @@ public:...@@ -1834,7 +1851,7 @@ public:
1834 }1851 }
18351852
1836 constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(__self_view __sv) const noexcept {1853 constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(__self_view __sv) const noexcept {
1837 return __self_view(data(), size()).ends_with(__sv);1854 return __self_view(typename __self_view::__assume_valid(), data(), size()).ends_with(__sv);
1838 }1855 }
18391856
1840 constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(value_type __c) const noexcept {1857 constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(value_type __c) const noexcept {
...@@ -1844,52 +1861,47 @@ public:...@@ -1844,52 +1861,47 @@ public:
1844 constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept {1861 constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept {
1845 return ends_with(__self_view(__s));1862 return ends_with(__self_view(__s));
1846 }1863 }
1847#endif1864# endif
18481865
1849#if _LIBCPP_STD_VER >= 231866# if _LIBCPP_STD_VER >= 23
1850 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept {1867 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept {
1851 return __self_view(data(), size()).contains(__sv);1868 return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__sv);
1852 }1869 }
18531870
1854 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept {1871 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept {
1855 return __self_view(data(), size()).contains(__c);1872 return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__c);
1856 }1873 }
18571874
1858 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const {1875 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const {
1859 return __self_view(data(), size()).contains(__s);1876 return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__s);
1860 }1877 }
1861#endif1878# endif
18621879
1863 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const;1880 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const;
18641881
1865 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __clear_and_shrink() _NOEXCEPT;1882 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __clear_and_shrink() _NOEXCEPT;
18661883
1867private:1884private:
1868 template <class _Alloc>
1869 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool friend
1870 operator==(const basic_string<char, char_traits<char>, _Alloc>& __lhs,
1871 const basic_string<char, char_traits<char>, _Alloc>& __rhs) _NOEXCEPT;
1872
1873 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __shrink_or_extend(size_type __target_capacity);1885 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __shrink_or_extend(size_type __target_capacity);
18741886
1875 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS bool1887 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS bool
1876 __is_long() const _NOEXCEPT {1888 __is_long() const _NOEXCEPT {
1877 if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__r_.first().__l.__is_long_)) {1889 if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__rep_.__l.__is_long_)) {
1878 return __r_.first().__l.__is_long_;1890 return __rep_.__l.__is_long_;
1879 }1891 }
1880 return __r_.first().__s.__is_long_;1892 return __rep_.__s.__is_long_;
1881 }1893 }
18821894
1883 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __begin_lifetime(pointer __begin, size_type __n) {1895 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __begin_lifetime(pointer __begin, size_type __n) {
1884#if _LIBCPP_STD_VER >= 201896# if _LIBCPP_STD_VER >= 20
1885 if (__libcpp_is_constant_evaluated()) {1897 if (__libcpp_is_constant_evaluated()) {
1886 for (size_type __i = 0; __i != __n; ++__i)1898 for (size_type __i = 0; __i != __n; ++__i)
1887 std::construct_at(std::addressof(__begin[__i]));1899 std::construct_at(std::addressof(__begin[__i]));
1888 }1900 }
1889#else1901# else
1890 (void)__begin;1902 (void)__begin;
1891 (void)__n;1903 (void)__n;
1892#endif // _LIBCPP_STD_VER >= 201904# endif // _LIBCPP_STD_VER >= 20
1893 }1905 }
18941906
1895 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { return __sz < __min_cap; }1907 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { return __sz < __min_cap; }
...@@ -1905,13 +1917,17 @@ private:...@@ -1905,13 +1917,17 @@ private:
1905 template <class _ForwardIter, class _Sent>1917 template <class _ForwardIter, class _Sent>
1906 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static value_type*1918 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static value_type*
1907 __copy_non_overlapping_range(_ForwardIter __first, _Sent __last, value_type* __dest) {1919 __copy_non_overlapping_range(_ForwardIter __first, _Sent __last, value_type* __dest) {
1908#ifndef _LIBCPP_CXX03_LANG1920# ifndef _LIBCPP_CXX03_LANG
1909 if constexpr (__libcpp_is_contiguous_iterator<_ForwardIter>::value &&1921 if constexpr (__libcpp_is_contiguous_iterator<_ForwardIter>::value &&
1910 is_same<value_type, __iter_value_type<_ForwardIter>>::value && is_same<_ForwardIter, _Sent>::value) {1922 is_same<value_type, __remove_cvref_t<decltype(*__first)>>::value &&
1923 is_same<_ForwardIter, _Sent>::value) {
1924 _LIBCPP_ASSERT_INTERNAL(
1925 !std::__is_overlapping_range(std::__to_address(__first), std::__to_address(__last), __dest),
1926 "__copy_non_overlapping_range called with an overlapping range!");
1911 traits_type::copy(__dest, std::__to_address(__first), __last - __first);1927 traits_type::copy(__dest, std::__to_address(__first), __last - __first);
1912 return __dest + (__last - __first);1928 return __dest + (__last - __first);
1913 }1929 }
1914#endif1930# endif
19151931
1916 for (; __first != __last; ++__first)1932 for (; __first != __last; ++__first)
1917 traits_type::assign(*__dest++, *__first);1933 traits_type::assign(*__dest++, *__first);
...@@ -1937,7 +1953,7 @@ private:...@@ -1937,7 +1953,7 @@ private:
1937 __sz += __n;1953 __sz += __n;
1938 __set_size(__sz);1954 __set_size(__sz);
1939 traits_type::assign(__p[__sz], value_type());1955 traits_type::assign(__p[__sz], value_type());
1940 __copy_non_overlapping_range(__first, __last, __p + __ip);1956 __copy_non_overlapping_range(std::move(__first), std::move(__last), __p + __ip);
19411957
1942 return begin() + __ip;1958 return begin() + __ip;
1943 }1959 }
...@@ -1946,28 +1962,28 @@ private:...@@ -1946,28 +1962,28 @@ private:
1946 _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator1962 _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
1947 __insert_with_size(const_iterator __pos, _Iterator __first, _Sentinel __last, size_type __n);1963 __insert_with_size(const_iterator __pos, _Iterator __first, _Sentinel __last, size_type __n);
19481964
1949 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 allocator_type& __alloc() _NOEXCEPT { return __r_.second(); }
1950 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const allocator_type& __alloc() const _NOEXCEPT { return __r_.second(); }
1951
1952 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void1965 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void
1953 __set_short_size(size_type __s) _NOEXCEPT {1966 __set_short_size(size_type __s) _NOEXCEPT {
1954 _LIBCPP_ASSERT_INTERNAL(__s < __min_cap, "__s should never be greater than or equal to the short string capacity");1967 _LIBCPP_ASSERT_INTERNAL(__s < __min_cap, "__s should never be greater than or equal to the short string capacity");
1955 __r_.first().__s.__size_ = __s;1968 __rep_.__s.__size_ = __s;
1956 __r_.first().__s.__is_long_ = false;1969 __rep_.__s.__is_long_ = false;
1957 }1970 }
19581971
1959 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS size_type1972 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS size_type
1960 __get_short_size() const _NOEXCEPT {1973 __get_short_size() const _NOEXCEPT {
1961 _LIBCPP_ASSERT_INTERNAL(!__r_.first().__s.__is_long_, "String has to be short when trying to get the short size");1974 _LIBCPP_ASSERT_INTERNAL(!__rep_.__s.__is_long_, "String has to be short when trying to get the short size");
1962 return __r_.first().__s.__size_;1975 return __rep_.__s.__size_;
1963 }1976 }
19641977
1965 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_size(size_type __s) _NOEXCEPT {1978 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_size(size_type __s) _NOEXCEPT {
1966 __r_.first().__l.__size_ = __s;1979 __rep_.__l.__size_ = __s;
1967 }1980 }
1981
1968 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_long_size() const _NOEXCEPT {1982 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_long_size() const _NOEXCEPT {
1969 return __r_.first().__l.__size_;1983 _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long size");
1984 return __rep_.__l.__size_;
1970 }1985 }
1986
1971 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_size(size_type __s) _NOEXCEPT {1987 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_size(size_type __s) _NOEXCEPT {
1972 if (__is_long())1988 if (__is_long())
1973 __set_long_size(__s);1989 __set_long_size(__s);
...@@ -1976,31 +1992,40 @@ private:...@@ -1976,31 +1992,40 @@ private:
1976 }1992 }
19771993
1978 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_cap(size_type __s) _NOEXCEPT {1994 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_cap(size_type __s) _NOEXCEPT {
1979 __r_.first().__l.__cap_ = __s / __endian_factor;1995 _LIBCPP_ASSERT_INTERNAL(!__fits_in_sso(__s), "Long capacity should always be larger than the SSO");
1980 __r_.first().__l.__is_long_ = true;1996 __rep_.__l.__cap_ = __s / __endian_factor;
1997 __rep_.__l.__is_long_ = true;
1981 }1998 }
19821999
1983 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_long_cap() const _NOEXCEPT {2000 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_long_cap() const _NOEXCEPT {
1984 return __r_.first().__l.__cap_ * __endian_factor;2001 _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long capacity");
2002 return __rep_.__l.__cap_ * __endian_factor;
1985 }2003 }
19862004
1987 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_pointer(pointer __p) _NOEXCEPT {2005 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_pointer(pointer __p) _NOEXCEPT {
1988 __r_.first().__l.__data_ = __p;2006 __rep_.__l.__data_ = __p;
1989 }2007 }
2008
1990 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_long_pointer() _NOEXCEPT {2009 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_long_pointer() _NOEXCEPT {
1991 return _LIBCPP_ASAN_VOLATILE_WRAPPER(__r_.first().__l.__data_);2010 _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long pointer");
2011 return _LIBCPP_ASAN_VOLATILE_WRAPPER(__rep_.__l.__data_);
1992 }2012 }
2013
1993 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_long_pointer() const _NOEXCEPT {2014 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_long_pointer() const _NOEXCEPT {
1994 return _LIBCPP_ASAN_VOLATILE_WRAPPER(__r_.first().__l.__data_);2015 _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long pointer");
2016 return _LIBCPP_ASAN_VOLATILE_WRAPPER(__rep_.__l.__data_);
1995 }2017 }
2018
1996 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS pointer2019 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS pointer
1997 __get_short_pointer() _NOEXCEPT {2020 __get_short_pointer() _NOEXCEPT {
1998 return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]));2021 return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<pointer>::pointer_to(__rep_.__s.__data_[0]));
1999 }2022 }
2023
2000 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS const_pointer2024 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS const_pointer
2001 __get_short_pointer() const _NOEXCEPT {2025 __get_short_pointer() const _NOEXCEPT {
2002 return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]));2026 return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<const_pointer>::pointer_to(__rep_.__s.__data_[0]));
2003 }2027 }
2028
2004 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_pointer() _NOEXCEPT {2029 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_pointer() _NOEXCEPT {
2005 return __is_long() ? __get_long_pointer() : __get_short_pointer();2030 return __is_long() ? __get_long_pointer() : __get_short_pointer();
2006 }2031 }
...@@ -2013,45 +2038,45 @@ private:...@@ -2013,45 +2038,45 @@ private:
2013 __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {2038 __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {
2014 (void)__old_mid;2039 (void)__old_mid;
2015 (void)__new_mid;2040 (void)__new_mid;
2016#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)2041# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
2017 #if defined(__APPLE__)2042# if defined(__APPLE__)
2018 // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099)2043 // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099)
2019 if(!__is_long())2044 if (!__is_long())
2020 return;2045 return;
2021 #endif2046# endif
2022 std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity() + 1, __old_mid, __new_mid);2047 std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity() + 1, __old_mid, __new_mid);
2023#endif2048# endif
2024 }2049 }
20252050
2026 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT {2051 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT {
2027 (void)__current_size;2052 (void)__current_size;
2028#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)2053# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
2029 if (!__libcpp_is_constant_evaluated())2054 if (!__libcpp_is_constant_evaluated())
2030 __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1);2055 __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1);
2031#endif2056# endif
2032 }2057 }
20332058
2034 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT {2059 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT {
2035#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)2060# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
2036 if (!__libcpp_is_constant_evaluated())2061 if (!__libcpp_is_constant_evaluated())
2037 __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1);2062 __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1);
2038#endif2063# endif
2039 }2064 }
20402065
2041 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT {2066 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT {
2042 (void)__n;2067 (void)__n;
2043#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)2068# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
2044 if (!__libcpp_is_constant_evaluated())2069 if (!__libcpp_is_constant_evaluated())
2045 __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n);2070 __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n);
2046#endif2071# endif
2047 }2072 }
20482073
2049 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT {2074 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT {
2050 (void)__old_size;2075 (void)__old_size;
2051#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)2076# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
2052 if (!__libcpp_is_constant_evaluated())2077 if (!__libcpp_is_constant_evaluated())
2053 __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1);2078 __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1);
2054#endif2079# endif
2055 }2080 }
20562081
2057 template <size_type __a>2082 template <size_type __a>
...@@ -2067,6 +2092,8 @@ private:...@@ -2067,6 +2092,8 @@ private:
2067 size_type __guess = __align_it<__boundary>(__s + 1) - 1;2092 size_type __guess = __align_it<__boundary>(__s + 1) - 1;
2068 if (__guess == __min_cap)2093 if (__guess == __min_cap)
2069 __guess += __endian_factor;2094 __guess += __endian_factor;
2095
2096 _LIBCPP_ASSERT_INTERNAL(__guess >= __s, "recommendation is below the requested size");
2070 return __guess;2097 return __guess;
2071 }2098 }
20722099
...@@ -2098,9 +2125,9 @@ private:...@@ -2098,9 +2125,9 @@ private:
2098 __init_with_size(_InputIterator __first, _Sentinel __last, size_type __sz);2125 __init_with_size(_InputIterator __first, _Sentinel __last, size_type __sz);
20992126
2100 _LIBCPP_CONSTEXPR_SINCE_CXX202127 _LIBCPP_CONSTEXPR_SINCE_CXX20
2101#if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv12128# if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1
2102 _LIBCPP_HIDE_FROM_ABI2129 _LIBCPP_HIDE_FROM_ABI
2103#endif2130# endif
2104 _LIBCPP_DEPRECATED_("use __grow_by_without_replace") void __grow_by(2131 _LIBCPP_DEPRECATED_("use __grow_by_without_replace") void __grow_by(
2105 size_type __old_cap,2132 size_type __old_cap,
2106 size_type __delta_cap,2133 size_type __delta_cap,
...@@ -2131,6 +2158,7 @@ private:...@@ -2131,6 +2158,7 @@ private:
2131 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string& __assign_no_alias(const value_type* __s, size_type __n);2158 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string& __assign_no_alias(const value_type* __s, size_type __n);
21322159
2133 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __erase_to_end(size_type __pos) {2160 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __erase_to_end(size_type __pos) {
2161 _LIBCPP_ASSERT_INTERNAL(__pos <= capacity(), "Trying to erase at position outside the strings capacity!");
2134 __null_terminate_at(std::__to_address(__get_pointer()), __pos);2162 __null_terminate_at(std::__to_address(__get_pointer()), __pos);
2135 }2163 }
21362164
...@@ -2144,24 +2172,24 @@ private:...@@ -2144,24 +2172,24 @@ private:
2144 }2172 }
21452173
2146 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const basic_string& __str, true_type) {2174 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const basic_string& __str, true_type) {
2147 if (__alloc() == __str.__alloc())2175 if (__alloc_ == __str.__alloc_)
2148 __alloc() = __str.__alloc();2176 __alloc_ = __str.__alloc_;
2149 else {2177 else {
2150 if (!__str.__is_long()) {2178 if (!__str.__is_long()) {
2151 __clear_and_shrink();2179 __clear_and_shrink();
2152 __alloc() = __str.__alloc();2180 __alloc_ = __str.__alloc_;
2153 } else {2181 } else {
2154 __annotate_delete();2182 __annotate_delete();
2155 allocator_type __a = __str.__alloc();2183 auto __guard = std::__make_scope_guard(__annotate_new_size(*this));
2184 allocator_type __a = __str.__alloc_;
2156 auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap());2185 auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap());
2157 __begin_lifetime(__allocation.ptr, __allocation.count);2186 __begin_lifetime(__allocation.ptr, __allocation.count);
2158 if (__is_long())2187 if (__is_long())
2159 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());2188 __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());
2160 __alloc() = std::move(__a);2189 __alloc_ = std::move(__a);
2161 __set_long_pointer(__allocation.ptr);2190 __set_long_pointer(__allocation.ptr);
2162 __set_long_cap(__allocation.count);2191 __set_long_cap(__allocation.count);
2163 __set_long_size(__str.size());2192 __set_long_size(__str.size());
2164 __annotate_new(__get_long_size());
2165 }2193 }
2166 }2194 }
2167 }2195 }
...@@ -2169,17 +2197,17 @@ private:...@@ -2169,17 +2197,17 @@ private:
2169 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void2197 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
2170 __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT {}2198 __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT {}
21712199
2172#ifndef _LIBCPP_CXX03_LANG2200# ifndef _LIBCPP_CXX03_LANG
2173 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void2201 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
2174 __move_assign(basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value);2202 __move_assign(basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value);
2175 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void2203 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void
2176 __move_assign(basic_string& __str, true_type)2204 __move_assign(basic_string& __str, true_type)
2177# if _LIBCPP_STD_VER >= 172205# if _LIBCPP_STD_VER >= 17
2178 noexcept;2206 noexcept;
2179# else2207# else
2180 noexcept(is_nothrow_move_assignable<allocator_type>::value);2208 noexcept(is_nothrow_move_assignable<allocator_type>::value);
2209# endif
2181# endif2210# endif
2182#endif
21832211
2184 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(basic_string& __str)2212 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(basic_string& __str)
2185 _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value ||2213 _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value ||
...@@ -2190,7 +2218,7 @@ private:...@@ -2190,7 +2218,7 @@ private:
21902218
2191 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(basic_string& __c, true_type)2219 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(basic_string& __c, true_type)
2192 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {2220 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
2193 __alloc() = std::move(__c.__alloc());2221 __alloc_ = std::move(__c.__alloc_);
2194 }2222 }
21952223
2196 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(basic_string&, false_type) _NOEXCEPT {}2224 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(basic_string&, false_type) _NOEXCEPT {}
...@@ -2229,11 +2257,11 @@ private:...@@ -2229,11 +2257,11 @@ private:
2229 return std::__is_pointer_in_range(data(), data() + size() + 1, std::addressof(__v));2257 return std::__is_pointer_in_range(data(), data() + size() + 1, std::addressof(__v));
2230 }2258 }
22312259
2232 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const {2260 [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_length_error() {
2233 std::__throw_length_error("basic_string");2261 std::__throw_length_error("basic_string");
2234 }2262 }
22352263
2236 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const {2264 [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_out_of_range() {
2237 std::__throw_out_of_range("basic_string");2265 std::__throw_out_of_range("basic_string");
2238 }2266 }
22392267
...@@ -2242,29 +2270,33 @@ private:...@@ -2242,29 +2270,33 @@ private:
2242 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(value_type, const basic_string&);2270 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(value_type, const basic_string&);
2243 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const value_type*);2271 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const value_type*);
2244 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, value_type);2272 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, value_type);
2245#if _LIBCPP_STD_VER >= 262273# if _LIBCPP_STD_VER >= 26
2246 friend constexpr basic_string operator+ <>(const basic_string&, type_identity_t<__self_view>);2274 friend constexpr basic_string operator+ <>(const basic_string&, type_identity_t<__self_view>);
2247 friend constexpr basic_string operator+ <>(type_identity_t<__self_view>, const basic_string&);2275 friend constexpr basic_string operator+ <>(type_identity_t<__self_view>, const basic_string&);
2248#endif2276# endif
2277
2278 template <class _CharT2, class _Traits2, class _Allocator2>
2279 friend inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
2280 operator==(const basic_string<_CharT2, _Traits2, _Allocator2>&, const _CharT2*) _NOEXCEPT;
2249};2281};
22502282
2251// These declarations must appear before any functions are implicitly used2283// These declarations must appear before any functions are implicitly used
2252// so that they have the correct visibility specifier.2284// so that they have the correct visibility specifier.
2253#define _LIBCPP_DECLARE(...) extern template __VA_ARGS__;2285# define _LIBCPP_DECLARE(...) extern template __VA_ARGS__;
2254#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION2286# ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
2255_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char)2287_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char)
2256# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2288# if _LIBCPP_HAS_WIDE_CHARACTERS
2257_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t)2289_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t)
2258# endif2290# endif
2259#else2291# else
2260_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char)2292_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char)
2261# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS2293# if _LIBCPP_HAS_WIDE_CHARACTERS
2262_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t)2294_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t)
2295# endif
2263# endif2296# endif
2264#endif2297# undef _LIBCPP_DECLARE
2265#undef _LIBCPP_DECLARE
22662298
2267#if _LIBCPP_STD_VER >= 172299# if _LIBCPP_STD_VER >= 17
2268template <class _InputIterator,2300template <class _InputIterator,
2269 class _CharT = __iter_value_type<_InputIterator>,2301 class _CharT = __iter_value_type<_InputIterator>,
2270 class _Allocator = allocator<_CharT>,2302 class _Allocator = allocator<_CharT>,
...@@ -2287,21 +2319,21 @@ template <class _CharT,...@@ -2287,21 +2319,21 @@ template <class _CharT,
2287 class _Sz = typename allocator_traits<_Allocator>::size_type >2319 class _Sz = typename allocator_traits<_Allocator>::size_type >
2288basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator())2320basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator())
2289 -> basic_string<_CharT, _Traits, _Allocator>;2321 -> basic_string<_CharT, _Traits, _Allocator>;
2290#endif2322# endif
22912323
2292#if _LIBCPP_STD_VER >= 232324# if _LIBCPP_STD_VER >= 23
2293template <ranges::input_range _Range,2325template <ranges::input_range _Range,
2294 class _Allocator = allocator<ranges::range_value_t<_Range>>,2326 class _Allocator = allocator<ranges::range_value_t<_Range>>,
2295 class = enable_if_t<__is_allocator<_Allocator>::value> >2327 class = enable_if_t<__is_allocator<_Allocator>::value> >
2296basic_string(from_range_t, _Range&&, _Allocator = _Allocator())2328basic_string(from_range_t, _Range&&, _Allocator = _Allocator())
2297 -> basic_string<ranges::range_value_t<_Range>, char_traits<ranges::range_value_t<_Range>>, _Allocator>;2329 -> basic_string<ranges::range_value_t<_Range>, char_traits<ranges::range_value_t<_Range>>, _Allocator>;
2298#endif2330# endif
22992331
2300template <class _CharT, class _Traits, class _Allocator>2332template <class _CharT, class _Traits, class _Allocator>
2301_LIBCPP_CONSTEXPR_SINCE_CXX20 void2333_LIBCPP_CONSTEXPR_SINCE_CXX20 void
2302basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) {2334basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) {
2303 if (__libcpp_is_constant_evaluated())2335 if (__libcpp_is_constant_evaluated())
2304 __r_.first() = __rep();2336 __rep_ = __rep();
2305 if (__reserve > max_size())2337 if (__reserve > max_size())
2306 __throw_length_error();2338 __throw_length_error();
2307 pointer __p;2339 pointer __p;
...@@ -2309,7 +2341,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty...@@ -2309,7 +2341,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty
2309 __set_short_size(__sz);2341 __set_short_size(__sz);
2310 __p = __get_short_pointer();2342 __p = __get_short_pointer();
2311 } else {2343 } else {
2312 auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__reserve) + 1);2344 auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__reserve) + 1);
2313 __p = __allocation.ptr;2345 __p = __allocation.ptr;
2314 __begin_lifetime(__p, __allocation.count);2346 __begin_lifetime(__p, __allocation.count);
2315 __set_long_pointer(__p);2347 __set_long_pointer(__p);
...@@ -2325,7 +2357,7 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -2325,7 +2357,7 @@ template <class _CharT, class _Traits, class _Allocator>
2325_LIBCPP_CONSTEXPR_SINCE_CXX20 void2357_LIBCPP_CONSTEXPR_SINCE_CXX20 void
2326basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) {2358basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) {
2327 if (__libcpp_is_constant_evaluated())2359 if (__libcpp_is_constant_evaluated())
2328 __r_.first() = __rep();2360 __rep_ = __rep();
2329 if (__sz > max_size())2361 if (__sz > max_size())
2330 __throw_length_error();2362 __throw_length_error();
2331 pointer __p;2363 pointer __p;
...@@ -2333,7 +2365,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty...@@ -2333,7 +2365,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty
2333 __set_short_size(__sz);2365 __set_short_size(__sz);
2334 __p = __get_short_pointer();2366 __p = __get_short_pointer();
2335 } else {2367 } else {
2336 auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1);2368 auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1);
2337 __p = __allocation.ptr;2369 __p = __allocation.ptr;
2338 __begin_lifetime(__p, __allocation.count);2370 __begin_lifetime(__p, __allocation.count);
2339 __set_long_pointer(__p);2371 __set_long_pointer(__p);
...@@ -2349,7 +2381,7 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -2349,7 +2381,7 @@ template <class _CharT, class _Traits, class _Allocator>
2349_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void2381_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void
2350basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value_type* __s, size_type __sz) {2382basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value_type* __s, size_type __sz) {
2351 if (__libcpp_is_constant_evaluated())2383 if (__libcpp_is_constant_evaluated())
2352 __r_.first() = __rep();2384 __rep_ = __rep();
23532385
2354 pointer __p;2386 pointer __p;
2355 if (__fits_in_sso(__sz)) {2387 if (__fits_in_sso(__sz)) {
...@@ -2358,7 +2390,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value...@@ -2358,7 +2390,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value
2358 } else {2390 } else {
2359 if (__sz > max_size())2391 if (__sz > max_size())
2360 __throw_length_error();2392 __throw_length_error();
2361 auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1);2393 auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1);
2362 __p = __allocation.ptr;2394 __p = __allocation.ptr;
2363 __begin_lifetime(__p, __allocation.count);2395 __begin_lifetime(__p, __allocation.count);
2364 __set_long_pointer(__p);2396 __set_long_pointer(__p);
...@@ -2372,7 +2404,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value...@@ -2372,7 +2404,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value
2372template <class _CharT, class _Traits, class _Allocator>2404template <class _CharT, class _Traits, class _Allocator>
2373_LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) {2405_LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) {
2374 if (__libcpp_is_constant_evaluated())2406 if (__libcpp_is_constant_evaluated())
2375 __r_.first() = __rep();2407 __rep_ = __rep();
23762408
2377 if (__n > max_size())2409 if (__n > max_size())
2378 __throw_length_error();2410 __throw_length_error();
...@@ -2381,7 +2413,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__...@@ -2381,7 +2413,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__
2381 __set_short_size(__n);2413 __set_short_size(__n);
2382 __p = __get_short_pointer();2414 __p = __get_short_pointer();
2383 } else {2415 } else {
2384 auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__n) + 1);2416 auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__n) + 1);
2385 __p = __allocation.ptr;2417 __p = __allocation.ptr;
2386 __begin_lifetime(__p, __allocation.count);2418 __begin_lifetime(__p, __allocation.count);
2387 __set_long_pointer(__p);2419 __set_long_pointer(__p);
...@@ -2404,22 +2436,22 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -2404,22 +2436,22 @@ template <class _CharT, class _Traits, class _Allocator>
2404template <class _InputIterator, class _Sentinel>2436template <class _InputIterator, class _Sentinel>
2405_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void2437_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
2406basic_string<_CharT, _Traits, _Allocator>::__init_with_sentinel(_InputIterator __first, _Sentinel __last) {2438basic_string<_CharT, _Traits, _Allocator>::__init_with_sentinel(_InputIterator __first, _Sentinel __last) {
2407 __r_.first() = __rep();2439 __rep_ = __rep();
2408 __annotate_new(0);2440 __annotate_new(0);
24092441
2410#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2442# if _LIBCPP_HAS_EXCEPTIONS
2411 try {2443 try {
2412#endif // _LIBCPP_HAS_NO_EXCEPTIONS2444# endif // _LIBCPP_HAS_EXCEPTIONS
2413 for (; __first != __last; ++__first)2445 for (; __first != __last; ++__first)
2414 push_back(*__first);2446 push_back(*__first);
2415#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2447# if _LIBCPP_HAS_EXCEPTIONS
2416 } catch (...) {2448 } catch (...) {
2417 __annotate_delete();2449 __annotate_delete();
2418 if (__is_long())2450 if (__is_long())
2419 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());2451 __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());
2420 throw;2452 throw;
2421 }2453 }
2422#endif // _LIBCPP_HAS_NO_EXCEPTIONS2454# endif // _LIBCPP_HAS_EXCEPTIONS
2423}2455}
24242456
2425template <class _CharT, class _Traits, class _Allocator>2457template <class _CharT, class _Traits, class _Allocator>
...@@ -2435,7 +2467,7 @@ template <class _InputIterator, class _Sentinel>...@@ -2435,7 +2467,7 @@ template <class _InputIterator, class _Sentinel>
2435_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void2467_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
2436basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __first, _Sentinel __last, size_type __sz) {2468basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __first, _Sentinel __last, size_type __sz) {
2437 if (__libcpp_is_constant_evaluated())2469 if (__libcpp_is_constant_evaluated())
2438 __r_.first() = __rep();2470 __rep_ = __rep();
24392471
2440 if (__sz > max_size())2472 if (__sz > max_size())
2441 __throw_length_error();2473 __throw_length_error();
...@@ -2446,7 +2478,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir...@@ -2446,7 +2478,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir
2446 __p = __get_short_pointer();2478 __p = __get_short_pointer();
24472479
2448 } else {2480 } else {
2449 auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1);2481 auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1);
2450 __p = __allocation.ptr;2482 __p = __allocation.ptr;
2451 __begin_lifetime(__p, __allocation.count);2483 __begin_lifetime(__p, __allocation.count);
2452 __set_long_pointer(__p);2484 __set_long_pointer(__p);
...@@ -2454,18 +2486,18 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir...@@ -2454,18 +2486,18 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir
2454 __set_long_size(__sz);2486 __set_long_size(__sz);
2455 }2487 }
24562488
2457#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2489# if _LIBCPP_HAS_EXCEPTIONS
2458 try {2490 try {
2459#endif // _LIBCPP_HAS_NO_EXCEPTIONS2491# endif // _LIBCPP_HAS_EXCEPTIONS
2460 auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__p));2492 auto __end = __copy_non_overlapping_range(std::move(__first), std::move(__last), std::__to_address(__p));
2461 traits_type::assign(*__end, value_type());2493 traits_type::assign(*__end, value_type());
2462#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2494# if _LIBCPP_HAS_EXCEPTIONS
2463 } catch (...) {2495 } catch (...) {
2464 if (__is_long())2496 if (__is_long())
2465 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());2497 __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());
2466 throw;2498 throw;
2467 }2499 }
2468#endif // _LIBCPP_HAS_NO_EXCEPTIONS2500# endif // _LIBCPP_HAS_EXCEPTIONS
2469 __annotate_new(__sz);2501 __annotate_new(__sz);
2470}2502}
24712503
...@@ -2485,7 +2517,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__...@@ -2485,7 +2517,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__
2485 size_type __cap =2517 size_type __cap =
2486 __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1;2518 __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1;
2487 __annotate_delete();2519 __annotate_delete();
2488 auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1);2520 auto __guard = std::__make_scope_guard(__annotate_new_size(*this));
2521 auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1);
2489 pointer __p = __allocation.ptr;2522 pointer __p = __allocation.ptr;
2490 __begin_lifetime(__p, __allocation.count);2523 __begin_lifetime(__p, __allocation.count);
2491 if (__n_copy != 0)2524 if (__n_copy != 0)
...@@ -2497,13 +2530,12 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__...@@ -2497,13 +2530,12 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__
2497 traits_type::copy(2530 traits_type::copy(
2498 std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz);2531 std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz);
2499 if (__old_cap + 1 != __min_cap)2532 if (__old_cap + 1 != __min_cap)
2500 __alloc_traits::deallocate(__alloc(), __old_p, __old_cap + 1);2533 __alloc_traits::deallocate(__alloc_, __old_p, __old_cap + 1);
2501 __set_long_pointer(__p);2534 __set_long_pointer(__p);
2502 __set_long_cap(__allocation.count);2535 __set_long_cap(__allocation.count);
2503 __old_sz = __n_copy + __n_add + __sec_cp_sz;2536 __old_sz = __n_copy + __n_add + __sec_cp_sz;
2504 __set_long_size(__old_sz);2537 __set_long_size(__old_sz);
2505 traits_type::assign(__p[__old_sz], value_type());2538 traits_type::assign(__p[__old_sz], value_type());
2506 __annotate_new(__old_sz);
2507}2539}
25082540
2509// __grow_by is deprecated because it does not set the size. It may not update the size when the size is changed, and it2541// __grow_by is deprecated because it does not set the size. It may not update the size when the size is changed, and it
...@@ -2511,9 +2543,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__...@@ -2511,9 +2543,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__
2511// not removed or changed to avoid breaking the ABI.2543// not removed or changed to avoid breaking the ABI.
2512template <class _CharT, class _Traits, class _Allocator>2544template <class _CharT, class _Traits, class _Allocator>
2513void _LIBCPP_CONSTEXPR_SINCE_CXX202545void _LIBCPP_CONSTEXPR_SINCE_CXX20
2514#if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv12546# if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1
2515_LIBCPP_HIDE_FROM_ABI2547_LIBCPP_HIDE_FROM_ABI
2516#endif2548# endif
2517_LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Traits, _Allocator>::__grow_by(2549_LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Traits, _Allocator>::__grow_by(
2518 size_type __old_cap,2550 size_type __old_cap,
2519 size_type __delta_cap,2551 size_type __delta_cap,
...@@ -2527,8 +2559,7 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait...@@ -2527,8 +2559,7 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait
2527 pointer __old_p = __get_pointer();2559 pointer __old_p = __get_pointer();
2528 size_type __cap =2560 size_type __cap =
2529 __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1;2561 __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1;
2530 __annotate_delete();2562 auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1);
2531 auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1);
2532 pointer __p = __allocation.ptr;2563 pointer __p = __allocation.ptr;
2533 __begin_lifetime(__p, __allocation.count);2564 __begin_lifetime(__p, __allocation.count);
2534 if (__n_copy != 0)2565 if (__n_copy != 0)
...@@ -2538,7 +2569,7 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait...@@ -2538,7 +2569,7 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait
2538 traits_type::copy(2569 traits_type::copy(
2539 std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz);2570 std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz);
2540 if (__old_cap + 1 != __min_cap)2571 if (__old_cap + 1 != __min_cap)
2541 __alloc_traits::deallocate(__alloc(), __old_p, __old_cap + 1);2572 __alloc_traits::deallocate(__alloc_, __old_p, __old_cap + 1);
2542 __set_long_pointer(__p);2573 __set_long_pointer(__p);
2543 __set_long_cap(__allocation.count);2574 __set_long_cap(__allocation.count);
2544}2575}
...@@ -2552,11 +2583,12 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_without_replace(...@@ -2552,11 +2583,12 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_without_replace(
2552 size_type __n_copy,2583 size_type __n_copy,
2553 size_type __n_del,2584 size_type __n_del,
2554 size_type __n_add) {2585 size_type __n_add) {
2586 __annotate_delete();
2587 auto __guard = std::__make_scope_guard(__annotate_new_size(*this));
2555 _LIBCPP_SUPPRESS_DEPRECATED_PUSH2588 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
2556 __grow_by(__old_cap, __delta_cap, __old_sz, __n_copy, __n_del, __n_add);2589 __grow_by(__old_cap, __delta_cap, __old_sz, __n_copy, __n_del, __n_add);
2557 _LIBCPP_SUPPRESS_DEPRECATED_POP2590 _LIBCPP_SUPPRESS_DEPRECATED_POP
2558 __set_long_size(__old_sz - __n_del + __n_add);2591 __set_long_size(__old_sz - __n_del + __n_add);
2559 __annotate_new(__old_sz - __n_del + __n_add);
2560}2592}
25612593
2562// assign2594// assign
...@@ -2655,7 +2687,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)...@@ -2655,7 +2687,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
2655 size_type __old_size = __get_short_size();2687 size_type __old_size = __get_short_size();
2656 if (__get_short_size() < __str.__get_short_size())2688 if (__get_short_size() < __str.__get_short_size())
2657 __annotate_increase(__str.__get_short_size() - __get_short_size());2689 __annotate_increase(__str.__get_short_size() - __get_short_size());
2658 __r_.first() = __str.__r_.first();2690 __rep_ = __str.__rep_;
2659 if (__old_size > __get_short_size())2691 if (__old_size > __get_short_size())
2660 __annotate_shrink(__old_size);2692 __annotate_shrink(__old_size);
2661 } else {2693 } else {
...@@ -2668,12 +2700,12 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)...@@ -2668,12 +2700,12 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
2668 return *this;2700 return *this;
2669}2701}
26702702
2671#ifndef _LIBCPP_CXX03_LANG2703# ifndef _LIBCPP_CXX03_LANG
26722704
2673template <class _CharT, class _Traits, class _Allocator>2705template <class _CharT, class _Traits, class _Allocator>
2674inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__move_assign(2706inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__move_assign(
2675 basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value) {2707 basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value) {
2676 if (__alloc() != __str.__alloc())2708 if (__alloc_ != __str.__alloc_)
2677 assign(__str);2709 assign(__str);
2678 else2710 else
2679 __move_assign(__str, true_type());2711 __move_assign(__str, true_type());
...@@ -2682,32 +2714,32 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat...@@ -2682,32 +2714,32 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat
2682template <class _CharT, class _Traits, class _Allocator>2714template <class _CharT, class _Traits, class _Allocator>
2683inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void2715inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void
2684basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)2716basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)
2685# if _LIBCPP_STD_VER >= 172717# if _LIBCPP_STD_VER >= 17
2686 noexcept2718 noexcept
2687# else2719# else
2688 noexcept(is_nothrow_move_assignable<allocator_type>::value)2720 noexcept(is_nothrow_move_assignable<allocator_type>::value)
2689# endif2721# endif
2690{2722{
2691 __annotate_delete();2723 __annotate_delete();
2692 if (__is_long()) {2724 if (__is_long()) {
2693 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());2725 __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());
2694# if _LIBCPP_STD_VER <= 142726# if _LIBCPP_STD_VER <= 14
2695 if (!is_nothrow_move_assignable<allocator_type>::value) {2727 if (!is_nothrow_move_assignable<allocator_type>::value) {
2696 __set_short_size(0);2728 __set_short_size(0);
2697 traits_type::assign(__get_short_pointer()[0], value_type());2729 traits_type::assign(__get_short_pointer()[0], value_type());
2698 __annotate_new(0);2730 __annotate_new(0);
2699 }2731 }
2700# endif2732# endif
2701 }2733 }
2702 size_type __str_old_size = __str.size();2734 size_type __str_old_size = __str.size();
2703 bool __str_was_short = !__str.__is_long();2735 bool __str_was_short = !__str.__is_long();
27042736
2705 __move_assign_alloc(__str);2737 __move_assign_alloc(__str);
2706 __r_.first() = __str.__r_.first();2738 __rep_ = __str.__rep_;
2707 __str.__set_short_size(0);2739 __str.__set_short_size(0);
2708 traits_type::assign(__str.__get_short_pointer()[0], value_type());2740 traits_type::assign(__str.__get_short_pointer()[0], value_type());
27092741
2710 if (__str_was_short && this != &__str)2742 if (__str_was_short && this != std::addressof(__str))
2711 __str.__annotate_shrink(__str_old_size);2743 __str.__annotate_shrink(__str_old_size);
2712 else2744 else
2713 // ASan annotations: was long, so object memory is unpoisoned as new.2745 // ASan annotations: was long, so object memory is unpoisoned as new.
...@@ -2721,12 +2753,12 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr...@@ -2721,12 +2753,12 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr
2721 // invariants hold (so functions without preconditions, such as the assignment operator,2753 // invariants hold (so functions without preconditions, such as the assignment operator,
2722 // can be safely used on the object after it was moved from):"2754 // can be safely used on the object after it was moved from):"
2723 // Quote: "v = std::move(v); // the value of v is unspecified"2755 // Quote: "v = std::move(v); // the value of v is unspecified"
2724 if (!__is_long() && &__str != this)2756 if (!__is_long() && std::addressof(__str) != this)
2725 // If it is long string, delete was never called on original __str's buffer.2757 // If it is long string, delete was never called on original __str's buffer.
2726 __annotate_new(__get_short_size());2758 __annotate_new(__get_short_size());
2727}2759}
27282760
2729#endif2761# endif
27302762
2731template <class _CharT, class _Traits, class _Allocator>2763template <class _CharT, class _Traits, class _Allocator>
2732template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >2764template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
...@@ -2740,7 +2772,7 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -2740,7 +2772,7 @@ template <class _CharT, class _Traits, class _Allocator>
2740template <class _InputIterator, class _Sentinel>2772template <class _InputIterator, class _Sentinel>
2741_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void2773_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
2742basic_string<_CharT, _Traits, _Allocator>::__assign_with_sentinel(_InputIterator __first, _Sentinel __last) {2774basic_string<_CharT, _Traits, _Allocator>::__assign_with_sentinel(_InputIterator __first, _Sentinel __last) {
2743 const basic_string __temp(__init_with_sentinel_tag(), std::move(__first), std::move(__last), __alloc());2775 const basic_string __temp(__init_with_sentinel_tag(), std::move(__first), std::move(__last), __alloc_);
2744 assign(__temp.data(), __temp.size());2776 assign(__temp.data(), __temp.size());
2745}2777}
27462778
...@@ -2928,7 +2960,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _For...@@ -2928,7 +2960,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _For
2928 traits_type::assign(*__end, value_type());2960 traits_type::assign(*__end, value_type());
2929 __set_size(__sz + __n);2961 __set_size(__sz + __n);
2930 } else {2962 } else {
2931 const basic_string __temp(__first, __last, __alloc());2963 const basic_string __temp(__first, __last, __alloc_);
2932 append(__temp.data(), __temp.size());2964 append(__temp.data(), __temp.size());
2933 }2965 }
2934 }2966 }
...@@ -3026,7 +3058,7 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -3026,7 +3058,7 @@ template <class _CharT, class _Traits, class _Allocator>
3026template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >3058template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
3027_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator3059_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator
3028basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) {3060basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) {
3029 const basic_string __temp(__first, __last, __alloc());3061 const basic_string __temp(__first, __last, __alloc_);
3030 return insert(__pos, __temp.data(), __temp.data() + __temp.size());3062 return insert(__pos, __temp.data(), __temp.data() + __temp.size());
3031}3063}
30323064
...@@ -3049,9 +3081,9 @@ basic_string<_CharT, _Traits, _Allocator>::__insert_with_size(...@@ -3049,9 +3081,9 @@ basic_string<_CharT, _Traits, _Allocator>::__insert_with_size(
3049 return begin() + __ip;3081 return begin() + __ip;
30503082
3051 if (__string_is_trivial_iterator<_Iterator>::value && !__addr_in_range(*__first)) {3083 if (__string_is_trivial_iterator<_Iterator>::value && !__addr_in_range(*__first)) {
3052 return __insert_from_safe_copy(__n, __ip, __first, __last);3084 return __insert_from_safe_copy(__n, __ip, std::move(__first), std::move(__last));
3053 } else {3085 } else {
3054 const basic_string __temp(__init_with_sentinel_tag(), __first, __last, __alloc());3086 const basic_string __temp(__init_with_sentinel_tag(), std::move(__first), std::move(__last), __alloc_);
3055 return __insert_from_safe_copy(__n, __ip, __temp.begin(), __temp.end());3087 return __insert_from_safe_copy(__n, __ip, __temp.begin(), __temp.end());
3056 }3088 }
3057}3089}
...@@ -3188,7 +3220,7 @@ template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_Inp...@@ -3188,7 +3220,7 @@ template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_Inp
3188_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&3220_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
3189basic_string<_CharT, _Traits, _Allocator>::replace(3221basic_string<_CharT, _Traits, _Allocator>::replace(
3190 const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2) {3222 const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2) {
3191 const basic_string __temp(__j1, __j2, __alloc());3223 const basic_string __temp(__j1, __j2, __alloc_);
3192 return replace(__i1, __i2, __temp);3224 return replace(__i1, __i2, __temp);
3193}3225}
31943226
...@@ -3325,12 +3357,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re...@@ -3325,12 +3357,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re
3325 if (__requested_capacity <= capacity())3357 if (__requested_capacity <= capacity())
3326 return;3358 return;
33273359
3328 size_type __target_capacity = std::max(__requested_capacity, size());3360 __shrink_or_extend(__recommend(__requested_capacity));
3329 __target_capacity = __recommend(__target_capacity);
3330 if (__target_capacity == capacity())
3331 return;
3332
3333 __shrink_or_extend(__target_capacity);
3334}3361}
33353362
3336template <class _CharT, class _Traits, class _Allocator>3363template <class _CharT, class _Traits, class _Allocator>
...@@ -3346,6 +3373,7 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -3346,6 +3373,7 @@ template <class _CharT, class _Traits, class _Allocator>
3346inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void3373inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void
3347basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity) {3374basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity) {
3348 __annotate_delete();3375 __annotate_delete();
3376 auto __guard = std::__make_scope_guard(__annotate_new_size(*this));
3349 size_type __cap = capacity();3377 size_type __cap = capacity();
3350 size_type __sz = size();3378 size_type __sz = size();
33513379
...@@ -3360,33 +3388,32 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target...@@ -3360,33 +3388,32 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
3360 if (__target_capacity > __cap) {3388 if (__target_capacity > __cap) {
3361 // Extend3389 // Extend
3362 // - called from reserve should propagate the exception thrown.3390 // - called from reserve should propagate the exception thrown.
3363 auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1);3391 auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1);
3364 __new_data = __allocation.ptr;3392 __new_data = __allocation.ptr;
3365 __target_capacity = __allocation.count - 1;3393 __target_capacity = __allocation.count - 1;
3366 } else {3394 } else {
3367 // Shrink3395 // Shrink
3368 // - called from shrink_to_fit should not throw.3396 // - called from shrink_to_fit should not throw.
3369 // - called from reserve may throw but is not required to.3397 // - called from reserve may throw but is not required to.
3370#ifndef _LIBCPP_HAS_NO_EXCEPTIONS3398# if _LIBCPP_HAS_EXCEPTIONS
3371 try {3399 try {
3372#endif // _LIBCPP_HAS_NO_EXCEPTIONS3400# endif // _LIBCPP_HAS_EXCEPTIONS
3373 auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1);3401 auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1);
33743402
3375 // The Standard mandates shrink_to_fit() does not increase the capacity.3403 // The Standard mandates shrink_to_fit() does not increase the capacity.
3376 // With equal capacity keep the existing buffer. This avoids extra work3404 // With equal capacity keep the existing buffer. This avoids extra work
3377 // due to swapping the elements.3405 // due to swapping the elements.
3378 if (__allocation.count - 1 > __target_capacity) {3406 if (__allocation.count - 1 > capacity()) {
3379 __alloc_traits::deallocate(__alloc(), __allocation.ptr, __allocation.count);3407 __alloc_traits::deallocate(__alloc_, __allocation.ptr, __allocation.count);
3380 __annotate_new(__sz); // Undoes the __annotate_delete()
3381 return;3408 return;
3382 }3409 }
3383 __new_data = __allocation.ptr;3410 __new_data = __allocation.ptr;
3384 __target_capacity = __allocation.count - 1;3411 __target_capacity = __allocation.count - 1;
3385#ifndef _LIBCPP_HAS_NO_EXCEPTIONS3412# if _LIBCPP_HAS_EXCEPTIONS
3386 } catch (...) {3413 } catch (...) {
3387 return;3414 return;
3388 }3415 }
3389#endif // _LIBCPP_HAS_NO_EXCEPTIONS3416# endif // _LIBCPP_HAS_EXCEPTIONS
3390 }3417 }
3391 __begin_lifetime(__new_data, __target_capacity + 1);3418 __begin_lifetime(__new_data, __target_capacity + 1);
3392 __now_long = true;3419 __now_long = true;
...@@ -3395,14 +3422,13 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target...@@ -3395,14 +3422,13 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
3395 }3422 }
3396 traits_type::copy(std::__to_address(__new_data), std::__to_address(__p), size() + 1);3423 traits_type::copy(std::__to_address(__new_data), std::__to_address(__p), size() + 1);
3397 if (__was_long)3424 if (__was_long)
3398 __alloc_traits::deallocate(__alloc(), __p, __cap + 1);3425 __alloc_traits::deallocate(__alloc_, __p, __cap + 1);
3399 if (__now_long) {3426 if (__now_long) {
3400 __set_long_cap(__target_capacity + 1);3427 __set_long_cap(__target_capacity + 1);
3401 __set_long_size(__sz);3428 __set_long_size(__sz);
3402 __set_long_pointer(__new_data);3429 __set_long_pointer(__new_data);
3403 } else3430 } else
3404 __set_short_size(__sz);3431 __set_short_size(__sz);
3405 __annotate_new(__sz);
3406}3432}
34073433
3408template <class _CharT, class _Traits, class _Allocator>3434template <class _CharT, class _Traits, class _Allocator>
...@@ -3434,38 +3460,30 @@ basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n,...@@ -3434,38 +3460,30 @@ basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n,
34343460
3435template <class _CharT, class _Traits, class _Allocator>3461template <class _CharT, class _Traits, class _Allocator>
3436inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)3462inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
3437#if _LIBCPP_STD_VER >= 143463# if _LIBCPP_STD_VER >= 14
3438 _NOEXCEPT3464 _NOEXCEPT
3439#else3465# else
3440 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)3466 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
3441#endif3467# endif
3442{3468{
3443 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(3469 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
3444 __alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value ||3470 __alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value ||
3445 __alloc() == __str.__alloc(),3471 __alloc_ == __str.__alloc_,
3446 "swapping non-equal allocators");3472 "swapping non-equal allocators");
3447 if (!__is_long())3473 if (!__is_long())
3448 __annotate_delete();3474 __annotate_delete();
3449 if (this != &__str && !__str.__is_long())3475 if (this != std::addressof(__str) && !__str.__is_long())
3450 __str.__annotate_delete();3476 __str.__annotate_delete();
3451 std::swap(__r_.first(), __str.__r_.first());3477 std::swap(__rep_, __str.__rep_);
3452 std::__swap_allocator(__alloc(), __str.__alloc());3478 std::__swap_allocator(__alloc_, __str.__alloc_);
3453 if (!__is_long())3479 if (!__is_long())
3454 __annotate_new(__get_short_size());3480 __annotate_new(__get_short_size());
3455 if (this != &__str && !__str.__is_long())3481 if (this != std::addressof(__str) && !__str.__is_long())
3456 __str.__annotate_new(__str.__get_short_size());3482 __str.__annotate_new(__str.__get_short_size());
3457}3483}
34583484
3459// find3485// find
34603486
3461template <class _Traits>
3462struct _LIBCPP_HIDDEN __traits_eq {
3463 typedef typename _Traits::char_type char_type;
3464 _LIBCPP_HIDE_FROM_ABI bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT {
3465 return _Traits::eq(__x, __y);
3466 }
3467};
3468
3469template <class _CharT, class _Traits, class _Allocator>3487template <class _CharT, class _Traits, class _Allocator>
3470_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type3488_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3471basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {3489basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {
...@@ -3810,8 +3828,8 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat...@@ -3810,8 +3828,8 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat
3810 clear();3828 clear();
3811 if (__is_long()) {3829 if (__is_long()) {
3812 __annotate_delete();3830 __annotate_delete();
3813 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1);3831 __alloc_traits::deallocate(__alloc_, __get_long_pointer(), capacity() + 1);
3814 __r_.first() = __rep();3832 __rep_ = __rep();
3815 }3833 }
3816}3834}
38173835
...@@ -3821,53 +3839,36 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -3821,53 +3839,36 @@ template <class _CharT, class _Traits, class _Allocator>
3821inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool3839inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
3822operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,3840operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3823 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {3841 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {
3824#if _LIBCPP_STD_VER >= 20
3825 return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs);
3826#else
3827 size_t __lhs_sz = __lhs.size();3842 size_t __lhs_sz = __lhs.size();
3828 return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(), __rhs.data(), __lhs_sz) == 0;3843 return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(), __rhs.data(), __lhs_sz) == 0;
3829#endif
3830}3844}
38313845
3832template <class _Allocator>
3833inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
3834operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
3835 const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT {
3836 size_t __sz = __lhs.size();
3837 if (__sz != __rhs.size())
3838 return false;
3839 return char_traits<char>::compare(__lhs.data(), __rhs.data(), __sz) == 0;
3840}
3841
3842#if _LIBCPP_STD_VER <= 17
3843template <class _CharT, class _Traits, class _Allocator>
3844inline _LIBCPP_HIDE_FROM_ABI bool
3845operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {
3846 typedef basic_string<_CharT, _Traits, _Allocator> _String;
3847 _LIBCPP_ASSERT_NON_NULL(__lhs != nullptr, "operator==(char*, basic_string): received nullptr");
3848 size_t __lhs_len = _Traits::length(__lhs);
3849 if (__lhs_len != __rhs.size())
3850 return false;
3851 return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0;
3852}
3853#endif // _LIBCPP_STD_VER <= 17
3854
3855template <class _CharT, class _Traits, class _Allocator>3846template <class _CharT, class _Traits, class _Allocator>
3856inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool3847inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
3857operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT {3848operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT {
3858#if _LIBCPP_STD_VER >= 20
3859 return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs);
3860#else
3861 typedef basic_string<_CharT, _Traits, _Allocator> _String;
3862 _LIBCPP_ASSERT_NON_NULL(__rhs != nullptr, "operator==(basic_string, char*): received nullptr");3849 _LIBCPP_ASSERT_NON_NULL(__rhs != nullptr, "operator==(basic_string, char*): received nullptr");
3850
3851 using _String = basic_string<_CharT, _Traits, _Allocator>;
3852
3863 size_t __rhs_len = _Traits::length(__rhs);3853 size_t __rhs_len = _Traits::length(__rhs);
3854 if (__builtin_constant_p(__rhs_len) && !_String::__fits_in_sso(__rhs_len)) {
3855 if (!__lhs.__is_long())
3856 return false;
3857 }
3864 if (__rhs_len != __lhs.size())3858 if (__rhs_len != __lhs.size())
3865 return false;3859 return false;
3866 return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0;3860 return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0;
3867#endif
3868}3861}
38693862
3870#if _LIBCPP_STD_VER >= 203863# if _LIBCPP_STD_VER <= 17
3864template <class _CharT, class _Traits, class _Allocator>
3865inline _LIBCPP_HIDE_FROM_ABI bool
3866operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {
3867 return __rhs == __lhs;
3868}
3869# endif // _LIBCPP_STD_VER <= 17
3870
3871# if _LIBCPP_STD_VER >= 20
38713872
3872template <class _CharT, class _Traits, class _Allocator>3873template <class _CharT, class _Traits, class _Allocator>
3873_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs,3874_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
...@@ -3881,7 +3882,7 @@ operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT...@@ -3881,7 +3882,7 @@ operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT
3881 return basic_string_view<_CharT, _Traits>(__lhs) <=> basic_string_view<_CharT, _Traits>(__rhs);3882 return basic_string_view<_CharT, _Traits>(__lhs) <=> basic_string_view<_CharT, _Traits>(__rhs);
3882}3883}
38833884
3884#else // _LIBCPP_STD_VER >= 203885# else // _LIBCPP_STD_VER >= 20
38853886
3886template <class _CharT, class _Traits, class _Allocator>3887template <class _CharT, class _Traits, class _Allocator>
3887inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,3888inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
...@@ -3980,7 +3981,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool...@@ -3980,7 +3981,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool
3980operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {3981operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT {
3981 return !(__lhs < __rhs);3982 return !(__lhs < __rhs);
3982}3983}
3983#endif // _LIBCPP_STD_VER >= 203984# endif // _LIBCPP_STD_VER >= 20
39843985
3985// operator +3986// operator +
39863987
...@@ -4063,7 +4064,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)...@@ -4063,7 +4064,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)
4063 return __r;4064 return __r;
4064}4065}
40654066
4066#ifndef _LIBCPP_CXX03_LANG4067# ifndef _LIBCPP_CXX03_LANG
40674068
4068template <class _CharT, class _Traits, class _Allocator>4069template <class _CharT, class _Traits, class _Allocator>
4069inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>4070inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>
...@@ -4109,9 +4110,9 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) {...@@ -4109,9 +4110,9 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) {
4109 return std::move(__lhs);4110 return std::move(__lhs);
4110}4111}
41114112
4112#endif // _LIBCPP_CXX03_LANG4113# endif // _LIBCPP_CXX03_LANG
41134114
4114#if _LIBCPP_STD_VER >= 264115# if _LIBCPP_STD_VER >= 26
41154116
4116template <class _CharT, class _Traits, class _Allocator>4117template <class _CharT, class _Traits, class _Allocator>
4117_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>4118_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
...@@ -4163,7 +4164,7 @@ operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,...@@ -4163,7 +4164,7 @@ operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,
4163 return std::move(__rhs);4164 return std::move(__rhs);
4164}4165}
41654166
4166#endif // _LIBCPP_STD_VER >= 264167# endif // _LIBCPP_STD_VER >= 26
41674168
4168// swap4169// swap
41694170
...@@ -4194,7 +4195,7 @@ _LIBCPP_EXPORTED_FROM_ABI string to_string(float __val);...@@ -4194,7 +4195,7 @@ _LIBCPP_EXPORTED_FROM_ABI string to_string(float __val);
4194_LIBCPP_EXPORTED_FROM_ABI string to_string(double __val);4195_LIBCPP_EXPORTED_FROM_ABI string to_string(double __val);
4195_LIBCPP_EXPORTED_FROM_ABI string to_string(long double __val);4196_LIBCPP_EXPORTED_FROM_ABI string to_string(long double __val);
41964197
4197#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4198# if _LIBCPP_HAS_WIDE_CHARACTERS
4198_LIBCPP_EXPORTED_FROM_ABI int stoi(const wstring& __str, size_t* __idx = nullptr, int __base = 10);4199_LIBCPP_EXPORTED_FROM_ABI int stoi(const wstring& __str, size_t* __idx = nullptr, int __base = 10);
4199_LIBCPP_EXPORTED_FROM_ABI long stol(const wstring& __str, size_t* __idx = nullptr, int __base = 10);4200_LIBCPP_EXPORTED_FROM_ABI long stol(const wstring& __str, size_t* __idx = nullptr, int __base = 10);
4200_LIBCPP_EXPORTED_FROM_ABI unsigned long stoul(const wstring& __str, size_t* __idx = nullptr, int __base = 10);4201_LIBCPP_EXPORTED_FROM_ABI unsigned long stoul(const wstring& __str, size_t* __idx = nullptr, int __base = 10);
...@@ -4214,7 +4215,7 @@ _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned long long __val);...@@ -4214,7 +4215,7 @@ _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned long long __val);
4214_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(float __val);4215_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(float __val);
4215_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(double __val);4216_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(double __val);
4216_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long double __val);4217_LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long double __val);
4217#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS4218# endif // _LIBCPP_HAS_WIDE_CHARACTERS
42184219
4219template <class _CharT, class _Traits, class _Allocator>4220template <class _CharT, class _Traits, class _Allocator>
4220_LIBCPP_TEMPLATE_DATA_VIS const typename basic_string<_CharT, _Traits, _Allocator>::size_type4221_LIBCPP_TEMPLATE_DATA_VIS const typename basic_string<_CharT, _Traits, _Allocator>::size_type
...@@ -4231,10 +4232,10 @@ struct __string_hash : public __unary_function<basic_string<_CharT, char_traits<...@@ -4231,10 +4232,10 @@ struct __string_hash : public __unary_function<basic_string<_CharT, char_traits<
4231template <class _Allocator>4232template <class _Allocator>
4232struct hash<basic_string<char, char_traits<char>, _Allocator> > : __string_hash<char, _Allocator> {};4233struct hash<basic_string<char, char_traits<char>, _Allocator> > : __string_hash<char, _Allocator> {};
42334234
4234#ifndef _LIBCPP_HAS_NO_CHAR8_T4235# if _LIBCPP_HAS_CHAR8_T
4235template <class _Allocator>4236template <class _Allocator>
4236struct hash<basic_string<char8_t, char_traits<char8_t>, _Allocator> > : __string_hash<char8_t, _Allocator> {};4237struct hash<basic_string<char8_t, char_traits<char8_t>, _Allocator> > : __string_hash<char8_t, _Allocator> {};
4237#endif4238# endif
42384239
4239template <class _Allocator>4240template <class _Allocator>
4240struct hash<basic_string<char16_t, char_traits<char16_t>, _Allocator> > : __string_hash<char16_t, _Allocator> {};4241struct hash<basic_string<char16_t, char_traits<char16_t>, _Allocator> > : __string_hash<char16_t, _Allocator> {};
...@@ -4242,10 +4243,10 @@ struct hash<basic_string<char16_t, char_traits<char16_t>, _Allocator> > : __stri...@@ -4242,10 +4243,10 @@ struct hash<basic_string<char16_t, char_traits<char16_t>, _Allocator> > : __stri
4242template <class _Allocator>4243template <class _Allocator>
4243struct hash<basic_string<char32_t, char_traits<char32_t>, _Allocator> > : __string_hash<char32_t, _Allocator> {};4244struct hash<basic_string<char32_t, char_traits<char32_t>, _Allocator> > : __string_hash<char32_t, _Allocator> {};
42444245
4245#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4246# if _LIBCPP_HAS_WIDE_CHARACTERS
4246template <class _Allocator>4247template <class _Allocator>
4247struct hash<basic_string<wchar_t, char_traits<wchar_t>, _Allocator> > : __string_hash<wchar_t, _Allocator> {};4248struct hash<basic_string<wchar_t, char_traits<wchar_t>, _Allocator> > : __string_hash<wchar_t, _Allocator> {};
4248#endif4249# endif
42494250
4250template <class _CharT, class _Traits, class _Allocator>4251template <class _CharT, class _Traits, class _Allocator>
4251_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&4252_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
...@@ -4271,7 +4272,7 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -4271,7 +4272,7 @@ template <class _CharT, class _Traits, class _Allocator>
4271inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&4272inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
4272getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str);4273getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str);
42734274
4274#if _LIBCPP_STD_VER >= 204275# if _LIBCPP_STD_VER >= 20
4275template <class _CharT, class _Traits, class _Allocator, class _Up>4276template <class _CharT, class _Traits, class _Allocator, class _Up>
4276inline _LIBCPP_HIDE_FROM_ABI typename basic_string<_CharT, _Traits, _Allocator>::size_type4277inline _LIBCPP_HIDE_FROM_ABI typename basic_string<_CharT, _Traits, _Allocator>::size_type
4277erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) {4278erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) {
...@@ -4287,9 +4288,9 @@ erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) {...@@ -4287,9 +4288,9 @@ erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) {
4287 __str.erase(std::remove_if(__str.begin(), __str.end(), __pred), __str.end());4288 __str.erase(std::remove_if(__str.begin(), __str.end(), __pred), __str.end());
4288 return __old_size - __str.size();4289 return __old_size - __str.size();
4289}4290}
4290#endif4291# endif
42914292
4292#if _LIBCPP_STD_VER >= 144293# if _LIBCPP_STD_VER >= 14
4293// Literal suffixes for basic_string [basic.string.literals]4294// Literal suffixes for basic_string [basic.string.literals]
4294inline namespace literals {4295inline namespace literals {
4295inline namespace string_literals {4296inline namespace string_literals {
...@@ -4298,18 +4299,18 @@ operator""s(const char* __str, size_t __len) {...@@ -4298,18 +4299,18 @@ operator""s(const char* __str, size_t __len) {
4298 return basic_string<char>(__str, __len);4299 return basic_string<char>(__str, __len);
4299}4300}
43004301
4301# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4302# if _LIBCPP_HAS_WIDE_CHARACTERS
4302inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<wchar_t>4303inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<wchar_t>
4303operator""s(const wchar_t* __str, size_t __len) {4304operator""s(const wchar_t* __str, size_t __len) {
4304 return basic_string<wchar_t>(__str, __len);4305 return basic_string<wchar_t>(__str, __len);
4305}4306}
4306# endif4307# endif
43074308
4308# ifndef _LIBCPP_HAS_NO_CHAR8_T4309# if _LIBCPP_HAS_CHAR8_T
4309inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string<char8_t> operator""s(const char8_t* __str, size_t __len) {4310inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string<char8_t> operator""s(const char8_t* __str, size_t __len) {
4310 return basic_string<char8_t>(__str, __len);4311 return basic_string<char8_t>(__str, __len);
4311}4312}
4312# endif4313# endif
43134314
4314inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char16_t>4315inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char16_t>
4315operator""s(const char16_t* __str, size_t __len) {4316operator""s(const char16_t* __str, size_t __len) {
...@@ -4323,30 +4324,31 @@ operator""s(const char32_t* __str, size_t __len) {...@@ -4323,30 +4324,31 @@ operator""s(const char32_t* __str, size_t __len) {
4323} // namespace string_literals4324} // namespace string_literals
4324} // namespace literals4325} // namespace literals
43254326
4326# if _LIBCPP_STD_VER >= 204327# if _LIBCPP_STD_VER >= 20
4327template <>4328template <>
4328inline constexpr bool __format::__enable_insertable<std::basic_string<char>> = true;4329inline constexpr bool __format::__enable_insertable<std::basic_string<char>> = true;
4329# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4330# if _LIBCPP_HAS_WIDE_CHARACTERS
4330template <>4331template <>
4331inline constexpr bool __format::__enable_insertable<std::basic_string<wchar_t>> = true;4332inline constexpr bool __format::__enable_insertable<std::basic_string<wchar_t>> = true;
4333# endif
4332# endif4334# endif
4333# endif
43344335
4335#endif4336# endif
43364337
4337_LIBCPP_END_NAMESPACE_STD4338_LIBCPP_END_NAMESPACE_STD
43384339
4339_LIBCPP_POP_MACROS4340_LIBCPP_POP_MACROS
43404341
4341#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 204342# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
4342# include <algorithm>4343# include <algorithm>
4343# include <concepts>4344# include <concepts>
4344# include <cstdlib>4345# include <cstdlib>
4345# include <iterator>4346# include <iterator>
4346# include <new>4347# include <new>
4347# include <type_traits>4348# include <type_traits>
4348# include <typeinfo>4349# include <typeinfo>
4349# include <utility>4350# include <utility>
4350#endif4351# endif
4352#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
43514353
4352#endif // _LIBCPP_STRING4354#endif // _LIBCPP_STRING
lib/libcxx/include/string.h+17-12
...@@ -51,24 +51,28 @@ size_t strlen(const char* s);...@@ -51,24 +51,28 @@ size_t strlen(const char* s);
5151
52*/52*/
5353
54#include <__config>54#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
55# include <__cxx03/string.h>
56#else
57# include <__config>
5558
56#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)59# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
57# pragma GCC system_header60# pragma GCC system_header
58#endif61# endif
5962
60#if __has_include_next(<string.h>)63# if __has_include_next(<string.h>)
61# include_next <string.h>64# include_next <string.h>
62#endif65# endif
6366
64// MSVCRT, GNU libc and its derivates may already have the correct prototype in67// MSVCRT, GNU libc and its derivates may already have the correct prototype in
65// <string.h>. This macro can be defined by users if their C library provides68// <string.h>. This macro can be defined by users if their C library provides
66// the right signature.69// the right signature.
67#if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)70# if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || \
68# define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS71 defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
69#endif72# define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS
73# endif
7074
71#if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)75# if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
72extern "C++" {76extern "C++" {
73inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strchr(const char* __s, int __c) {77inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strchr(const char* __s, int __c) {
74 return __builtin_strchr(__s, __c);78 return __builtin_strchr(__s, __c);
...@@ -105,6 +109,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strstr(char* __s1,...@@ -105,6 +109,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strstr(char* __s1,
105 return __builtin_strstr(__s1, __s2);109 return __builtin_strstr(__s1, __s2);
106}110}
107} // extern "C++"111} // extern "C++"
108#endif112# endif
113#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
109114
110#endif // _LIBCPP_STRING_H115#endif // _LIBCPP_STRING_H
lib/libcxx/include/string_view+126-119
...@@ -205,57 +205,63 @@ namespace std {...@@ -205,57 +205,63 @@ namespace std {
205205
206// clang-format on206// clang-format on
207207
208#include <__algorithm/min.h>208#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
209#include <__assert>209# include <__cxx03/string_view>
210#include <__config>210#else
211#include <__functional/hash.h>211# include <__algorithm/min.h>
212#include <__functional/unary_function.h>212# include <__assert>
213#include <__fwd/ostream.h>213# include <__config>
214#include <__fwd/string_view.h>214# include <__cstddef/nullptr_t.h>
215#include <__iterator/bounded_iter.h>215# include <__cstddef/ptrdiff_t.h>
216#include <__iterator/concepts.h>216# include <__cstddef/size_t.h>
217#include <__iterator/iterator_traits.h>217# include <__functional/hash.h>
218#include <__iterator/reverse_iterator.h>218# include <__functional/unary_function.h>
219#include <__iterator/wrap_iter.h>219# include <__fwd/ostream.h>
220#include <__memory/pointer_traits.h>220# include <__fwd/string.h>
221#include <__ranges/concepts.h>221# include <__fwd/string_view.h>
222#include <__ranges/data.h>222# include <__iterator/bounded_iter.h>
223#include <__ranges/enable_borrowed_range.h>223# include <__iterator/concepts.h>
224#include <__ranges/enable_view.h>224# include <__iterator/iterator_traits.h>
225#include <__ranges/size.h>225# include <__iterator/reverse_iterator.h>
226#include <__string/char_traits.h>226# include <__iterator/wrap_iter.h>
227#include <__type_traits/is_array.h>227# include <__memory/pointer_traits.h>
228#include <__type_traits/is_convertible.h>228# include <__ranges/concepts.h>
229#include <__type_traits/is_same.h>229# include <__ranges/data.h>
230#include <__type_traits/is_standard_layout.h>230# include <__ranges/enable_borrowed_range.h>
231#include <__type_traits/is_trivial.h>231# include <__ranges/enable_view.h>
232#include <__type_traits/remove_cvref.h>232# include <__ranges/size.h>
233#include <__type_traits/remove_reference.h>233# include <__string/char_traits.h>
234#include <__type_traits/type_identity.h>234# include <__type_traits/is_array.h>
235#include <cstddef>235# include <__type_traits/is_convertible.h>
236#include <iosfwd>236# include <__type_traits/is_same.h>
237#include <limits>237# include <__type_traits/is_standard_layout.h>
238#include <stdexcept>238# include <__type_traits/is_trivial.h>
239#include <version>239# include <__type_traits/remove_cvref.h>
240# include <__type_traits/remove_reference.h>
241# include <__type_traits/type_identity.h>
242# include <iosfwd>
243# include <limits>
244# include <stdexcept>
245# include <version>
240246
241// standard-mandated includes247// standard-mandated includes
242248
243// [iterator.range]249// [iterator.range]
244#include <__iterator/access.h>250# include <__iterator/access.h>
245#include <__iterator/data.h>251# include <__iterator/data.h>
246#include <__iterator/empty.h>252# include <__iterator/empty.h>
247#include <__iterator/reverse_access.h>253# include <__iterator/reverse_access.h>
248#include <__iterator/size.h>254# include <__iterator/size.h>
249255
250// [string.view.synop]256// [string.view.synop]
251#include <compare>257# include <compare>
252258
253#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)259# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
254# pragma GCC system_header260# pragma GCC system_header
255#endif261# endif
256262
257_LIBCPP_PUSH_MACROS263_LIBCPP_PUSH_MACROS
258#include <__undef_macros>264# include <__undef_macros>
259265
260_LIBCPP_BEGIN_NAMESPACE_STD266_LIBCPP_BEGIN_NAMESPACE_STD
261267
...@@ -280,13 +286,13 @@ public:...@@ -280,13 +286,13 @@ public:
280 using const_pointer = const _CharT*;286 using const_pointer = const _CharT*;
281 using reference = _CharT&;287 using reference = _CharT&;
282 using const_reference = const _CharT&;288 using const_reference = const _CharT&;
283#if defined(_LIBCPP_ABI_BOUNDED_ITERATORS)289# if defined(_LIBCPP_ABI_BOUNDED_ITERATORS)
284 using const_iterator = __bounded_iter<const_pointer>;290 using const_iterator = __bounded_iter<const_pointer>;
285#elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW)291# elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW)
286 using const_iterator = __wrap_iter<const_pointer>;292 using const_iterator = __wrap_iter<const_pointer>;
287#else293# else
288 using const_iterator = const_pointer;294 using const_iterator = const_pointer;
289#endif295# endif
290 using iterator = const_iterator;296 using iterator = const_iterator;
291 using const_reverse_iterator = std::reverse_iterator<const_iterator>;297 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
292 using reverse_iterator = const_reverse_iterator;298 using reverse_iterator = const_reverse_iterator;
...@@ -310,7 +316,7 @@ public:...@@ -310,7 +316,7 @@ public:
310 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT316 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT
311 : __data_(__s),317 : __data_(__s),
312 __size_(__len) {318 __size_(__len) {
313#if _LIBCPP_STD_VER >= 14319# if _LIBCPP_STD_VER >= 14
314 // Allocations must fit in `ptrdiff_t` for pointer arithmetic to work. If `__len` exceeds it, the input320 // Allocations must fit in `ptrdiff_t` for pointer arithmetic to work. If `__len` exceeds it, the input
315 // range could not have been valid. Most likely the caller underflowed some arithmetic and inadvertently321 // range could not have been valid. Most likely the caller underflowed some arithmetic and inadvertently
316 // passed in a negative length.322 // passed in a negative length.
...@@ -319,10 +325,10 @@ public:...@@ -319,10 +325,10 @@ public:
319 "string_view::string_view(_CharT *, size_t): length does not fit in difference_type");325 "string_view::string_view(_CharT *, size_t): length does not fit in difference_type");
320 _LIBCPP_ASSERT_NON_NULL(326 _LIBCPP_ASSERT_NON_NULL(
321 __len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");327 __len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
322#endif328# endif
323 }329 }
324330
325#if _LIBCPP_STD_VER >= 20331# if _LIBCPP_STD_VER >= 20
326 template <contiguous_iterator _It, sized_sentinel_for<_It> _End>332 template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
327 requires(is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>)333 requires(is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>)
328 constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end)334 constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end)
...@@ -330,9 +336,9 @@ public:...@@ -330,9 +336,9 @@ public:
330 _LIBCPP_ASSERT_VALID_INPUT_RANGE(336 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
331 (__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range");337 (__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range");
332 }338 }
333#endif // _LIBCPP_STD_VER >= 20339# endif // _LIBCPP_STD_VER >= 20
334340
335#if _LIBCPP_STD_VER >= 23341# if _LIBCPP_STD_VER >= 23
336 template <class _Range>342 template <class _Range>
337 requires(!is_same_v<remove_cvref_t<_Range>, basic_string_view> && ranges::contiguous_range<_Range> &&343 requires(!is_same_v<remove_cvref_t<_Range>, basic_string_view> && ranges::contiguous_range<_Range> &&
338 ranges::sized_range<_Range> && is_same_v<ranges::range_value_t<_Range>, _CharT> &&344 ranges::sized_range<_Range> && is_same_v<ranges::range_value_t<_Range>, _CharT> &&
...@@ -340,14 +346,14 @@ public:...@@ -340,14 +346,14 @@ public:
340 (!requires(remove_cvref_t<_Range>& __d) { __d.operator std::basic_string_view<_CharT, _Traits>(); }))346 (!requires(remove_cvref_t<_Range>& __d) { __d.operator std::basic_string_view<_CharT, _Traits>(); }))
341 constexpr explicit _LIBCPP_HIDE_FROM_ABI basic_string_view(_Range&& __r)347 constexpr explicit _LIBCPP_HIDE_FROM_ABI basic_string_view(_Range&& __r)
342 : __data_(ranges::data(__r)), __size_(ranges::size(__r)) {}348 : __data_(ranges::data(__r)), __size_(ranges::size(__r)) {}
343#endif // _LIBCPP_STD_VER >= 23349# endif // _LIBCPP_STD_VER >= 23
344350
345 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s)351 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s)
346 : __data_(__s), __size_(std::__char_traits_length_checked<_Traits>(__s)) {}352 : __data_(__s), __size_(std::__char_traits_length_checked<_Traits>(__s)) {}
347353
348#if _LIBCPP_STD_VER >= 23354# if _LIBCPP_STD_VER >= 23
349 basic_string_view(nullptr_t) = delete;355 basic_string_view(nullptr_t) = delete;
350#endif356# endif
351357
352 // [string.view.iterators], iterators358 // [string.view.iterators], iterators
353 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return cbegin(); }359 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return cbegin(); }
...@@ -355,19 +361,19 @@ public:...@@ -355,19 +361,19 @@ public:
355 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return cend(); }361 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return cend(); }
356362
357 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT {363 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT {
358#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS364# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
359 return std::__make_bounded_iter(data(), data(), data() + size());365 return std::__make_bounded_iter(data(), data(), data() + size());
360#else366# else
361 return const_iterator(__data_);367 return const_iterator(__data_);
362#endif368# endif
363 }369 }
364370
365 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT {371 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT {
366#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS372# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
367 return std::__make_bounded_iter(data() + size(), data(), data() + size());373 return std::__make_bounded_iter(data() + size(), data(), data() + size());
368#else374# else
369 return const_iterator(__data_ + __size_);375 return const_iterator(__data_ + __size_);
370#endif376# endif
371 }377 }
372378
373 _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {379 _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {
...@@ -395,7 +401,7 @@ public:...@@ -395,7 +401,7 @@ public:
395 return numeric_limits<size_type>::max() / sizeof(value_type);401 return numeric_limits<size_type>::max() / sizeof(value_type);
396 }402 }
397403
398 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size_ == 0; }404 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size_ == 0; }
399405
400 // [string.view.access], element access406 // [string.view.access], element access
401 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __pos) const _NOEXCEPT {407 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __pos) const _NOEXCEPT {
...@@ -448,8 +454,11 @@ public:...@@ -448,8 +454,11 @@ public:
448 }454 }
449455
450 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view substr(size_type __pos = 0, size_type __n = npos) const {456 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view substr(size_type __pos = 0, size_type __n = npos) const {
457 // Use the `__assume_valid` form of the constructor to avoid an unnecessary check. Any substring of a view is a
458 // valid view. In particular, `size()` is known to be smaller than `numeric_limits<difference_type>::max()`, so the
459 // new size is also smaller. See also https://github.com/llvm/llvm-project/issues/91634.
451 return __pos > size() ? (__throw_out_of_range("string_view::substr"), basic_string_view())460 return __pos > size() ? (__throw_out_of_range("string_view::substr"), basic_string_view())
452 : basic_string_view(data() + __pos, std::min(__n, size() - __pos));461 : basic_string_view(__assume_valid(), data() + __pos, std::min(__n, size() - __pos));
453 }462 }
454463
455 _LIBCPP_CONSTEXPR_SINCE_CXX14 int compare(basic_string_view __sv) const _NOEXCEPT {464 _LIBCPP_CONSTEXPR_SINCE_CXX14 int compare(basic_string_view __sv) const _NOEXCEPT {
...@@ -639,7 +648,7 @@ public:...@@ -639,7 +648,7 @@ public:
639 data(), size(), __s, __pos, traits_type::length(__s));648 data(), size(), __s, __pos, traits_type::length(__s));
640 }649 }
641650
642#if _LIBCPP_STD_VER >= 20651# if _LIBCPP_STD_VER >= 20
643 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(basic_string_view __s) const noexcept {652 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(basic_string_view __s) const noexcept {
644 return size() >= __s.size() && compare(0, __s.size(), __s) == 0;653 return size() >= __s.size() && compare(0, __s.size(), __s) == 0;
645 }654 }
...@@ -663,54 +672,70 @@ public:...@@ -663,54 +672,70 @@ public:
663 constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept {672 constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept {
664 return ends_with(basic_string_view(__s));673 return ends_with(basic_string_view(__s));
665 }674 }
666#endif675# endif
667676
668#if _LIBCPP_STD_VER >= 23677# if _LIBCPP_STD_VER >= 23
669 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(basic_string_view __sv) const noexcept { return find(__sv) != npos; }678 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(basic_string_view __sv) const noexcept { return find(__sv) != npos; }
670679
671 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept { return find(__c) != npos; }680 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept { return find(__c) != npos; }
672681
673 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const { return find(__s) != npos; }682 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const { return find(__s) != npos; }
674#endif683# endif
675684
676private:685private:
686 struct __assume_valid {};
687
688 // This is the same as the pointer and length constructor, but without the additional hardening checks. It is intended
689 // for use within the class, when the class invariants already guarantee the resulting object is valid. The compiler
690 // usually cannot eliminate the redundant checks because it does not know class invariants.
691 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI
692 basic_string_view(__assume_valid, const _CharT* __s, size_type __len) _NOEXCEPT
693 : __data_(__s),
694 __size_(__len) {}
695
677 const value_type* __data_;696 const value_type* __data_;
678 size_type __size_;697 size_type __size_;
698
699 template <class, class, class>
700 friend class basic_string;
679};701};
680_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_string_view);702_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_string_view);
681703
682#if _LIBCPP_STD_VER >= 20704# if _LIBCPP_STD_VER >= 20
683template <class _CharT, class _Traits>705template <class _CharT, class _Traits>
684inline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true;706inline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true;
685707
686template <class _CharT, class _Traits>708template <class _CharT, class _Traits>
687inline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true;709inline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true;
688#endif // _LIBCPP_STD_VER >= 20710# endif // _LIBCPP_STD_VER >= 20
689711
690// [string.view.deduct]712// [string.view.deduct]
691713
692#if _LIBCPP_STD_VER >= 20714# if _LIBCPP_STD_VER >= 20
693template <contiguous_iterator _It, sized_sentinel_for<_It> _End>715template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
694basic_string_view(_It, _End) -> basic_string_view<iter_value_t<_It>>;716basic_string_view(_It, _End) -> basic_string_view<iter_value_t<_It>>;
695#endif // _LIBCPP_STD_VER >= 20717# endif // _LIBCPP_STD_VER >= 20
696718
697#if _LIBCPP_STD_VER >= 23719# if _LIBCPP_STD_VER >= 23
698template <ranges::contiguous_range _Range>720template <ranges::contiguous_range _Range>
699basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>;721basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>;
700#endif722# endif
701723
702// [string.view.comparison]724// [string.view.comparison]
703725
704#if _LIBCPP_STD_VER >= 20726// The dummy default template parameters are used to work around a MSVC issue with mangling, see VSO-409326 for details.
705727// This applies to the other sufficient overloads below for the other comparison operators.
706template <class _CharT, class _Traits>728template <class _CharT, class _Traits, int = 1>
707_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(basic_string_view<_CharT, _Traits> __lhs,729_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
708 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept {730operator==(basic_string_view<_CharT, _Traits> __lhs,
731 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
709 if (__lhs.size() != __rhs.size())732 if (__lhs.size() != __rhs.size())
710 return false;733 return false;
711 return __lhs.compare(__rhs) == 0;734 return __lhs.compare(__rhs) == 0;
712}735}
713736
737# if _LIBCPP_STD_VER >= 20
738
714template <class _CharT, class _Traits>739template <class _CharT, class _Traits>
715_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(basic_string_view<_CharT, _Traits> __lhs,740_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(basic_string_view<_CharT, _Traits> __lhs,
716 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept {741 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept {
...@@ -724,7 +749,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(basic_string_view<_CharT, _Trai...@@ -724,7 +749,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(basic_string_view<_CharT, _Trai
724 }749 }
725}750}
726751
727#else752# else
728753
729// operator ==754// operator ==
730755
...@@ -736,51 +761,32 @@ operator==(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _...@@ -736,51 +761,32 @@ operator==(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _
736 return __lhs.compare(__rhs) == 0;761 return __lhs.compare(__rhs) == 0;
737}762}
738763
739// The dummy default template parameters are used to work around a MSVC issue with mangling, see VSO-409326 for details.
740// This applies to the other sufficient overloads below for the other comparison operators.
741template <class _CharT, class _Traits, int = 1>
742_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
743operator==(basic_string_view<_CharT, _Traits> __lhs,
744 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
745 if (__lhs.size() != __rhs.size())
746 return false;
747 return __lhs.compare(__rhs) == 0;
748}
749
750template <class _CharT, class _Traits, int = 2>764template <class _CharT, class _Traits, int = 2>
751_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool765_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
752operator==(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,766operator==(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
753 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {767 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
754 if (__lhs.size() != __rhs.size())768 return __lhs == __rhs;
755 return false;
756 return __lhs.compare(__rhs) == 0;
757}769}
758770
759// operator !=771// operator !=
760template <class _CharT, class _Traits>772template <class _CharT, class _Traits>
761_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool773_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
762operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {774operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
763 if (__lhs.size() != __rhs.size())775 return !(__lhs == __rhs);
764 return true;
765 return __lhs.compare(__rhs) != 0;
766}776}
767777
768template <class _CharT, class _Traits, int = 1>778template <class _CharT, class _Traits, int = 1>
769_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool779_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
770operator!=(basic_string_view<_CharT, _Traits> __lhs,780operator!=(basic_string_view<_CharT, _Traits> __lhs,
771 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {781 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT {
772 if (__lhs.size() != __rhs.size())782 return !(__lhs == __rhs);
773 return true;
774 return __lhs.compare(__rhs) != 0;
775}783}
776784
777template <class _CharT, class _Traits, int = 2>785template <class _CharT, class _Traits, int = 2>
778_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool786_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
779operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,787operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
780 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {788 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT {
781 if (__lhs.size() != __rhs.size())789 return !(__lhs == __rhs);
782 return true;
783 return __lhs.compare(__rhs) != 0;
784}790}
785791
786// operator <792// operator <
...@@ -867,7 +873,7 @@ operator>=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,...@@ -867,7 +873,7 @@ operator>=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
867 return __lhs.compare(__rhs) >= 0;873 return __lhs.compare(__rhs) >= 0;
868}874}
869875
870#endif // _LIBCPP_STD_VER >= 20876# endif // _LIBCPP_STD_VER >= 20
871877
872template <class _CharT, class _Traits>878template <class _CharT, class _Traits>
873_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&879_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
...@@ -884,10 +890,10 @@ struct __string_view_hash : public __unary_function<basic_string_view<_CharT, ch...@@ -884,10 +890,10 @@ struct __string_view_hash : public __unary_function<basic_string_view<_CharT, ch
884template <>890template <>
885struct hash<basic_string_view<char, char_traits<char> > > : __string_view_hash<char> {};891struct hash<basic_string_view<char, char_traits<char> > > : __string_view_hash<char> {};
886892
887#ifndef _LIBCPP_HAS_NO_CHAR8_T893# if _LIBCPP_HAS_CHAR8_T
888template <>894template <>
889struct hash<basic_string_view<char8_t, char_traits<char8_t> > > : __string_view_hash<char8_t> {};895struct hash<basic_string_view<char8_t, char_traits<char8_t> > > : __string_view_hash<char8_t> {};
890#endif896# endif
891897
892template <>898template <>
893struct hash<basic_string_view<char16_t, char_traits<char16_t> > > : __string_view_hash<char16_t> {};899struct hash<basic_string_view<char16_t, char_traits<char16_t> > > : __string_view_hash<char16_t> {};
...@@ -895,31 +901,31 @@ struct hash<basic_string_view<char16_t, char_traits<char16_t> > > : __string_vie...@@ -895,31 +901,31 @@ struct hash<basic_string_view<char16_t, char_traits<char16_t> > > : __string_vie
895template <>901template <>
896struct hash<basic_string_view<char32_t, char_traits<char32_t> > > : __string_view_hash<char32_t> {};902struct hash<basic_string_view<char32_t, char_traits<char32_t> > > : __string_view_hash<char32_t> {};
897903
898#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS904# if _LIBCPP_HAS_WIDE_CHARACTERS
899template <>905template <>
900struct hash<basic_string_view<wchar_t, char_traits<wchar_t> > > : __string_view_hash<wchar_t> {};906struct hash<basic_string_view<wchar_t, char_traits<wchar_t> > > : __string_view_hash<wchar_t> {};
901#endif907# endif
902908
903#if _LIBCPP_STD_VER >= 14909# if _LIBCPP_STD_VER >= 14
904inline namespace literals {910inline namespace literals {
905inline namespace string_view_literals {911inline namespace string_view_literals {
906inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char> operator""sv(const char* __str, size_t __len) noexcept {912inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char> operator""sv(const char* __str, size_t __len) noexcept {
907 return basic_string_view<char>(__str, __len);913 return basic_string_view<char>(__str, __len);
908}914}
909915
910# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS916# if _LIBCPP_HAS_WIDE_CHARACTERS
911inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<wchar_t>917inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<wchar_t>
912operator""sv(const wchar_t* __str, size_t __len) noexcept {918operator""sv(const wchar_t* __str, size_t __len) noexcept {
913 return basic_string_view<wchar_t>(__str, __len);919 return basic_string_view<wchar_t>(__str, __len);
914}920}
915# endif921# endif
916922
917# ifndef _LIBCPP_HAS_NO_CHAR8_T923# if _LIBCPP_HAS_CHAR8_T
918inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char8_t>924inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char8_t>
919operator""sv(const char8_t* __str, size_t __len) noexcept {925operator""sv(const char8_t* __str, size_t __len) noexcept {
920 return basic_string_view<char8_t>(__str, __len);926 return basic_string_view<char8_t>(__str, __len);
921}927}
922# endif928# endif
923929
924inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char16_t>930inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char16_t>
925operator""sv(const char16_t* __str, size_t __len) noexcept {931operator""sv(const char16_t* __str, size_t __len) noexcept {
...@@ -932,17 +938,18 @@ operator""sv(const char32_t* __str, size_t __len) noexcept {...@@ -932,17 +938,18 @@ operator""sv(const char32_t* __str, size_t __len) noexcept {
932}938}
933} // namespace string_view_literals939} // namespace string_view_literals
934} // namespace literals940} // namespace literals
935#endif941# endif
936_LIBCPP_END_NAMESPACE_STD942_LIBCPP_END_NAMESPACE_STD
937943
938_LIBCPP_POP_MACROS944_LIBCPP_POP_MACROS
939945
940#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20946# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
941# include <algorithm>947# include <algorithm>
942# include <concepts>948# include <concepts>
943# include <cstdlib>949# include <cstdlib>
944# include <iterator>950# include <iterator>
945# include <type_traits>951# include <type_traits>
946#endif952# endif
953#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
947954
948#endif // _LIBCPP_STRING_VIEW955#endif // _LIBCPP_STRING_VIEW
lib/libcxx/include/strstream+29-24
...@@ -129,30 +129,34 @@ private:...@@ -129,30 +129,34 @@ private:
129129
130*/130*/
131131
132#include <__config>132#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
133#include <istream>133# include <__cxx03/strstream>
134#include <ostream>134#else
135#include <version>135# include <__config>
136136# include <__ostream/basic_ostream.h>
137#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)137# include <istream>
138# pragma GCC system_header138# include <streambuf>
139#endif139# include <version>
140
141# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
142# pragma GCC system_header
143# endif
140144
141#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY)145# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY)
142146
143_LIBCPP_PUSH_MACROS147_LIBCPP_PUSH_MACROS
144# include <__undef_macros>148# include <__undef_macros>
145149
146_LIBCPP_BEGIN_NAMESPACE_STD150_LIBCPP_BEGIN_NAMESPACE_STD
147151
148class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstreambuf : public streambuf {152class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstreambuf : public streambuf {
149public:153public:
150# ifndef _LIBCPP_CXX03_LANG154# ifndef _LIBCPP_CXX03_LANG
151 _LIBCPP_HIDE_FROM_ABI strstreambuf() : strstreambuf(0) {}155 _LIBCPP_HIDE_FROM_ABI strstreambuf() : strstreambuf(0) {}
152 explicit strstreambuf(streamsize __alsize);156 explicit strstreambuf(streamsize __alsize);
153# else157# else
154 explicit strstreambuf(streamsize __alsize = 0);158 explicit strstreambuf(streamsize __alsize = 0);
155# endif159# endif
156 strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));160 strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));
157 strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr);161 strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr);
158 strstreambuf(const char* __gnext, streamsize __n);162 strstreambuf(const char* __gnext, streamsize __n);
...@@ -162,10 +166,10 @@ public:...@@ -162,10 +166,10 @@ public:
162 strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr);166 strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr);
163 strstreambuf(const unsigned char* __gnext, streamsize __n);167 strstreambuf(const unsigned char* __gnext, streamsize __n);
164168
165# ifndef _LIBCPP_CXX03_LANG169# ifndef _LIBCPP_CXX03_LANG
166 _LIBCPP_HIDE_FROM_ABI strstreambuf(strstreambuf&& __rhs);170 _LIBCPP_HIDE_FROM_ABI strstreambuf(strstreambuf&& __rhs);
167 _LIBCPP_HIDE_FROM_ABI strstreambuf& operator=(strstreambuf&& __rhs);171 _LIBCPP_HIDE_FROM_ABI strstreambuf& operator=(strstreambuf&& __rhs);
168# endif // _LIBCPP_CXX03_LANG172# endif // _LIBCPP_CXX03_LANG
169173
170 ~strstreambuf() override;174 ~strstreambuf() override;
171175
...@@ -199,7 +203,7 @@ private:...@@ -199,7 +203,7 @@ private:
199 void __init(char* __gnext, streamsize __n, char* __pbeg);203 void __init(char* __gnext, streamsize __n, char* __pbeg);
200};204};
201205
202# ifndef _LIBCPP_CXX03_LANG206# ifndef _LIBCPP_CXX03_LANG
203207
204inline _LIBCPP_HIDE_FROM_ABI strstreambuf::strstreambuf(strstreambuf&& __rhs)208inline _LIBCPP_HIDE_FROM_ABI strstreambuf::strstreambuf(strstreambuf&& __rhs)
205 : streambuf(__rhs),209 : streambuf(__rhs),
...@@ -228,7 +232,7 @@ inline _LIBCPP_HIDE_FROM_ABI strstreambuf& strstreambuf::operator=(strstreambuf&...@@ -228,7 +232,7 @@ inline _LIBCPP_HIDE_FROM_ABI strstreambuf& strstreambuf::operator=(strstreambuf&
228 return *this;232 return *this;
229}233}
230234
231# endif // _LIBCPP_CXX03_LANG235# endif // _LIBCPP_CXX03_LANG
232236
233class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI istrstream : public istream {237class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI istrstream : public istream {
234public:238public:
...@@ -237,7 +241,7 @@ public:...@@ -237,7 +241,7 @@ public:
237 _LIBCPP_HIDE_FROM_ABI istrstream(const char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {}241 _LIBCPP_HIDE_FROM_ABI istrstream(const char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {}
238 _LIBCPP_HIDE_FROM_ABI istrstream(char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {}242 _LIBCPP_HIDE_FROM_ABI istrstream(char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {}
239243
240# ifndef _LIBCPP_CXX03_LANG244# ifndef _LIBCPP_CXX03_LANG
241 _LIBCPP_HIDE_FROM_ABI istrstream(istrstream&& __rhs) // extension245 _LIBCPP_HIDE_FROM_ABI istrstream(istrstream&& __rhs) // extension
242 : istream(std::move(static_cast<istream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {246 : istream(std::move(static_cast<istream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {
243 istream::set_rdbuf(&__sb_);247 istream::set_rdbuf(&__sb_);
...@@ -248,7 +252,7 @@ public:...@@ -248,7 +252,7 @@ public:
248 istream::operator=(std::move(__rhs));252 istream::operator=(std::move(__rhs));
249 return *this;253 return *this;
250 }254 }
251# endif // _LIBCPP_CXX03_LANG255# endif // _LIBCPP_CXX03_LANG
252256
253 ~istrstream() override;257 ~istrstream() override;
254258
...@@ -270,7 +274,7 @@ public:...@@ -270,7 +274,7 @@ public:
270 _LIBCPP_HIDE_FROM_ABI ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)274 _LIBCPP_HIDE_FROM_ABI ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)
271 : ostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {}275 : ostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {}
272276
273# ifndef _LIBCPP_CXX03_LANG277# ifndef _LIBCPP_CXX03_LANG
274 _LIBCPP_HIDE_FROM_ABI ostrstream(ostrstream&& __rhs) // extension278 _LIBCPP_HIDE_FROM_ABI ostrstream(ostrstream&& __rhs) // extension
275 : ostream(std::move(static_cast<ostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {279 : ostream(std::move(static_cast<ostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {
276 ostream::set_rdbuf(&__sb_);280 ostream::set_rdbuf(&__sb_);
...@@ -281,7 +285,7 @@ public:...@@ -281,7 +285,7 @@ public:
281 ostream::operator=(std::move(__rhs));285 ostream::operator=(std::move(__rhs));
282 return *this;286 return *this;
283 }287 }
284# endif // _LIBCPP_CXX03_LANG288# endif // _LIBCPP_CXX03_LANG
285289
286 ~ostrstream() override;290 ~ostrstream() override;
287291
...@@ -312,7 +316,7 @@ public:...@@ -312,7 +316,7 @@ public:
312 _LIBCPP_HIDE_FROM_ABI strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)316 _LIBCPP_HIDE_FROM_ABI strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)
313 : iostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {}317 : iostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {}
314318
315# ifndef _LIBCPP_CXX03_LANG319# ifndef _LIBCPP_CXX03_LANG
316 _LIBCPP_HIDE_FROM_ABI strstream(strstream&& __rhs) // extension320 _LIBCPP_HIDE_FROM_ABI strstream(strstream&& __rhs) // extension
317 : iostream(std::move(static_cast<iostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {321 : iostream(std::move(static_cast<iostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {
318 iostream::set_rdbuf(&__sb_);322 iostream::set_rdbuf(&__sb_);
...@@ -323,7 +327,7 @@ public:...@@ -323,7 +327,7 @@ public:
323 iostream::operator=(std::move(__rhs));327 iostream::operator=(std::move(__rhs));
324 return *this;328 return *this;
325 }329 }
326# endif // _LIBCPP_CXX03_LANG330# endif // _LIBCPP_CXX03_LANG
327331
328 ~strstream() override;332 ~strstream() override;
329333
...@@ -346,6 +350,7 @@ _LIBCPP_END_NAMESPACE_STD...@@ -346,6 +350,7 @@ _LIBCPP_END_NAMESPACE_STD
346350
347_LIBCPP_POP_MACROS351_LIBCPP_POP_MACROS
348352
349#endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY)353# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY)
354#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
350355
351#endif // _LIBCPP_STRSTREAM356#endif // _LIBCPP_STRSTREAM
lib/libcxx/include/syncstream+58-46
...@@ -46,7 +46,9 @@ namespace std {...@@ -46,7 +46,9 @@ namespace std {
46 using streambuf_type = basic_streambuf<charT, traits>;46 using streambuf_type = basic_streambuf<charT, traits>;
4747
48 // [syncstream.syncbuf.cons], construction and destruction48 // [syncstream.syncbuf.cons], construction and destruction
49 explicit basic_syncbuf(streambuf_type* obuf = nullptr)49 basic_syncbuf()
50 : basic_syncbuf(nullptr) {}
51 explicit basic_syncbuf(streambuf_type* obuf)
50 : basic_syncbuf(obuf, Allocator()) {}52 : basic_syncbuf(obuf, Allocator()) {}
51 basic_syncbuf(streambuf_type*, const Allocator&);53 basic_syncbuf(streambuf_type*, const Allocator&);
52 basic_syncbuf(basic_syncbuf&&);54 basic_syncbuf(basic_syncbuf&&);
...@@ -115,34 +117,40 @@ namespace std {...@@ -115,34 +117,40 @@ namespace std {
115117
116*/118*/
117119
118#include <__config>120#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
119#include <__utility/move.h>121# include <__cxx03/syncstream>
120#include <ios>122#else
121#include <iosfwd> // required for declaration of default arguments123# include <__config>
122#include <streambuf>
123#include <string>
124124
125#ifndef _LIBCPP_HAS_NO_THREADS125# if _LIBCPP_HAS_LOCALIZATION
126# include <map>126
127# include <mutex>127# include <__mutex/lock_guard.h>
128# include <shared_mutex>128# include <__utility/move.h>
129#endif129# include <ios>
130# include <iosfwd> // required for declaration of default arguments
131# include <streambuf>
132# include <string>
133
134# if _LIBCPP_HAS_THREADS
135# include <map>
136# include <shared_mutex>
137# endif
130138
131// standard-mandated includes139// standard-mandated includes
132140
133// [syncstream.syn]141// [syncstream.syn]
134#include <ostream>142# include <ostream>
135143
136#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)144# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
137# pragma GCC system_header145# pragma GCC system_header
138#endif146# endif
139147
140_LIBCPP_PUSH_MACROS148_LIBCPP_PUSH_MACROS
141#include <__undef_macros>149# include <__undef_macros>
142150
143_LIBCPP_BEGIN_NAMESPACE_STD151_LIBCPP_BEGIN_NAMESPACE_STD
144152
145#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)153# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM
146154
147// [syncstream.syncbuf.overview]/1155// [syncstream.syncbuf.overview]/1
148// Class template basic_syncbuf stores character data written to it,156// Class template basic_syncbuf stores character data written to it,
...@@ -155,7 +163,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -155,7 +163,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
155//163//
156// This helper singleton is used to implement the required164// This helper singleton is used to implement the required
157// synchronisation guarantees.165// synchronisation guarantees.
158# ifndef _LIBCPP_HAS_NO_THREADS166# if _LIBCPP_HAS_THREADS
159class __wrapped_streambuf_mutex {167class __wrapped_streambuf_mutex {
160 _LIBCPP_HIDE_FROM_ABI __wrapped_streambuf_mutex() = default;168 _LIBCPP_HIDE_FROM_ABI __wrapped_streambuf_mutex() = default;
161169
...@@ -228,7 +236,7 @@ private:...@@ -228,7 +236,7 @@ private:
228 return __it;236 return __it;
229 }237 }
230};238};
231# endif // _LIBCPP_HAS_NO_THREADS239# endif // _LIBCPP_HAS_THREADS
232240
233// basic_syncbuf241// basic_syncbuf
234242
...@@ -253,8 +261,9 @@ public:...@@ -253,8 +261,9 @@ public:
253261
254 // [syncstream.syncbuf.cons], construction and destruction262 // [syncstream.syncbuf.cons], construction and destruction
255263
256 _LIBCPP_HIDE_FROM_ABI explicit basic_syncbuf(streambuf_type* __obuf = nullptr)264 _LIBCPP_HIDE_FROM_ABI basic_syncbuf() : basic_syncbuf(nullptr) {}
257 : basic_syncbuf(__obuf, _Allocator()) {}265
266 _LIBCPP_HIDE_FROM_ABI explicit basic_syncbuf(streambuf_type* __obuf) : basic_syncbuf(__obuf, _Allocator()) {}
258267
259 _LIBCPP_HIDE_FROM_ABI basic_syncbuf(streambuf_type* __obuf, _Allocator const& __alloc)268 _LIBCPP_HIDE_FROM_ABI basic_syncbuf(streambuf_type* __obuf, _Allocator const& __alloc)
260 : __wrapped_(__obuf), __str_(__alloc) {269 : __wrapped_(__obuf), __str_(__alloc) {
...@@ -267,14 +276,14 @@ public:...@@ -267,14 +276,14 @@ public:
267 }276 }
268277
269 _LIBCPP_HIDE_FROM_ABI ~basic_syncbuf() {278 _LIBCPP_HIDE_FROM_ABI ~basic_syncbuf() {
270# ifndef _LIBCPP_HAS_NO_EXCEPTIONS279# if _LIBCPP_HAS_EXCEPTIONS
271 try {280 try {
272# endif // _LIBCPP_HAS_NO_EXCEPTIONS281# endif // _LIBCPP_HAS_EXCEPTIONS
273 emit();282 emit();
274# ifndef _LIBCPP_HAS_NO_EXCEPTIONS283# if _LIBCPP_HAS_EXCEPTIONS
275 } catch (...) {284 } catch (...) {
276 }285 }
277# endif // _LIBCPP_HAS_NO_EXCEPTIONS286# endif // _LIBCPP_HAS_EXCEPTIONS
278 __dec_reference();287 __dec_reference();
279 }288 }
280289
...@@ -331,9 +340,9 @@ protected:...@@ -331,9 +340,9 @@ protected:
331 return traits_type::not_eof(__c);340 return traits_type::not_eof(__c);
332341
333 if (this->pptr() == this->epptr()) {342 if (this->pptr() == this->epptr()) {
334# ifndef _LIBCPP_HAS_NO_EXCEPTIONS343# if _LIBCPP_HAS_EXCEPTIONS
335 try {344 try {
336# endif345# endif
337 size_t __size = __str_.size();346 size_t __size = __str_.size();
338 __str_.resize(__str_.capacity() + 1);347 __str_.resize(__str_.capacity() + 1);
339 _LIBCPP_ASSERT_INTERNAL(__str_.size() > __size, "the buffer hasn't grown");348 _LIBCPP_ASSERT_INTERNAL(__str_.size() > __size, "the buffer hasn't grown");
...@@ -342,11 +351,11 @@ protected:...@@ -342,11 +351,11 @@ protected:
342 this->setp(__p, __p + __str_.size());351 this->setp(__p, __p + __str_.size());
343 this->pbump(__size);352 this->pbump(__size);
344353
345# ifndef _LIBCPP_HAS_NO_EXCEPTIONS354# if _LIBCPP_HAS_EXCEPTIONS
346 } catch (...) {355 } catch (...) {
347 return traits_type::eof();356 return traits_type::eof();
348 }357 }
349# endif358# endif
350 }359 }
351360
352 return this->sputc(traits_type::to_char_type(__c));361 return this->sputc(traits_type::to_char_type(__c));
...@@ -358,7 +367,7 @@ private:...@@ -358,7 +367,7 @@ private:
358 // TODO Use a more generic buffer.367 // TODO Use a more generic buffer.
359 // That buffer should be light with almost no additional headers. Then368 // That buffer should be light with almost no additional headers. Then
360 // it can be use here, the __retarget_buffer, and place that use369 // it can be use here, the __retarget_buffer, and place that use
361 // the now deprecated get_temporary_buffer370 // the now removed get_temporary_buffer
362371
363 basic_string<_CharT, _Traits, _Allocator> __str_;372 basic_string<_CharT, _Traits, _Allocator> __str_;
364 bool __emit_on_sync_{false};373 bool __emit_on_sync_{false};
...@@ -367,9 +376,9 @@ private:...@@ -367,9 +376,9 @@ private:
367 if (!__wrapped_)376 if (!__wrapped_)
368 return false;377 return false;
369378
370# ifndef _LIBCPP_HAS_NO_THREADS379# if _LIBCPP_HAS_THREADS
371 lock_guard<mutex> __lock = __wrapped_streambuf_mutex::__instance().__get_lock(__wrapped_);380 lock_guard<mutex> __lock = __wrapped_streambuf_mutex::__instance().__get_lock(__wrapped_);
372# endif381# endif
373382
374 bool __result = true;383 bool __result = true;
375 if (this->pptr() != this->pbase()) {384 if (this->pptr() != this->pbase()) {
...@@ -401,24 +410,24 @@ private:...@@ -401,24 +410,24 @@ private:
401 }410 }
402411
403 _LIBCPP_HIDE_FROM_ABI void __inc_reference() {412 _LIBCPP_HIDE_FROM_ABI void __inc_reference() {
404# ifndef _LIBCPP_HAS_NO_THREADS413# if _LIBCPP_HAS_THREADS
405 if (__wrapped_)414 if (__wrapped_)
406 __wrapped_streambuf_mutex::__instance().__inc_reference(__wrapped_);415 __wrapped_streambuf_mutex::__instance().__inc_reference(__wrapped_);
407# endif416# endif
408 }417 }
409418
410 _LIBCPP_HIDE_FROM_ABI void __dec_reference() noexcept {419 _LIBCPP_HIDE_FROM_ABI void __dec_reference() noexcept {
411# ifndef _LIBCPP_HAS_NO_THREADS420# if _LIBCPP_HAS_THREADS
412 if (__wrapped_)421 if (__wrapped_)
413 __wrapped_streambuf_mutex::__instance().__dec_reference(__wrapped_);422 __wrapped_streambuf_mutex::__instance().__dec_reference(__wrapped_);
414# endif423# endif
415 }424 }
416};425};
417426
418using std::syncbuf;427using std::syncbuf;
419# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS428# if _LIBCPP_HAS_WIDE_CHARACTERS
420using std::wsyncbuf;429using std::wsyncbuf;
421# endif430# endif
422431
423// [syncstream.syncbuf.special], specialized algorithms432// [syncstream.syncbuf.special], specialized algorithms
424template <class _CharT, class _Traits, class _Allocator>433template <class _CharT, class _Traits, class _Allocator>
...@@ -474,17 +483,17 @@ public:...@@ -474,17 +483,17 @@ public:
474 // TODO validate other unformatted output functions.483 // TODO validate other unformatted output functions.
475 typename basic_ostream<char_type, traits_type>::sentry __s(*this);484 typename basic_ostream<char_type, traits_type>::sentry __s(*this);
476 if (__s) {485 if (__s) {
477# ifndef _LIBCPP_HAS_NO_EXCEPTIONS486# if _LIBCPP_HAS_EXCEPTIONS
478 try {487 try {
479# endif488# endif
480489
481 if (__sb_.emit() == false)490 if (__sb_.emit() == false)
482 this->setstate(ios::badbit);491 this->setstate(ios::badbit);
483# ifndef _LIBCPP_HAS_NO_EXCEPTIONS492# if _LIBCPP_HAS_EXCEPTIONS
484 } catch (...) {493 } catch (...) {
485 this->__set_badbit_and_consider_rethrow();494 this->__set_badbit_and_consider_rethrow();
486 }495 }
487# endif496# endif
488 }497 }
489 }498 }
490499
...@@ -499,14 +508,17 @@ private:...@@ -499,14 +508,17 @@ private:
499};508};
500509
501using std::osyncstream;510using std::osyncstream;
502# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS511# if _LIBCPP_HAS_WIDE_CHARACTERS
503using std::wosyncstream;512using std::wosyncstream;
504# endif513# endif
505514
506#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)515# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM
507516
508_LIBCPP_END_NAMESPACE_STD517_LIBCPP_END_NAMESPACE_STD
509518
510_LIBCPP_POP_MACROS519_LIBCPP_POP_MACROS
511520
521# endif // _LIBCPP_HAS_LOCALIZATION
522#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
523
512#endif // _LIBCPP_SYNCSTREAM524#endif // _LIBCPP_SYNCSTREAM
lib/libcxx/include/system_error+23-19
...@@ -144,28 +144,32 @@ template <> struct hash<std::error_condition>;...@@ -144,28 +144,32 @@ template <> struct hash<std::error_condition>;
144144
145*/145*/
146146
147#include <__config>147#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
148#include <__system_error/errc.h>148# include <__cxx03/system_error>
149#include <__system_error/error_category.h>149#else
150#include <__system_error/error_code.h>150# include <__config>
151#include <__system_error/error_condition.h>151# include <__system_error/errc.h>
152#include <__system_error/system_error.h>152# include <__system_error/error_category.h>
153#include <version>153# include <__system_error/error_code.h>
154# include <__system_error/error_condition.h>
155# include <__system_error/system_error.h>
156# include <version>
154157
155// standard-mandated includes158// standard-mandated includes
156159
157// [system.error.syn]160// [system.error.syn]
158#include <compare>161# include <compare>
159162
160#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)163# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
161# pragma GCC system_header164# pragma GCC system_header
162#endif165# endif
163166
164#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20167# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
165# include <cstdint>168# include <cstdint>
166# include <cstring>169# include <cstring>
167# include <limits>170# include <limits>
168# include <type_traits>171# include <type_traits>
169#endif172# endif
173#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
170174
171#endif // _LIBCPP_SYSTEM_ERROR175#endif // _LIBCPP_SYSTEM_ERROR
lib/libcxx/include/tgmath.h+15-10
...@@ -17,18 +17,23 @@...@@ -17,18 +17,23 @@
1717
18*/18*/
1919
20#include <__config>20#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
21# include <__cxx03/tgmath.h>
22#else
23# include <__config>
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
24#endif27# endif
2528
26#ifdef __cplusplus29# ifdef __cplusplus
27# include <ctgmath>30# include <cmath>
28#else31# include <complex>
29# if __has_include_next(<tgmath.h>)32# else
30# include_next <tgmath.h>33# if __has_include_next(<tgmath.h>)
34# include_next <tgmath.h>
35# endif
31# endif36# endif
32#endif37#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
3338
34#endif // _LIBCPP_TGMATH_H39#endif // _LIBCPP_TGMATH_H
lib/libcxx/include/thread+34-31
...@@ -86,45 +86,48 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);...@@ -86,45 +86,48 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
8686
87*/87*/
8888
89#include <__config>89#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
90# include <__cxx03/thread>
91#else
92# include <__config>
9093
91#if !defined(_LIBCPP_HAS_NO_THREADS)94# if _LIBCPP_HAS_THREADS
9295
93# include <__thread/formatter.h>96# include <__thread/this_thread.h>
94# include <__thread/jthread.h>97# include <__thread/thread.h>
95# include <__thread/support.h>98
96# include <__thread/this_thread.h>99# if _LIBCPP_STD_VER >= 20
97# include <__thread/thread.h>100# include <__thread/jthread.h>
98# include <version>101# endif
102
103# if _LIBCPP_STD_VER >= 23
104# include <__thread/formatter.h>
105# endif
106
107# include <version>
99108
100// standard-mandated includes109// standard-mandated includes
101110
102// [thread.syn]111// [thread.syn]
103# include <compare>112# include <compare>
104113
105# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)114# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
106# pragma GCC system_header115# pragma GCC system_header
116# endif
117
118# endif // _LIBCPP_HAS_THREADS
119
120# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
121# include <chrono>
107# endif122# endif
108123
109#endif // !defined(_LIBCPP_HAS_NO_THREADS)124# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
110125# include <cstring>
111#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)126# include <functional>
112# include <cstddef>127# include <new>
113# include <ctime>128# include <system_error>
114# include <iosfwd>129# include <type_traits>
115# include <ratio>130# endif
116#endif131#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
117
118#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
119# include <chrono>
120#endif
121
122#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
123# include <cstring>
124# include <functional>
125# include <new>
126# include <system_error>
127# include <type_traits>
128#endif
129132
130#endif // _LIBCPP_THREAD133#endif // _LIBCPP_THREAD
lib/libcxx/include/tuple+159-136
...@@ -210,73 +210,80 @@ template <class... Types>...@@ -210,73 +210,80 @@ template <class... Types>
210210
211// clang-format on211// clang-format on
212212
213#include <__compare/common_comparison_category.h>213#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
214#include <__compare/synth_three_way.h>214# include <__cxx03/tuple>
215#include <__config>215#else
216#include <__functional/invoke.h>216# include <__compare/common_comparison_category.h>
217#include <__fwd/array.h>217# include <__compare/ordering.h>
218#include <__fwd/pair.h>218# include <__compare/synth_three_way.h>
219#include <__fwd/tuple.h>219# include <__config>
220#include <__memory/allocator_arg_t.h>220# include <__cstddef/size_t.h>
221#include <__memory/uses_allocator.h>221# include <__fwd/array.h>
222#include <__tuple/find_index.h>222# include <__fwd/pair.h>
223#include <__tuple/ignore.h>223# include <__fwd/tuple.h>
224#include <__tuple/make_tuple_types.h>224# include <__memory/allocator_arg_t.h>
225#include <__tuple/sfinae_helpers.h>225# include <__memory/uses_allocator.h>
226#include <__tuple/tuple_element.h>226# include <__tuple/find_index.h>
227#include <__tuple/tuple_indices.h>227# include <__tuple/ignore.h>
228#include <__tuple/tuple_like_ext.h>228# include <__tuple/make_tuple_types.h>
229#include <__tuple/tuple_size.h>229# include <__tuple/sfinae_helpers.h>
230#include <__tuple/tuple_types.h>230# include <__tuple/tuple_element.h>
231#include <__type_traits/common_reference.h>231# include <__tuple/tuple_indices.h>
232#include <__type_traits/common_type.h>232# include <__tuple/tuple_like_ext.h>
233#include <__type_traits/conditional.h>233# include <__tuple/tuple_size.h>
234#include <__type_traits/conjunction.h>234# include <__tuple/tuple_types.h>
235#include <__type_traits/copy_cvref.h>235# include <__type_traits/common_reference.h>
236#include <__type_traits/disjunction.h>236# include <__type_traits/common_type.h>
237#include <__type_traits/is_arithmetic.h>237# include <__type_traits/conditional.h>
238#include <__type_traits/is_assignable.h>238# include <__type_traits/conjunction.h>
239#include <__type_traits/is_constructible.h>239# include <__type_traits/copy_cvref.h>
240#include <__type_traits/is_convertible.h>240# include <__type_traits/disjunction.h>
241#include <__type_traits/is_empty.h>241# include <__type_traits/enable_if.h>
242#include <__type_traits/is_final.h>242# include <__type_traits/invoke.h>
243#include <__type_traits/is_implicitly_default_constructible.h>243# include <__type_traits/is_arithmetic.h>
244#include <__type_traits/is_nothrow_assignable.h>244# include <__type_traits/is_assignable.h>
245#include <__type_traits/is_nothrow_constructible.h>245# include <__type_traits/is_constructible.h>
246#include <__type_traits/is_reference.h>246# include <__type_traits/is_convertible.h>
247#include <__type_traits/is_same.h>247# include <__type_traits/is_empty.h>
248#include <__type_traits/is_swappable.h>248# include <__type_traits/is_final.h>
249#include <__type_traits/is_trivially_relocatable.h>249# include <__type_traits/is_implicitly_default_constructible.h>
250#include <__type_traits/lazy.h>250# include <__type_traits/is_nothrow_assignable.h>
251#include <__type_traits/maybe_const.h>251# include <__type_traits/is_nothrow_constructible.h>
252#include <__type_traits/nat.h>252# include <__type_traits/is_reference.h>
253#include <__type_traits/negation.h>253# include <__type_traits/is_same.h>
254#include <__type_traits/remove_cvref.h>254# include <__type_traits/is_swappable.h>
255#include <__type_traits/remove_reference.h>255# include <__type_traits/is_trivially_relocatable.h>
256#include <__type_traits/unwrap_ref.h>256# include <__type_traits/lazy.h>
257#include <__utility/forward.h>257# include <__type_traits/maybe_const.h>
258#include <__utility/integer_sequence.h>258# include <__type_traits/nat.h>
259#include <__utility/move.h>259# include <__type_traits/negation.h>
260#include <__utility/piecewise_construct.h>260# include <__type_traits/remove_cv.h>
261#include <__utility/swap.h>261# include <__type_traits/remove_cvref.h>
262#include <cstddef>262# include <__type_traits/remove_reference.h>
263#include <version>263# include <__type_traits/unwrap_ref.h>
264# include <__utility/declval.h>
265# include <__utility/forward.h>
266# include <__utility/integer_sequence.h>
267# include <__utility/move.h>
268# include <__utility/piecewise_construct.h>
269# include <__utility/swap.h>
270# include <version>
264271
265// standard-mandated includes272// standard-mandated includes
266273
267// [tuple.syn]274// [tuple.syn]
268#include <compare>275# include <compare>
269276
270#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)277# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
271# pragma GCC system_header278# pragma GCC system_header
272#endif279# endif
273280
274_LIBCPP_PUSH_MACROS281_LIBCPP_PUSH_MACROS
275#include <__undef_macros>282# include <__undef_macros>
276283
277_LIBCPP_BEGIN_NAMESPACE_STD284_LIBCPP_BEGIN_NAMESPACE_STD
278285
279#ifndef _LIBCPP_CXX03_LANG286# ifndef _LIBCPP_CXX03_LANG
280287
281// __tuple_leaf288// __tuple_leaf
282289
...@@ -302,11 +309,11 @@ class __tuple_leaf {...@@ -302,11 +309,11 @@ class __tuple_leaf {
302309
303 template <class _Tp>310 template <class _Tp>
304 static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference() {311 static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference() {
305# if __has_keyword(__reference_binds_to_temporary)312# if __has_keyword(__reference_binds_to_temporary)
306 return !__reference_binds_to_temporary(_Hp, _Tp);313 return !__reference_binds_to_temporary(_Hp, _Tp);
307# else314# else
308 return true;315 return true;
309# endif316# endif
310 }317 }
311318
312public:319public:
...@@ -384,7 +391,7 @@ public:...@@ -384,7 +391,7 @@ public:
384};391};
385392
386template <size_t _Ip, class _Hp>393template <size_t _Ip, class _Hp>
387class __tuple_leaf<_Ip, _Hp, true> : private _Hp {394class __tuple_leaf<_Ip, _Hp, true> : private __remove_cv_t<_Hp> {
388public:395public:
389 _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete;396 _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete;
390397
...@@ -546,7 +553,8 @@ class _LIBCPP_TEMPLATE_VIS tuple {...@@ -546,7 +553,8 @@ class _LIBCPP_TEMPLATE_VIS tuple {
546 get(const tuple<_Up...>&&) _NOEXCEPT;553 get(const tuple<_Up...>&&) _NOEXCEPT;
547554
548public:555public:
549 using __trivially_relocatable = __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>;556 using __trivially_relocatable _LIBCPP_NODEBUG =
557 __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>;
550558
551 // [tuple.cnstr]559 // [tuple.cnstr]
552560
...@@ -690,7 +698,7 @@ public:...@@ -690,7 +698,7 @@ public:
690 tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)698 tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
691 : __base_(allocator_arg_t(), __a, __t) {}699 : __base_(allocator_arg_t(), __a, __t) {}
692700
693# if _LIBCPP_STD_VER >= 23701# if _LIBCPP_STD_VER >= 23
694 // tuple(tuple<U...>&) constructors (including allocator_arg_t variants)702 // tuple(tuple<U...>&) constructors (including allocator_arg_t variants)
695703
696 template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>704 template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
...@@ -701,7 +709,7 @@ public:...@@ -701,7 +709,7 @@ public:
701 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value)709 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value)
702 tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t)710 tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t)
703 : __base_(allocator_arg_t(), __alloc, __t) {}711 : __base_(allocator_arg_t(), __alloc, __t) {}
704# endif // _LIBCPP_STD_VER >= 23712# endif // _LIBCPP_STD_VER >= 23
705713
706 // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)714 // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)
707 template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0>715 template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0>
...@@ -716,7 +724,7 @@ public:...@@ -716,7 +724,7 @@ public:
716 tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)724 tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
717 : __base_(allocator_arg_t(), __a, std::move(__t)) {}725 : __base_(allocator_arg_t(), __a, std::move(__t)) {}
718726
719# if _LIBCPP_STD_VER >= 23727# if _LIBCPP_STD_VER >= 23
720 // tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants)728 // tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants)
721729
722 template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>730 template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
...@@ -730,7 +738,7 @@ public:...@@ -730,7 +738,7 @@ public:
730 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value)738 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value)
731 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t)739 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t)
732 : __base_(allocator_arg_t(), __alloc, std::move(__t)) {}740 : __base_(allocator_arg_t(), __alloc, std::move(__t)) {}
733# endif // _LIBCPP_STD_VER >= 23741# endif // _LIBCPP_STD_VER >= 23
734742
735 // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)743 // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)
736744
...@@ -776,7 +784,7 @@ public:...@@ -776,7 +784,7 @@ public:
776 tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)784 tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
777 : __base_(allocator_arg_t(), __a, __p) {}785 : __base_(allocator_arg_t(), __a, __p) {}
778786
779# if _LIBCPP_STD_VER >= 23787# if _LIBCPP_STD_VER >= 23
780 // tuple(pair<U1, U2>&) constructors (including allocator_arg_t variants)788 // tuple(pair<U1, U2>&) constructors (including allocator_arg_t variants)
781789
782 template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<pair<_U1, _U2>&>::value>* = nullptr>790 template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<pair<_U1, _U2>&>::value>* = nullptr>
...@@ -791,7 +799,7 @@ public:...@@ -791,7 +799,7 @@ public:
791 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)799 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
792 tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p)800 tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p)
793 : __base_(allocator_arg_t(), __alloc, __p) {}801 : __base_(allocator_arg_t(), __alloc, __p) {}
794# endif802# endif
795803
796 // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants)804 // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants)
797805
...@@ -814,7 +822,7 @@ public:...@@ -814,7 +822,7 @@ public:
814 tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)822 tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
815 : __base_(allocator_arg_t(), __a, std::move(__p)) {}823 : __base_(allocator_arg_t(), __a, std::move(__p)) {}
816824
817# if _LIBCPP_STD_VER >= 23825# if _LIBCPP_STD_VER >= 23
818 // tuple(const pair<U1, U2>&&) constructors (including allocator_arg_t variants)826 // tuple(const pair<U1, U2>&&) constructors (including allocator_arg_t variants)
819827
820 template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>828 template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
...@@ -829,17 +837,17 @@ public:...@@ -829,17 +837,17 @@ public:
829 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)837 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
830 tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p)838 tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p)
831 : __base_(allocator_arg_t(), __alloc, std::move(__p)) {}839 : __base_(allocator_arg_t(), __alloc, std::move(__p)) {}
832# endif // _LIBCPP_STD_VER >= 23840# endif // _LIBCPP_STD_VER >= 23
833841
834 // [tuple.assign]842 // [tuple.assign]
835 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&843 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
836 operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)844 operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) noexcept(
837 noexcept(_And<is_nothrow_copy_assignable<_Tp>...>::value) {845 _And<is_nothrow_copy_assignable<_Tp>...>::value) {
838 std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());846 std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
839 return *this;847 return *this;
840 }848 }
841849
842# if _LIBCPP_STD_VER >= 23850# if _LIBCPP_STD_VER >= 23
843 _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple const& __tuple) const851 _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple const& __tuple) const
844 requires(_And<is_copy_assignable<const _Tp>...>::value)852 requires(_And<is_copy_assignable<const _Tp>...>::value)
845 {853 {
...@@ -854,11 +862,11 @@ public:...@@ -854,11 +862,11 @@ public:
854 *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());862 *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
855 return *this;863 return *this;
856 }864 }
857# endif // _LIBCPP_STD_VER >= 23865# endif // _LIBCPP_STD_VER >= 23
858866
859 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&867 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
860 operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple)868 operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple) noexcept(
861 noexcept(_And<is_nothrow_move_assignable<_Tp>...>::value) {869 _And<is_nothrow_move_assignable<_Tp>...>::value) {
862 std::__memberwise_forward_assign(870 std::__memberwise_forward_assign(
863 *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());871 *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
864 return *this;872 return *this;
...@@ -868,8 +876,8 @@ public:...@@ -868,8 +876,8 @@ public:
868 class... _Up,876 class... _Up,
869 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up const&>... >::value,877 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up const&>... >::value,
870 int> = 0>878 int> = 0>
871 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...> const& __tuple)879 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
872 noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) {880 operator=(tuple<_Up...> const& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) {
873 std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());881 std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
874 return *this;882 return *this;
875 }883 }
...@@ -877,14 +885,14 @@ public:...@@ -877,14 +885,14 @@ public:
877 template <class... _Up,885 template <class... _Up,
878 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up>... >::value,886 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up>... >::value,
879 int> = 0>887 int> = 0>
880 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...>&& __tuple)888 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
881 noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) {889 operator=(tuple<_Up...>&& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) {
882 std::__memberwise_forward_assign(890 std::__memberwise_forward_assign(
883 *this, std::move(__tuple), __tuple_types<_Up...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());891 *this, std::move(__tuple), __tuple_types<_Up...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
884 return *this;892 return *this;
885 }893 }
886894
887# if _LIBCPP_STD_VER >= 23895# if _LIBCPP_STD_VER >= 23
888 template <class... _UTypes,896 template <class... _UTypes,
889 enable_if_t< _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,897 enable_if_t< _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
890 is_assignable<const _Tp&, const _UTypes&>...>::value>* = nullptr>898 is_assignable<const _Tp&, const _UTypes&>...>::value>* = nullptr>
...@@ -901,7 +909,7 @@ public:...@@ -901,7 +909,7 @@ public:
901 *this, __u, __tuple_types<_UTypes...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());909 *this, __u, __tuple_types<_UTypes...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
902 return *this;910 return *this;
903 }911 }
904# endif // _LIBCPP_STD_VER >= 23912# endif // _LIBCPP_STD_VER >= 23
905913
906 template <template <class...> class _Pred,914 template <template <class...> class _Pred,
907 bool _Const,915 bool _Const,
...@@ -921,7 +929,7 @@ public:...@@ -921,7 +929,7 @@ public:
921 template <bool _Const, class _Pair>929 template <bool _Const, class _Pair>
922 struct _NothrowAssignFromPair : _AssignPredicateFromPair<is_nothrow_assignable, _Const, _Pair> {};930 struct _NothrowAssignFromPair : _AssignPredicateFromPair<is_nothrow_assignable, _Const, _Pair> {};
923931
924# if _LIBCPP_STD_VER >= 23932# if _LIBCPP_STD_VER >= 23
925 template <class _U1, class _U2, enable_if_t< _EnableAssignFromPair<true, const pair<_U1, _U2>&>::value>* = nullptr>933 template <class _U1, class _U2, enable_if_t< _EnableAssignFromPair<true, const pair<_U1, _U2>&>::value>* = nullptr>
926 _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(const pair<_U1, _U2>& __pair) const934 _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(const pair<_U1, _U2>& __pair) const
927 noexcept(_NothrowAssignFromPair<true, const pair<_U1, _U2>&>::value) {935 noexcept(_NothrowAssignFromPair<true, const pair<_U1, _U2>&>::value) {
...@@ -937,21 +945,21 @@ public:...@@ -937,21 +945,21 @@ public:
937 std::get<1>(*this) = std::move(__pair.second);945 std::get<1>(*this) = std::move(__pair.second);
938 return *this;946 return *this;
939 }947 }
940# endif // _LIBCPP_STD_VER >= 23948# endif // _LIBCPP_STD_VER >= 23
941949
942 template <class _Up1,950 template <class _Up1,
943 class _Up2,951 class _Up2,
944 __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value, int> = 0>952 __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value, int> = 0>
945 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(pair<_Up1, _Up2> const& __pair)953 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
946 noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value) {954 operator=(pair<_Up1, _Up2> const& __pair) noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value) {
947 std::get<0>(*this) = __pair.first;955 std::get<0>(*this) = __pair.first;
948 std::get<1>(*this) = __pair.second;956 std::get<1>(*this) = __pair.second;
949 return *this;957 return *this;
950 }958 }
951959
952 template <class _Up1, class _Up2, __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value, int> = 0>960 template <class _Up1, class _Up2, __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value, int> = 0>
953 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(pair<_Up1, _Up2>&& __pair)961 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
954 noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value) {962 operator=(pair<_Up1, _Up2>&& __pair) noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value) {
955 std::get<0>(*this) = std::forward<_Up1>(__pair.first);963 std::get<0>(*this) = std::forward<_Up1>(__pair.first);
956 std::get<1>(*this) = std::forward<_Up2>(__pair.second);964 std::get<1>(*this) = std::forward<_Up2>(__pair.second);
957 return *this;965 return *this;
...@@ -962,8 +970,8 @@ public:...@@ -962,8 +970,8 @@ public:
962 class _Up,970 class _Up,
963 size_t _Np,971 size_t _Np,
964 __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up const&>... >::value, int> = 0>972 __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up const&>... >::value, int> = 0>
965 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np> const& __array)973 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
966 noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) {974 operator=(array<_Up, _Np> const& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) {
967 std::__memberwise_copy_assign(*this, __array, typename __make_tuple_indices<sizeof...(_Tp)>::type());975 std::__memberwise_copy_assign(*this, __array, typename __make_tuple_indices<sizeof...(_Tp)>::type());
968 return *this;976 return *this;
969 }977 }
...@@ -973,8 +981,8 @@ public:...@@ -973,8 +981,8 @@ public:
973 size_t _Np,981 size_t _Np,
974 class = void,982 class = void,
975 __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up>... >::value, int> = 0>983 __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up>... >::value, int> = 0>
976 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np>&& __array)984 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
977 noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) {985 operator=(array<_Up, _Np>&& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) {
978 std::__memberwise_forward_assign(986 std::__memberwise_forward_assign(
979 *this,987 *this,
980 std::move(__array),988 std::move(__array),
...@@ -984,17 +992,17 @@ public:...@@ -984,17 +992,17 @@ public:
984 }992 }
985993
986 // [tuple.swap]994 // [tuple.swap]
987 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple& __t)995 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
988 noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) {996 swap(tuple& __t) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) {
989 __base_.swap(__t.__base_);997 __base_.swap(__t.__base_);
990 }998 }
991999
992# if _LIBCPP_STD_VER >= 231000# if _LIBCPP_STD_VER >= 23
993 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple& __t) const1001 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple& __t) const
994 noexcept(__all<is_nothrow_swappable_v<const _Tp&>...>::value) {1002 noexcept(__all<is_nothrow_swappable_v<const _Tp&>...>::value) {
995 __base_.swap(__t.__base_);1003 __base_.swap(__t.__base_);
996 }1004 }
997# endif // _LIBCPP_STD_VER >= 231005# endif // _LIBCPP_STD_VER >= 23
998};1006};
9991007
1000template <>1008template <>
...@@ -1010,12 +1018,12 @@ public:...@@ -1010,12 +1018,12 @@ public:
1010 template <class _Alloc, class _Up>1018 template <class _Alloc, class _Up>
1011 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}1019 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
1012 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple&) _NOEXCEPT {}1020 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple&) _NOEXCEPT {}
1013# if _LIBCPP_STD_VER >= 231021# if _LIBCPP_STD_VER >= 23
1014 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}1022 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}
1015# endif1023# endif
1016};1024};
10171025
1018# if _LIBCPP_STD_VER >= 231026# if _LIBCPP_STD_VER >= 23
1019template <class... _TTypes, class... _UTypes, template <class> class _TQual, template <class> class _UQual>1027template <class... _TTypes, class... _UTypes, template <class> class _TQual, template <class> class _UQual>
1020 requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; }1028 requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; }
1021struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> {1029struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> {
...@@ -1027,9 +1035,9 @@ template <class... _TTypes, class... _UTypes>...@@ -1027,9 +1035,9 @@ template <class... _TTypes, class... _UTypes>
1027struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> {1035struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> {
1028 using type = tuple<common_type_t<_TTypes, _UTypes>...>;1036 using type = tuple<common_type_t<_TTypes, _UTypes>...>;
1029};1037};
1030# endif // _LIBCPP_STD_VER >= 231038# endif // _LIBCPP_STD_VER >= 23
10311039
1032# if _LIBCPP_STD_VER >= 171040# if _LIBCPP_STD_VER >= 17
1033template <class... _Tp>1041template <class... _Tp>
1034tuple(_Tp...) -> tuple<_Tp...>;1042tuple(_Tp...) -> tuple<_Tp...>;
1035template <class _Tp1, class _Tp2>1043template <class _Tp1, class _Tp2>
...@@ -1040,54 +1048,54 @@ template <class _Alloc, class _Tp1, class _Tp2>...@@ -1040,54 +1048,54 @@ template <class _Alloc, class _Tp1, class _Tp2>
1040tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;1048tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
1041template <class _Alloc, class... _Tp>1049template <class _Alloc, class... _Tp>
1042tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;1050tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
1043# endif1051# endif
10441052
1045template <class... _Tp, __enable_if_t<__all<__is_swappable_v<_Tp>...>::value, int> = 0>1053template <class... _Tp, __enable_if_t<__all<__is_swappable_v<_Tp>...>::value, int> = 0>
1046inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)1054inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
1047 noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) {1055swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) {
1048 __t.swap(__u);1056 __t.swap(__u);
1049}1057}
10501058
1051# if _LIBCPP_STD_VER >= 231059# if _LIBCPP_STD_VER >= 23
1052template <class... _Tp>1060template <class... _Tp>
1053_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<__all<is_swappable_v<const _Tp>...>::value, void>1061_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<__all<is_swappable_v<const _Tp>...>::value, void>
1054swap(const tuple<_Tp...>& __lhs,1062swap(const tuple<_Tp...>& __lhs,
1055 const tuple<_Tp...>& __rhs) noexcept(__all<is_nothrow_swappable_v<const _Tp>...>::value) {1063 const tuple<_Tp...>& __rhs) noexcept(__all<is_nothrow_swappable_v<const _Tp>...>::value) {
1056 __lhs.swap(__rhs);1064 __lhs.swap(__rhs);
1057}1065}
1058# endif1066# endif
10591067
1060// get1068// get
10611069
1062template <size_t _Ip, class... _Tp>1070template <size_t _Ip, class... _Tp>
1063inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&1071inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&
1064get(tuple<_Tp...>& __t) _NOEXCEPT {1072get(tuple<_Tp...>& __t) _NOEXCEPT {
1065 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;1073 using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type;
1066 return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();1074 return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
1067}1075}
10681076
1069template <size_t _Ip, class... _Tp>1077template <size_t _Ip, class... _Tp>
1070inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&1078inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&
1071get(const tuple<_Tp...>& __t) _NOEXCEPT {1079get(const tuple<_Tp...>& __t) _NOEXCEPT {
1072 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;1080 using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type;
1073 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();1081 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
1074}1082}
10751083
1076template <size_t _Ip, class... _Tp>1084template <size_t _Ip, class... _Tp>
1077inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&&1085inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
1078get(tuple<_Tp...>&& __t) _NOEXCEPT {1086get(tuple<_Tp...>&& __t) _NOEXCEPT {
1079 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;1087 using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type;
1080 return static_cast<type&&>(static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());1088 return static_cast<type&&>(static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
1081}1089}
10821090
1083template <size_t _Ip, class... _Tp>1091template <size_t _Ip, class... _Tp>
1084inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&&1092inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
1085get(const tuple<_Tp...>&& __t) _NOEXCEPT {1093get(const tuple<_Tp...>&& __t) _NOEXCEPT {
1086 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;1094 using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type;
1087 return static_cast<const type&&>(static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());1095 return static_cast<const type&&>(static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
1088}1096}
10891097
1090# if _LIBCPP_STD_VER >= 141098# if _LIBCPP_STD_VER >= 14
10911099
1092template <class _T1, class... _Args>1100template <class _T1, class... _Args>
1093inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(tuple<_Args...>& __tup) noexcept {1101inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(tuple<_Args...>& __tup) noexcept {
...@@ -1109,7 +1117,7 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(tuple<_Args...> const&& _...@@ -1109,7 +1117,7 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(tuple<_Args...> const&& _
1109 return std::get<__find_exactly_one_t<_T1, _Args...>::value>(std::move(__tup));1117 return std::get<__find_exactly_one_t<_T1, _Args...>::value>(std::move(__tup));
1110}1118}
11111119
1112# endif1120# endif
11131121
1114// tie1122// tie
11151123
...@@ -1119,9 +1127,9 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_T...@@ -1119,9 +1127,9 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_T
1119}1127}
11201128
1121template <class... _Tp>1129template <class... _Tp>
1122inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<typename __unwrap_ref_decay<_Tp>::type...>1130inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<__unwrap_ref_decay_t<_Tp>...>
1123make_tuple(_Tp&&... __t) {1131make_tuple(_Tp&&... __t) {
1124 return tuple<typename __unwrap_ref_decay<_Tp>::type...>(std::forward<_Tp>(__t)...);1132 return tuple<__unwrap_ref_decay_t<_Tp>...>(std::forward<_Tp>(__t)...);
1125}1133}
11261134
1127template <class... _Tp>1135template <class... _Tp>
...@@ -1152,7 +1160,7 @@ operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {...@@ -1152,7 +1160,7 @@ operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1152 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);1160 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
1153}1161}
11541162
1155# if _LIBCPP_STD_VER >= 201163# if _LIBCPP_STD_VER >= 20
11561164
1157// operator<=>1165// operator<=>
11581166
...@@ -1172,7 +1180,7 @@ operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {...@@ -1172,7 +1180,7 @@ operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1172 return std::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{});1180 return std::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{});
1173}1181}
11741182
1175# else // _LIBCPP_STD_VER >= 201183# else // _LIBCPP_STD_VER >= 20
11761184
1177template <class... _Tp, class... _Up>1185template <class... _Tp, class... _Up>
1178inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool1186inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
...@@ -1226,7 +1234,7 @@ operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {...@@ -1226,7 +1234,7 @@ operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1226 return !(__y < __x);1234 return !(__y < __x);
1227}1235}
12281236
1229# endif // _LIBCPP_STD_VER >= 201237# endif // _LIBCPP_STD_VER >= 20
12301238
1231// tuple_cat1239// tuple_cat
12321240
...@@ -1235,7 +1243,7 @@ struct __tuple_cat_type;...@@ -1235,7 +1243,7 @@ struct __tuple_cat_type;
12351243
1236template <class... _Ttypes, class... _Utypes>1244template <class... _Ttypes, class... _Utypes>
1237struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> > {1245struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> > {
1238 typedef _LIBCPP_NODEBUG tuple<_Ttypes..., _Utypes...> type;1246 using type _LIBCPP_NODEBUG = tuple<_Ttypes..., _Utypes...>;
1239};1247};
12401248
1241template <class _ResultTuple, bool _Is_Tuple0TupleLike, class... _Tuples>1249template <class _ResultTuple, bool _Is_Tuple0TupleLike, class... _Tuples>
...@@ -1269,7 +1277,7 @@ struct __tuple_cat_return<_Tuple0, _Tuples...>...@@ -1269,7 +1277,7 @@ struct __tuple_cat_return<_Tuple0, _Tuples...>
12691277
1270template <>1278template <>
1271struct __tuple_cat_return<> {1279struct __tuple_cat_return<> {
1272 typedef _LIBCPP_NODEBUG tuple<> type;1280 using type _LIBCPP_NODEBUG = tuple<>;
1273};1281};
12741282
1275inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<> tuple_cat() { return tuple<>(); }1283inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<> tuple_cat() { return tuple<>(); }
...@@ -1279,7 +1287,7 @@ struct __tuple_cat_return_ref_imp;...@@ -1279,7 +1287,7 @@ struct __tuple_cat_return_ref_imp;
12791287
1280template <class... _Types, size_t... _I0, class _Tuple0>1288template <class... _Types, size_t... _I0, class _Tuple0>
1281struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0> {1289struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0> {
1282 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;1290 using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>;
1283 typedef tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type;1291 typedef tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type;
1284};1292};
12851293
...@@ -1319,8 +1327,8 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J...@@ -1319,8 +1327,8 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
1319 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type1327 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1320 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&&... __tpls) {1328 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&&... __tpls) {
1321 (void)__t; // avoid unused parameter warning on GCC when _I0 is empty1329 (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
1322 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;1330 using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>;
1323 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple1> _T1;1331 using _T1 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple1>;
1324 return __tuple_cat<tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>,1332 return __tuple_cat<tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>,
1325 typename __make_tuple_indices<sizeof...(_Types) + tuple_size<_T0>::value>::type,1333 typename __make_tuple_indices<sizeof...(_Types) + tuple_size<_T0>::value>::type,
1326 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(1334 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(
...@@ -1331,20 +1339,33 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J...@@ -1331,20 +1339,33 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
1331 }1339 }
1332};1340};
13331341
1342template <class _TupleDst, class _TupleSrc, size_t... _Indices>
1343inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _TupleDst
1344__tuple_cat_select_element_wise(_TupleSrc&& __src, __tuple_indices<_Indices...>) {
1345 static_assert(tuple_size<_TupleDst>::value == tuple_size<_TupleSrc>::value,
1346 "misuse of __tuple_cat_select_element_wise with tuples of different sizes");
1347 return _TupleDst(std::get<_Indices>(std::forward<_TupleSrc>(__src))...);
1348}
1349
1334template <class _Tuple0, class... _Tuples>1350template <class _Tuple0, class... _Tuples>
1335inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __tuple_cat_return<_Tuple0, _Tuples...>::type1351inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1336tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) {1352tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) {
1337 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;1353 using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>;
1338 return __tuple_cat<tuple<>, __tuple_indices<>, typename __make_tuple_indices<tuple_size<_T0>::value>::type>()(1354 using _TRet _LIBCPP_NODEBUG = typename __tuple_cat_return<_Tuple0, _Tuples...>::type;
1339 tuple<>(), std::forward<_Tuple0>(__t0), std::forward<_Tuples>(__tpls)...);1355 using _T0Indices _LIBCPP_NODEBUG = typename __make_tuple_indices<tuple_size<_T0>::value>::type;
1356 using _TRetIndices _LIBCPP_NODEBUG = typename __make_tuple_indices<tuple_size<_TRet>::value>::type;
1357 return std::__tuple_cat_select_element_wise<_TRet>(
1358 __tuple_cat<tuple<>, __tuple_indices<>, _T0Indices>()(
1359 tuple<>(), std::forward<_Tuple0>(__t0), std::forward<_Tuples>(__tpls)...),
1360 _TRetIndices());
1340}1361}
13411362
1342template <class... _Tp, class _Alloc>1363template <class... _Tp, class _Alloc>
1343struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc> : true_type {};1364struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc> : true_type {};
13441365
1345# if _LIBCPP_STD_VER >= 171366# if _LIBCPP_STD_VER >= 17
1346# define _LIBCPP_NOEXCEPT_RETURN(...) \1367# define _LIBCPP_NOEXCEPT_RETURN(...) \
1347 noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }1368 noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
13481369
1349// The _LIBCPP_NOEXCEPT_RETURN macro breaks formatting.1370// The _LIBCPP_NOEXCEPT_RETURN macro breaks formatting.
1350// clang-format off1371// clang-format off
...@@ -1407,13 +1428,15 @@ _LIBCPP_POP_MACROS...@@ -1407,13 +1428,15 @@ _LIBCPP_POP_MACROS
14071428
1408// clang-format on1429// clang-format on
14091430
1410#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 201431# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1411# include <exception>1432# include <cstddef>
1412# include <iosfwd>1433# include <exception>
1413# include <new>1434# include <iosfwd>
1414# include <type_traits>1435# include <new>
1415# include <typeinfo>1436# include <type_traits>
1416# include <utility>1437# include <typeinfo>
1417#endif1438# include <utility>
1439# endif
1440#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
14181441
1419#endif // _LIBCPP_TUPLE1442#endif // _LIBCPP_TUPLE
lib/libcxx/include/type_traits+114-102
...@@ -137,6 +137,8 @@ namespace std...@@ -137,6 +137,8 @@ namespace std
137 template <class T> struct is_nothrow_swappable; // C++17137 template <class T> struct is_nothrow_swappable; // C++17
138 template <class T> struct is_nothrow_destructible;138 template <class T> struct is_nothrow_destructible;
139139
140 template<class T> struct is_implicit_lifetime; // Since C++23
141
140 template <class T> struct has_virtual_destructor;142 template <class T> struct has_virtual_destructor;
141143
142 template<class T> struct has_unique_object_representations; // C++17144 template<class T> struct has_unique_object_representations; // C++17
...@@ -144,6 +146,7 @@ namespace std...@@ -144,6 +146,7 @@ namespace std
144 // Relationships between types:146 // Relationships between types:
145 template <class T, class U> struct is_same;147 template <class T, class U> struct is_same;
146 template <class Base, class Derived> struct is_base_of;148 template <class Base, class Derived> struct is_base_of;
149 template <class Base, class Derived> struct is_virtual_base_of; // C++26
147150
148 template <class From, class To> struct is_convertible;151 template <class From, class To> struct is_convertible;
149 template <typename From, typename To> struct is_nothrow_convertible; // C++20152 template <typename From, typename To> struct is_nothrow_convertible; // C++20
...@@ -373,6 +376,8 @@ namespace std...@@ -373,6 +376,8 @@ namespace std
373 = is_nothrow_swappable<T>::value; // C++17376 = is_nothrow_swappable<T>::value; // C++17
374 template <class T> inline constexpr bool is_nothrow_destructible_v377 template <class T> inline constexpr bool is_nothrow_destructible_v
375 = is_nothrow_destructible<T>::value; // C++17378 = is_nothrow_destructible<T>::value; // C++17
379 template<class T>
380 constexpr bool is_implicit_lifetime_v = is_implicit_lifetime<T>::value; // Since C++23
376 template <class T> inline constexpr bool has_virtual_destructor_v381 template <class T> inline constexpr bool has_virtual_destructor_v
377 = has_virtual_destructor<T>::value; // C++17382 = has_virtual_destructor<T>::value; // C++17
378 template<class T> inline constexpr bool has_unique_object_representations_v // C++17383 template<class T> inline constexpr bool has_unique_object_representations_v // C++17
...@@ -391,6 +396,8 @@ namespace std...@@ -391,6 +396,8 @@ namespace std
391 = is_same<T, U>::value; // C++17396 = is_same<T, U>::value; // C++17
392 template <class Base, class Derived> inline constexpr bool is_base_of_v397 template <class Base, class Derived> inline constexpr bool is_base_of_v
393 = is_base_of<Base, Derived>::value; // C++17398 = is_base_of<Base, Derived>::value; // C++17
399 template <class Base, class Derived> inline constexpr bool is_virtual_base_of_v
400 = is_virtual_base_of<Base, Derived>::value; // C++26
394 template <class From, class To> inline constexpr bool is_convertible_v401 template <class From, class To> inline constexpr bool is_convertible_v
395 = is_convertible<From, To>::value; // C++17402 = is_convertible<From, To>::value; // C++17
396 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v403 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v
...@@ -417,107 +424,112 @@ namespace std...@@ -417,107 +424,112 @@ namespace std
417424
418*/425*/
419426
420#include <__config>427#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
421#include <__fwd/functional.h> // This is https://llvm.org/PR56938428# include <__cxx03/type_traits>
422#include <__type_traits/add_const.h>429#else
423#include <__type_traits/add_cv.h>430# include <__config>
424#include <__type_traits/add_lvalue_reference.h>431# include <__type_traits/add_cv_quals.h>
425#include <__type_traits/add_pointer.h>432# include <__type_traits/add_lvalue_reference.h>
426#include <__type_traits/add_rvalue_reference.h>433# include <__type_traits/add_pointer.h>
427#include <__type_traits/add_volatile.h>434# include <__type_traits/add_rvalue_reference.h>
428#include <__type_traits/aligned_storage.h>435# include <__type_traits/aligned_storage.h>
429#include <__type_traits/aligned_union.h>436# include <__type_traits/aligned_union.h>
430#include <__type_traits/alignment_of.h>437# include <__type_traits/alignment_of.h>
431#include <__type_traits/common_type.h>438# include <__type_traits/common_type.h>
432#include <__type_traits/conditional.h>439# include <__type_traits/conditional.h>
433#include <__type_traits/decay.h>440# include <__type_traits/decay.h>
434#include <__type_traits/enable_if.h>441# include <__type_traits/enable_if.h>
435#include <__type_traits/extent.h>442# include <__type_traits/extent.h>
436#include <__type_traits/has_virtual_destructor.h>443# include <__type_traits/has_virtual_destructor.h>
437#include <__type_traits/integral_constant.h>444# include <__type_traits/integral_constant.h>
438#include <__type_traits/is_abstract.h>445# include <__type_traits/is_abstract.h>
439#include <__type_traits/is_arithmetic.h>446# include <__type_traits/is_arithmetic.h>
440#include <__type_traits/is_array.h>447# include <__type_traits/is_array.h>
441#include <__type_traits/is_assignable.h>448# include <__type_traits/is_assignable.h>
442#include <__type_traits/is_base_of.h>449# include <__type_traits/is_base_of.h>
443#include <__type_traits/is_class.h>450# include <__type_traits/is_class.h>
444#include <__type_traits/is_compound.h>451# include <__type_traits/is_compound.h>
445#include <__type_traits/is_const.h>452# include <__type_traits/is_const.h>
446#include <__type_traits/is_constructible.h>453# include <__type_traits/is_constructible.h>
447#include <__type_traits/is_convertible.h>454# include <__type_traits/is_convertible.h>
448#include <__type_traits/is_destructible.h>455# include <__type_traits/is_destructible.h>
449#include <__type_traits/is_empty.h>456# include <__type_traits/is_empty.h>
450#include <__type_traits/is_enum.h>457# include <__type_traits/is_enum.h>
451#include <__type_traits/is_floating_point.h>458# include <__type_traits/is_floating_point.h>
452#include <__type_traits/is_function.h>459# include <__type_traits/is_function.h>
453#include <__type_traits/is_fundamental.h>460# include <__type_traits/is_fundamental.h>
454#include <__type_traits/is_integral.h>461# include <__type_traits/is_integral.h>
455#include <__type_traits/is_literal_type.h>462# include <__type_traits/is_literal_type.h>
456#include <__type_traits/is_member_pointer.h>463# include <__type_traits/is_member_pointer.h>
457#include <__type_traits/is_nothrow_assignable.h>464# include <__type_traits/is_nothrow_assignable.h>
458#include <__type_traits/is_nothrow_constructible.h>465# include <__type_traits/is_nothrow_constructible.h>
459#include <__type_traits/is_nothrow_destructible.h>466# include <__type_traits/is_nothrow_destructible.h>
460#include <__type_traits/is_object.h>467# include <__type_traits/is_object.h>
461#include <__type_traits/is_pod.h>468# include <__type_traits/is_pod.h>
462#include <__type_traits/is_pointer.h>469# include <__type_traits/is_pointer.h>
463#include <__type_traits/is_polymorphic.h>470# include <__type_traits/is_polymorphic.h>
464#include <__type_traits/is_reference.h>471# include <__type_traits/is_reference.h>
465#include <__type_traits/is_same.h>472# include <__type_traits/is_same.h>
466#include <__type_traits/is_scalar.h>473# include <__type_traits/is_scalar.h>
467#include <__type_traits/is_signed.h>474# include <__type_traits/is_signed.h>
468#include <__type_traits/is_standard_layout.h>475# include <__type_traits/is_standard_layout.h>
469#include <__type_traits/is_trivial.h>476# include <__type_traits/is_trivial.h>
470#include <__type_traits/is_trivially_assignable.h>477# include <__type_traits/is_trivially_assignable.h>
471#include <__type_traits/is_trivially_constructible.h>478# include <__type_traits/is_trivially_constructible.h>
472#include <__type_traits/is_trivially_copyable.h>479# include <__type_traits/is_trivially_copyable.h>
473#include <__type_traits/is_trivially_destructible.h>480# include <__type_traits/is_trivially_destructible.h>
474#include <__type_traits/is_union.h>481# include <__type_traits/is_union.h>
475#include <__type_traits/is_unsigned.h>482# include <__type_traits/is_unsigned.h>
476#include <__type_traits/is_void.h>483# include <__type_traits/is_void.h>
477#include <__type_traits/is_volatile.h>484# include <__type_traits/is_volatile.h>
478#include <__type_traits/make_signed.h>485# include <__type_traits/make_signed.h>
479#include <__type_traits/make_unsigned.h>486# include <__type_traits/make_unsigned.h>
480#include <__type_traits/rank.h>487# include <__type_traits/rank.h>
481#include <__type_traits/remove_all_extents.h>488# include <__type_traits/remove_all_extents.h>
482#include <__type_traits/remove_const.h>489# include <__type_traits/remove_const.h>
483#include <__type_traits/remove_cv.h>490# include <__type_traits/remove_cv.h>
484#include <__type_traits/remove_extent.h>491# include <__type_traits/remove_extent.h>
485#include <__type_traits/remove_pointer.h>492# include <__type_traits/remove_pointer.h>
486#include <__type_traits/remove_reference.h>493# include <__type_traits/remove_reference.h>
487#include <__type_traits/remove_volatile.h>494# include <__type_traits/remove_volatile.h>
488#include <__type_traits/result_of.h>495# include <__type_traits/result_of.h>
489#include <__type_traits/underlying_type.h>496# include <__type_traits/underlying_type.h>
490497
491#if _LIBCPP_STD_VER >= 14498# if _LIBCPP_STD_VER >= 14
492# include <__type_traits/is_final.h>499# include <__type_traits/is_final.h>
493# include <__type_traits/is_null_pointer.h>500# include <__type_traits/is_null_pointer.h>
494#endif501# endif
495502
496#if _LIBCPP_STD_VER >= 17503# if _LIBCPP_STD_VER >= 17
497# include <__type_traits/conjunction.h>504# include <__type_traits/conjunction.h>
498# include <__type_traits/disjunction.h>505# include <__type_traits/disjunction.h>
499# include <__type_traits/has_unique_object_representation.h>506# include <__type_traits/has_unique_object_representation.h>
500# include <__type_traits/invoke.h>507# include <__type_traits/invoke.h>
501# include <__type_traits/is_aggregate.h>508# include <__type_traits/is_aggregate.h>
502# include <__type_traits/is_swappable.h>509# include <__type_traits/is_swappable.h>
503# include <__type_traits/negation.h>510# include <__type_traits/negation.h>
504# include <__type_traits/void_t.h>511# include <__type_traits/void_t.h>
505#endif512# endif
506513
507#if _LIBCPP_STD_VER >= 20514# if _LIBCPP_STD_VER >= 20
508# include <__type_traits/common_reference.h>515# include <__type_traits/common_reference.h>
509# include <__type_traits/is_bounded_array.h>516# include <__type_traits/is_bounded_array.h>
510# include <__type_traits/is_constant_evaluated.h>517# include <__type_traits/is_constant_evaluated.h>
511# include <__type_traits/is_nothrow_convertible.h>518# include <__type_traits/is_nothrow_convertible.h>
512# include <__type_traits/is_unbounded_array.h>519# include <__type_traits/is_unbounded_array.h>
513# include <__type_traits/type_identity.h>520# include <__type_traits/type_identity.h>
514# include <__type_traits/unwrap_ref.h>521# include <__type_traits/unwrap_ref.h>
515#endif522# endif
516523
517#include <version>524# if _LIBCPP_STD_VER >= 23
518525# include <__type_traits/is_implicit_lifetime.h>
519#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)526# endif
520# pragma GCC system_header527
521#endif528# include <version>
529
530# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
531# pragma GCC system_header
532# endif
533#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
522534
523#endif // _LIBCPP_TYPE_TRAITS535#endif // _LIBCPP_TYPE_TRAITS
lib/libcxx/include/typeindex+22-17
...@@ -45,17 +45,20 @@ struct hash<type_index>...@@ -45,17 +45,20 @@ struct hash<type_index>
4545
46*/46*/
4747
48#include <__config>48#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
49#include <__functional/unary_function.h>49# include <__cxx03/typeindex>
50#include <typeinfo>50#else
51#include <version>51# include <__config>
52# include <__functional/unary_function.h>
53# include <typeinfo>
54# include <version>
5255
53// standard-mandated includes56// standard-mandated includes
54#include <compare>57# include <compare>
5558
56#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)59# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
57# pragma GCC system_header60# pragma GCC system_header
58#endif61# endif
5962
60_LIBCPP_BEGIN_NAMESPACE_STD63_LIBCPP_BEGIN_NAMESPACE_STD
6164
...@@ -66,14 +69,14 @@ public:...@@ -66,14 +69,14 @@ public:
66 _LIBCPP_HIDE_FROM_ABI type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {}69 _LIBCPP_HIDE_FROM_ABI type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {}
6770
68 _LIBCPP_HIDE_FROM_ABI bool operator==(const type_index& __y) const _NOEXCEPT { return *__t_ == *__y.__t_; }71 _LIBCPP_HIDE_FROM_ABI bool operator==(const type_index& __y) const _NOEXCEPT { return *__t_ == *__y.__t_; }
69#if _LIBCPP_STD_VER <= 1772# if _LIBCPP_STD_VER <= 17
70 _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_index& __y) const _NOEXCEPT { return *__t_ != *__y.__t_; }73 _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_index& __y) const _NOEXCEPT { return *__t_ != *__y.__t_; }
71#endif74# endif
72 _LIBCPP_HIDE_FROM_ABI bool operator<(const type_index& __y) const _NOEXCEPT { return __t_->before(*__y.__t_); }75 _LIBCPP_HIDE_FROM_ABI bool operator<(const type_index& __y) const _NOEXCEPT { return __t_->before(*__y.__t_); }
73 _LIBCPP_HIDE_FROM_ABI bool operator<=(const type_index& __y) const _NOEXCEPT { return !__y.__t_->before(*__t_); }76 _LIBCPP_HIDE_FROM_ABI bool operator<=(const type_index& __y) const _NOEXCEPT { return !__y.__t_->before(*__t_); }
74 _LIBCPP_HIDE_FROM_ABI bool operator>(const type_index& __y) const _NOEXCEPT { return __y.__t_->before(*__t_); }77 _LIBCPP_HIDE_FROM_ABI bool operator>(const type_index& __y) const _NOEXCEPT { return __y.__t_->before(*__t_); }
75 _LIBCPP_HIDE_FROM_ABI bool operator>=(const type_index& __y) const _NOEXCEPT { return !__t_->before(*__y.__t_); }78 _LIBCPP_HIDE_FROM_ABI bool operator>=(const type_index& __y) const _NOEXCEPT { return !__t_->before(*__y.__t_); }
76#if _LIBCPP_STD_VER >= 2079# if _LIBCPP_STD_VER >= 20
77 _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(const type_index& __y) const noexcept {80 _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(const type_index& __y) const noexcept {
78 if (*__t_ == *__y.__t_)81 if (*__t_ == *__y.__t_)
79 return strong_ordering::equal;82 return strong_ordering::equal;
...@@ -81,7 +84,7 @@ public:...@@ -81,7 +84,7 @@ public:
81 return strong_ordering::less;84 return strong_ordering::less;
82 return strong_ordering::greater;85 return strong_ordering::greater;
83 }86 }
84#endif87# endif
8588
86 _LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __t_->hash_code(); }89 _LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __t_->hash_code(); }
87 _LIBCPP_HIDE_FROM_ABI const char* name() const _NOEXCEPT { return __t_->name(); }90 _LIBCPP_HIDE_FROM_ABI const char* name() const _NOEXCEPT { return __t_->name(); }
...@@ -97,10 +100,12 @@ struct _LIBCPP_TEMPLATE_VIS hash<type_index> : public __unary_function<type_inde...@@ -97,10 +100,12 @@ struct _LIBCPP_TEMPLATE_VIS hash<type_index> : public __unary_function<type_inde
97100
98_LIBCPP_END_NAMESPACE_STD101_LIBCPP_END_NAMESPACE_STD
99102
100#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20103# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
101# include <iosfwd>104# include <cstddef>
102# include <new>105# include <iosfwd>
103# include <utility>106# include <new>
104#endif107# include <utility>
108# endif
109#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
105110
106#endif // _LIBCPP_TYPEINDEX111#endif // _LIBCPP_TYPEINDEX
lib/libcxx/include/typeinfo+62-55
...@@ -56,25 +56,30 @@ public:...@@ -56,25 +56,30 @@ public:
5656
57*/57*/
5858
59#include <__config>59#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
60#include <__exception/exception.h>60# include <__cxx03/typeinfo>
61#include <__type_traits/is_constant_evaluated.h>
62#include <__verbose_abort>
63#include <cstddef>
64#include <cstdint>
65
66#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
67# pragma GCC system_header
68#endif
69
70#if defined(_LIBCPP_ABI_VCRUNTIME)
71# include <vcruntime_typeinfo.h>
72#else61#else
62# include <__config>
63# include <__cstddef/size_t.h>
64# include <__exception/exception.h>
65# include <__type_traits/integral_constant.h>
66# include <__type_traits/is_constant_evaluated.h>
67# include <__verbose_abort>
68# include <cstdint>
69# include <version>
70
71# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
72# pragma GCC system_header
73# endif
74
75# if defined(_LIBCPP_ABI_VCRUNTIME)
76# include <vcruntime_typeinfo.h>
77# else
7378
74namespace std // purposefully not using versioning namespace79namespace std // purposefully not using versioning namespace
75{80{
7681
77# if defined(_LIBCPP_ABI_MICROSOFT)82# if defined(_LIBCPP_ABI_MICROSOFT)
7883
79class _LIBCPP_EXPORTED_FROM_ABI type_info {84class _LIBCPP_EXPORTED_FROM_ABI type_info {
80 type_info& operator=(const type_info&);85 type_info& operator=(const type_info&);
...@@ -105,12 +110,12 @@ public:...@@ -105,12 +110,12 @@ public:
105 return __compare(__arg) == 0;110 return __compare(__arg) == 0;
106 }111 }
107112
108# if _LIBCPP_STD_VER <= 17113# if _LIBCPP_STD_VER <= 17
109 _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); }114 _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); }
110# endif115# endif
111};116};
112117
113# else // !defined(_LIBCPP_ABI_MICROSOFT)118# else // !defined(_LIBCPP_ABI_MICROSOFT)
114119
115// ========================================================================== //120// ========================================================================== //
116// Implementations121// Implementations
...@@ -165,21 +170,21 @@ public:...@@ -165,21 +170,21 @@ public:
165170
166// This value can be overriden in the __config_site. When it's not overriden,171// This value can be overriden in the __config_site. When it's not overriden,
167// we pick a default implementation based on the platform here.172// we pick a default implementation based on the platform here.
168# ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION173# ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
169174
170// Windows and AIX binaries can't merge typeinfos, so use the NonUnique implementation.175// Windows and AIX binaries can't merge typeinfos, so use the NonUnique implementation.
171# if defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)176# if defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)
172# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2177# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2
173178
174// On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation.179// On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation.
175# elif defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)180# elif defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
176# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 3181# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 3
177182
178// On all other platforms, assume the Itanium C++ ABI and use the Unique implementation.183// On all other platforms, assume the Itanium C++ ABI and use the Unique implementation.
179# else184# else
180# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1185# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1
186# endif
181# endif187# endif
182# endif
183188
184struct __type_info_implementations {189struct __type_info_implementations {
185 struct __string_impl_base {190 struct __string_impl_base {
...@@ -263,30 +268,30 @@ struct __type_info_implementations {...@@ -263,30 +268,30 @@ struct __type_info_implementations {
263 };268 };
264269
265 typedef270 typedef
266# if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1271# if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1
267 __unique_impl272 __unique_impl
268# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2273# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2
269 __non_unique_impl274 __non_unique_impl
270# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3275# elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3
271 __non_unique_arm_rtti_bit_impl276 __non_unique_arm_rtti_bit_impl
272# else277# else
273# error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION278# error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
274# endif279# endif
275 __impl;280 __impl;
276};281};
277282
278# if __has_cpp_attribute(_Clang::__ptrauth_vtable_pointer__)283# if __has_cpp_attribute(_Clang::__ptrauth_vtable_pointer__)
279# if __has_feature(ptrauth_type_info_vtable_pointer_discrimination)284# if __has_feature(ptrauth_type_info_vtable_pointer_discrimination)
280# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \285# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \
281 [[_Clang::__ptrauth_vtable_pointer__(process_independent, address_discrimination, type_discrimination)]]286 [[_Clang::__ptrauth_vtable_pointer__(process_independent, address_discrimination, type_discrimination)]]
287# else
288# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \
289 [[_Clang::__ptrauth_vtable_pointer__( \
290 process_independent, no_address_discrimination, no_extra_discrimination)]]
291# endif
282# else292# else
283# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \293# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH
284 [[_Clang::__ptrauth_vtable_pointer__( \
285 process_independent, no_address_discrimination, no_extra_discrimination)]]
286# endif294# endif
287# else
288# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH
289# endif
290295
291class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH type_info {296class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH type_info {
292 type_info& operator=(const type_info&);297 type_info& operator=(const type_info&);
...@@ -319,11 +324,11 @@ public:...@@ -319,11 +324,11 @@ public:
319 return __impl::__eq(__type_name, __arg.__type_name);324 return __impl::__eq(__type_name, __arg.__type_name);
320 }325 }
321326
322# if _LIBCPP_STD_VER <= 17327# if _LIBCPP_STD_VER <= 17
323 _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); }328 _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); }
324# endif329# endif
325};330};
326# endif // defined(_LIBCPP_ABI_MICROSOFT)331# endif // defined(_LIBCPP_ABI_MICROSOFT)
327332
328class _LIBCPP_EXPORTED_FROM_ABI bad_cast : public exception {333class _LIBCPP_EXPORTED_FROM_ABI bad_cast : public exception {
329public:334public:
...@@ -345,9 +350,9 @@ public:...@@ -345,9 +350,9 @@ public:
345350
346} // namespace std351} // namespace std
347352
348#endif // defined(_LIBCPP_ABI_VCRUNTIME)353# endif // defined(_LIBCPP_ABI_VCRUNTIME)
349354
350#if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0355# if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
351356
352namespace std {357namespace std {
353358
...@@ -369,21 +374,23 @@ private:...@@ -369,21 +374,23 @@ private:
369374
370} // namespace std375} // namespace std
371376
372#endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0377# endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
373378
374_LIBCPP_BEGIN_NAMESPACE_STD379_LIBCPP_BEGIN_NAMESPACE_STD
375_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_cast() {380[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_cast() {
376#ifndef _LIBCPP_HAS_NO_EXCEPTIONS381# if _LIBCPP_HAS_EXCEPTIONS
377 throw bad_cast();382 throw bad_cast();
378#else383# else
379 _LIBCPP_VERBOSE_ABORT("bad_cast was thrown in -fno-exceptions mode");384 _LIBCPP_VERBOSE_ABORT("bad_cast was thrown in -fno-exceptions mode");
380#endif385# endif
381}386}
382_LIBCPP_END_NAMESPACE_STD387_LIBCPP_END_NAMESPACE_STD
383388
384#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20389# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
385# include <cstdlib>390# include <cstddef>
386# include <type_traits>391# include <cstdlib>
387#endif392# include <type_traits>
393# endif
394#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
388395
389#endif // _LIBCPP_TYPEINFO396#endif // _LIBCPP_TYPEINFO
lib/libcxx/include/uchar.h+17-13
...@@ -32,25 +32,29 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);...@@ -32,25 +32,29 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
3232
33*/33*/
3434
35#include <__config>35#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
36# include <__cxx03/uchar.h>
37#else
38# include <__config>
3639
37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)40# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
38# pragma GCC system_header41# pragma GCC system_header
39#endif42# endif
4043
41#if !defined(_LIBCPP_CXX03_LANG)44# if !defined(_LIBCPP_CXX03_LANG)
4245
43// Some platforms don't implement <uchar.h> and we don't want to give a hard46// Some platforms don't implement <uchar.h> and we don't want to give a hard
44// error on those platforms. When the platform doesn't provide <uchar.h>, at47// error on those platforms. When the platform doesn't provide <uchar.h>, at
45// least include <stddef.h> so we get the declaration for size_t, and try to48// least include <stddef.h> so we get the declaration for size_t, and try to
46// get the declaration of mbstate_t too.49// get the declaration of mbstate_t too.
47# if __has_include_next(<uchar.h>)50# if __has_include_next(<uchar.h>)
48# include_next <uchar.h>51# include_next <uchar.h>
49# else52# else
50# include <__mbstate_t.h>53# include <__mbstate_t.h>
51# include <stddef.h>54# include <stddef.h>
52# endif55# endif
5356
54#endif // _LIBCPP_CXX03_LANG57# endif // _LIBCPP_CXX03_LANG
58#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
5559
56#endif // _LIBCPP_UCHAR_H60#endif // _LIBCPP_UCHAR_H
lib/libcxx/include/unordered_map+197-161
...@@ -583,49 +583,63 @@ template <class Key, class T, class Hash, class Pred, class Alloc>...@@ -583,49 +583,63 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
583583
584*/584*/
585585
586#include <__algorithm/is_permutation.h>586#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
587#include <__assert>587# include <__cxx03/unordered_map>
588#include <__config>588#else
589#include <__functional/is_transparent.h>589# include <__algorithm/is_permutation.h>
590#include <__functional/operations.h>590# include <__assert>
591#include <__hash_table>591# include <__config>
592#include <__iterator/distance.h>592# include <__functional/hash.h>
593#include <__iterator/erase_if_container.h>593# include <__functional/is_transparent.h>
594#include <__iterator/iterator_traits.h>594# include <__functional/operations.h>
595#include <__iterator/ranges_iterator_traits.h>595# include <__hash_table>
596#include <__memory/addressof.h>596# include <__iterator/distance.h>
597#include <__memory/allocator.h>597# include <__iterator/erase_if_container.h>
598#include <__memory_resource/polymorphic_allocator.h>598# include <__iterator/iterator_traits.h>
599#include <__node_handle>599# include <__iterator/ranges_iterator_traits.h>
600#include <__ranges/concepts.h>600# include <__memory/addressof.h>
601#include <__ranges/container_compatible_range.h>601# include <__memory/allocator.h>
602#include <__ranges/from_range.h>602# include <__memory/allocator_traits.h>
603#include <__type_traits/is_allocator.h>603# include <__memory/pointer_traits.h>
604#include <__type_traits/type_identity.h>604# include <__memory/unique_ptr.h>
605#include <__utility/forward.h>605# include <__memory_resource/polymorphic_allocator.h>
606#include <stdexcept>606# include <__new/launder.h>
607#include <tuple>607# include <__node_handle>
608#include <version>608# include <__ranges/concepts.h>
609# include <__ranges/container_compatible_range.h>
610# include <__ranges/from_range.h>
611# include <__type_traits/container_traits.h>
612# include <__type_traits/enable_if.h>
613# include <__type_traits/invoke.h>
614# include <__type_traits/is_allocator.h>
615# include <__type_traits/is_integral.h>
616# include <__type_traits/remove_const.h>
617# include <__type_traits/type_identity.h>
618# include <__utility/forward.h>
619# include <__utility/pair.h>
620# include <stdexcept>
621# include <tuple>
622# include <version>
609623
610// standard-mandated includes624// standard-mandated includes
611625
612// [iterator.range]626// [iterator.range]
613#include <__iterator/access.h>627# include <__iterator/access.h>
614#include <__iterator/data.h>628# include <__iterator/data.h>
615#include <__iterator/empty.h>629# include <__iterator/empty.h>
616#include <__iterator/reverse_access.h>630# include <__iterator/reverse_access.h>
617#include <__iterator/size.h>631# include <__iterator/size.h>
618632
619// [unord.map.syn]633// [unord.map.syn]
620#include <compare>634# include <compare>
621#include <initializer_list>635# include <initializer_list>
622636
623#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)637# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
624# pragma GCC system_header638# pragma GCC system_header
625#endif639# endif
626640
627_LIBCPP_PUSH_MACROS641_LIBCPP_PUSH_MACROS
628#include <__undef_macros>642# include <__undef_macros>
629643
630_LIBCPP_BEGIN_NAMESPACE_STD644_LIBCPP_BEGIN_NAMESPACE_STD
631645
...@@ -644,12 +658,12 @@ public:...@@ -644,12 +658,12 @@ public:
644 return static_cast<const _Hash&>(*this)(__x.__get_value().first);658 return static_cast<const _Hash&>(*this)(__x.__get_value().first);
645 }659 }
646 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return static_cast<const _Hash&>(*this)(__x); }660 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return static_cast<const _Hash&>(*this)(__x); }
647#if _LIBCPP_STD_VER >= 20661# if _LIBCPP_STD_VER >= 20
648 template <typename _K2>662 template <typename _K2>
649 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _K2& __x) const {663 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _K2& __x) const {
650 return static_cast<const _Hash&>(*this)(__x);664 return static_cast<const _Hash&>(*this)(__x);
651 }665 }
652#endif666# endif
653 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Hash>) {667 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Hash>) {
654 using std::swap;668 using std::swap;
655 swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y));669 swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y));
...@@ -668,12 +682,12 @@ public:...@@ -668,12 +682,12 @@ public:
668 _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return __hash_; }682 _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return __hash_; }
669 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { return __hash_(__x.__get_value().first); }683 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { return __hash_(__x.__get_value().first); }
670 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return __hash_(__x); }684 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return __hash_(__x); }
671#if _LIBCPP_STD_VER >= 20685# if _LIBCPP_STD_VER >= 20
672 template <typename _K2>686 template <typename _K2>
673 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _K2& __x) const {687 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _K2& __x) const {
674 return __hash_(__x);688 return __hash_(__x);
675 }689 }
676#endif690# endif
677 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Hash>) {691 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Hash>) {
678 using std::swap;692 using std::swap;
679 swap(__hash_, __y.__hash_);693 swap(__hash_, __y.__hash_);
...@@ -707,7 +721,7 @@ public:...@@ -707,7 +721,7 @@ public:
707 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const {721 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const {
708 return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);722 return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);
709 }723 }
710#if _LIBCPP_STD_VER >= 20724# if _LIBCPP_STD_VER >= 20
711 template <typename _K2>725 template <typename _K2>
712 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const {726 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const {
713 return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);727 return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);
...@@ -724,7 +738,7 @@ public:...@@ -724,7 +738,7 @@ public:
724 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Key& __y) const {738 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Key& __y) const {
725 return static_cast<const _Pred&>(*this)(__x, __y);739 return static_cast<const _Pred&>(*this)(__x, __y);
726 }740 }
727#endif741# endif
728 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Pred>) {742 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Pred>) {
729 using std::swap;743 using std::swap;
730 swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y));744 swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y));
...@@ -750,7 +764,7 @@ public:...@@ -750,7 +764,7 @@ public:
750 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const {764 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const {
751 return __pred_(__x, __y.__get_value().first);765 return __pred_(__x, __y.__get_value().first);
752 }766 }
753#if _LIBCPP_STD_VER >= 20767# if _LIBCPP_STD_VER >= 20
754 template <typename _K2>768 template <typename _K2>
755 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const {769 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const {
756 return __pred_(__x.__get_value().first, __y);770 return __pred_(__x.__get_value().first, __y);
...@@ -767,7 +781,7 @@ public:...@@ -767,7 +781,7 @@ public:
767 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Key& __y) const {781 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Key& __y) const {
768 return __pred_(__x, __y);782 return __pred_(__x, __y);
769 }783 }
770#endif784# endif
771 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Pred>) {785 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Pred>) {
772 using std::swap;786 using std::swap;
773 swap(__pred_, __y.__pred_);787 swap(__pred_, __y.__pred_);
...@@ -803,19 +817,19 @@ public:...@@ -803,19 +817,19 @@ public:
803 __first_constructed(false),817 __first_constructed(false),
804 __second_constructed(false) {}818 __second_constructed(false) {}
805819
806#ifndef _LIBCPP_CXX03_LANG820# ifndef _LIBCPP_CXX03_LANG
807 _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x) _NOEXCEPT821 _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x) _NOEXCEPT
808 : __na_(__x.__na_),822 : __na_(__x.__na_),
809 __first_constructed(__x.__value_constructed),823 __first_constructed(__x.__value_constructed),
810 __second_constructed(__x.__value_constructed) {824 __second_constructed(__x.__value_constructed) {
811 __x.__value_constructed = false;825 __x.__value_constructed = false;
812 }826 }
813#else // _LIBCPP_CXX03_LANG827# else // _LIBCPP_CXX03_LANG
814 _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)828 _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
815 : __na_(__x.__na_), __first_constructed(__x.__value_constructed), __second_constructed(__x.__value_constructed) {829 : __na_(__x.__na_), __first_constructed(__x.__value_constructed), __second_constructed(__x.__value_constructed) {
816 const_cast<bool&>(__x.__value_constructed) = false;830 const_cast<bool&>(__x.__value_constructed) = false;
817 }831 }
818#endif // _LIBCPP_CXX03_LANG832# endif // _LIBCPP_CXX03_LANG
819833
820 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {834 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {
821 if (__second_constructed)835 if (__second_constructed)
...@@ -827,7 +841,7 @@ public:...@@ -827,7 +841,7 @@ public:
827 }841 }
828};842};
829843
830#ifndef _LIBCPP_CXX03_LANG844# ifndef _LIBCPP_CXX03_LANG
831template <class _Key, class _Tp>845template <class _Key, class _Tp>
832struct _LIBCPP_STANDALONE_DEBUG __hash_value_type {846struct _LIBCPP_STANDALONE_DEBUG __hash_value_type {
833 typedef _Key key_type;847 typedef _Key key_type;
...@@ -841,19 +855,19 @@ private:...@@ -841,19 +855,19 @@ private:
841855
842public:856public:
843 _LIBCPP_HIDE_FROM_ABI value_type& __get_value() {857 _LIBCPP_HIDE_FROM_ABI value_type& __get_value() {
844# if _LIBCPP_STD_VER >= 17858# if _LIBCPP_STD_VER >= 17
845 return *std::launder(std::addressof(__cc_));859 return *std::launder(std::addressof(__cc_));
846# else860# else
847 return __cc_;861 return __cc_;
848# endif862# endif
849 }863 }
850864
851 _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const {865 _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const {
852# if _LIBCPP_STD_VER >= 17866# if _LIBCPP_STD_VER >= 17
853 return *std::launder(std::addressof(__cc_));867 return *std::launder(std::addressof(__cc_));
854# else868# else
855 return __cc_;869 return __cc_;
856# endif870# endif
857 }871 }
858872
859 _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() {873 _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() {
...@@ -890,7 +904,7 @@ public:...@@ -890,7 +904,7 @@ public:
890 ~__hash_value_type() = delete;904 ~__hash_value_type() = delete;
891};905};
892906
893#else907# else
894908
895template <class _Key, class _Tp>909template <class _Key, class _Tp>
896struct __hash_value_type {910struct __hash_value_type {
...@@ -908,7 +922,7 @@ public:...@@ -908,7 +922,7 @@ public:
908 ~__hash_value_type() = delete;922 ~__hash_value_type() = delete;
909};923};
910924
911#endif925# endif
912926
913template <class _HashIterator>927template <class _HashIterator>
914class _LIBCPP_TEMPLATE_VIS __hash_map_iterator {928class _LIBCPP_TEMPLATE_VIS __hash_map_iterator {
...@@ -943,11 +957,11 @@ public:...@@ -943,11 +957,11 @@ public:
943 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y) {957 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y) {
944 return __x.__i_ == __y.__i_;958 return __x.__i_ == __y.__i_;
945 }959 }
946#if _LIBCPP_STD_VER <= 17960# if _LIBCPP_STD_VER <= 17
947 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) {961 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) {
948 return __x.__i_ != __y.__i_;962 return __x.__i_ != __y.__i_;
949 }963 }
950#endif964# endif
951965
952 template <class, class, class, class, class>966 template <class, class, class, class, class>
953 friend class _LIBCPP_TEMPLATE_VIS unordered_map;967 friend class _LIBCPP_TEMPLATE_VIS unordered_map;
...@@ -998,12 +1012,12 @@ public:...@@ -998,12 +1012,12 @@ public:
998 operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) {1012 operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) {
999 return __x.__i_ == __y.__i_;1013 return __x.__i_ == __y.__i_;
1000 }1014 }
1001#if _LIBCPP_STD_VER <= 171015# if _LIBCPP_STD_VER <= 17
1002 friend _LIBCPP_HIDE_FROM_ABI bool1016 friend _LIBCPP_HIDE_FROM_ABI bool
1003 operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) {1017 operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) {
1004 return __x.__i_ != __y.__i_;1018 return __x.__i_ != __y.__i_;
1005 }1019 }
1006#endif1020# endif
10071021
1008 template <class, class, class, class, class>1022 template <class, class, class, class, class>
1009 friend class _LIBCPP_TEMPLATE_VIS unordered_map;1023 friend class _LIBCPP_TEMPLATE_VIS unordered_map;
...@@ -1073,10 +1087,10 @@ public:...@@ -1073,10 +1087,10 @@ public:
1073 typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;1087 typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
1074 typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;1088 typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
10751089
1076#if _LIBCPP_STD_VER >= 171090# if _LIBCPP_STD_VER >= 17
1077 typedef __map_node_handle<__node, allocator_type> node_type;1091 typedef __map_node_handle<__node, allocator_type> node_type;
1078 typedef __insert_return_type<iterator, node_type> insert_return_type;1092 typedef __insert_return_type<iterator, node_type> insert_return_type;
1079#endif1093# endif
10801094
1081 template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>1095 template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
1082 friend class _LIBCPP_TEMPLATE_VIS unordered_map;1096 friend class _LIBCPP_TEMPLATE_VIS unordered_map;
...@@ -1106,7 +1120,7 @@ public:...@@ -1106,7 +1120,7 @@ public:
1106 const key_equal& __eql,1120 const key_equal& __eql,
1107 const allocator_type& __a);1121 const allocator_type& __a);
11081122
1109#if _LIBCPP_STD_VER >= 231123# if _LIBCPP_STD_VER >= 23
1110 template <_ContainerCompatibleRange<value_type> _Range>1124 template <_ContainerCompatibleRange<value_type> _Range>
1111 _LIBCPP_HIDE_FROM_ABI unordered_map(1125 _LIBCPP_HIDE_FROM_ABI unordered_map(
1112 from_range_t,1126 from_range_t,
...@@ -1121,12 +1135,12 @@ public:...@@ -1121,12 +1135,12 @@ public:
1121 }1135 }
1122 insert_range(std::forward<_Range>(__range));1136 insert_range(std::forward<_Range>(__range));
1123 }1137 }
1124#endif1138# endif
11251139
1126 _LIBCPP_HIDE_FROM_ABI explicit unordered_map(const allocator_type& __a);1140 _LIBCPP_HIDE_FROM_ABI explicit unordered_map(const allocator_type& __a);
1127 _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u);1141 _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u);
1128 _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u, const allocator_type& __a);1142 _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u, const allocator_type& __a);
1129#ifndef _LIBCPP_CXX03_LANG1143# ifndef _LIBCPP_CXX03_LANG
1130 _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u) _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);1144 _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u) _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
1131 _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u, const allocator_type& __a);1145 _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u, const allocator_type& __a);
1132 _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il);1146 _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il);
...@@ -1141,8 +1155,8 @@ public:...@@ -1141,8 +1155,8 @@ public:
1141 const hasher& __hf,1155 const hasher& __hf,
1142 const key_equal& __eql,1156 const key_equal& __eql,
1143 const allocator_type& __a);1157 const allocator_type& __a);
1144#endif // _LIBCPP_CXX03_LANG1158# endif // _LIBCPP_CXX03_LANG
1145#if _LIBCPP_STD_VER >= 141159# if _LIBCPP_STD_VER >= 14
1146 _LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const allocator_type& __a)1160 _LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const allocator_type& __a)
1147 : unordered_map(__n, hasher(), key_equal(), __a) {}1161 : unordered_map(__n, hasher(), key_equal(), __a) {}
1148 _LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a)1162 _LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a)
...@@ -1156,7 +1170,7 @@ public:...@@ -1156,7 +1170,7 @@ public:
1156 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)1170 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
1157 : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}1171 : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}
11581172
1159# if _LIBCPP_STD_VER >= 231173# if _LIBCPP_STD_VER >= 23
1160 template <_ContainerCompatibleRange<value_type> _Range>1174 template <_ContainerCompatibleRange<value_type> _Range>
1161 _LIBCPP_HIDE_FROM_ABI unordered_map(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)1175 _LIBCPP_HIDE_FROM_ABI unordered_map(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
1162 : unordered_map(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}1176 : unordered_map(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
...@@ -1165,22 +1179,22 @@ public:...@@ -1165,22 +1179,22 @@ public:
1165 _LIBCPP_HIDE_FROM_ABI1179 _LIBCPP_HIDE_FROM_ABI
1166 unordered_map(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)1180 unordered_map(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
1167 : unordered_map(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}1181 : unordered_map(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
1168# endif1182# endif
11691183
1170 _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)1184 _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
1171 : unordered_map(__il, __n, hasher(), key_equal(), __a) {}1185 : unordered_map(__il, __n, hasher(), key_equal(), __a) {}
1172 _LIBCPP_HIDE_FROM_ABI1186 _LIBCPP_HIDE_FROM_ABI
1173 unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)1187 unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
1174 : unordered_map(__il, __n, __hf, key_equal(), __a) {}1188 : unordered_map(__il, __n, __hf, key_equal(), __a) {}
1175#endif1189# endif
1176 _LIBCPP_HIDE_FROM_ABI ~unordered_map() {1190 _LIBCPP_HIDE_FROM_ABI ~unordered_map() {
1177 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");1191 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
1178 }1192 }
11791193
1180 _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(const unordered_map& __u) {1194 _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(const unordered_map& __u) {
1181#ifndef _LIBCPP_CXX03_LANG1195# ifndef _LIBCPP_CXX03_LANG
1182 __table_ = __u.__table_;1196 __table_ = __u.__table_;
1183#else1197# else
1184 if (this != std::addressof(__u)) {1198 if (this != std::addressof(__u)) {
1185 __table_.clear();1199 __table_.clear();
1186 __table_.hash_function() = __u.__table_.hash_function();1200 __table_.hash_function() = __u.__table_.hash_function();
...@@ -1189,20 +1203,20 @@ public:...@@ -1189,20 +1203,20 @@ public:
1189 __table_.__copy_assign_alloc(__u.__table_);1203 __table_.__copy_assign_alloc(__u.__table_);
1190 insert(__u.begin(), __u.end());1204 insert(__u.begin(), __u.end());
1191 }1205 }
1192#endif1206# endif
1193 return *this;1207 return *this;
1194 }1208 }
1195#ifndef _LIBCPP_CXX03_LANG1209# ifndef _LIBCPP_CXX03_LANG
1196 _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(unordered_map&& __u)1210 _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(unordered_map&& __u)
1197 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);1211 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
1198 _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(initializer_list<value_type> __il);1212 _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(initializer_list<value_type> __il);
1199#endif // _LIBCPP_CXX03_LANG1213# endif // _LIBCPP_CXX03_LANG
12001214
1201 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {1215 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
1202 return allocator_type(__table_.__node_alloc());1216 return allocator_type(__table_.__node_alloc());
1203 }1217 }
12041218
1205 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }1219 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
1206 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }1220 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
1207 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }1221 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
12081222
...@@ -1220,16 +1234,16 @@ public:...@@ -1220,16 +1234,16 @@ public:
1220 template <class _InputIterator>1234 template <class _InputIterator>
1221 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);1235 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);
12221236
1223#if _LIBCPP_STD_VER >= 231237# if _LIBCPP_STD_VER >= 23
1224 template <_ContainerCompatibleRange<value_type> _Range>1238 template <_ContainerCompatibleRange<value_type> _Range>
1225 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {1239 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
1226 for (auto&& __element : __range) {1240 for (auto&& __element : __range) {
1227 __table_.__insert_unique(std::forward<decltype(__element)>(__element));1241 __table_.__insert_unique(std::forward<decltype(__element)>(__element));
1228 }1242 }
1229 }1243 }
1230#endif1244# endif
12311245
1232#ifndef _LIBCPP_CXX03_LANG1246# ifndef _LIBCPP_CXX03_LANG
1233 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }1247 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
12341248
1235 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) {1249 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) {
...@@ -1260,9 +1274,9 @@ public:...@@ -1260,9 +1274,9 @@ public:
1260 return __table_.__emplace_unique(std::forward<_Args>(__args)...).first;1274 return __table_.__emplace_unique(std::forward<_Args>(__args)...).first;
1261 }1275 }
12621276
1263#endif // _LIBCPP_CXX03_LANG1277# endif // _LIBCPP_CXX03_LANG
12641278
1265#if _LIBCPP_STD_VER >= 171279# if _LIBCPP_STD_VER >= 17
1266 template <class... _Args>1280 template <class... _Args>
1267 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) {1281 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) {
1268 return __table_.__emplace_unique_key_args(1282 return __table_.__emplace_unique_key_args(
...@@ -1315,7 +1329,7 @@ public:...@@ -1315,7 +1329,7 @@ public:
1315 _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator, key_type&& __k, _Vp&& __v) {1329 _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator, key_type&& __k, _Vp&& __v) {
1316 return insert_or_assign(std::move(__k), std::forward<_Vp>(__v)).first;1330 return insert_or_assign(std::move(__k), std::forward<_Vp>(__v)).first;
1317 }1331 }
1318#endif // _LIBCPP_STD_VER >= 171332# endif // _LIBCPP_STD_VER >= 17
13191333
1320 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p.__i_); }1334 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p.__i_); }
1321 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __table_.erase(__p.__i_); }1335 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __table_.erase(__p.__i_); }
...@@ -1325,7 +1339,7 @@ public:...@@ -1325,7 +1339,7 @@ public:
1325 }1339 }
1326 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); }1340 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); }
13271341
1328#if _LIBCPP_STD_VER >= 171342# if _LIBCPP_STD_VER >= 17
1329 _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {1343 _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {
1330 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),1344 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
1331 "node_type with incompatible allocator passed to unordered_map::insert()");1345 "node_type with incompatible allocator passed to unordered_map::insert()");
...@@ -1367,7 +1381,7 @@ public:...@@ -1367,7 +1381,7 @@ public:
1367 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");1381 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
1368 return __table_.__node_handle_merge_unique(__source.__table_);1382 return __table_.__node_handle_merge_unique(__source.__table_);
1369 }1383 }
1370#endif1384# endif
13711385
1372 _LIBCPP_HIDE_FROM_ABI void swap(unordered_map& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {1386 _LIBCPP_HIDE_FROM_ABI void swap(unordered_map& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {
1373 __table_.swap(__u.__table_);1387 __table_.swap(__u.__table_);
...@@ -1378,7 +1392,7 @@ public:...@@ -1378,7 +1392,7 @@ public:
13781392
1379 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }1393 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
1380 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }1394 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
1381#if _LIBCPP_STD_VER >= 201395# if _LIBCPP_STD_VER >= 20
1382 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>1396 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1383 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {1397 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
1384 return __table_.find(__k);1398 return __table_.find(__k);
...@@ -1387,24 +1401,24 @@ public:...@@ -1387,24 +1401,24 @@ public:
1387 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {1401 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
1388 return __table_.find(__k);1402 return __table_.find(__k);
1389 }1403 }
1390#endif // _LIBCPP_STD_VER >= 201404# endif // _LIBCPP_STD_VER >= 20
13911405
1392 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); }1406 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); }
1393#if _LIBCPP_STD_VER >= 201407# if _LIBCPP_STD_VER >= 20
1394 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>1408 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1395 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {1409 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
1396 return __table_.__count_unique(__k);1410 return __table_.__count_unique(__k);
1397 }1411 }
1398#endif // _LIBCPP_STD_VER >= 201412# endif // _LIBCPP_STD_VER >= 20
13991413
1400#if _LIBCPP_STD_VER >= 201414# if _LIBCPP_STD_VER >= 20
1401 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }1415 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
14021416
1403 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>1417 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1404 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {1418 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
1405 return find(__k) != end();1419 return find(__k) != end();
1406 }1420 }
1407#endif // _LIBCPP_STD_VER >= 201421# endif // _LIBCPP_STD_VER >= 20
14081422
1409 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {1423 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
1410 return __table_.__equal_range_unique(__k);1424 return __table_.__equal_range_unique(__k);
...@@ -1412,7 +1426,7 @@ public:...@@ -1412,7 +1426,7 @@ public:
1412 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {1426 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
1413 return __table_.__equal_range_unique(__k);1427 return __table_.__equal_range_unique(__k);
1414 }1428 }
1415#if _LIBCPP_STD_VER >= 201429# if _LIBCPP_STD_VER >= 20
1416 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>1430 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1417 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {1431 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
1418 return __table_.__equal_range_unique(__k);1432 return __table_.__equal_range_unique(__k);
...@@ -1421,12 +1435,12 @@ public:...@@ -1421,12 +1435,12 @@ public:
1421 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {1435 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
1422 return __table_.__equal_range_unique(__k);1436 return __table_.__equal_range_unique(__k);
1423 }1437 }
1424#endif // _LIBCPP_STD_VER >= 201438# endif // _LIBCPP_STD_VER >= 20
14251439
1426 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k);1440 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k);
1427#ifndef _LIBCPP_CXX03_LANG1441# ifndef _LIBCPP_CXX03_LANG
1428 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k);1442 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k);
1429#endif1443# endif
14301444
1431 _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k);1445 _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k);
1432 _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const;1446 _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const;
...@@ -1451,12 +1465,12 @@ public:...@@ -1451,12 +1465,12 @@ public:
1451 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); }1465 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); }
14521466
1453private:1467private:
1454#ifdef _LIBCPP_CXX03_LANG1468# ifdef _LIBCPP_CXX03_LANG
1455 _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k);1469 _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k);
1456#endif1470# endif
1457};1471};
14581472
1459#if _LIBCPP_STD_VER >= 171473# if _LIBCPP_STD_VER >= 17
1460template <class _InputIterator,1474template <class _InputIterator,
1461 class _Hash = hash<__iter_key_type<_InputIterator>>,1475 class _Hash = hash<__iter_key_type<_InputIterator>>,
1462 class _Pred = equal_to<__iter_key_type<_InputIterator>>,1476 class _Pred = equal_to<__iter_key_type<_InputIterator>>,
...@@ -1474,7 +1488,7 @@ unordered_map(_InputIterator,...@@ -1474,7 +1488,7 @@ unordered_map(_InputIterator,
1474 _Allocator = _Allocator())1488 _Allocator = _Allocator())
1475 -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>;1489 -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>;
14761490
1477# if _LIBCPP_STD_VER >= 231491# if _LIBCPP_STD_VER >= 23
1478template <ranges::input_range _Range,1492template <ranges::input_range _Range,
1479 class _Hash = hash<__range_key_type<_Range>>,1493 class _Hash = hash<__range_key_type<_Range>>,
1480 class _Pred = equal_to<__range_key_type<_Range>>,1494 class _Pred = equal_to<__range_key_type<_Range>>,
...@@ -1490,7 +1504,7 @@ unordered_map(from_range_t,...@@ -1490,7 +1504,7 @@ unordered_map(from_range_t,
1490 _Pred = _Pred(),1504 _Pred = _Pred(),
1491 _Allocator = _Allocator())1505 _Allocator = _Allocator())
1492 -> unordered_map<__range_key_type<_Range>, __range_mapped_type<_Range>, _Hash, _Pred, _Allocator>; // C++231506 -> unordered_map<__range_key_type<_Range>, __range_mapped_type<_Range>, _Hash, _Pred, _Allocator>; // C++23
1493# endif1507# endif
14941508
1495template <class _Key,1509template <class _Key,
1496 class _Tp,1510 class _Tp,
...@@ -1543,7 +1557,7 @@ unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocat...@@ -1543,7 +1557,7 @@ unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocat
1543 equal_to<__iter_key_type<_InputIterator>>,1557 equal_to<__iter_key_type<_InputIterator>>,
1544 _Allocator>;1558 _Allocator>;
15451559
1546# if _LIBCPP_STD_VER >= 231560# if _LIBCPP_STD_VER >= 23
15471561
1548template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>1562template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
1549unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)1563unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)
...@@ -1574,7 +1588,7 @@ unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::siz...@@ -1574,7 +1588,7 @@ unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::siz
1574 equal_to<__range_key_type<_Range>>,1588 equal_to<__range_key_type<_Range>>,
1575 _Allocator>;1589 _Allocator>;
15761590
1577# endif1591# endif
15781592
1579template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>1593template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
1580unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)1594unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)
...@@ -1593,7 +1607,7 @@ template <class _Key,...@@ -1593,7 +1607,7 @@ template <class _Key,
1593 class = enable_if_t<__is_allocator<_Allocator>::value>>1607 class = enable_if_t<__is_allocator<_Allocator>::value>>
1594unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)1608unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1595 -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, equal_to<remove_const_t<_Key>>, _Allocator>;1609 -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, equal_to<remove_const_t<_Key>>, _Allocator>;
1596#endif1610# endif
15971611
1598template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1612template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1599unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(size_type __n, const hasher& __hf, const key_equal& __eql)1613unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(size_type __n, const hasher& __hf, const key_equal& __eql)
...@@ -1654,7 +1668,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const unordered_ma...@@ -1654,7 +1668,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const unordered_ma
1654 insert(__u.begin(), __u.end());1668 insert(__u.begin(), __u.end());
1655}1669}
16561670
1657#ifndef _LIBCPP_CXX03_LANG1671# ifndef _LIBCPP_CXX03_LANG
16581672
1659template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1673template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1660inline unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(unordered_map&& __u)1674inline unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(unordered_map&& __u)
...@@ -1712,7 +1726,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(initializer_list<value...@@ -1712,7 +1726,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(initializer_list<value
1712 return *this;1726 return *this;
1713}1727}
17141728
1715#endif // _LIBCPP_CXX03_LANG1729# endif // _LIBCPP_CXX03_LANG
17161730
1717template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1731template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1718template <class _InputIterator>1732template <class _InputIterator>
...@@ -1721,7 +1735,7 @@ inline void unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterato...@@ -1721,7 +1735,7 @@ inline void unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterato
1721 __table_.__insert_unique(*__first);1735 __table_.__insert_unique(*__first);
1722}1736}
17231737
1724#ifndef _LIBCPP_CXX03_LANG1738# ifndef _LIBCPP_CXX03_LANG
17251739
1726template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1740template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1727_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) {1741_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) {
...@@ -1739,7 +1753,7 @@ _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)...@@ -1739,7 +1753,7 @@ _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
1739 .first->__get_value()1753 .first->__get_value()
1740 .second;1754 .second;
1741}1755}
1742#else // _LIBCPP_CXX03_LANG1756# else // _LIBCPP_CXX03_LANG
17431757
1744template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1758template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1745typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder1759typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
...@@ -1764,7 +1778,7 @@ _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&...@@ -1764,7 +1778,7 @@ _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&
1764 return __r.first->second;1778 return __r.first->second;
1765}1779}
17661780
1767#endif // _LIBCPP_CXX03_LANG1781# endif // _LIBCPP_CXX03_LANG
17681782
1769template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1783template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1770_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) {1784_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) {
...@@ -1789,13 +1803,13 @@ swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_map<_Key, _T...@@ -1789,13 +1803,13 @@ swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_map<_Key, _T
1789 __x.swap(__y);1803 __x.swap(__y);
1790}1804}
17911805
1792#if _LIBCPP_STD_VER >= 201806# if _LIBCPP_STD_VER >= 20
1793template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate>1807template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate>
1794inline _LIBCPP_HIDE_FROM_ABI typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type1808inline _LIBCPP_HIDE_FROM_ABI typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type
1795erase_if(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {1809erase_if(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {
1796 return std::__libcpp_erase_if_container(__c, __pred);1810 return std::__libcpp_erase_if_container(__c, __pred);
1797}1811}
1798#endif1812# endif
17991813
1800template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1814template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1801_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,1815_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
...@@ -1811,7 +1825,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_map<_Key, _Tp, _Hash, _Pre...@@ -1811,7 +1825,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_map<_Key, _Tp, _Hash, _Pre
1811 return true;1825 return true;
1812}1826}
18131827
1814#if _LIBCPP_STD_VER <= 171828# if _LIBCPP_STD_VER <= 17
18151829
1816template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1830template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1817inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,1831inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
...@@ -1819,7 +1833,17 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_map<_Key, _Tp, _Has...@@ -1819,7 +1833,17 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_map<_Key, _Tp, _Has
1819 return !(__x == __y);1833 return !(__x == __y);
1820}1834}
18211835
1822#endif1836# endif
1837
1838template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1839struct __container_traits<unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> > {
1840 // http://eel.is/c++draft/unord.req.except#2
1841 // For unordered associative containers, if an exception is thrown by any operation
1842 // other than the container's hash function from within an insert or emplace function
1843 // inserting a single element, the insertion has no effect.
1844 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
1845 __is_nothrow_invocable_v<_Hash, const _Key&>;
1846};
18231847
1824template <class _Key,1848template <class _Key,
1825 class _Tp,1849 class _Tp,
...@@ -1872,9 +1896,9 @@ public:...@@ -1872,9 +1896,9 @@ public:
1872 typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;1896 typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
1873 typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;1897 typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
18741898
1875#if _LIBCPP_STD_VER >= 171899# if _LIBCPP_STD_VER >= 17
1876 typedef __map_node_handle<__node, allocator_type> node_type;1900 typedef __map_node_handle<__node, allocator_type> node_type;
1877#endif1901# endif
18781902
1879 template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>1903 template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
1880 friend class _LIBCPP_TEMPLATE_VIS unordered_map;1904 friend class _LIBCPP_TEMPLATE_VIS unordered_map;
...@@ -1904,7 +1928,7 @@ public:...@@ -1904,7 +1928,7 @@ public:
1904 const key_equal& __eql,1928 const key_equal& __eql,
1905 const allocator_type& __a);1929 const allocator_type& __a);
19061930
1907#if _LIBCPP_STD_VER >= 231931# if _LIBCPP_STD_VER >= 23
1908 template <_ContainerCompatibleRange<value_type> _Range>1932 template <_ContainerCompatibleRange<value_type> _Range>
1909 _LIBCPP_HIDE_FROM_ABI unordered_multimap(1933 _LIBCPP_HIDE_FROM_ABI unordered_multimap(
1910 from_range_t,1934 from_range_t,
...@@ -1919,12 +1943,12 @@ public:...@@ -1919,12 +1943,12 @@ public:
1919 }1943 }
1920 insert_range(std::forward<_Range>(__range));1944 insert_range(std::forward<_Range>(__range));
1921 }1945 }
1922#endif1946# endif
19231947
1924 _LIBCPP_HIDE_FROM_ABI explicit unordered_multimap(const allocator_type& __a);1948 _LIBCPP_HIDE_FROM_ABI explicit unordered_multimap(const allocator_type& __a);
1925 _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u);1949 _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u);
1926 _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u, const allocator_type& __a);1950 _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u, const allocator_type& __a);
1927#ifndef _LIBCPP_CXX03_LANG1951# ifndef _LIBCPP_CXX03_LANG
1928 _LIBCPP_HIDE_FROM_ABI unordered_multimap(unordered_multimap&& __u)1952 _LIBCPP_HIDE_FROM_ABI unordered_multimap(unordered_multimap&& __u)
1929 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);1953 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
1930 _LIBCPP_HIDE_FROM_ABI unordered_multimap(unordered_multimap&& __u, const allocator_type& __a);1954 _LIBCPP_HIDE_FROM_ABI unordered_multimap(unordered_multimap&& __u, const allocator_type& __a);
...@@ -1940,8 +1964,8 @@ public:...@@ -1940,8 +1964,8 @@ public:
1940 const hasher& __hf,1964 const hasher& __hf,
1941 const key_equal& __eql,1965 const key_equal& __eql,
1942 const allocator_type& __a);1966 const allocator_type& __a);
1943#endif // _LIBCPP_CXX03_LANG1967# endif // _LIBCPP_CXX03_LANG
1944#if _LIBCPP_STD_VER >= 141968# if _LIBCPP_STD_VER >= 14
1945 _LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const allocator_type& __a)1969 _LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const allocator_type& __a)
1946 : unordered_multimap(__n, hasher(), key_equal(), __a) {}1970 : unordered_multimap(__n, hasher(), key_equal(), __a) {}
1947 _LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a)1971 _LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a)
...@@ -1955,7 +1979,7 @@ public:...@@ -1955,7 +1979,7 @@ public:
1955 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)1979 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
1956 : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}1980 : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}
19571981
1958# if _LIBCPP_STD_VER >= 231982# if _LIBCPP_STD_VER >= 23
1959 template <_ContainerCompatibleRange<value_type> _Range>1983 template <_ContainerCompatibleRange<value_type> _Range>
1960 _LIBCPP_HIDE_FROM_ABI unordered_multimap(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)1984 _LIBCPP_HIDE_FROM_ABI unordered_multimap(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
1961 : unordered_multimap(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}1985 : unordered_multimap(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
...@@ -1964,22 +1988,22 @@ public:...@@ -1964,22 +1988,22 @@ public:
1964 _LIBCPP_HIDE_FROM_ABI1988 _LIBCPP_HIDE_FROM_ABI
1965 unordered_multimap(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)1989 unordered_multimap(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
1966 : unordered_multimap(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}1990 : unordered_multimap(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
1967# endif1991# endif
19681992
1969 _LIBCPP_HIDE_FROM_ABI unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)1993 _LIBCPP_HIDE_FROM_ABI unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
1970 : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}1994 : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}
1971 _LIBCPP_HIDE_FROM_ABI1995 _LIBCPP_HIDE_FROM_ABI
1972 unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)1996 unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
1973 : unordered_multimap(__il, __n, __hf, key_equal(), __a) {}1997 : unordered_multimap(__il, __n, __hf, key_equal(), __a) {}
1974#endif1998# endif
1975 _LIBCPP_HIDE_FROM_ABI ~unordered_multimap() {1999 _LIBCPP_HIDE_FROM_ABI ~unordered_multimap() {
1976 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");2000 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
1977 }2001 }
19782002
1979 _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(const unordered_multimap& __u) {2003 _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(const unordered_multimap& __u) {
1980#ifndef _LIBCPP_CXX03_LANG2004# ifndef _LIBCPP_CXX03_LANG
1981 __table_ = __u.__table_;2005 __table_ = __u.__table_;
1982#else2006# else
1983 if (this != std::addressof(__u)) {2007 if (this != std::addressof(__u)) {
1984 __table_.clear();2008 __table_.clear();
1985 __table_.hash_function() = __u.__table_.hash_function();2009 __table_.hash_function() = __u.__table_.hash_function();
...@@ -1988,20 +2012,20 @@ public:...@@ -1988,20 +2012,20 @@ public:
1988 __table_.__copy_assign_alloc(__u.__table_);2012 __table_.__copy_assign_alloc(__u.__table_);
1989 insert(__u.begin(), __u.end());2013 insert(__u.begin(), __u.end());
1990 }2014 }
1991#endif2015# endif
1992 return *this;2016 return *this;
1993 }2017 }
1994#ifndef _LIBCPP_CXX03_LANG2018# ifndef _LIBCPP_CXX03_LANG
1995 _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(unordered_multimap&& __u)2019 _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(unordered_multimap&& __u)
1996 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);2020 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
1997 _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(initializer_list<value_type> __il);2021 _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(initializer_list<value_type> __il);
1998#endif // _LIBCPP_CXX03_LANG2022# endif // _LIBCPP_CXX03_LANG
19992023
2000 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {2024 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
2001 return allocator_type(__table_.__node_alloc());2025 return allocator_type(__table_.__node_alloc());
2002 }2026 }
20032027
2004 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }2028 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
2005 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }2029 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
2006 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }2030 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
20072031
...@@ -2021,16 +2045,16 @@ public:...@@ -2021,16 +2045,16 @@ public:
2021 template <class _InputIterator>2045 template <class _InputIterator>
2022 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);2046 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);
20232047
2024#if _LIBCPP_STD_VER >= 232048# if _LIBCPP_STD_VER >= 23
2025 template <_ContainerCompatibleRange<value_type> _Range>2049 template <_ContainerCompatibleRange<value_type> _Range>
2026 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {2050 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
2027 for (auto&& __element : __range) {2051 for (auto&& __element : __range) {
2028 __table_.__insert_multi(std::forward<decltype(__element)>(__element));2052 __table_.__insert_multi(std::forward<decltype(__element)>(__element));
2029 }2053 }
2030 }2054 }
2031#endif2055# endif
20322056
2033#ifndef _LIBCPP_CXX03_LANG2057# ifndef _LIBCPP_CXX03_LANG
2034 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }2058 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
2035 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__insert_multi(std::move(__x)); }2059 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__insert_multi(std::move(__x)); }
20362060
...@@ -2057,7 +2081,7 @@ public:...@@ -2057,7 +2081,7 @@ public:
2057 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {2081 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {
2058 return __table_.__emplace_hint_multi(__p.__i_, std::forward<_Args>(__args)...);2082 return __table_.__emplace_hint_multi(__p.__i_, std::forward<_Args>(__args)...);
2059 }2083 }
2060#endif // _LIBCPP_CXX03_LANG2084# endif // _LIBCPP_CXX03_LANG
20612085
2062 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p.__i_); }2086 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p.__i_); }
2063 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __table_.erase(__p.__i_); }2087 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __table_.erase(__p.__i_); }
...@@ -2067,7 +2091,7 @@ public:...@@ -2067,7 +2091,7 @@ public:
2067 }2091 }
2068 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); }2092 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); }
20692093
2070#if _LIBCPP_STD_VER >= 172094# if _LIBCPP_STD_VER >= 17
2071 _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {2095 _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {
2072 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),2096 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
2073 "node_type with incompatible allocator passed to unordered_multimap::insert()");2097 "node_type with incompatible allocator passed to unordered_multimap::insert()");
...@@ -2109,7 +2133,7 @@ public:...@@ -2109,7 +2133,7 @@ public:
2109 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");2133 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
2110 return __table_.__node_handle_merge_multi(__source.__table_);2134 return __table_.__node_handle_merge_multi(__source.__table_);
2111 }2135 }
2112#endif2136# endif
21132137
2114 _LIBCPP_HIDE_FROM_ABI void swap(unordered_multimap& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {2138 _LIBCPP_HIDE_FROM_ABI void swap(unordered_multimap& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {
2115 __table_.swap(__u.__table_);2139 __table_.swap(__u.__table_);
...@@ -2120,7 +2144,7 @@ public:...@@ -2120,7 +2144,7 @@ public:
21202144
2121 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }2145 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
2122 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }2146 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
2123#if _LIBCPP_STD_VER >= 202147# if _LIBCPP_STD_VER >= 20
2124 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>2148 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
2125 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {2149 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
2126 return __table_.find(__k);2150 return __table_.find(__k);
...@@ -2129,24 +2153,24 @@ public:...@@ -2129,24 +2153,24 @@ public:
2129 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {2153 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
2130 return __table_.find(__k);2154 return __table_.find(__k);
2131 }2155 }
2132#endif // _LIBCPP_STD_VER >= 202156# endif // _LIBCPP_STD_VER >= 20
21332157
2134 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); }2158 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); }
2135#if _LIBCPP_STD_VER >= 202159# if _LIBCPP_STD_VER >= 20
2136 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>2160 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
2137 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {2161 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
2138 return __table_.__count_multi(__k);2162 return __table_.__count_multi(__k);
2139 }2163 }
2140#endif // _LIBCPP_STD_VER >= 202164# endif // _LIBCPP_STD_VER >= 20
21412165
2142#if _LIBCPP_STD_VER >= 202166# if _LIBCPP_STD_VER >= 20
2143 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }2167 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
21442168
2145 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>2169 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
2146 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {2170 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
2147 return find(__k) != end();2171 return find(__k) != end();
2148 }2172 }
2149#endif // _LIBCPP_STD_VER >= 202173# endif // _LIBCPP_STD_VER >= 20
21502174
2151 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {2175 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
2152 return __table_.__equal_range_multi(__k);2176 return __table_.__equal_range_multi(__k);
...@@ -2154,7 +2178,7 @@ public:...@@ -2154,7 +2178,7 @@ public:
2154 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {2178 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
2155 return __table_.__equal_range_multi(__k);2179 return __table_.__equal_range_multi(__k);
2156 }2180 }
2157#if _LIBCPP_STD_VER >= 202181# if _LIBCPP_STD_VER >= 20
2158 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>2182 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
2159 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {2183 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
2160 return __table_.__equal_range_multi(__k);2184 return __table_.__equal_range_multi(__k);
...@@ -2163,7 +2187,7 @@ public:...@@ -2163,7 +2187,7 @@ public:
2163 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {2187 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
2164 return __table_.__equal_range_multi(__k);2188 return __table_.__equal_range_multi(__k);
2165 }2189 }
2166#endif // _LIBCPP_STD_VER >= 202190# endif // _LIBCPP_STD_VER >= 20
21672191
2168 _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); }2192 _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); }
2169 _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); }2193 _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); }
...@@ -2185,7 +2209,7 @@ public:...@@ -2185,7 +2209,7 @@ public:
2185 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); }2209 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); }
2186};2210};
21872211
2188#if _LIBCPP_STD_VER >= 172212# if _LIBCPP_STD_VER >= 17
2189template <class _InputIterator,2213template <class _InputIterator,
2190 class _Hash = hash<__iter_key_type<_InputIterator>>,2214 class _Hash = hash<__iter_key_type<_InputIterator>>,
2191 class _Pred = equal_to<__iter_key_type<_InputIterator>>,2215 class _Pred = equal_to<__iter_key_type<_InputIterator>>,
...@@ -2207,7 +2231,7 @@ unordered_multimap(_InputIterator,...@@ -2207,7 +2231,7 @@ unordered_multimap(_InputIterator,
2207 _Pred,2231 _Pred,
2208 _Allocator>;2232 _Allocator>;
22092233
2210# if _LIBCPP_STD_VER >= 232234# if _LIBCPP_STD_VER >= 23
2211template <ranges::input_range _Range,2235template <ranges::input_range _Range,
2212 class _Hash = hash<__range_key_type<_Range>>,2236 class _Hash = hash<__range_key_type<_Range>>,
2213 class _Pred = equal_to<__range_key_type<_Range>>,2237 class _Pred = equal_to<__range_key_type<_Range>>,
...@@ -2223,7 +2247,7 @@ unordered_multimap(from_range_t,...@@ -2223,7 +2247,7 @@ unordered_multimap(from_range_t,
2223 _Pred = _Pred(),2247 _Pred = _Pred(),
2224 _Allocator = _Allocator())2248 _Allocator = _Allocator())
2225 -> unordered_multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, _Hash, _Pred, _Allocator>;2249 -> unordered_multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, _Hash, _Pred, _Allocator>;
2226# endif2250# endif
22272251
2228template <class _Key,2252template <class _Key,
2229 class _Tp,2253 class _Tp,
...@@ -2277,7 +2301,7 @@ unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Al...@@ -2277,7 +2301,7 @@ unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Al
2277 equal_to<__iter_key_type<_InputIterator>>,2301 equal_to<__iter_key_type<_InputIterator>>,
2278 _Allocator>;2302 _Allocator>;
22792303
2280# if _LIBCPP_STD_VER >= 232304# if _LIBCPP_STD_VER >= 23
22812305
2282template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>2306template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
2283unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)2307unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)
...@@ -2308,7 +2332,7 @@ unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>...@@ -2308,7 +2332,7 @@ unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>
2308 equal_to<__range_key_type<_Range>>,2332 equal_to<__range_key_type<_Range>>,
2309 _Allocator>;2333 _Allocator>;
23102334
2311# endif2335# endif
23122336
2313template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>2337template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
2314unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)2338unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator)
...@@ -2336,7 +2360,7 @@ template <class _Key,...@@ -2336,7 +2360,7 @@ template <class _Key,
2336unordered_multimap(2360unordered_multimap(
2337 initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)2361 initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
2338 -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, equal_to<remove_const_t<_Key>>, _Allocator>;2362 -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, equal_to<remove_const_t<_Key>>, _Allocator>;
2339#endif2363# endif
23402364
2341template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>2365template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2342unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(2366unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
...@@ -2400,7 +2424,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2400,7 +2424,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2400 insert(__u.begin(), __u.end());2424 insert(__u.begin(), __u.end());
2401}2425}
24022426
2403#ifndef _LIBCPP_CXX03_LANG2427# ifndef _LIBCPP_CXX03_LANG
24042428
2405template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>2429template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2406inline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(unordered_multimap&& __u)2430inline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(unordered_multimap&& __u)
...@@ -2459,7 +2483,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(initializer_list<...@@ -2459,7 +2483,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(initializer_list<
2459 return *this;2483 return *this;
2460}2484}
24612485
2462#endif // _LIBCPP_CXX03_LANG2486# endif // _LIBCPP_CXX03_LANG
24632487
2464template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>2488template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2465template <class _InputIterator>2489template <class _InputIterator>
...@@ -2475,13 +2499,13 @@ swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_multima...@@ -2475,13 +2499,13 @@ swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_multima
2475 __x.swap(__y);2499 __x.swap(__y);
2476}2500}
24772501
2478#if _LIBCPP_STD_VER >= 202502# if _LIBCPP_STD_VER >= 20
2479template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate>2503template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate>
2480inline _LIBCPP_HIDE_FROM_ABI typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type2504inline _LIBCPP_HIDE_FROM_ABI typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type
2481erase_if(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {2505erase_if(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {
2482 return std::__libcpp_erase_if_container(__c, __pred);2506 return std::__libcpp_erase_if_container(__c, __pred);
2483}2507}
2484#endif2508# endif
24852509
2486template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>2510template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2487_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,2511_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
...@@ -2501,7 +2525,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multimap<_Key, _Tp, _Hash,...@@ -2501,7 +2525,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multimap<_Key, _Tp, _Hash,
2501 return true;2525 return true;
2502}2526}
25032527
2504#if _LIBCPP_STD_VER <= 172528# if _LIBCPP_STD_VER <= 17
25052529
2506template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>2530template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2507inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,2531inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
...@@ -2509,11 +2533,21 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multimap<_Key, _Tp,...@@ -2509,11 +2533,21 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multimap<_Key, _Tp,
2509 return !(__x == __y);2533 return !(__x == __y);
2510}2534}
25112535
2512#endif2536# endif
2537
2538template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2539struct __container_traits<unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> > {
2540 // http://eel.is/c++draft/unord.req.except#2
2541 // For unordered associative containers, if an exception is thrown by any operation
2542 // other than the container's hash function from within an insert or emplace function
2543 // inserting a single element, the insertion has no effect.
2544 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
2545 __is_nothrow_invocable_v<_Hash, const _Key&>;
2546};
25132547
2514_LIBCPP_END_NAMESPACE_STD2548_LIBCPP_END_NAMESPACE_STD
25152549
2516#if _LIBCPP_STD_VER >= 172550# if _LIBCPP_STD_VER >= 17
2517_LIBCPP_BEGIN_NAMESPACE_STD2551_LIBCPP_BEGIN_NAMESPACE_STD
2518namespace pmr {2552namespace pmr {
2519template <class _KeyT, class _ValueT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>2553template <class _KeyT, class _ValueT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
...@@ -2525,17 +2559,19 @@ using unordered_multimap _LIBCPP_AVAILABILITY_PMR =...@@ -2525,17 +2559,19 @@ using unordered_multimap _LIBCPP_AVAILABILITY_PMR =
2525 std::unordered_multimap<_KeyT, _ValueT, _HashT, _PredT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;2559 std::unordered_multimap<_KeyT, _ValueT, _HashT, _PredT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
2526} // namespace pmr2560} // namespace pmr
2527_LIBCPP_END_NAMESPACE_STD2561_LIBCPP_END_NAMESPACE_STD
2528#endif2562# endif
25292563
2530_LIBCPP_POP_MACROS2564_LIBCPP_POP_MACROS
25312565
2532#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 202566# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2533# include <algorithm>2567# include <algorithm>
2534# include <bit>2568# include <bit>
2535# include <concepts>2569# include <cmath>
2536# include <cstdlib>2570# include <concepts>
2537# include <iterator>2571# include <cstdlib>
2538# include <type_traits>2572# include <iterator>
2539#endif2573# include <type_traits>
2574# endif
2575#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
25402576
2541#endif // _LIBCPP_UNORDERED_MAP2577#endif // _LIBCPP_UNORDERED_MAP
lib/libcxx/include/unordered_set+165-127
...@@ -531,46 +531,62 @@ template <class Value, class Hash, class Pred, class Alloc>...@@ -531,46 +531,62 @@ template <class Value, class Hash, class Pred, class Alloc>
531531
532// clang-format on532// clang-format on
533533
534#include <__algorithm/is_permutation.h>534#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
535#include <__assert>535# include <__cxx03/unordered_set>
536#include <__config>536#else
537#include <__functional/is_transparent.h>537# include <__algorithm/is_permutation.h>
538#include <__functional/operations.h>538# include <__assert>
539#include <__hash_table>539# include <__config>
540#include <__iterator/distance.h>540# include <__functional/hash.h>
541#include <__iterator/erase_if_container.h>541# include <__functional/is_transparent.h>
542#include <__iterator/iterator_traits.h>542# include <__functional/operations.h>
543#include <__iterator/ranges_iterator_traits.h>543# include <__hash_table>
544#include <__memory/addressof.h>544# include <__iterator/distance.h>
545#include <__memory/allocator.h>545# include <__iterator/erase_if_container.h>
546#include <__memory_resource/polymorphic_allocator.h>546# include <__iterator/iterator_traits.h>
547#include <__node_handle>547# include <__iterator/ranges_iterator_traits.h>
548#include <__ranges/concepts.h>548# include <__memory/addressof.h>
549#include <__ranges/container_compatible_range.h>549# include <__memory/allocator.h>
550#include <__ranges/from_range.h>550# include <__memory/allocator_traits.h>
551#include <__type_traits/is_allocator.h>551# include <__memory_resource/polymorphic_allocator.h>
552#include <__utility/forward.h>552# include <__node_handle>
553#include <version>553# include <__ranges/concepts.h>
554# include <__ranges/container_compatible_range.h>
555# include <__ranges/from_range.h>
556# include <__type_traits/container_traits.h>
557# include <__type_traits/enable_if.h>
558# include <__type_traits/invoke.h>
559# include <__type_traits/is_allocator.h>
560# include <__type_traits/is_integral.h>
561# include <__type_traits/is_nothrow_assignable.h>
562# include <__type_traits/is_nothrow_constructible.h>
563# include <__type_traits/is_same.h>
564# include <__type_traits/is_swappable.h>
565# include <__type_traits/type_identity.h>
566# include <__utility/forward.h>
567# include <__utility/move.h>
568# include <__utility/pair.h>
569# include <version>
554570
555// standard-mandated includes571// standard-mandated includes
556572
557// [iterator.range]573// [iterator.range]
558#include <__iterator/access.h>574# include <__iterator/access.h>
559#include <__iterator/data.h>575# include <__iterator/data.h>
560#include <__iterator/empty.h>576# include <__iterator/empty.h>
561#include <__iterator/reverse_access.h>577# include <__iterator/reverse_access.h>
562#include <__iterator/size.h>578# include <__iterator/size.h>
563579
564// [unord.set.syn]580// [unord.set.syn]
565#include <compare>581# include <compare>
566#include <initializer_list>582# include <initializer_list>
567583
568#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)584# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
569# pragma GCC system_header585# pragma GCC system_header
570#endif586# endif
571587
572_LIBCPP_PUSH_MACROS588_LIBCPP_PUSH_MACROS
573#include <__undef_macros>589# include <__undef_macros>
574590
575_LIBCPP_BEGIN_NAMESPACE_STD591_LIBCPP_BEGIN_NAMESPACE_STD
576592
...@@ -608,10 +624,10 @@ public:...@@ -608,10 +624,10 @@ public:
608 typedef typename __table::const_local_iterator local_iterator;624 typedef typename __table::const_local_iterator local_iterator;
609 typedef typename __table::const_local_iterator const_local_iterator;625 typedef typename __table::const_local_iterator const_local_iterator;
610626
611#if _LIBCPP_STD_VER >= 17627# if _LIBCPP_STD_VER >= 17
612 typedef __set_node_handle<typename __table::__node, allocator_type> node_type;628 typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
613 typedef __insert_return_type<iterator, node_type> insert_return_type;629 typedef __insert_return_type<iterator, node_type> insert_return_type;
614#endif630# endif
615631
616 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>632 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
617 friend class _LIBCPP_TEMPLATE_VIS unordered_set;633 friend class _LIBCPP_TEMPLATE_VIS unordered_set;
...@@ -621,12 +637,12 @@ public:...@@ -621,12 +637,12 @@ public:
621 _LIBCPP_HIDE_FROM_ABI unordered_set() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}637 _LIBCPP_HIDE_FROM_ABI unordered_set() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}
622 explicit _LIBCPP_HIDE_FROM_ABI638 explicit _LIBCPP_HIDE_FROM_ABI
623 unordered_set(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());639 unordered_set(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
624#if _LIBCPP_STD_VER >= 14640# if _LIBCPP_STD_VER >= 14
625 inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const allocator_type& __a)641 inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const allocator_type& __a)
626 : unordered_set(__n, hasher(), key_equal(), __a) {}642 : unordered_set(__n, hasher(), key_equal(), __a) {}
627 inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a)643 inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a)
628 : unordered_set(__n, __hf, key_equal(), __a) {}644 : unordered_set(__n, __hf, key_equal(), __a) {}
629#endif645# endif
630 _LIBCPP_HIDE_FROM_ABI646 _LIBCPP_HIDE_FROM_ABI
631 unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);647 unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);
632 template <class _InputIterator>648 template <class _InputIterator>
...@@ -647,7 +663,7 @@ public:...@@ -647,7 +663,7 @@ public:
647 const key_equal& __eql,663 const key_equal& __eql,
648 const allocator_type& __a);664 const allocator_type& __a);
649665
650#if _LIBCPP_STD_VER >= 23666# if _LIBCPP_STD_VER >= 23
651 template <_ContainerCompatibleRange<value_type> _Range>667 template <_ContainerCompatibleRange<value_type> _Range>
652 _LIBCPP_HIDE_FROM_ABI unordered_set(668 _LIBCPP_HIDE_FROM_ABI unordered_set(
653 from_range_t,669 from_range_t,
...@@ -662,9 +678,9 @@ public:...@@ -662,9 +678,9 @@ public:
662 }678 }
663 insert_range(std::forward<_Range>(__range));679 insert_range(std::forward<_Range>(__range));
664 }680 }
665#endif681# endif
666682
667#if _LIBCPP_STD_VER >= 14683# if _LIBCPP_STD_VER >= 14
668 template <class _InputIterator>684 template <class _InputIterator>
669 inline _LIBCPP_HIDE_FROM_ABI685 inline _LIBCPP_HIDE_FROM_ABI
670 unordered_set(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)686 unordered_set(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
...@@ -673,9 +689,9 @@ public:...@@ -673,9 +689,9 @@ public:
673 _LIBCPP_HIDE_FROM_ABI unordered_set(689 _LIBCPP_HIDE_FROM_ABI unordered_set(
674 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)690 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
675 : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}691 : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
676#endif692# endif
677693
678#if _LIBCPP_STD_VER >= 23694# if _LIBCPP_STD_VER >= 23
679 template <_ContainerCompatibleRange<value_type> _Range>695 template <_ContainerCompatibleRange<value_type> _Range>
680 _LIBCPP_HIDE_FROM_ABI unordered_set(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)696 _LIBCPP_HIDE_FROM_ABI unordered_set(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
681 : unordered_set(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}697 : unordered_set(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
...@@ -684,12 +700,12 @@ public:...@@ -684,12 +700,12 @@ public:
684 _LIBCPP_HIDE_FROM_ABI700 _LIBCPP_HIDE_FROM_ABI
685 unordered_set(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)701 unordered_set(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
686 : unordered_set(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}702 : unordered_set(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
687#endif703# endif
688704
689 _LIBCPP_HIDE_FROM_ABI explicit unordered_set(const allocator_type& __a);705 _LIBCPP_HIDE_FROM_ABI explicit unordered_set(const allocator_type& __a);
690 _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u);706 _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u);
691 _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u, const allocator_type& __a);707 _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u, const allocator_type& __a);
692#ifndef _LIBCPP_CXX03_LANG708# ifndef _LIBCPP_CXX03_LANG
693 _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u) _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);709 _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u) _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
694 _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u, const allocator_type& __a);710 _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u, const allocator_type& __a);
695 _LIBCPP_HIDE_FROM_ABI unordered_set(initializer_list<value_type> __il);711 _LIBCPP_HIDE_FROM_ABI unordered_set(initializer_list<value_type> __il);
...@@ -704,15 +720,15 @@ public:...@@ -704,15 +720,15 @@ public:
704 const hasher& __hf,720 const hasher& __hf,
705 const key_equal& __eql,721 const key_equal& __eql,
706 const allocator_type& __a);722 const allocator_type& __a);
707# if _LIBCPP_STD_VER >= 14723# if _LIBCPP_STD_VER >= 14
708 inline _LIBCPP_HIDE_FROM_ABI724 inline _LIBCPP_HIDE_FROM_ABI
709 unordered_set(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)725 unordered_set(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
710 : unordered_set(__il, __n, hasher(), key_equal(), __a) {}726 : unordered_set(__il, __n, hasher(), key_equal(), __a) {}
711 inline _LIBCPP_HIDE_FROM_ABI727 inline _LIBCPP_HIDE_FROM_ABI
712 unordered_set(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)728 unordered_set(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
713 : unordered_set(__il, __n, __hf, key_equal(), __a) {}729 : unordered_set(__il, __n, __hf, key_equal(), __a) {}
714# endif730# endif
715#endif // _LIBCPP_CXX03_LANG731# endif // _LIBCPP_CXX03_LANG
716 _LIBCPP_HIDE_FROM_ABI ~unordered_set() {732 _LIBCPP_HIDE_FROM_ABI ~unordered_set() {
717 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");733 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
718 }734 }
...@@ -721,17 +737,17 @@ public:...@@ -721,17 +737,17 @@ public:
721 __table_ = __u.__table_;737 __table_ = __u.__table_;
722 return *this;738 return *this;
723 }739 }
724#ifndef _LIBCPP_CXX03_LANG740# ifndef _LIBCPP_CXX03_LANG
725 _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(unordered_set&& __u)741 _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(unordered_set&& __u)
726 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);742 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
727 _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(initializer_list<value_type> __il);743 _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(initializer_list<value_type> __il);
728#endif // _LIBCPP_CXX03_LANG744# endif // _LIBCPP_CXX03_LANG
729745
730 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {746 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
731 return allocator_type(__table_.__node_alloc());747 return allocator_type(__table_.__node_alloc());
732 }748 }
733749
734 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }750 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
735 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }751 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
736 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }752 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
737753
...@@ -742,7 +758,7 @@ public:...@@ -742,7 +758,7 @@ public:
742 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }758 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }
743 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }759 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }
744760
745#ifndef _LIBCPP_CXX03_LANG761# ifndef _LIBCPP_CXX03_LANG
746 template <class... _Args>762 template <class... _Args>
747 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {763 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {
748 return __table_.__emplace_unique(std::forward<_Args>(__args)...);764 return __table_.__emplace_unique(std::forward<_Args>(__args)...);
...@@ -758,21 +774,21 @@ public:...@@ -758,21 +774,21 @@ public:
758 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) { return insert(std::move(__x)).first; }774 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) { return insert(std::move(__x)).first; }
759775
760 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }776 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
761#endif // _LIBCPP_CXX03_LANG777# endif // _LIBCPP_CXX03_LANG
762 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__insert_unique(__x); }778 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__insert_unique(__x); }
763779
764 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; }780 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; }
765 template <class _InputIterator>781 template <class _InputIterator>
766 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);782 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);
767783
768#if _LIBCPP_STD_VER >= 23784# if _LIBCPP_STD_VER >= 23
769 template <_ContainerCompatibleRange<value_type> _Range>785 template <_ContainerCompatibleRange<value_type> _Range>
770 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {786 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
771 for (auto&& __element : __range) {787 for (auto&& __element : __range) {
772 __table_.__insert_unique(std::forward<decltype(__element)>(__element));788 __table_.__insert_unique(std::forward<decltype(__element)>(__element));
773 }789 }
774 }790 }
775#endif791# endif
776792
777 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p); }793 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p); }
778 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_unique(__k); }794 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_unique(__k); }
...@@ -781,7 +797,7 @@ public:...@@ -781,7 +797,7 @@ public:
781 }797 }
782 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); }798 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); }
783799
784#if _LIBCPP_STD_VER >= 17800# if _LIBCPP_STD_VER >= 17
785 _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {801 _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {
786 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),802 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
787 "node_type with incompatible allocator passed to unordered_set::insert()");803 "node_type with incompatible allocator passed to unordered_set::insert()");
...@@ -823,7 +839,7 @@ public:...@@ -823,7 +839,7 @@ public:
823 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");839 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
824 __table_.__node_handle_merge_unique(__source.__table_);840 __table_.__node_handle_merge_unique(__source.__table_);
825 }841 }
826#endif842# endif
827843
828 _LIBCPP_HIDE_FROM_ABI void swap(unordered_set& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {844 _LIBCPP_HIDE_FROM_ABI void swap(unordered_set& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {
829 __table_.swap(__u.__table_);845 __table_.swap(__u.__table_);
...@@ -834,7 +850,7 @@ public:...@@ -834,7 +850,7 @@ public:
834850
835 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }851 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
836 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }852 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
837#if _LIBCPP_STD_VER >= 20853# if _LIBCPP_STD_VER >= 20
838 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>854 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
839 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {855 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
840 return __table_.find(__k);856 return __table_.find(__k);
...@@ -843,24 +859,24 @@ public:...@@ -843,24 +859,24 @@ public:
843 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {859 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
844 return __table_.find(__k);860 return __table_.find(__k);
845 }861 }
846#endif // _LIBCPP_STD_VER >= 20862# endif // _LIBCPP_STD_VER >= 20
847863
848 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); }864 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); }
849#if _LIBCPP_STD_VER >= 20865# if _LIBCPP_STD_VER >= 20
850 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>866 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
851 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {867 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
852 return __table_.__count_unique(__k);868 return __table_.__count_unique(__k);
853 }869 }
854#endif // _LIBCPP_STD_VER >= 20870# endif // _LIBCPP_STD_VER >= 20
855871
856#if _LIBCPP_STD_VER >= 20872# if _LIBCPP_STD_VER >= 20
857 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }873 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
858874
859 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>875 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
860 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {876 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
861 return find(__k) != end();877 return find(__k) != end();
862 }878 }
863#endif // _LIBCPP_STD_VER >= 20879# endif // _LIBCPP_STD_VER >= 20
864880
865 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {881 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
866 return __table_.__equal_range_unique(__k);882 return __table_.__equal_range_unique(__k);
...@@ -868,7 +884,7 @@ public:...@@ -868,7 +884,7 @@ public:
868 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {884 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
869 return __table_.__equal_range_unique(__k);885 return __table_.__equal_range_unique(__k);
870 }886 }
871#if _LIBCPP_STD_VER >= 20887# if _LIBCPP_STD_VER >= 20
872 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>888 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
873 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {889 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
874 return __table_.__equal_range_unique(__k);890 return __table_.__equal_range_unique(__k);
...@@ -877,7 +893,7 @@ public:...@@ -877,7 +893,7 @@ public:
877 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {893 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
878 return __table_.__equal_range_unique(__k);894 return __table_.__equal_range_unique(__k);
879 }895 }
880#endif // _LIBCPP_STD_VER >= 20896# endif // _LIBCPP_STD_VER >= 20
881897
882 _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); }898 _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); }
883 _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); }899 _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); }
...@@ -899,7 +915,7 @@ public:...@@ -899,7 +915,7 @@ public:
899 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); }915 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); }
900};916};
901917
902#if _LIBCPP_STD_VER >= 17918# if _LIBCPP_STD_VER >= 17
903template <class _InputIterator,919template <class _InputIterator,
904 class _Hash = hash<__iter_value_type<_InputIterator>>,920 class _Hash = hash<__iter_value_type<_InputIterator>>,
905 class _Pred = equal_to<__iter_value_type<_InputIterator>>,921 class _Pred = equal_to<__iter_value_type<_InputIterator>>,
...@@ -916,7 +932,7 @@ unordered_set(_InputIterator,...@@ -916,7 +932,7 @@ unordered_set(_InputIterator,
916 _Pred = _Pred(),932 _Pred = _Pred(),
917 _Allocator = _Allocator()) -> unordered_set<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;933 _Allocator = _Allocator()) -> unordered_set<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;
918934
919# if _LIBCPP_STD_VER >= 23935# if _LIBCPP_STD_VER >= 23
920template <ranges::input_range _Range,936template <ranges::input_range _Range,
921 class _Hash = hash<ranges::range_value_t<_Range>>,937 class _Hash = hash<ranges::range_value_t<_Range>>,
922 class _Pred = equal_to<ranges::range_value_t<_Range>>,938 class _Pred = equal_to<ranges::range_value_t<_Range>>,
...@@ -932,7 +948,7 @@ unordered_set(...@@ -932,7 +948,7 @@ unordered_set(
932 _Hash = _Hash(),948 _Hash = _Hash(),
933 _Pred = _Pred(),949 _Pred = _Pred(),
934 _Allocator = _Allocator()) -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23950 _Allocator = _Allocator()) -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23
935# endif951# endif
936952
937template <class _Tp,953template <class _Tp,
938 class _Hash = hash<_Tp>,954 class _Hash = hash<_Tp>,
...@@ -968,7 +984,7 @@ template <class _InputIterator,...@@ -968,7 +984,7 @@ template <class _InputIterator,
968unordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)984unordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
969 -> unordered_set<__iter_value_type<_InputIterator>, _Hash, equal_to<__iter_value_type<_InputIterator>>, _Allocator>;985 -> unordered_set<__iter_value_type<_InputIterator>, _Hash, equal_to<__iter_value_type<_InputIterator>>, _Allocator>;
970986
971# if _LIBCPP_STD_VER >= 23987# if _LIBCPP_STD_VER >= 23
972988
973template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>989template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
974unordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)990unordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)
...@@ -993,7 +1009,7 @@ template <ranges::input_range _Range,...@@ -993,7 +1009,7 @@ template <ranges::input_range _Range,
993unordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)1009unordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
994 -> unordered_set<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>;1010 -> unordered_set<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>;
9951011
996# endif1012# endif
9971013
998template <class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>1014template <class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
999unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)1015unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)
...@@ -1007,7 +1023,7 @@ template <class _Tp,...@@ -1007,7 +1023,7 @@ template <class _Tp,
1007 class = enable_if_t<__is_allocator<_Allocator>::value>>1023 class = enable_if_t<__is_allocator<_Allocator>::value>>
1008unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)1024unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1009 -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>;1025 -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
1010#endif1026# endif
10111027
1012template <class _Value, class _Hash, class _Pred, class _Alloc>1028template <class _Value, class _Hash, class _Pred, class _Alloc>
1013unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql)1029unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql)
...@@ -1067,7 +1083,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const unordered_set&...@@ -1067,7 +1083,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const unordered_set&
1067 insert(__u.begin(), __u.end());1083 insert(__u.begin(), __u.end());
1068}1084}
10691085
1070#ifndef _LIBCPP_CXX03_LANG1086# ifndef _LIBCPP_CXX03_LANG
10711087
1072template <class _Value, class _Hash, class _Pred, class _Alloc>1088template <class _Value, class _Hash, class _Pred, class _Alloc>
1073inline unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(unordered_set&& __u)1089inline unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(unordered_set&& __u)
...@@ -1124,7 +1140,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_ty...@@ -1124,7 +1140,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_ty
1124 return *this;1140 return *this;
1125}1141}
11261142
1127#endif // _LIBCPP_CXX03_LANG1143# endif // _LIBCPP_CXX03_LANG
11281144
1129template <class _Value, class _Hash, class _Pred, class _Alloc>1145template <class _Value, class _Hash, class _Pred, class _Alloc>
1130template <class _InputIterator>1146template <class _InputIterator>
...@@ -1140,13 +1156,13 @@ swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, unordered_set<_Value, _Ha...@@ -1140,13 +1156,13 @@ swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, unordered_set<_Value, _Ha
1140 __x.swap(__y);1156 __x.swap(__y);
1141}1157}
11421158
1143#if _LIBCPP_STD_VER >= 201159# if _LIBCPP_STD_VER >= 20
1144template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>1160template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>
1145inline _LIBCPP_HIDE_FROM_ABI typename unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type1161inline _LIBCPP_HIDE_FROM_ABI typename unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type
1146erase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {1162erase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {
1147 return std::__libcpp_erase_if_container(__c, __pred);1163 return std::__libcpp_erase_if_container(__c, __pred);
1148}1164}
1149#endif1165# endif
11501166
1151template <class _Value, class _Hash, class _Pred, class _Alloc>1167template <class _Value, class _Hash, class _Pred, class _Alloc>
1152_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,1168_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
...@@ -1162,7 +1178,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_set<_Value, _Hash, _Pred,...@@ -1162,7 +1178,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_set<_Value, _Hash, _Pred,
1162 return true;1178 return true;
1163}1179}
11641180
1165#if _LIBCPP_STD_VER <= 171181# if _LIBCPP_STD_VER <= 17
11661182
1167template <class _Value, class _Hash, class _Pred, class _Alloc>1183template <class _Value, class _Hash, class _Pred, class _Alloc>
1168inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,1184inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
...@@ -1170,7 +1186,17 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_set<_Value, _Hash,...@@ -1170,7 +1186,17 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_set<_Value, _Hash,
1170 return !(__x == __y);1186 return !(__x == __y);
1171}1187}
11721188
1173#endif1189# endif
1190
1191template <class _Value, class _Hash, class _Pred, class _Alloc>
1192struct __container_traits<unordered_set<_Value, _Hash, _Pred, _Alloc> > {
1193 // http://eel.is/c++draft/unord.req.except#2
1194 // For unordered associative containers, if an exception is thrown by any operation
1195 // other than the container's hash function from within an insert or emplace function
1196 // inserting a single element, the insertion has no effect.
1197 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
1198 __is_nothrow_invocable_v<_Hash, const _Value&>;
1199};
11741200
1175template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> >1201template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> >
1176class _LIBCPP_TEMPLATE_VIS unordered_multiset {1202class _LIBCPP_TEMPLATE_VIS unordered_multiset {
...@@ -1202,9 +1228,9 @@ public:...@@ -1202,9 +1228,9 @@ public:
1202 typedef typename __table::const_local_iterator local_iterator;1228 typedef typename __table::const_local_iterator local_iterator;
1203 typedef typename __table::const_local_iterator const_local_iterator;1229 typedef typename __table::const_local_iterator const_local_iterator;
12041230
1205#if _LIBCPP_STD_VER >= 171231# if _LIBCPP_STD_VER >= 17
1206 typedef __set_node_handle<typename __table::__node, allocator_type> node_type;1232 typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
1207#endif1233# endif
12081234
1209 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>1235 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
1210 friend class _LIBCPP_TEMPLATE_VIS unordered_set;1236 friend class _LIBCPP_TEMPLATE_VIS unordered_set;
...@@ -1216,12 +1242,12 @@ public:...@@ -1216,12 +1242,12 @@ public:
1216 unordered_multiset(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());1242 unordered_multiset(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
1217 _LIBCPP_HIDE_FROM_ABI1243 _LIBCPP_HIDE_FROM_ABI
1218 unordered_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);1244 unordered_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);
1219#if _LIBCPP_STD_VER >= 141245# if _LIBCPP_STD_VER >= 14
1220 inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const allocator_type& __a)1246 inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const allocator_type& __a)
1221 : unordered_multiset(__n, hasher(), key_equal(), __a) {}1247 : unordered_multiset(__n, hasher(), key_equal(), __a) {}
1222 inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a)1248 inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a)
1223 : unordered_multiset(__n, __hf, key_equal(), __a) {}1249 : unordered_multiset(__n, __hf, key_equal(), __a) {}
1224#endif1250# endif
1225 template <class _InputIterator>1251 template <class _InputIterator>
1226 _LIBCPP_HIDE_FROM_ABI unordered_multiset(_InputIterator __first, _InputIterator __last);1252 _LIBCPP_HIDE_FROM_ABI unordered_multiset(_InputIterator __first, _InputIterator __last);
1227 template <class _InputIterator>1253 template <class _InputIterator>
...@@ -1240,7 +1266,7 @@ public:...@@ -1240,7 +1266,7 @@ public:
1240 const key_equal& __eql,1266 const key_equal& __eql,
1241 const allocator_type& __a);1267 const allocator_type& __a);
12421268
1243#if _LIBCPP_STD_VER >= 231269# if _LIBCPP_STD_VER >= 23
1244 template <_ContainerCompatibleRange<value_type> _Range>1270 template <_ContainerCompatibleRange<value_type> _Range>
1245 _LIBCPP_HIDE_FROM_ABI unordered_multiset(1271 _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1246 from_range_t,1272 from_range_t,
...@@ -1255,9 +1281,9 @@ public:...@@ -1255,9 +1281,9 @@ public:
1255 }1281 }
1256 insert_range(std::forward<_Range>(__range));1282 insert_range(std::forward<_Range>(__range));
1257 }1283 }
1258#endif1284# endif
12591285
1260#if _LIBCPP_STD_VER >= 141286# if _LIBCPP_STD_VER >= 14
1261 template <class _InputIterator>1287 template <class _InputIterator>
1262 inline _LIBCPP_HIDE_FROM_ABI1288 inline _LIBCPP_HIDE_FROM_ABI
1263 unordered_multiset(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)1289 unordered_multiset(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
...@@ -1266,9 +1292,9 @@ public:...@@ -1266,9 +1292,9 @@ public:
1266 inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(1292 inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(
1267 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)1293 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
1268 : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}1294 : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
1269#endif1295# endif
12701296
1271#if _LIBCPP_STD_VER >= 231297# if _LIBCPP_STD_VER >= 23
1272 template <_ContainerCompatibleRange<value_type> _Range>1298 template <_ContainerCompatibleRange<value_type> _Range>
1273 _LIBCPP_HIDE_FROM_ABI unordered_multiset(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)1299 _LIBCPP_HIDE_FROM_ABI unordered_multiset(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
1274 : unordered_multiset(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}1300 : unordered_multiset(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
...@@ -1277,12 +1303,12 @@ public:...@@ -1277,12 +1303,12 @@ public:
1277 _LIBCPP_HIDE_FROM_ABI1303 _LIBCPP_HIDE_FROM_ABI
1278 unordered_multiset(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)1304 unordered_multiset(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
1279 : unordered_multiset(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}1305 : unordered_multiset(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
1280#endif1306# endif
12811307
1282 _LIBCPP_HIDE_FROM_ABI explicit unordered_multiset(const allocator_type& __a);1308 _LIBCPP_HIDE_FROM_ABI explicit unordered_multiset(const allocator_type& __a);
1283 _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u);1309 _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u);
1284 _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);1310 _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
1285#ifndef _LIBCPP_CXX03_LANG1311# ifndef _LIBCPP_CXX03_LANG
1286 _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u)1312 _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u)
1287 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);1313 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
1288 _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);1314 _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
...@@ -1298,15 +1324,15 @@ public:...@@ -1298,15 +1324,15 @@ public:
1298 const hasher& __hf,1324 const hasher& __hf,
1299 const key_equal& __eql,1325 const key_equal& __eql,
1300 const allocator_type& __a);1326 const allocator_type& __a);
1301# if _LIBCPP_STD_VER >= 141327# if _LIBCPP_STD_VER >= 14
1302 inline _LIBCPP_HIDE_FROM_ABI1328 inline _LIBCPP_HIDE_FROM_ABI
1303 unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)1329 unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
1304 : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {}1330 : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {}
1305 inline _LIBCPP_HIDE_FROM_ABI1331 inline _LIBCPP_HIDE_FROM_ABI
1306 unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)1332 unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
1307 : unordered_multiset(__il, __n, __hf, key_equal(), __a) {}1333 : unordered_multiset(__il, __n, __hf, key_equal(), __a) {}
1308# endif1334# endif
1309#endif // _LIBCPP_CXX03_LANG1335# endif // _LIBCPP_CXX03_LANG
1310 _LIBCPP_HIDE_FROM_ABI ~unordered_multiset() {1336 _LIBCPP_HIDE_FROM_ABI ~unordered_multiset() {
1311 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");1337 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
1312 }1338 }
...@@ -1315,17 +1341,17 @@ public:...@@ -1315,17 +1341,17 @@ public:
1315 __table_ = __u.__table_;1341 __table_ = __u.__table_;
1316 return *this;1342 return *this;
1317 }1343 }
1318#ifndef _LIBCPP_CXX03_LANG1344# ifndef _LIBCPP_CXX03_LANG
1319 _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(unordered_multiset&& __u)1345 _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(unordered_multiset&& __u)
1320 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);1346 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
1321 _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(initializer_list<value_type> __il);1347 _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(initializer_list<value_type> __il);
1322#endif // _LIBCPP_CXX03_LANG1348# endif // _LIBCPP_CXX03_LANG
13231349
1324 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {1350 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
1325 return allocator_type(__table_.__node_alloc());1351 return allocator_type(__table_.__node_alloc());
1326 }1352 }
13271353
1328 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }1354 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
1329 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }1355 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
1330 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }1356 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
13311357
...@@ -1336,7 +1362,7 @@ public:...@@ -1336,7 +1362,7 @@ public:
1336 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }1362 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }
1337 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }1363 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }
13381364
1339#ifndef _LIBCPP_CXX03_LANG1365# ifndef _LIBCPP_CXX03_LANG
1340 template <class... _Args>1366 template <class... _Args>
1341 _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {1367 _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {
1342 return __table_.__emplace_multi(std::forward<_Args>(__args)...);1368 return __table_.__emplace_multi(std::forward<_Args>(__args)...);
...@@ -1351,7 +1377,7 @@ public:...@@ -1351,7 +1377,7 @@ public:
1351 return __table_.__insert_multi(__p, std::move(__x));1377 return __table_.__insert_multi(__p, std::move(__x));
1352 }1378 }
1353 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }1379 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
1354#endif // _LIBCPP_CXX03_LANG1380# endif // _LIBCPP_CXX03_LANG
13551381
1356 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); }1382 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); }
13571383
...@@ -1362,16 +1388,16 @@ public:...@@ -1362,16 +1388,16 @@ public:
1362 template <class _InputIterator>1388 template <class _InputIterator>
1363 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);1389 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);
13641390
1365#if _LIBCPP_STD_VER >= 231391# if _LIBCPP_STD_VER >= 23
1366 template <_ContainerCompatibleRange<value_type> _Range>1392 template <_ContainerCompatibleRange<value_type> _Range>
1367 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {1393 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
1368 for (auto&& __element : __range) {1394 for (auto&& __element : __range) {
1369 __table_.__insert_multi(std::forward<decltype(__element)>(__element));1395 __table_.__insert_multi(std::forward<decltype(__element)>(__element));
1370 }1396 }
1371 }1397 }
1372#endif1398# endif
13731399
1374#if _LIBCPP_STD_VER >= 171400# if _LIBCPP_STD_VER >= 17
1375 _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {1401 _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {
1376 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),1402 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
1377 "node_type with incompatible allocator passed to unordered_multiset::insert()");1403 "node_type with incompatible allocator passed to unordered_multiset::insert()");
...@@ -1413,7 +1439,7 @@ public:...@@ -1413,7 +1439,7 @@ public:
1413 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");1439 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
1414 return __table_.__node_handle_merge_multi(__source.__table_);1440 return __table_.__node_handle_merge_multi(__source.__table_);
1415 }1441 }
1416#endif1442# endif
14171443
1418 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p); }1444 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p); }
1419 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_multi(__k); }1445 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_multi(__k); }
...@@ -1431,7 +1457,7 @@ public:...@@ -1431,7 +1457,7 @@ public:
14311457
1432 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }1458 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
1433 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }1459 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
1434#if _LIBCPP_STD_VER >= 201460# if _LIBCPP_STD_VER >= 20
1435 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>1461 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1436 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {1462 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
1437 return __table_.find(__k);1463 return __table_.find(__k);
...@@ -1440,24 +1466,24 @@ public:...@@ -1440,24 +1466,24 @@ public:
1440 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {1466 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
1441 return __table_.find(__k);1467 return __table_.find(__k);
1442 }1468 }
1443#endif // _LIBCPP_STD_VER >= 201469# endif // _LIBCPP_STD_VER >= 20
14441470
1445 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); }1471 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); }
1446#if _LIBCPP_STD_VER >= 201472# if _LIBCPP_STD_VER >= 20
1447 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>1473 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1448 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {1474 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
1449 return __table_.__count_multi(__k);1475 return __table_.__count_multi(__k);
1450 }1476 }
1451#endif // _LIBCPP_STD_VER >= 201477# endif // _LIBCPP_STD_VER >= 20
14521478
1453#if _LIBCPP_STD_VER >= 201479# if _LIBCPP_STD_VER >= 20
1454 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }1480 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
14551481
1456 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>1482 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1457 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {1483 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
1458 return find(__k) != end();1484 return find(__k) != end();
1459 }1485 }
1460#endif // _LIBCPP_STD_VER >= 201486# endif // _LIBCPP_STD_VER >= 20
14611487
1462 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {1488 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
1463 return __table_.__equal_range_multi(__k);1489 return __table_.__equal_range_multi(__k);
...@@ -1465,7 +1491,7 @@ public:...@@ -1465,7 +1491,7 @@ public:
1465 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {1491 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
1466 return __table_.__equal_range_multi(__k);1492 return __table_.__equal_range_multi(__k);
1467 }1493 }
1468#if _LIBCPP_STD_VER >= 201494# if _LIBCPP_STD_VER >= 20
1469 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>1495 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1470 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {1496 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
1471 return __table_.__equal_range_multi(__k);1497 return __table_.__equal_range_multi(__k);
...@@ -1474,7 +1500,7 @@ public:...@@ -1474,7 +1500,7 @@ public:
1474 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {1500 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
1475 return __table_.__equal_range_multi(__k);1501 return __table_.__equal_range_multi(__k);
1476 }1502 }
1477#endif // _LIBCPP_STD_VER >= 201503# endif // _LIBCPP_STD_VER >= 20
14781504
1479 _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); }1505 _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); }
1480 _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); }1506 _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); }
...@@ -1496,7 +1522,7 @@ public:...@@ -1496,7 +1522,7 @@ public:
1496 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); }1522 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); }
1497};1523};
14981524
1499#if _LIBCPP_STD_VER >= 171525# if _LIBCPP_STD_VER >= 17
1500template <class _InputIterator,1526template <class _InputIterator,
1501 class _Hash = hash<__iter_value_type<_InputIterator>>,1527 class _Hash = hash<__iter_value_type<_InputIterator>>,
1502 class _Pred = equal_to<__iter_value_type<_InputIterator>>,1528 class _Pred = equal_to<__iter_value_type<_InputIterator>>,
...@@ -1514,7 +1540,7 @@ unordered_multiset(...@@ -1514,7 +1540,7 @@ unordered_multiset(
1514 _Pred = _Pred(),1540 _Pred = _Pred(),
1515 _Allocator = _Allocator()) -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;1541 _Allocator = _Allocator()) -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>;
15161542
1517# if _LIBCPP_STD_VER >= 231543# if _LIBCPP_STD_VER >= 23
1518template <ranges::input_range _Range,1544template <ranges::input_range _Range,
1519 class _Hash = hash<ranges::range_value_t<_Range>>,1545 class _Hash = hash<ranges::range_value_t<_Range>>,
1520 class _Pred = equal_to<ranges::range_value_t<_Range>>,1546 class _Pred = equal_to<ranges::range_value_t<_Range>>,
...@@ -1530,7 +1556,7 @@ unordered_multiset(...@@ -1530,7 +1556,7 @@ unordered_multiset(
1530 _Hash = _Hash(),1556 _Hash = _Hash(),
1531 _Pred = _Pred(),1557 _Pred = _Pred(),
1532 _Allocator = _Allocator()) -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++231558 _Allocator = _Allocator()) -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23
1533# endif1559# endif
15341560
1535template <class _Tp,1561template <class _Tp,
1536 class _Hash = hash<_Tp>,1562 class _Hash = hash<_Tp>,
...@@ -1569,7 +1595,7 @@ unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Al...@@ -1569,7 +1595,7 @@ unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Al
1569 equal_to<__iter_value_type<_InputIterator>>,1595 equal_to<__iter_value_type<_InputIterator>>,
1570 _Allocator>;1596 _Allocator>;
15711597
1572# if _LIBCPP_STD_VER >= 231598# if _LIBCPP_STD_VER >= 23
15731599
1574template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>1600template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
1575unordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)1601unordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator)
...@@ -1594,7 +1620,7 @@ template <ranges::input_range _Range,...@@ -1594,7 +1620,7 @@ template <ranges::input_range _Range,
1594unordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)1620unordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1595 -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>;1621 -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>;
15961622
1597# endif1623# endif
15981624
1599template <class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>1625template <class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>>
1600unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)1626unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator)
...@@ -1608,7 +1634,7 @@ template <class _Tp,...@@ -1608,7 +1634,7 @@ template <class _Tp,
1608 class = enable_if_t<__is_allocator<_Allocator>::value>>1634 class = enable_if_t<__is_allocator<_Allocator>::value>>
1609unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)1635unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator)
1610 -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>;1636 -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
1611#endif1637# endif
16121638
1613template <class _Value, class _Hash, class _Pred, class _Alloc>1639template <class _Value, class _Hash, class _Pred, class _Alloc>
1614unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(1640unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
...@@ -1672,7 +1698,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1672,7 +1698,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1672 insert(__u.begin(), __u.end());1698 insert(__u.begin(), __u.end());
1673}1699}
16741700
1675#ifndef _LIBCPP_CXX03_LANG1701# ifndef _LIBCPP_CXX03_LANG
16761702
1677template <class _Value, class _Hash, class _Pred, class _Alloc>1703template <class _Value, class _Hash, class _Pred, class _Alloc>
1678inline unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(unordered_multiset&& __u)1704inline unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(unordered_multiset&& __u)
...@@ -1730,7 +1756,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<val...@@ -1730,7 +1756,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<val
1730 return *this;1756 return *this;
1731}1757}
17321758
1733#endif // _LIBCPP_CXX03_LANG1759# endif // _LIBCPP_CXX03_LANG
17341760
1735template <class _Value, class _Hash, class _Pred, class _Alloc>1761template <class _Value, class _Hash, class _Pred, class _Alloc>
1736template <class _InputIterator>1762template <class _InputIterator>
...@@ -1746,13 +1772,13 @@ swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, unordered_multiset<_...@@ -1746,13 +1772,13 @@ swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, unordered_multiset<_
1746 __x.swap(__y);1772 __x.swap(__y);
1747}1773}
17481774
1749#if _LIBCPP_STD_VER >= 201775# if _LIBCPP_STD_VER >= 20
1750template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>1776template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>
1751inline _LIBCPP_HIDE_FROM_ABI typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::size_type1777inline _LIBCPP_HIDE_FROM_ABI typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::size_type
1752erase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {1778erase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) {
1753 return std::__libcpp_erase_if_container(__c, __pred);1779 return std::__libcpp_erase_if_container(__c, __pred);
1754}1780}
1755#endif1781# endif
17561782
1757template <class _Value, class _Hash, class _Pred, class _Alloc>1783template <class _Value, class _Hash, class _Pred, class _Alloc>
1758_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,1784_LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
...@@ -1772,7 +1798,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multiset<_Value, _Hash, _P...@@ -1772,7 +1798,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multiset<_Value, _Hash, _P
1772 return true;1798 return true;
1773}1799}
17741800
1775#if _LIBCPP_STD_VER <= 171801# if _LIBCPP_STD_VER <= 17
17761802
1777template <class _Value, class _Hash, class _Pred, class _Alloc>1803template <class _Value, class _Hash, class _Pred, class _Alloc>
1778inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,1804inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
...@@ -1780,11 +1806,21 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multiset<_Value, _H...@@ -1780,11 +1806,21 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multiset<_Value, _H
1780 return !(__x == __y);1806 return !(__x == __y);
1781}1807}
17821808
1783#endif1809# endif
1810
1811template <class _Value, class _Hash, class _Pred, class _Alloc>
1812struct __container_traits<unordered_multiset<_Value, _Hash, _Pred, _Alloc> > {
1813 // http://eel.is/c++draft/unord.req.except#2
1814 // For unordered associative containers, if an exception is thrown by any operation
1815 // other than the container's hash function from within an insert or emplace function
1816 // inserting a single element, the insertion has no effect.
1817 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
1818 __is_nothrow_invocable_v<_Hash, const _Value&>;
1819};
17841820
1785_LIBCPP_END_NAMESPACE_STD1821_LIBCPP_END_NAMESPACE_STD
17861822
1787#if _LIBCPP_STD_VER >= 171823# if _LIBCPP_STD_VER >= 17
1788_LIBCPP_BEGIN_NAMESPACE_STD1824_LIBCPP_BEGIN_NAMESPACE_STD
1789namespace pmr {1825namespace pmr {
1790template <class _KeyT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>1826template <class _KeyT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
...@@ -1795,17 +1831,19 @@ using unordered_multiset _LIBCPP_AVAILABILITY_PMR =...@@ -1795,17 +1831,19 @@ using unordered_multiset _LIBCPP_AVAILABILITY_PMR =
1795 std::unordered_multiset<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>;1831 std::unordered_multiset<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>;
1796} // namespace pmr1832} // namespace pmr
1797_LIBCPP_END_NAMESPACE_STD1833_LIBCPP_END_NAMESPACE_STD
1798#endif1834# endif
17991835
1800_LIBCPP_POP_MACROS1836_LIBCPP_POP_MACROS
18011837
1802#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 201838# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1803# include <concepts>1839# include <cmath>
1804# include <cstdlib>1840# include <concepts>
1805# include <functional>1841# include <cstdlib>
1806# include <iterator>1842# include <functional>
1807# include <stdexcept>1843# include <iterator>
1808# include <type_traits>1844# include <stdexcept>
1809#endif1845# include <type_traits>
1846# endif
1847#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
18101848
1811#endif // _LIBCPP_UNORDERED_SET1849#endif // _LIBCPP_UNORDERED_SET
lib/libcxx/include/utility+55-50
...@@ -246,64 +246,69 @@ template <class T>...@@ -246,64 +246,69 @@ template <class T>
246246
247*/247*/
248248
249#include <__config>249#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
250250# include <__cxx03/utility>
251#include <__utility/declval.h>251#else
252#include <__utility/forward.h>252# include <__config>
253#include <__utility/move.h>253
254#include <__utility/pair.h>254# include <__utility/declval.h>
255#include <__utility/piecewise_construct.h>255# include <__utility/forward.h>
256#include <__utility/rel_ops.h>256# include <__utility/move.h>
257#include <__utility/swap.h>257# include <__utility/pair.h>
258258# include <__utility/piecewise_construct.h>
259#if _LIBCPP_STD_VER >= 14259# include <__utility/rel_ops.h>
260# include <__utility/exchange.h>260# include <__utility/swap.h>
261# include <__utility/integer_sequence.h>261
262#endif262# if _LIBCPP_STD_VER >= 14
263263# include <__utility/exchange.h>
264#if _LIBCPP_STD_VER >= 17264# include <__utility/integer_sequence.h>
265# include <__utility/as_const.h>265# endif
266# include <__utility/in_place.h>266
267#endif267# if _LIBCPP_STD_VER >= 17
268268# include <__utility/as_const.h>
269#if _LIBCPP_STD_VER >= 20269# include <__utility/in_place.h>
270# include <__utility/cmp.h>270# endif
271#endif271
272272# if _LIBCPP_STD_VER >= 20
273#if _LIBCPP_STD_VER >= 23273# include <__utility/cmp.h>
274# include <__utility/forward_like.h>274# endif
275# include <__utility/to_underlying.h>275
276# include <__utility/unreachable.h>276# if _LIBCPP_STD_VER >= 23
277#endif277# include <__utility/forward_like.h>
278278# include <__utility/to_underlying.h>
279#include <version>279# include <__utility/unreachable.h>
280# endif
281
282# include <version>
280283
281// standard-mandated includes284// standard-mandated includes
282285
283// [utility.syn]286// [utility.syn]
284#include <compare>287# include <compare>
285#include <initializer_list>288# include <initializer_list>
286289
287// [tuple.creation]290// [tuple.creation]
288291
289#include <__tuple/ignore.h>292# include <__tuple/ignore.h>
290293
291// [tuple.helper]294// [tuple.helper]
292#include <__tuple/tuple_element.h>295# include <__tuple/tuple_element.h>
293#include <__tuple/tuple_size.h>296# include <__tuple/tuple_size.h>
294297
295#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)298# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
296# pragma GCC system_header299# pragma GCC system_header
297#endif300# endif
298301
299#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20302# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
300# include <limits>303# include <limits>
301#endif304# endif
302305
303#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20306# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
304# include <cstdlib>307# include <cstddef>
305# include <iosfwd>308# include <cstdlib>
306# include <type_traits>309# include <iosfwd>
307#endif310# include <type_traits>
311# endif
312#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
308313
309#endif // _LIBCPP_UTILITY314#endif // _LIBCPP_UTILITY
lib/libcxx/include/valarray+114-105
...@@ -343,39 +343,41 @@ template <class T> unspecified2 end(const valarray<T>& v);...@@ -343,39 +343,41 @@ template <class T> unspecified2 end(const valarray<T>& v);
343343
344*/344*/
345345
346#include <__algorithm/copy.h>346#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
347#include <__algorithm/count.h>347# include <__cxx03/valarray>
348#include <__algorithm/fill.h>348#else
349#include <__algorithm/max_element.h>349# include <__algorithm/copy.h>
350#include <__algorithm/min.h>350# include <__algorithm/count.h>
351#include <__algorithm/min_element.h>351# include <__algorithm/fill.h>
352#include <__algorithm/unwrap_iter.h>352# include <__algorithm/max_element.h>
353#include <__assert>353# include <__algorithm/min.h>
354#include <__config>354# include <__algorithm/min_element.h>
355#include <__functional/operations.h>355# include <__algorithm/unwrap_iter.h>
356#include <__memory/addressof.h>356# include <__assert>
357#include <__memory/allocator.h>357# include <__config>
358#include <__memory/uninitialized_algorithms.h>358# include <__cstddef/ptrdiff_t.h>
359#include <__type_traits/decay.h>359# include <__functional/operations.h>
360#include <__type_traits/remove_reference.h>360# include <__memory/addressof.h>
361#include <__utility/move.h>361# include <__memory/allocator.h>
362#include <__utility/swap.h>362# include <__memory/uninitialized_algorithms.h>
363#include <cmath>363# include <__type_traits/decay.h>
364#include <cstddef>364# include <__type_traits/remove_reference.h>
365#include <new>365# include <__utility/move.h>
366#include <version>366# include <__utility/swap.h>
367# include <cmath>
368# include <version>
367369
368// standard-mandated includes370// standard-mandated includes
369371
370// [valarray.syn]372// [valarray.syn]
371#include <initializer_list>373# include <initializer_list>
372374
373#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)375# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
374# pragma GCC system_header376# pragma GCC system_header
375#endif377# endif
376378
377_LIBCPP_PUSH_MACROS379_LIBCPP_PUSH_MACROS
378#include <__undef_macros>380# include <__undef_macros>
379381
380_LIBCPP_BEGIN_NAMESPACE_STD382_LIBCPP_BEGIN_NAMESPACE_STD
381383
...@@ -397,13 +399,13 @@ public:...@@ -397,13 +399,13 @@ public:
397 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }399 _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; }
398 _LIBCPP_HIDE_FROM_ABI size_t stride() const { return __stride_; }400 _LIBCPP_HIDE_FROM_ABI size_t stride() const { return __stride_; }
399401
400#if _LIBCPP_STD_VER >= 20402# if _LIBCPP_STD_VER >= 20
401403
402 _LIBCPP_HIDE_FROM_ABI friend bool operator==(const slice& __x, const slice& __y) {404 _LIBCPP_HIDE_FROM_ABI friend bool operator==(const slice& __x, const slice& __y) {
403 return __x.start() == __y.start() && __x.size() == __y.size() && __x.stride() == __y.stride();405 return __x.start() == __y.start() && __x.size() == __y.size() && __x.stride() == __y.stride();
404 }406 }
405407
406#endif408# endif
407};409};
408410
409template <class _Tp>411template <class _Tp>
...@@ -794,10 +796,10 @@ public:...@@ -794,10 +796,10 @@ public:
794 _LIBCPP_HIDE_FROM_ABI valarray(const value_type& __x, size_t __n);796 _LIBCPP_HIDE_FROM_ABI valarray(const value_type& __x, size_t __n);
795 valarray(const value_type* __p, size_t __n);797 valarray(const value_type* __p, size_t __n);
796 valarray(const valarray& __v);798 valarray(const valarray& __v);
797#ifndef _LIBCPP_CXX03_LANG799# ifndef _LIBCPP_CXX03_LANG
798 _LIBCPP_HIDE_FROM_ABI valarray(valarray&& __v) _NOEXCEPT;800 _LIBCPP_HIDE_FROM_ABI valarray(valarray&& __v) _NOEXCEPT;
799 valarray(initializer_list<value_type> __il);801 valarray(initializer_list<value_type> __il);
800#endif // _LIBCPP_CXX03_LANG802# endif // _LIBCPP_CXX03_LANG
801 valarray(const slice_array<value_type>& __sa);803 valarray(const slice_array<value_type>& __sa);
802 valarray(const gslice_array<value_type>& __ga);804 valarray(const gslice_array<value_type>& __ga);
803 valarray(const mask_array<value_type>& __ma);805 valarray(const mask_array<value_type>& __ma);
...@@ -806,10 +808,10 @@ public:...@@ -806,10 +808,10 @@ public:
806808
807 // assignment:809 // assignment:
808 valarray& operator=(const valarray& __v);810 valarray& operator=(const valarray& __v);
809#ifndef _LIBCPP_CXX03_LANG811# ifndef _LIBCPP_CXX03_LANG
810 _LIBCPP_HIDE_FROM_ABI valarray& operator=(valarray&& __v) _NOEXCEPT;812 _LIBCPP_HIDE_FROM_ABI valarray& operator=(valarray&& __v) _NOEXCEPT;
811 _LIBCPP_HIDE_FROM_ABI valarray& operator=(initializer_list<value_type>);813 _LIBCPP_HIDE_FROM_ABI valarray& operator=(initializer_list<value_type>);
812#endif // _LIBCPP_CXX03_LANG814# endif // _LIBCPP_CXX03_LANG
813 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const value_type& __x);815 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const value_type& __x);
814 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const slice_array<value_type>& __sa);816 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const slice_array<value_type>& __sa);
815 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const gslice_array<value_type>& __ga);817 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const gslice_array<value_type>& __ga);
...@@ -819,31 +821,37 @@ public:...@@ -819,31 +821,37 @@ public:
819 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const __val_expr<_ValExpr>& __v);821 _LIBCPP_HIDE_FROM_ABI valarray& operator=(const __val_expr<_ValExpr>& __v);
820822
821 // element access:823 // element access:
822 _LIBCPP_HIDE_FROM_ABI const value_type& operator[](size_t __i) const { return __begin_[__i]; }824 _LIBCPP_HIDE_FROM_ABI const value_type& operator[](size_t __i) const {
825 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds");
826 return __begin_[__i];
827 }
823828
824 _LIBCPP_HIDE_FROM_ABI value_type& operator[](size_t __i) { return __begin_[__i]; }829 _LIBCPP_HIDE_FROM_ABI value_type& operator[](size_t __i) {
830 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds");
831 return __begin_[__i];
832 }
825833
826 // subset operations:834 // subset operations:
827 _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;835 _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;
828 _LIBCPP_HIDE_FROM_ABI slice_array<value_type> operator[](slice __s);836 _LIBCPP_HIDE_FROM_ABI slice_array<value_type> operator[](slice __s);
829 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;837 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
830 _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](const gslice& __gs);838 _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](const gslice& __gs);
831#ifndef _LIBCPP_CXX03_LANG839# ifndef _LIBCPP_CXX03_LANG
832 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;840 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
833 _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](gslice&& __gs);841 _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](gslice&& __gs);
834#endif // _LIBCPP_CXX03_LANG842# endif // _LIBCPP_CXX03_LANG
835 _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;843 _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;
836 _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](const valarray<bool>& __vb);844 _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](const valarray<bool>& __vb);
837#ifndef _LIBCPP_CXX03_LANG845# ifndef _LIBCPP_CXX03_LANG
838 _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;846 _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;
839 _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](valarray<bool>&& __vb);847 _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](valarray<bool>&& __vb);
840#endif // _LIBCPP_CXX03_LANG848# endif // _LIBCPP_CXX03_LANG
841 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;849 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
842 _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](const valarray<size_t>& __vs);850 _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](const valarray<size_t>& __vs);
843#ifndef _LIBCPP_CXX03_LANG851# ifndef _LIBCPP_CXX03_LANG
844 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;852 _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
845 _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](valarray<size_t>&& __vs);853 _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](valarray<size_t>&& __vs);
846#endif // _LIBCPP_CXX03_LANG854# endif // _LIBCPP_CXX03_LANG
847855
848 // unary operators:856 // unary operators:
849 _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const;857 _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const;
...@@ -942,10 +950,10 @@ private:...@@ -942,10 +950,10 @@ private:
942 valarray& __assign_range(const value_type* __f, const value_type* __l);950 valarray& __assign_range(const value_type* __f, const value_type* __l);
943};951};
944952
945#if _LIBCPP_STD_VER >= 17953# if _LIBCPP_STD_VER >= 17
946template <class _Tp, size_t _Size>954template <class _Tp, size_t _Size>
947valarray(const _Tp (&)[_Size], size_t) -> valarray<_Tp>;955valarray(const _Tp (&)[_Size], size_t) -> valarray<_Tp>;
948#endif956# endif
949957
950template <class _Expr,958template <class _Expr,
951 __enable_if_t<__is_val_expr<_Expr>::value && __val_expr_use_member_functions<_Expr>::value, int> = 0>959 __enable_if_t<__is_val_expr<_Expr>::value && __val_expr_use_member_functions<_Expr>::value, int> = 0>
...@@ -1221,7 +1229,7 @@ public:...@@ -1221,7 +1229,7 @@ public:
1221 __init(__start);1229 __init(__start);
1222 }1230 }
12231231
1224#ifndef _LIBCPP_CXX03_LANG1232# ifndef _LIBCPP_CXX03_LANG
12251233
1226 _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, const valarray<size_t>& __size, valarray<size_t>&& __stride)1234 _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, const valarray<size_t>& __size, valarray<size_t>&& __stride)
1227 : __size_(__size), __stride_(std::move(__stride)) {1235 : __size_(__size), __stride_(std::move(__stride)) {
...@@ -1238,7 +1246,7 @@ public:...@@ -1238,7 +1246,7 @@ public:
1238 __init(__start);1246 __init(__start);
1239 }1247 }
12401248
1241#endif // _LIBCPP_CXX03_LANG1249# endif // _LIBCPP_CXX03_LANG
12421250
1243 _LIBCPP_HIDE_FROM_ABI size_t start() const { return __1d_.size() ? __1d_[0] : 0; }1251 _LIBCPP_HIDE_FROM_ABI size_t start() const { return __1d_.size() ? __1d_[0] : 0; }
12441252
...@@ -1318,10 +1326,10 @@ private:...@@ -1318,10 +1326,10 @@ private:
1318 gslice_array(const gslice& __gs, const valarray<value_type>& __v)1326 gslice_array(const gslice& __gs, const valarray<value_type>& __v)
1319 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__gs.__1d_) {}1327 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__gs.__1d_) {}
13201328
1321#ifndef _LIBCPP_CXX03_LANG1329# ifndef _LIBCPP_CXX03_LANG
1322 gslice_array(gslice&& __gs, const valarray<value_type>& __v)1330 gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1323 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__gs.__1d_)) {}1331 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__gs.__1d_)) {}
1324#endif // _LIBCPP_CXX03_LANG1332# endif // _LIBCPP_CXX03_LANG
13251333
1326 template <class>1334 template <class>
1327 friend class valarray;1335 friend class valarray;
...@@ -1708,12 +1716,12 @@ private:...@@ -1708,12 +1716,12 @@ private:
1708 _LIBCPP_HIDE_FROM_ABI indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)1716 _LIBCPP_HIDE_FROM_ABI indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
1709 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__ia) {}1717 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__ia) {}
17101718
1711#ifndef _LIBCPP_CXX03_LANG1719# ifndef _LIBCPP_CXX03_LANG
17121720
1713 _LIBCPP_HIDE_FROM_ABI indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)1721 _LIBCPP_HIDE_FROM_ABI indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
1714 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__ia)) {}1722 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__ia)) {}
17151723
1716#endif // _LIBCPP_CXX03_LANG1724# endif // _LIBCPP_CXX03_LANG
17171725
1718 template <class>1726 template <class>
1719 friend class valarray;1727 friend class valarray;
...@@ -1837,12 +1845,12 @@ private:...@@ -1837,12 +1845,12 @@ private:
18371845
1838 _LIBCPP_HIDE_FROM_ABI __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e) : __expr_(__e), __1d_(__ia) {}1846 _LIBCPP_HIDE_FROM_ABI __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e) : __expr_(__e), __1d_(__ia) {}
18391847
1840#ifndef _LIBCPP_CXX03_LANG1848# ifndef _LIBCPP_CXX03_LANG
18411849
1842 _LIBCPP_HIDE_FROM_ABI __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)1850 _LIBCPP_HIDE_FROM_ABI __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
1843 : __expr_(__e), __1d_(std::move(__ia)) {}1851 : __expr_(__e), __1d_(std::move(__ia)) {}
18441852
1845#endif // _LIBCPP_CXX03_LANG1853# endif // _LIBCPP_CXX03_LANG
18461854
1847public:1855public:
1848 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; }1856 _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; }
...@@ -1984,17 +1992,17 @@ template <class _Tp>...@@ -1984,17 +1992,17 @@ template <class _Tp>
1984inline valarray<_Tp>::valarray(size_t __n) : __begin_(nullptr), __end_(nullptr) {1992inline valarray<_Tp>::valarray(size_t __n) : __begin_(nullptr), __end_(nullptr) {
1985 if (__n) {1993 if (__n) {
1986 __begin_ = __end_ = allocator<value_type>().allocate(__n);1994 __begin_ = __end_ = allocator<value_type>().allocate(__n);
1987#ifndef _LIBCPP_HAS_NO_EXCEPTIONS1995# if _LIBCPP_HAS_EXCEPTIONS
1988 try {1996 try {
1989#endif // _LIBCPP_HAS_NO_EXCEPTIONS1997# endif // _LIBCPP_HAS_EXCEPTIONS
1990 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)1998 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
1991 ::new ((void*)__end_) value_type();1999 ::new ((void*)__end_) value_type();
1992#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2000# if _LIBCPP_HAS_EXCEPTIONS
1993 } catch (...) {2001 } catch (...) {
1994 __clear(__n);2002 __clear(__n);
1995 throw;2003 throw;
1996 }2004 }
1997#endif // _LIBCPP_HAS_NO_EXCEPTIONS2005# endif // _LIBCPP_HAS_EXCEPTIONS
1998 }2006 }
1999}2007}
20002008
...@@ -2007,17 +2015,17 @@ template <class _Tp>...@@ -2007,17 +2015,17 @@ template <class _Tp>
2007valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(nullptr), __end_(nullptr) {2015valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(nullptr), __end_(nullptr) {
2008 if (__n) {2016 if (__n) {
2009 __begin_ = __end_ = allocator<value_type>().allocate(__n);2017 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2010#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2018# if _LIBCPP_HAS_EXCEPTIONS
2011 try {2019 try {
2012#endif // _LIBCPP_HAS_NO_EXCEPTIONS2020# endif // _LIBCPP_HAS_EXCEPTIONS
2013 for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left)2021 for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left)
2014 ::new ((void*)__end_) value_type(*__p);2022 ::new ((void*)__end_) value_type(*__p);
2015#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2023# if _LIBCPP_HAS_EXCEPTIONS
2016 } catch (...) {2024 } catch (...) {
2017 __clear(__n);2025 __clear(__n);
2018 throw;2026 throw;
2019 }2027 }
2020#endif // _LIBCPP_HAS_NO_EXCEPTIONS2028# endif // _LIBCPP_HAS_EXCEPTIONS
2021 }2029 }
2022}2030}
20232031
...@@ -2025,21 +2033,21 @@ template <class _Tp>...@@ -2025,21 +2033,21 @@ template <class _Tp>
2025valarray<_Tp>::valarray(const valarray& __v) : __begin_(nullptr), __end_(nullptr) {2033valarray<_Tp>::valarray(const valarray& __v) : __begin_(nullptr), __end_(nullptr) {
2026 if (__v.size()) {2034 if (__v.size()) {
2027 __begin_ = __end_ = allocator<value_type>().allocate(__v.size());2035 __begin_ = __end_ = allocator<value_type>().allocate(__v.size());
2028#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2036# if _LIBCPP_HAS_EXCEPTIONS
2029 try {2037 try {
2030#endif // _LIBCPP_HAS_NO_EXCEPTIONS2038# endif // _LIBCPP_HAS_EXCEPTIONS
2031 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)2039 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2032 ::new ((void*)__end_) value_type(*__p);2040 ::new ((void*)__end_) value_type(*__p);
2033#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2041# if _LIBCPP_HAS_EXCEPTIONS
2034 } catch (...) {2042 } catch (...) {
2035 __clear(__v.size());2043 __clear(__v.size());
2036 throw;2044 throw;
2037 }2045 }
2038#endif // _LIBCPP_HAS_NO_EXCEPTIONS2046# endif // _LIBCPP_HAS_EXCEPTIONS
2039 }2047 }
2040}2048}
20412049
2042#ifndef _LIBCPP_CXX03_LANG2050# ifndef _LIBCPP_CXX03_LANG
20432051
2044template <class _Tp>2052template <class _Tp>
2045inline valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT : __begin_(__v.__begin_), __end_(__v.__end_) {2053inline valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT : __begin_(__v.__begin_), __end_(__v.__end_) {
...@@ -2051,40 +2059,40 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il) : __begin_(nullptr),...@@ -2051,40 +2059,40 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il) : __begin_(nullptr),
2051 const size_t __n = __il.size();2059 const size_t __n = __il.size();
2052 if (__n) {2060 if (__n) {
2053 __begin_ = __end_ = allocator<value_type>().allocate(__n);2061 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2054# ifndef _LIBCPP_HAS_NO_EXCEPTIONS2062# if _LIBCPP_HAS_EXCEPTIONS
2055 try {2063 try {
2056# endif // _LIBCPP_HAS_NO_EXCEPTIONS2064# endif // _LIBCPP_HAS_EXCEPTIONS
2057 size_t __n_left = __n;2065 size_t __n_left = __n;
2058 for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left)2066 for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left)
2059 ::new ((void*)__end_) value_type(*__p);2067 ::new ((void*)__end_) value_type(*__p);
2060# ifndef _LIBCPP_HAS_NO_EXCEPTIONS2068# if _LIBCPP_HAS_EXCEPTIONS
2061 } catch (...) {2069 } catch (...) {
2062 __clear(__n);2070 __clear(__n);
2063 throw;2071 throw;
2064 }2072 }
2065# endif // _LIBCPP_HAS_NO_EXCEPTIONS2073# endif // _LIBCPP_HAS_EXCEPTIONS
2066 }2074 }
2067}2075}
20682076
2069#endif // _LIBCPP_CXX03_LANG2077# endif // _LIBCPP_CXX03_LANG
20702078
2071template <class _Tp>2079template <class _Tp>
2072valarray<_Tp>::valarray(const slice_array<value_type>& __sa) : __begin_(nullptr), __end_(nullptr) {2080valarray<_Tp>::valarray(const slice_array<value_type>& __sa) : __begin_(nullptr), __end_(nullptr) {
2073 const size_t __n = __sa.__size_;2081 const size_t __n = __sa.__size_;
2074 if (__n) {2082 if (__n) {
2075 __begin_ = __end_ = allocator<value_type>().allocate(__n);2083 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2076#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2084# if _LIBCPP_HAS_EXCEPTIONS
2077 try {2085 try {
2078#endif // _LIBCPP_HAS_NO_EXCEPTIONS2086# endif // _LIBCPP_HAS_EXCEPTIONS
2079 size_t __n_left = __n;2087 size_t __n_left = __n;
2080 for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left)2088 for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left)
2081 ::new ((void*)__end_) value_type(*__p);2089 ::new ((void*)__end_) value_type(*__p);
2082#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2090# if _LIBCPP_HAS_EXCEPTIONS
2083 } catch (...) {2091 } catch (...) {
2084 __clear(__n);2092 __clear(__n);
2085 throw;2093 throw;
2086 }2094 }
2087#endif // _LIBCPP_HAS_NO_EXCEPTIONS2095# endif // _LIBCPP_HAS_EXCEPTIONS
2088 }2096 }
2089}2097}
20902098
...@@ -2093,19 +2101,19 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) : __begin_(nullptr...@@ -2093,19 +2101,19 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) : __begin_(nullptr
2093 const size_t __n = __ga.__1d_.size();2101 const size_t __n = __ga.__1d_.size();
2094 if (__n) {2102 if (__n) {
2095 __begin_ = __end_ = allocator<value_type>().allocate(__n);2103 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2096#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2104# if _LIBCPP_HAS_EXCEPTIONS
2097 try {2105 try {
2098#endif // _LIBCPP_HAS_NO_EXCEPTIONS2106# endif // _LIBCPP_HAS_EXCEPTIONS
2099 typedef const size_t* _Ip;2107 typedef const size_t* _Ip;
2100 const value_type* __s = __ga.__vp_;2108 const value_type* __s = __ga.__vp_;
2101 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_)2109 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_)
2102 ::new ((void*)__end_) value_type(__s[*__i]);2110 ::new ((void*)__end_) value_type(__s[*__i]);
2103#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2111# if _LIBCPP_HAS_EXCEPTIONS
2104 } catch (...) {2112 } catch (...) {
2105 __clear(__n);2113 __clear(__n);
2106 throw;2114 throw;
2107 }2115 }
2108#endif // _LIBCPP_HAS_NO_EXCEPTIONS2116# endif // _LIBCPP_HAS_EXCEPTIONS
2109 }2117 }
2110}2118}
21112119
...@@ -2114,19 +2122,19 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma) : __begin_(nullptr),...@@ -2114,19 +2122,19 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma) : __begin_(nullptr),
2114 const size_t __n = __ma.__1d_.size();2122 const size_t __n = __ma.__1d_.size();
2115 if (__n) {2123 if (__n) {
2116 __begin_ = __end_ = allocator<value_type>().allocate(__n);2124 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2117#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2125# if _LIBCPP_HAS_EXCEPTIONS
2118 try {2126 try {
2119#endif // _LIBCPP_HAS_NO_EXCEPTIONS2127# endif // _LIBCPP_HAS_EXCEPTIONS
2120 typedef const size_t* _Ip;2128 typedef const size_t* _Ip;
2121 const value_type* __s = __ma.__vp_;2129 const value_type* __s = __ma.__vp_;
2122 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_)2130 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_)
2123 ::new ((void*)__end_) value_type(__s[*__i]);2131 ::new ((void*)__end_) value_type(__s[*__i]);
2124#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2132# if _LIBCPP_HAS_EXCEPTIONS
2125 } catch (...) {2133 } catch (...) {
2126 __clear(__n);2134 __clear(__n);
2127 throw;2135 throw;
2128 }2136 }
2129#endif // _LIBCPP_HAS_NO_EXCEPTIONS2137# endif // _LIBCPP_HAS_EXCEPTIONS
2130 }2138 }
2131}2139}
21322140
...@@ -2135,19 +2143,19 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) : __begin_(nullp...@@ -2135,19 +2143,19 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) : __begin_(nullp
2135 const size_t __n = __ia.__1d_.size();2143 const size_t __n = __ia.__1d_.size();
2136 if (__n) {2144 if (__n) {
2137 __begin_ = __end_ = allocator<value_type>().allocate(__n);2145 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2138#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2146# if _LIBCPP_HAS_EXCEPTIONS
2139 try {2147 try {
2140#endif // _LIBCPP_HAS_NO_EXCEPTIONS2148# endif // _LIBCPP_HAS_EXCEPTIONS
2141 typedef const size_t* _Ip;2149 typedef const size_t* _Ip;
2142 const value_type* __s = __ia.__vp_;2150 const value_type* __s = __ia.__vp_;
2143 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_)2151 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_)
2144 ::new ((void*)__end_) value_type(__s[*__i]);2152 ::new ((void*)__end_) value_type(__s[*__i]);
2145#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2153# if _LIBCPP_HAS_EXCEPTIONS
2146 } catch (...) {2154 } catch (...) {
2147 __clear(__n);2155 __clear(__n);
2148 throw;2156 throw;
2149 }2157 }
2150#endif // _LIBCPP_HAS_NO_EXCEPTIONS2158# endif // _LIBCPP_HAS_EXCEPTIONS
2151 }2159 }
2152}2160}
21532161
...@@ -2177,7 +2185,7 @@ valarray<_Tp>& valarray<_Tp>::operator=(const valarray& __v) {...@@ -2177,7 +2185,7 @@ valarray<_Tp>& valarray<_Tp>::operator=(const valarray& __v) {
2177 return *this;2185 return *this;
2178}2186}
21792187
2180#ifndef _LIBCPP_CXX03_LANG2188# ifndef _LIBCPP_CXX03_LANG
21812189
2182template <class _Tp>2190template <class _Tp>
2183inline valarray<_Tp>& valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT {2191inline valarray<_Tp>& valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT {
...@@ -2194,7 +2202,7 @@ inline valarray<_Tp>& valarray<_Tp>::operator=(initializer_list<value_type> __il...@@ -2194,7 +2202,7 @@ inline valarray<_Tp>& valarray<_Tp>::operator=(initializer_list<value_type> __il
2194 return __assign_range(__il.begin(), __il.end());2202 return __assign_range(__il.begin(), __il.end());
2195}2203}
21962204
2197#endif // _LIBCPP_CXX03_LANG2205# endif // _LIBCPP_CXX03_LANG
21982206
2199template <class _Tp>2207template <class _Tp>
2200inline valarray<_Tp>& valarray<_Tp>::operator=(const value_type& __x) {2208inline valarray<_Tp>& valarray<_Tp>::operator=(const value_type& __x) {
...@@ -2273,7 +2281,7 @@ inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __gs) {...@@ -2273,7 +2281,7 @@ inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __gs) {
2273 return gslice_array<value_type>(__gs, *this);2281 return gslice_array<value_type>(__gs, *this);
2274}2282}
22752283
2276#ifndef _LIBCPP_CXX03_LANG2284# ifndef _LIBCPP_CXX03_LANG
22772285
2278template <class _Tp>2286template <class _Tp>
2279inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](gslice&& __gs) const {2287inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](gslice&& __gs) const {
...@@ -2285,7 +2293,7 @@ inline gslice_array<_Tp> valarray<_Tp>::operator[](gslice&& __gs) {...@@ -2285,7 +2293,7 @@ inline gslice_array<_Tp> valarray<_Tp>::operator[](gslice&& __gs) {
2285 return gslice_array<value_type>(std::move(__gs), *this);2293 return gslice_array<value_type>(std::move(__gs), *this);
2286}2294}
22872295
2288#endif // _LIBCPP_CXX03_LANG2296# endif // _LIBCPP_CXX03_LANG
22892297
2290template <class _Tp>2298template <class _Tp>
2291inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const valarray<bool>& __vb) const {2299inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const valarray<bool>& __vb) const {
...@@ -2297,7 +2305,7 @@ inline mask_array<_Tp> valarray<_Tp>::operator[](const valarray<bool>& __vb) {...@@ -2297,7 +2305,7 @@ inline mask_array<_Tp> valarray<_Tp>::operator[](const valarray<bool>& __vb) {
2297 return mask_array<value_type>(__vb, *this);2305 return mask_array<value_type>(__vb, *this);
2298}2306}
22992307
2300#ifndef _LIBCPP_CXX03_LANG2308# ifndef _LIBCPP_CXX03_LANG
23012309
2302template <class _Tp>2310template <class _Tp>
2303inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<bool>&& __vb) const {2311inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<bool>&& __vb) const {
...@@ -2309,7 +2317,7 @@ inline mask_array<_Tp> valarray<_Tp>::operator[](valarray<bool>&& __vb) {...@@ -2309,7 +2317,7 @@ inline mask_array<_Tp> valarray<_Tp>::operator[](valarray<bool>&& __vb) {
2309 return mask_array<value_type>(std::move(__vb), *this);2317 return mask_array<value_type>(std::move(__vb), *this);
2310}2318}
23112319
2312#endif // _LIBCPP_CXX03_LANG2320# endif // _LIBCPP_CXX03_LANG
23132321
2314template <class _Tp>2322template <class _Tp>
2315inline __val_expr<__indirect_expr<const valarray<_Tp>&> >2323inline __val_expr<__indirect_expr<const valarray<_Tp>&> >
...@@ -2322,7 +2330,7 @@ inline indirect_array<_Tp> valarray<_Tp>::operator[](const valarray<size_t>& __v...@@ -2322,7 +2330,7 @@ inline indirect_array<_Tp> valarray<_Tp>::operator[](const valarray<size_t>& __v
2322 return indirect_array<value_type>(__vs, *this);2330 return indirect_array<value_type>(__vs, *this);
2323}2331}
23242332
2325#ifndef _LIBCPP_CXX03_LANG2333# ifndef _LIBCPP_CXX03_LANG
23262334
2327template <class _Tp>2335template <class _Tp>
2328inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<size_t>&& __vs) const {2336inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<size_t>&& __vs) const {
...@@ -2334,7 +2342,7 @@ inline indirect_array<_Tp> valarray<_Tp>::operator[](valarray<size_t>&& __vs) {...@@ -2334,7 +2342,7 @@ inline indirect_array<_Tp> valarray<_Tp>::operator[](valarray<size_t>&& __vs) {
2334 return indirect_array<value_type>(std::move(__vs), *this);2342 return indirect_array<value_type>(std::move(__vs), *this);
2335}2343}
23362344
2337#endif // _LIBCPP_CXX03_LANG2345# endif // _LIBCPP_CXX03_LANG
23382346
2339template <class _Tp>2347template <class _Tp>
2340inline __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator+() const {2348inline __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator+() const {
...@@ -2636,17 +2644,17 @@ void valarray<_Tp>::resize(size_t __n, value_type __x) {...@@ -2636,17 +2644,17 @@ void valarray<_Tp>::resize(size_t __n, value_type __x) {
2636 __clear(size());2644 __clear(size());
2637 if (__n) {2645 if (__n) {
2638 __begin_ = __end_ = allocator<value_type>().allocate(__n);2646 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2639#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2647# if _LIBCPP_HAS_EXCEPTIONS
2640 try {2648 try {
2641#endif // _LIBCPP_HAS_NO_EXCEPTIONS2649# endif // _LIBCPP_HAS_EXCEPTIONS
2642 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)2650 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
2643 ::new ((void*)__end_) value_type(__x);2651 ::new ((void*)__end_) value_type(__x);
2644#ifndef _LIBCPP_HAS_NO_EXCEPTIONS2652# if _LIBCPP_HAS_EXCEPTIONS
2645 } catch (...) {2653 } catch (...) {
2646 __clear(__n);2654 __clear(__n);
2647 throw;2655 throw;
2648 }2656 }
2649#endif // _LIBCPP_HAS_NO_EXCEPTIONS2657# endif // _LIBCPP_HAS_EXCEPTIONS
2650 }2658 }
2651}2659}
26522660
...@@ -3351,14 +3359,15 @@ _LIBCPP_END_NAMESPACE_STD...@@ -3351,14 +3359,15 @@ _LIBCPP_END_NAMESPACE_STD
33513359
3352_LIBCPP_POP_MACROS3360_LIBCPP_POP_MACROS
33533361
3354#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 203362# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
3355# include <algorithm>3363# include <algorithm>
3356# include <concepts>3364# include <concepts>
3357# include <cstdlib>3365# include <cstdlib>
3358# include <cstring>3366# include <cstring>
3359# include <functional>3367# include <functional>
3360# include <stdexcept>3368# include <stdexcept>
3361# include <type_traits>3369# include <type_traits>
3362#endif3370# endif
3371#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
33633372
3364#endif // _LIBCPP_VALARRAY3373#endif // _LIBCPP_VALARRAY
lib/libcxx/include/variant+215-223
...@@ -212,66 +212,76 @@ namespace std {...@@ -212,66 +212,76 @@ namespace std {
212212
213*/213*/
214214
215#include <__compare/common_comparison_category.h>215#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
216#include <__compare/compare_three_way_result.h>216# include <__cxx03/variant>
217#include <__compare/three_way_comparable.h>217#else
218#include <__config>218# include <__compare/common_comparison_category.h>
219#include <__exception/exception.h>219# include <__compare/compare_three_way_result.h>
220#include <__functional/hash.h>220# include <__compare/ordering.h>
221#include <__functional/invoke.h>221# include <__compare/three_way_comparable.h>
222#include <__functional/operations.h>222# include <__config>
223#include <__functional/unary_function.h>223# include <__exception/exception.h>
224#include <__memory/addressof.h>224# include <__functional/hash.h>
225#include <__memory/construct_at.h>225# include <__functional/operations.h>
226#include <__tuple/find_index.h>226# include <__functional/unary_function.h>
227#include <__tuple/sfinae_helpers.h>227# include <__fwd/variant.h>
228#include <__type_traits/add_const.h>228# include <__memory/addressof.h>
229#include <__type_traits/add_cv.h>229# include <__memory/construct_at.h>
230#include <__type_traits/add_pointer.h>230# include <__tuple/find_index.h>
231#include <__type_traits/add_volatile.h>231# include <__tuple/sfinae_helpers.h>
232#include <__type_traits/common_type.h>232# include <__type_traits/add_cv_quals.h>
233#include <__type_traits/conjunction.h>233# include <__type_traits/add_pointer.h>
234#include <__type_traits/dependent_type.h>234# include <__type_traits/common_type.h>
235#include <__type_traits/is_array.h>235# include <__type_traits/conditional.h>
236#include <__type_traits/is_constructible.h>236# include <__type_traits/conjunction.h>
237#include <__type_traits/is_destructible.h>237# include <__type_traits/decay.h>
238#include <__type_traits/is_nothrow_assignable.h>238# include <__type_traits/dependent_type.h>
239#include <__type_traits/is_nothrow_constructible.h>239# include <__type_traits/enable_if.h>
240#include <__type_traits/is_reference.h>240# include <__type_traits/invoke.h>
241#include <__type_traits/is_trivially_assignable.h>241# include <__type_traits/is_array.h>
242#include <__type_traits/is_trivially_constructible.h>242# include <__type_traits/is_assignable.h>
243#include <__type_traits/is_trivially_destructible.h>243# include <__type_traits/is_constructible.h>
244#include <__type_traits/is_trivially_relocatable.h>244# include <__type_traits/is_convertible.h>
245#include <__type_traits/is_void.h>245# include <__type_traits/is_destructible.h>
246#include <__type_traits/remove_const.h>246# include <__type_traits/is_nothrow_assignable.h>
247#include <__type_traits/remove_cvref.h>247# include <__type_traits/is_nothrow_constructible.h>
248#include <__type_traits/type_identity.h>248# include <__type_traits/is_reference.h>
249#include <__type_traits/void_t.h>249# include <__type_traits/is_same.h>
250#include <__utility/declval.h>250# include <__type_traits/is_swappable.h>
251#include <__utility/forward.h>251# include <__type_traits/is_trivially_assignable.h>
252#include <__utility/forward_like.h>252# include <__type_traits/is_trivially_constructible.h>
253#include <__utility/in_place.h>253# include <__type_traits/is_trivially_destructible.h>
254#include <__utility/integer_sequence.h>254# include <__type_traits/is_trivially_relocatable.h>
255#include <__utility/move.h>255# include <__type_traits/is_void.h>
256#include <__utility/swap.h>256# include <__type_traits/remove_const.h>
257#include <__variant/monostate.h>257# include <__type_traits/remove_cvref.h>
258#include <__verbose_abort>258# include <__type_traits/remove_reference.h>
259#include <initializer_list>259# include <__type_traits/type_identity.h>
260#include <limits>260# include <__type_traits/void_t.h>
261#include <new>261# include <__utility/declval.h>
262#include <version>262# include <__utility/forward.h>
263# include <__utility/forward_like.h>
264# include <__utility/in_place.h>
265# include <__utility/integer_sequence.h>
266# include <__utility/move.h>
267# include <__utility/swap.h>
268# include <__variant/monostate.h>
269# include <__verbose_abort>
270# include <initializer_list>
271# include <limits>
272# include <version>
263273
264// standard-mandated includes274// standard-mandated includes
265275
266// [variant.syn]276// [variant.syn]
267#include <compare>277# include <compare>
268278
269#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)279# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
270# pragma GCC system_header280# pragma GCC system_header
271#endif281# endif
272282
273_LIBCPP_PUSH_MACROS283_LIBCPP_PUSH_MACROS
274#include <__undef_macros>284# include <__undef_macros>
275285
276namespace std { // explicitly not using versioning namespace286namespace std { // explicitly not using versioning namespace
277287
...@@ -284,7 +294,7 @@ public:...@@ -284,7 +294,7 @@ public:
284294
285_LIBCPP_BEGIN_NAMESPACE_STD295_LIBCPP_BEGIN_NAMESPACE_STD
286296
287#if _LIBCPP_STD_VER >= 17297# if _LIBCPP_STD_VER >= 17
288298
289// Light N-dimensional array of function pointers. Used in place of std::array to avoid299// Light N-dimensional array of function pointers. Used in place of std::array to avoid
290// adding a dependency.300// adding a dependency.
...@@ -296,24 +306,16 @@ struct __farray {...@@ -296,24 +306,16 @@ struct __farray {
296 _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](size_t __n) const noexcept { return __buf_[__n]; }306 _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](size_t __n) const noexcept { return __buf_[__n]; }
297};307};
298308
299_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS void309[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS void
300__throw_bad_variant_access() {310__throw_bad_variant_access() {
301# ifndef _LIBCPP_HAS_NO_EXCEPTIONS311# if _LIBCPP_HAS_EXCEPTIONS
302 throw bad_variant_access();312 throw bad_variant_access();
303# else313# else
304 _LIBCPP_VERBOSE_ABORT("bad_variant_access was thrown in -fno-exceptions mode");314 _LIBCPP_VERBOSE_ABORT("bad_variant_access was thrown in -fno-exceptions mode");
305# endif315# endif
306}316}
307317
308template <class... _Types>318// variant_size
309class _LIBCPP_TEMPLATE_VIS variant;
310
311template <class _Tp>
312struct _LIBCPP_TEMPLATE_VIS variant_size;
313
314template <class _Tp>
315inline constexpr size_t variant_size_v = variant_size<_Tp>::value;
316
317template <class _Tp>319template <class _Tp>
318struct _LIBCPP_TEMPLATE_VIS variant_size<const _Tp> : variant_size<_Tp> {};320struct _LIBCPP_TEMPLATE_VIS variant_size<const _Tp> : variant_size<_Tp> {};
319321
...@@ -326,12 +328,7 @@ struct _LIBCPP_TEMPLATE_VIS variant_size<const volatile _Tp> : variant_size<_Tp>...@@ -326,12 +328,7 @@ struct _LIBCPP_TEMPLATE_VIS variant_size<const volatile _Tp> : variant_size<_Tp>
326template <class... _Types>328template <class... _Types>
327struct _LIBCPP_TEMPLATE_VIS variant_size<variant<_Types...>> : integral_constant<size_t, sizeof...(_Types)> {};329struct _LIBCPP_TEMPLATE_VIS variant_size<variant<_Types...>> : integral_constant<size_t, sizeof...(_Types)> {};
328330
329template <size_t _Ip, class _Tp>331// variant_alternative
330struct _LIBCPP_TEMPLATE_VIS variant_alternative;
331
332template <size_t _Ip, class _Tp>
333using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type;
334
335template <size_t _Ip, class _Tp>332template <size_t _Ip, class _Tp>
336struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, const _Tp> : add_const<variant_alternative_t<_Ip, _Tp>> {};333struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, const _Tp> : add_const<variant_alternative_t<_Ip, _Tp>> {};
337334
...@@ -347,29 +344,24 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {...@@ -347,29 +344,24 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {
347 using type = __type_pack_element<_Ip, _Types...>;344 using type = __type_pack_element<_Ip, _Types...>;
348};345};
349346
350inline constexpr size_t variant_npos = static_cast<size_t>(-1);
351
352template <size_t _NumAlternatives>347template <size_t _NumAlternatives>
353_LIBCPP_HIDE_FROM_ABI constexpr auto __choose_index_type() {348_LIBCPP_HIDE_FROM_ABI constexpr auto __choose_index_type() {
354# ifdef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION349# ifdef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
355 if constexpr (_NumAlternatives < numeric_limits<unsigned char>::max())350 if constexpr (_NumAlternatives < numeric_limits<unsigned char>::max())
356 return static_cast<unsigned char>(0);351 return static_cast<unsigned char>(0);
357 else if constexpr (_NumAlternatives < numeric_limits<unsigned short>::max())352 else if constexpr (_NumAlternatives < numeric_limits<unsigned short>::max())
358 return static_cast<unsigned short>(0);353 return static_cast<unsigned short>(0);
359 else354 else
360# endif // _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION355# endif // _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
361 return static_cast<unsigned int>(0);356 return static_cast<unsigned int>(0);
362}357}
363358
364template <size_t _NumAlts>359template <size_t _NumAlts>
365using __variant_index_t = decltype(std::__choose_index_type<_NumAlts>());360using __variant_index_t _LIBCPP_NODEBUG = decltype(std::__choose_index_type<_NumAlts>());
366361
367template <class _IndexType>362template <class _IndexType>
368constexpr _IndexType __variant_npos = static_cast<_IndexType>(-1);363constexpr _IndexType __variant_npos = static_cast<_IndexType>(-1);
369364
370template <class... _Types>
371class _LIBCPP_TEMPLATE_VIS variant;
372
373template <class... _Types>365template <class... _Types>
374_LIBCPP_HIDE_FROM_ABI constexpr variant<_Types...>& __as_variant(variant<_Types...>& __vs) noexcept {366_LIBCPP_HIDE_FROM_ABI constexpr variant<_Types...>& __as_variant(variant<_Types...>& __vs) noexcept {
375 return __vs;367 return __vs;
...@@ -605,12 +597,12 @@ struct __variant {...@@ -605,12 +597,12 @@ struct __variant {
605 return __visit_alt(__make_value_visitor(std::forward<_Visitor>(__visitor)), std::forward<_Vs>(__vs)...);597 return __visit_alt(__make_value_visitor(std::forward<_Visitor>(__visitor)), std::forward<_Vs>(__vs)...);
606 }598 }
607599
608# if _LIBCPP_STD_VER >= 20600# if _LIBCPP_STD_VER >= 20
609 template <class _Rp, class _Visitor, class... _Vs>601 template <class _Rp, class _Visitor, class... _Vs>
610 _LIBCPP_HIDE_FROM_ABI static constexpr _Rp __visit_value(_Visitor&& __visitor, _Vs&&... __vs) {602 _LIBCPP_HIDE_FROM_ABI static constexpr _Rp __visit_value(_Visitor&& __visitor, _Vs&&... __vs) {
611 return __visit_alt(__make_value_visitor<_Rp>(std::forward<_Visitor>(__visitor)), std::forward<_Vs>(__vs)...);603 return __visit_alt(__make_value_visitor<_Rp>(std::forward<_Visitor>(__visitor)), std::forward<_Vs>(__vs)...);
612 }604 }
613# endif605# endif
614606
615private:607private:
616 template <class _Visitor, class... _Values>608 template <class _Visitor, class... _Values>
...@@ -628,7 +620,7 @@ private:...@@ -628,7 +620,7 @@ private:
628 _Visitor&& __visitor;620 _Visitor&& __visitor;
629 };621 };
630622
631# if _LIBCPP_STD_VER >= 20623# if _LIBCPP_STD_VER >= 20
632 template <class _Rp, class _Visitor>624 template <class _Rp, class _Visitor>
633 struct __value_visitor_return_type {625 struct __value_visitor_return_type {
634 template <class... _Alts>626 template <class... _Alts>
...@@ -643,31 +635,31 @@ private:...@@ -643,31 +635,31 @@ private:
643635
644 _Visitor&& __visitor;636 _Visitor&& __visitor;
645 };637 };
646# endif638# endif
647639
648 template <class _Visitor>640 template <class _Visitor>
649 _LIBCPP_HIDE_FROM_ABI static constexpr auto __make_value_visitor(_Visitor&& __visitor) {641 _LIBCPP_HIDE_FROM_ABI static constexpr auto __make_value_visitor(_Visitor&& __visitor) {
650 return __value_visitor<_Visitor>{std::forward<_Visitor>(__visitor)};642 return __value_visitor<_Visitor>{std::forward<_Visitor>(__visitor)};
651 }643 }
652644
653# if _LIBCPP_STD_VER >= 20645# if _LIBCPP_STD_VER >= 20
654 template <class _Rp, class _Visitor>646 template <class _Rp, class _Visitor>
655 _LIBCPP_HIDE_FROM_ABI static constexpr auto __make_value_visitor(_Visitor&& __visitor) {647 _LIBCPP_HIDE_FROM_ABI static constexpr auto __make_value_visitor(_Visitor&& __visitor) {
656 return __value_visitor_return_type<_Rp, _Visitor>{std::forward<_Visitor>(__visitor)};648 return __value_visitor_return_type<_Rp, _Visitor>{std::forward<_Visitor>(__visitor)};
657 }649 }
658# endif650# endif
659};651};
660652
661} // namespace __visitation653} // namespace __visitation
662654
663// Adding semi-colons in macro expansions helps clang-format to do a better job.655// Adding semi-colons in macro expansions helps clang-format to do a better job.
664// This macro is used to avoid compilation errors due to "stray" semi-colons.656// This macro is used to avoid compilation errors due to "stray" semi-colons.
665# define _LIBCPP_EAT_SEMICOLON static_assert(true, "")657# define _LIBCPP_EAT_SEMICOLON static_assert(true, "")
666658
667template <size_t _Index, class _Tp>659template <size_t _Index, class _Tp>
668struct _LIBCPP_TEMPLATE_VIS __alt {660struct _LIBCPP_TEMPLATE_VIS __alt {
669 using __value_type = _Tp;661 using __value_type _LIBCPP_NODEBUG = _Tp;
670 static constexpr size_t __index = _Index;662 static constexpr size_t __index = _Index;
671663
672 template <class... _Args>664 template <class... _Args>
673 _LIBCPP_HIDE_FROM_ABI explicit constexpr __alt(in_place_t, _Args&&... __args)665 _LIBCPP_HIDE_FROM_ABI explicit constexpr __alt(in_place_t, _Args&&... __args)
...@@ -682,33 +674,33 @@ union _LIBCPP_TEMPLATE_VIS __union;...@@ -682,33 +674,33 @@ union _LIBCPP_TEMPLATE_VIS __union;
682template <_Trait _DestructibleTrait, size_t _Index>674template <_Trait _DestructibleTrait, size_t _Index>
683union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {};675union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {};
684676
685# define _LIBCPP_VARIANT_UNION(destructible_trait, destructor_definition) \677# define _LIBCPP_VARIANT_UNION(destructible_trait, destructor_definition) \
686 template <size_t _Index, class _Tp, class... _Types> \678 template <size_t _Index, class _Tp, class... _Types> \
687 union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, _Index, _Tp, _Types...> { \679 union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, _Index, _Tp, _Types...> { \
688 public: \680 public: \
689 _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \681 _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \
690 \682 \
691 template <class... _Args> \683 template <class... _Args> \
692 _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(in_place_index_t<0>, _Args&&... __args) \684 _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(in_place_index_t<0>, _Args&&... __args) \
693 : __head(in_place, std::forward<_Args>(__args)...) {} \685 : __head(in_place, std::forward<_Args>(__args)...) {} \
694 \686 \
695 template <size_t _Ip, class... _Args> \687 template <size_t _Ip, class... _Args> \
696 _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(in_place_index_t<_Ip>, _Args&&... __args) \688 _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(in_place_index_t<_Ip>, _Args&&... __args) \
697 : __tail(in_place_index<_Ip - 1>, std::forward<_Args>(__args)...) {} \689 : __tail(in_place_index<_Ip - 1>, std::forward<_Args>(__args)...) {} \
698 \690 \
699 _LIBCPP_HIDE_FROM_ABI __union(const __union&) = default; \691 _LIBCPP_HIDE_FROM_ABI __union(const __union&) = default; \
700 _LIBCPP_HIDE_FROM_ABI __union(__union&&) = default; \692 _LIBCPP_HIDE_FROM_ABI __union(__union&&) = default; \
701 _LIBCPP_HIDE_FROM_ABI __union& operator=(const __union&) = default; \693 _LIBCPP_HIDE_FROM_ABI __union& operator=(const __union&) = default; \
702 _LIBCPP_HIDE_FROM_ABI __union& operator=(__union&&) = default; \694 _LIBCPP_HIDE_FROM_ABI __union& operator=(__union&&) = default; \
703 destructor_definition; \695 destructor_definition; \
704 \696 \
705 private: \697 private: \
706 char __dummy; \698 char __dummy; \
707 __alt<_Index, _Tp> __head; \699 __alt<_Index, _Tp> __head; \
708 __union<destructible_trait, _Index + 1, _Types...> __tail; \700 __union<destructible_trait, _Index + 1, _Types...> __tail; \
709 \701 \
710 friend struct __access::__union; \702 friend struct __access::__union; \
711 }703 }
712704
713_LIBCPP_VARIANT_UNION(_Trait::_TriviallyAvailable,705_LIBCPP_VARIANT_UNION(_Trait::_TriviallyAvailable,
714 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() = default);706 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() = default);
...@@ -716,12 +708,12 @@ _LIBCPP_VARIANT_UNION(...@@ -716,12 +708,12 @@ _LIBCPP_VARIANT_UNION(
716 _Trait::_Available, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() {} _LIBCPP_EAT_SEMICOLON);708 _Trait::_Available, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() {} _LIBCPP_EAT_SEMICOLON);
717_LIBCPP_VARIANT_UNION(_Trait::_Unavailable, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() = delete);709_LIBCPP_VARIANT_UNION(_Trait::_Unavailable, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() = delete);
718710
719# undef _LIBCPP_VARIANT_UNION711# undef _LIBCPP_VARIANT_UNION
720712
721template <_Trait _DestructibleTrait, class... _Types>713template <_Trait _DestructibleTrait, class... _Types>
722class _LIBCPP_TEMPLATE_VIS __base {714class _LIBCPP_TEMPLATE_VIS __base {
723public:715public:
724 using __index_t = __variant_index_t<sizeof...(_Types)>;716 using __index_t _LIBCPP_NODEBUG = __variant_index_t<sizeof...(_Types)>;
725717
726 _LIBCPP_HIDE_FROM_ABI explicit constexpr __base(__valueless_t __tag) noexcept718 _LIBCPP_HIDE_FROM_ABI explicit constexpr __base(__valueless_t __tag) noexcept
727 : __data(__tag), __index(__variant_npos<__index_t>) {}719 : __data(__tag), __index(__variant_npos<__index_t>) {}
...@@ -757,25 +749,25 @@ protected:...@@ -757,25 +749,25 @@ protected:
757template <class _Traits, _Trait = _Traits::__destructible_trait>749template <class _Traits, _Trait = _Traits::__destructible_trait>
758class _LIBCPP_TEMPLATE_VIS __dtor;750class _LIBCPP_TEMPLATE_VIS __dtor;
759751
760# define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor_definition, destroy) \752# define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor_definition, destroy) \
761 template <class... _Types> \753 template <class... _Types> \
762 class _LIBCPP_TEMPLATE_VIS __dtor<__traits<_Types...>, destructible_trait> \754 class _LIBCPP_TEMPLATE_VIS __dtor<__traits<_Types...>, destructible_trait> \
763 : public __base<destructible_trait, _Types...> { \755 : public __base<destructible_trait, _Types...> { \
764 using __base_type = __base<destructible_trait, _Types...>; \756 using __base_type _LIBCPP_NODEBUG = __base<destructible_trait, _Types...>; \
765 using __index_t = typename __base_type::__index_t; \757 using __index_t _LIBCPP_NODEBUG = typename __base_type::__index_t; \
766 \758 \
767 public: \759 public: \
768 using __base_type::__base_type; \760 using __base_type::__base_type; \
769 using __base_type::operator=; \761 using __base_type::operator=; \
770 _LIBCPP_HIDE_FROM_ABI __dtor(const __dtor&) = default; \762 _LIBCPP_HIDE_FROM_ABI __dtor(const __dtor&) = default; \
771 _LIBCPP_HIDE_FROM_ABI __dtor(__dtor&&) = default; \763 _LIBCPP_HIDE_FROM_ABI __dtor(__dtor&&) = default; \
772 _LIBCPP_HIDE_FROM_ABI __dtor& operator=(const __dtor&) = default; \764 _LIBCPP_HIDE_FROM_ABI __dtor& operator=(const __dtor&) = default; \
773 _LIBCPP_HIDE_FROM_ABI __dtor& operator=(__dtor&&) = default; \765 _LIBCPP_HIDE_FROM_ABI __dtor& operator=(__dtor&&) = default; \
774 destructor_definition; \766 destructor_definition; \
775 \767 \
776 protected: \768 protected: \
777 destroy; \769 destroy; \
778 }770 }
779771
780_LIBCPP_VARIANT_DESTRUCTOR(772_LIBCPP_VARIANT_DESTRUCTOR(
781 _Trait::_TriviallyAvailable,773 _Trait::_TriviallyAvailable,
...@@ -803,11 +795,11 @@ _LIBCPP_VARIANT_DESTRUCTOR(_Trait::_Unavailable,...@@ -803,11 +795,11 @@ _LIBCPP_VARIANT_DESTRUCTOR(_Trait::_Unavailable,
803 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__dtor() = delete,795 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__dtor() = delete,
804 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy() noexcept = delete);796 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy() noexcept = delete);
805797
806# undef _LIBCPP_VARIANT_DESTRUCTOR798# undef _LIBCPP_VARIANT_DESTRUCTOR
807799
808template <class _Traits>800template <class _Traits>
809class _LIBCPP_TEMPLATE_VIS __ctor : public __dtor<_Traits> {801class _LIBCPP_TEMPLATE_VIS __ctor : public __dtor<_Traits> {
810 using __base_type = __dtor<_Traits>;802 using __base_type _LIBCPP_NODEBUG = __dtor<_Traits>;
811803
812public:804public:
813 using __base_type::__base_type;805 using __base_type::__base_type;
...@@ -835,22 +827,22 @@ protected:...@@ -835,22 +827,22 @@ protected:
835template <class _Traits, _Trait = _Traits::__move_constructible_trait>827template <class _Traits, _Trait = _Traits::__move_constructible_trait>
836class _LIBCPP_TEMPLATE_VIS __move_constructor;828class _LIBCPP_TEMPLATE_VIS __move_constructor;
837829
838# define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, move_constructor_definition) \830# define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, move_constructor_definition) \
839 template <class... _Types> \831 template <class... _Types> \
840 class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, move_constructible_trait> \832 class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, move_constructible_trait> \
841 : public __ctor<__traits<_Types...>> { \833 : public __ctor<__traits<_Types...>> { \
842 using __base_type = __ctor<__traits<_Types...>>; \834 using __base_type _LIBCPP_NODEBUG = __ctor<__traits<_Types...>>; \
843 \835 \
844 public: \836 public: \
845 using __base_type::__base_type; \837 using __base_type::__base_type; \
846 using __base_type::operator=; \838 using __base_type::operator=; \
847 \839 \
848 _LIBCPP_HIDE_FROM_ABI __move_constructor(const __move_constructor&) = default; \840 _LIBCPP_HIDE_FROM_ABI __move_constructor(const __move_constructor&) = default; \
849 _LIBCPP_HIDE_FROM_ABI ~__move_constructor() = default; \841 _LIBCPP_HIDE_FROM_ABI ~__move_constructor() = default; \
850 _LIBCPP_HIDE_FROM_ABI __move_constructor& operator=(const __move_constructor&) = default; \842 _LIBCPP_HIDE_FROM_ABI __move_constructor& operator=(const __move_constructor&) = default; \
851 _LIBCPP_HIDE_FROM_ABI __move_constructor& operator=(__move_constructor&&) = default; \843 _LIBCPP_HIDE_FROM_ABI __move_constructor& operator=(__move_constructor&&) = default; \
852 move_constructor_definition; \844 move_constructor_definition; \
853 }845 }
854846
855_LIBCPP_VARIANT_MOVE_CONSTRUCTOR(847_LIBCPP_VARIANT_MOVE_CONSTRUCTOR(
856 _Trait::_TriviallyAvailable,848 _Trait::_TriviallyAvailable,
...@@ -868,27 +860,27 @@ _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(...@@ -868,27 +860,27 @@ _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(
868 _Trait::_Unavailable,860 _Trait::_Unavailable,
869 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&&) = delete);861 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&&) = delete);
870862
871# undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR863# undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR
872864
873template <class _Traits, _Trait = _Traits::__copy_constructible_trait>865template <class _Traits, _Trait = _Traits::__copy_constructible_trait>
874class _LIBCPP_TEMPLATE_VIS __copy_constructor;866class _LIBCPP_TEMPLATE_VIS __copy_constructor;
875867
876# define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, copy_constructor_definition) \868# define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, copy_constructor_definition) \
877 template <class... _Types> \869 template <class... _Types> \
878 class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, copy_constructible_trait> \870 class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, copy_constructible_trait> \
879 : public __move_constructor<__traits<_Types...>> { \871 : public __move_constructor<__traits<_Types...>> { \
880 using __base_type = __move_constructor<__traits<_Types...>>; \872 using __base_type _LIBCPP_NODEBUG = __move_constructor<__traits<_Types...>>; \
881 \873 \
882 public: \874 public: \
883 using __base_type::__base_type; \875 using __base_type::__base_type; \
884 using __base_type::operator=; \876 using __base_type::operator=; \
885 \877 \
886 _LIBCPP_HIDE_FROM_ABI __copy_constructor(__copy_constructor&&) = default; \878 _LIBCPP_HIDE_FROM_ABI __copy_constructor(__copy_constructor&&) = default; \
887 _LIBCPP_HIDE_FROM_ABI ~__copy_constructor() = default; \879 _LIBCPP_HIDE_FROM_ABI ~__copy_constructor() = default; \
888 _LIBCPP_HIDE_FROM_ABI __copy_constructor& operator=(const __copy_constructor&) = default; \880 _LIBCPP_HIDE_FROM_ABI __copy_constructor& operator=(const __copy_constructor&) = default; \
889 _LIBCPP_HIDE_FROM_ABI __copy_constructor& operator=(__copy_constructor&&) = default; \881 _LIBCPP_HIDE_FROM_ABI __copy_constructor& operator=(__copy_constructor&&) = default; \
890 copy_constructor_definition; \882 copy_constructor_definition; \
891 }883 }
892884
893_LIBCPP_VARIANT_COPY_CONSTRUCTOR(885_LIBCPP_VARIANT_COPY_CONSTRUCTOR(
894 _Trait::_TriviallyAvailable,886 _Trait::_TriviallyAvailable,
...@@ -903,11 +895,11 @@ _LIBCPP_VARIANT_COPY_CONSTRUCTOR(...@@ -903,11 +895,11 @@ _LIBCPP_VARIANT_COPY_CONSTRUCTOR(
903 _Trait::_Unavailable,895 _Trait::_Unavailable,
904 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor&) = delete);896 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor&) = delete);
905897
906# undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR898# undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR
907899
908template <class _Traits>900template <class _Traits>
909class _LIBCPP_TEMPLATE_VIS __assignment : public __copy_constructor<_Traits> {901class _LIBCPP_TEMPLATE_VIS __assignment : public __copy_constructor<_Traits> {
910 using __base_type = __copy_constructor<_Traits>;902 using __base_type _LIBCPP_NODEBUG = __copy_constructor<_Traits>;
911903
912public:904public:
913 using __base_type::__base_type;905 using __base_type::__base_type;
...@@ -962,22 +954,22 @@ protected:...@@ -962,22 +954,22 @@ protected:
962template <class _Traits, _Trait = _Traits::__move_assignable_trait>954template <class _Traits, _Trait = _Traits::__move_assignable_trait>
963class _LIBCPP_TEMPLATE_VIS __move_assignment;955class _LIBCPP_TEMPLATE_VIS __move_assignment;
964956
965# define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, move_assignment_definition) \957# define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, move_assignment_definition) \
966 template <class... _Types> \958 template <class... _Types> \
967 class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, move_assignable_trait> \959 class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, move_assignable_trait> \
968 : public __assignment<__traits<_Types...>> { \960 : public __assignment<__traits<_Types...>> { \
969 using __base_type = __assignment<__traits<_Types...>>; \961 using __base_type _LIBCPP_NODEBUG = __assignment<__traits<_Types...>>; \
970 \962 \
971 public: \963 public: \
972 using __base_type::__base_type; \964 using __base_type::__base_type; \
973 using __base_type::operator=; \965 using __base_type::operator=; \
974 \966 \
975 _LIBCPP_HIDE_FROM_ABI __move_assignment(const __move_assignment&) = default; \967 _LIBCPP_HIDE_FROM_ABI __move_assignment(const __move_assignment&) = default; \
976 _LIBCPP_HIDE_FROM_ABI __move_assignment(__move_assignment&&) = default; \968 _LIBCPP_HIDE_FROM_ABI __move_assignment(__move_assignment&&) = default; \
977 _LIBCPP_HIDE_FROM_ABI ~__move_assignment() = default; \969 _LIBCPP_HIDE_FROM_ABI ~__move_assignment() = default; \
978 _LIBCPP_HIDE_FROM_ABI __move_assignment& operator=(const __move_assignment&) = default; \970 _LIBCPP_HIDE_FROM_ABI __move_assignment& operator=(const __move_assignment&) = default; \
979 move_assignment_definition; \971 move_assignment_definition; \
980 }972 }
981973
982_LIBCPP_VARIANT_MOVE_ASSIGNMENT(_Trait::_TriviallyAvailable,974_LIBCPP_VARIANT_MOVE_ASSIGNMENT(_Trait::_TriviallyAvailable,
983 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_assignment& operator=(975 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_assignment& operator=(
...@@ -996,27 +988,27 @@ _LIBCPP_VARIANT_MOVE_ASSIGNMENT(...@@ -996,27 +988,27 @@ _LIBCPP_VARIANT_MOVE_ASSIGNMENT(
996 _Trait::_Unavailable,988 _Trait::_Unavailable,
997 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_assignment& operator=(__move_assignment&&) = delete);989 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_assignment& operator=(__move_assignment&&) = delete);
998990
999# undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT991# undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT
1000992
1001template <class _Traits, _Trait = _Traits::__copy_assignable_trait>993template <class _Traits, _Trait = _Traits::__copy_assignable_trait>
1002class _LIBCPP_TEMPLATE_VIS __copy_assignment;994class _LIBCPP_TEMPLATE_VIS __copy_assignment;
1003995
1004# define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, copy_assignment_definition) \996# define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, copy_assignment_definition) \
1005 template <class... _Types> \997 template <class... _Types> \
1006 class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, copy_assignable_trait> \998 class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, copy_assignable_trait> \
1007 : public __move_assignment<__traits<_Types...>> { \999 : public __move_assignment<__traits<_Types...>> { \
1008 using __base_type = __move_assignment<__traits<_Types...>>; \1000 using __base_type _LIBCPP_NODEBUG = __move_assignment<__traits<_Types...>>; \
1009 \1001 \
1010 public: \1002 public: \
1011 using __base_type::__base_type; \1003 using __base_type::__base_type; \
1012 using __base_type::operator=; \1004 using __base_type::operator=; \
1013 \1005 \
1014 _LIBCPP_HIDE_FROM_ABI __copy_assignment(const __copy_assignment&) = default; \1006 _LIBCPP_HIDE_FROM_ABI __copy_assignment(const __copy_assignment&) = default; \
1015 _LIBCPP_HIDE_FROM_ABI __copy_assignment(__copy_assignment&&) = default; \1007 _LIBCPP_HIDE_FROM_ABI __copy_assignment(__copy_assignment&&) = default; \
1016 _LIBCPP_HIDE_FROM_ABI ~__copy_assignment() = default; \1008 _LIBCPP_HIDE_FROM_ABI ~__copy_assignment() = default; \
1017 _LIBCPP_HIDE_FROM_ABI __copy_assignment& operator=(__copy_assignment&&) = default; \1009 _LIBCPP_HIDE_FROM_ABI __copy_assignment& operator=(__copy_assignment&&) = default; \
1018 copy_assignment_definition; \1010 copy_assignment_definition; \
1019 }1011 }
10201012
1021_LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_TriviallyAvailable,1013_LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_TriviallyAvailable,
1022 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_assignment& operator=(1014 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_assignment& operator=(
...@@ -1034,11 +1026,11 @@ _LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_Unavailable,...@@ -1034,11 +1026,11 @@ _LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_Unavailable,
1034 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_assignment& operator=(1026 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_assignment& operator=(
1035 const __copy_assignment&) = delete);1027 const __copy_assignment&) = delete);
10361028
1037# undef _LIBCPP_VARIANT_COPY_ASSIGNMENT1029# undef _LIBCPP_VARIANT_COPY_ASSIGNMENT
10381030
1039template <class... _Types>1031template <class... _Types>
1040class _LIBCPP_TEMPLATE_VIS __impl : public __copy_assignment<__traits<_Types...>> {1032class _LIBCPP_TEMPLATE_VIS __impl : public __copy_assignment<__traits<_Types...>> {
1041 using __base_type = __copy_assignment<__traits<_Types...>>;1033 using __base_type _LIBCPP_NODEBUG = __copy_assignment<__traits<_Types...>>;
10421034
1043public:1035public:
1044 using __base_type::__base_type; // get in_place_index_t constructor & friends1036 using __base_type::__base_type; // get in_place_index_t constructor & friends
...@@ -1071,7 +1063,7 @@ public:...@@ -1071,7 +1063,7 @@ public:
1071 std::swap(__lhs, __rhs);1063 std::swap(__lhs, __rhs);
1072 }1064 }
1073 __impl __tmp(std::move(*__rhs));1065 __impl __tmp(std::move(*__rhs));
1074# ifndef _LIBCPP_HAS_NO_EXCEPTIONS1066# if _LIBCPP_HAS_EXCEPTIONS
1075 if constexpr (__all<is_nothrow_move_constructible_v<_Types>...>::value) {1067 if constexpr (__all<is_nothrow_move_constructible_v<_Types>...>::value) {
1076 this->__generic_construct(*__rhs, std::move(*__lhs));1068 this->__generic_construct(*__rhs, std::move(*__lhs));
1077 } else {1069 } else {
...@@ -1087,11 +1079,11 @@ public:...@@ -1087,11 +1079,11 @@ public:
1087 throw;1079 throw;
1088 }1080 }
1089 }1081 }
1090# else1082# else
1091 // this isn't consolidated with the `if constexpr` branch above due to1083 // this isn't consolidated with the `if constexpr` branch above due to
1092 // `throw` being ill-formed with exceptions disabled even when discarded.1084 // `throw` being ill-formed with exceptions disabled even when discarded.
1093 this->__generic_construct(*__rhs, std::move(*__lhs));1085 this->__generic_construct(*__rhs, std::move(*__lhs));
1094# endif1086# endif
1095 this->__generic_construct(*__lhs, std::move(__tmp));1087 this->__generic_construct(*__lhs, std::move(__tmp));
1096 }1088 }
1097 }1089 }
...@@ -1105,7 +1097,7 @@ private:...@@ -1105,7 +1097,7 @@ private:
11051097
1106struct __no_narrowing_check {1098struct __no_narrowing_check {
1107 template <class _Dest, class _Source>1099 template <class _Dest, class _Source>
1108 using _Apply = __type_identity<_Dest>;1100 using _Apply _LIBCPP_NODEBUG = __type_identity<_Dest>;
1109};1101};
11101102
1111struct __narrowing_check {1103struct __narrowing_check {
...@@ -1146,7 +1138,7 @@ using _MakeOverloads _LIBCPP_NODEBUG =...@@ -1146,7 +1138,7 @@ using _MakeOverloads _LIBCPP_NODEBUG =
1146 typename __make_overloads_imp< __make_indices_imp<sizeof...(_Types), 0> >::template _Apply<_Types...>;1138 typename __make_overloads_imp< __make_indices_imp<sizeof...(_Types), 0> >::template _Apply<_Types...>;
11471139
1148template <class _Tp, class... _Types>1140template <class _Tp, class... _Types>
1149using __best_match_t = typename invoke_result_t<_MakeOverloads<_Types...>, _Tp, _Tp>::type;1141using __best_match_t _LIBCPP_NODEBUG = typename invoke_result_t<_MakeOverloads<_Types...>, _Tp, _Tp>::type;
11501142
1151} // namespace __variant_detail1143} // namespace __variant_detail
11521144
...@@ -1154,17 +1146,17 @@ template <class _Visitor, class... _Vs, typename = void_t<decltype(std::__as_var...@@ -1154,17 +1146,17 @@ template <class _Visitor, class... _Vs, typename = void_t<decltype(std::__as_var
1154_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr decltype(auto)1146_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr decltype(auto)
1155visit(_Visitor&& __visitor, _Vs&&... __vs);1147visit(_Visitor&& __visitor, _Vs&&... __vs);
11561148
1157# if _LIBCPP_STD_VER >= 201149# if _LIBCPP_STD_VER >= 20
1158template <class _Rp,1150template <class _Rp,
1159 class _Visitor,1151 class _Visitor,
1160 class... _Vs,1152 class... _Vs,
1161 typename = void_t<decltype(std::__as_variant(std::declval<_Vs>()))...>>1153 typename = void_t<decltype(std::__as_variant(std::declval<_Vs>()))...>>
1162_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp1154_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp
1163visit(_Visitor&& __visitor, _Vs&&... __vs);1155visit(_Visitor&& __visitor, _Vs&&... __vs);
1164# endif1156# endif
11651157
1166template <class... _Types>1158template <class... _Types>
1167class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES variant1159class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES _LIBCPP_NO_SPECIALIZATIONS variant
1168 : private __sfinae_ctor_base< __all<is_copy_constructible_v<_Types>...>::value,1160 : private __sfinae_ctor_base< __all<is_copy_constructible_v<_Types>...>::value,
1169 __all<is_move_constructible_v<_Types>...>::value>,1161 __all<is_move_constructible_v<_Types>...>::value>,
1170 private __sfinae_assign_base<1162 private __sfinae_assign_base<
...@@ -1178,10 +1170,10 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES variant...@@ -1178,10 +1170,10 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES variant
11781170
1179 static_assert(__all<!is_void_v<_Types>...>::value, "variant can not have a void type as an alternative.");1171 static_assert(__all<!is_void_v<_Types>...>::value, "variant can not have a void type as an alternative.");
11801172
1181 using __first_type = variant_alternative_t<0, variant>;1173 using __first_type _LIBCPP_NODEBUG = variant_alternative_t<0, variant>;
11821174
1183public:1175public:
1184 using __trivially_relocatable =1176 using __trivially_relocatable _LIBCPP_NODEBUG =
1185 conditional_t<_And<__libcpp_is_trivially_relocatable<_Types>...>::value, variant, void>;1177 conditional_t<_And<__libcpp_is_trivially_relocatable<_Types>...>::value, variant, void>;
11861178
1187 template <bool _Dummy = true,1179 template <bool _Dummy = true,
...@@ -1309,7 +1301,7 @@ public:...@@ -1309,7 +1301,7 @@ public:
1309 __impl_.__swap(__that.__impl_);1301 __impl_.__swap(__that.__impl_);
1310 }1302 }
13111303
1312# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)1304# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
1313 // Helper class to implement [variant.visit]/101305 // Helper class to implement [variant.visit]/10
1314 // Constraints: The call to visit does not use an explicit template-argument-list1306 // Constraints: The call to visit does not use an explicit template-argument-list
1315 // that begins with a type template-argument.1307 // that begins with a type template-argument.
...@@ -1319,16 +1311,14 @@ public:...@@ -1319,16 +1311,14 @@ public:
13191311
1320 template <__variant_visit_barrier_tag = __variant_visit_barrier_tag{}, class _Self, class _Visitor>1312 template <__variant_visit_barrier_tag = __variant_visit_barrier_tag{}, class _Self, class _Visitor>
1321 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) visit(this _Self&& __self, _Visitor&& __visitor) {1313 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) visit(this _Self&& __self, _Visitor&& __visitor) {
1322 using _VariantT = _OverrideRef<_Self&&, _CopyConst<remove_reference_t<_Self>, variant>>;1314 return std::visit(std::forward<_Visitor>(__visitor), std::__forward_as<_Self, variant>(__self));
1323 return std::visit(std::forward<_Visitor>(__visitor), (_VariantT)__self);
1324 }1315 }
13251316
1326 template <class _Rp, class _Self, class _Visitor>1317 template <class _Rp, class _Self, class _Visitor>
1327 _LIBCPP_HIDE_FROM_ABI constexpr _Rp visit(this _Self&& __self, _Visitor&& __visitor) {1318 _LIBCPP_HIDE_FROM_ABI constexpr _Rp visit(this _Self&& __self, _Visitor&& __visitor) {
1328 using _VariantT = _OverrideRef<_Self&&, _CopyConst<remove_reference_t<_Self>, variant>>;1319 return std::visit<_Rp>(std::forward<_Visitor>(__visitor), std::__forward_as<_Self, variant>(__self));
1329 return std::visit<_Rp>(std::forward<_Visitor>(__visitor), (_VariantT)__self);
1330 }1320 }
1331# endif1321# endif
13321322
1333private:1323private:
1334 __variant_detail::__impl<_Types...> __impl_;1324 __variant_detail::__impl<_Types...> __impl_;
...@@ -1472,7 +1462,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const variant<_Types...>& __lhs,...@@ -1472,7 +1462,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const variant<_Types...>& __lhs,
1472 return __variant::__visit_value_at(__lhs.index(), __convert_to_bool<equal_to<>>{}, __lhs, __rhs);1462 return __variant::__visit_value_at(__lhs.index(), __convert_to_bool<equal_to<>>{}, __lhs, __rhs);
1473}1463}
14741464
1475# if _LIBCPP_STD_VER >= 201465# if _LIBCPP_STD_VER >= 20
14761466
1477template <class... _Types>1467template <class... _Types>
1478 requires(three_way_comparable<_Types> && ...)1468 requires(three_way_comparable<_Types> && ...)
...@@ -1492,7 +1482,7 @@ operator<=>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {...@@ -1492,7 +1482,7 @@ operator<=>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
1492 return __variant::__visit_value_at(__lhs.index(), __three_way, __lhs, __rhs);1482 return __variant::__visit_value_at(__lhs.index(), __three_way, __lhs, __rhs);
1493}1483}
14941484
1495# endif // _LIBCPP_STD_VER >= 201485# endif // _LIBCPP_STD_VER >= 20
14961486
1497template <class... _Types>1487template <class... _Types>
1498_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {1488_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
...@@ -1576,7 +1566,7 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) {...@@ -1576,7 +1566,7 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) {
1576 return __variant::__visit_value(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...);1566 return __variant::__visit_value(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...);
1577}1567}
15781568
1579# if _LIBCPP_STD_VER >= 201569# if _LIBCPP_STD_VER >= 20
1580template < class _Rp, class _Visitor, class... _Vs, typename>1570template < class _Rp, class _Visitor, class... _Vs, typename>
1581_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp1571_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp
1582visit(_Visitor&& __visitor, _Vs&&... __vs) {1572visit(_Visitor&& __visitor, _Vs&&... __vs) {
...@@ -1584,7 +1574,7 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) {...@@ -1584,7 +1574,7 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) {
1584 std::__throw_if_valueless(std::forward<_Vs>(__vs)...);1574 std::__throw_if_valueless(std::forward<_Vs>(__vs)...);
1585 return __variant::__visit_value<_Rp>(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...);1575 return __variant::__visit_value<_Rp>(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...);
1586}1576}
1587# endif1577# endif
15881578
1589template <class... _Types>1579template <class... _Types>
1590_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto1580_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto
...@@ -1633,18 +1623,20 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto&& __unchecked_get(variant<_Types...>& __v)...@@ -1633,18 +1623,20 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto&& __unchecked_get(variant<_Types...>& __v)
1633 return std::__unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);1623 return std::__unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
1634}1624}
16351625
1636#endif // _LIBCPP_STD_VER >= 171626# endif // _LIBCPP_STD_VER >= 17
16371627
1638_LIBCPP_END_NAMESPACE_STD1628_LIBCPP_END_NAMESPACE_STD
16391629
1640_LIBCPP_POP_MACROS1630_LIBCPP_POP_MACROS
16411631
1642#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 201632# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1643# include <exception>1633# include <cstddef>
1644# include <tuple>1634# include <exception>
1645# include <type_traits>1635# include <tuple>
1646# include <typeinfo>1636# include <type_traits>
1647# include <utility>1637# include <typeinfo>
1648#endif1638# include <utility>
1639# endif
1640#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
16491641
1650#endif // _LIBCPP_VARIANT1642#endif // _LIBCPP_VARIANT
lib/libcxx/include/vector+54-2711
...@@ -170,7 +170,7 @@ public:...@@ -170,7 +170,7 @@ public:
170170
171 vector()171 vector()
172 noexcept(is_nothrow_default_constructible<allocator_type>::value);172 noexcept(is_nothrow_default_constructible<allocator_type>::value);
173 explicit vector(const allocator_type&);173 explicit vector(const allocator_type&) noexcept;
174 explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14174 explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14
175 vector(size_type n, const value_type& value, const allocator_type& = allocator_type());175 vector(size_type n, const value_type& value, const allocator_type& = allocator_type());
176 template <class InputIterator>176 template <class InputIterator>
...@@ -178,8 +178,7 @@ public:...@@ -178,8 +178,7 @@ public:
178 template<container-compatible-range<bool> R>178 template<container-compatible-range<bool> R>
179 constexpr vector(from_range_t, R&& rg, const Allocator& = Allocator());179 constexpr vector(from_range_t, R&& rg, const Allocator& = Allocator());
180 vector(const vector& x);180 vector(const vector& x);
181 vector(vector&& x)181 vector(vector&& x) noexcept;
182 noexcept(is_nothrow_move_constructible<allocator_type>::value);
183 vector(initializer_list<value_type> il);182 vector(initializer_list<value_type> il);
184 vector(initializer_list<value_type> il, const allocator_type& a);183 vector(initializer_list<value_type> il, const allocator_type& a);
185 ~vector();184 ~vector();
...@@ -305,2727 +304,71 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++...@@ -305,2727 +304,71 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++
305304
306// clang-format on305// clang-format on
307306
308#include <__algorithm/copy.h>307#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
309#include <__algorithm/equal.h>308# include <__cxx03/vector>
310#include <__algorithm/fill_n.h>
311#include <__algorithm/iterator_operations.h>
312#include <__algorithm/lexicographical_compare.h>
313#include <__algorithm/lexicographical_compare_three_way.h>
314#include <__algorithm/remove.h>
315#include <__algorithm/remove_if.h>
316#include <__algorithm/rotate.h>
317#include <__algorithm/unwrap_iter.h>
318#include <__assert>
319#include <__bit_reference>
320#include <__concepts/same_as.h>
321#include <__config>
322#include <__debug_utils/sanitizers.h>
323#include <__format/enable_insertable.h>
324#include <__format/formatter.h>
325#include <__format/formatter_bool.h>
326#include <__functional/hash.h>
327#include <__functional/unary_function.h>
328#include <__fwd/vector.h>
329#include <__iterator/advance.h>
330#include <__iterator/bounded_iter.h>
331#include <__iterator/distance.h>
332#include <__iterator/iterator_traits.h>
333#include <__iterator/reverse_iterator.h>
334#include <__iterator/wrap_iter.h>
335#include <__memory/addressof.h>
336#include <__memory/allocate_at_least.h>
337#include <__memory/allocator_traits.h>
338#include <__memory/pointer_traits.h>
339#include <__memory/swap_allocator.h>
340#include <__memory/temp_value.h>
341#include <__memory/uninitialized_algorithms.h>
342#include <__memory_resource/polymorphic_allocator.h>
343#include <__ranges/access.h>
344#include <__ranges/concepts.h>
345#include <__ranges/container_compatible_range.h>
346#include <__ranges/from_range.h>
347#include <__ranges/size.h>
348#include <__split_buffer>
349#include <__type_traits/is_allocator.h>
350#include <__type_traits/is_constructible.h>
351#include <__type_traits/is_nothrow_assignable.h>
352#include <__type_traits/noexcept_move_assign_container.h>
353#include <__type_traits/type_identity.h>
354#include <__utility/exception_guard.h>
355#include <__utility/forward.h>
356#include <__utility/is_pointer_in_range.h>
357#include <__utility/move.h>
358#include <__utility/pair.h>
359#include <__utility/swap.h>
360#include <climits>
361#include <cstring>
362#include <limits>
363#include <stdexcept>
364#include <version>
365
366// standard-mandated includes
367
368// [iterator.range]
369#include <__iterator/access.h>
370#include <__iterator/data.h>
371#include <__iterator/empty.h>
372#include <__iterator/reverse_access.h>
373#include <__iterator/size.h>
374
375// [vector.syn]
376#include <compare>
377#include <initializer_list>
378
379#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
380# pragma GCC system_header
381#endif
382
383_LIBCPP_PUSH_MACROS
384#include <__undef_macros>
385
386_LIBCPP_BEGIN_NAMESPACE_STD
387
388template <class _Tp, class _Allocator /* = allocator<_Tp> */>
389class _LIBCPP_TEMPLATE_VIS vector {
390private:
391 typedef allocator<_Tp> __default_allocator_type;
392
393public:
394 typedef vector __self;
395 typedef _Tp value_type;
396 typedef _Allocator allocator_type;
397 typedef allocator_traits<allocator_type> __alloc_traits;
398 typedef value_type& reference;
399 typedef const value_type& const_reference;
400 typedef typename __alloc_traits::size_type size_type;
401 typedef typename __alloc_traits::difference_type difference_type;
402 typedef typename __alloc_traits::pointer pointer;
403 typedef typename __alloc_traits::const_pointer const_pointer;
404#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
405 // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's
406 // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is
407 // considered contiguous.
408 typedef __bounded_iter<__wrap_iter<pointer>> iterator;
409 typedef __bounded_iter<__wrap_iter<const_pointer>> const_iterator;
410#else
411 typedef __wrap_iter<pointer> iterator;
412 typedef __wrap_iter<const_pointer> const_iterator;
413#endif
414 typedef std::reverse_iterator<iterator> reverse_iterator;
415 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
416
417 // A vector containers the following members which may be trivially relocatable:
418 // - pointer: may be trivially relocatable, so it's checked
419 // - allocator_type: may be trivially relocatable, so it's checked
420 // vector doesn't contain any self-references, so it's trivially relocatable if its members are.
421 using __trivially_relocatable = __conditional_t<
422 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
423 vector,
424 void>;
425
426 static_assert(__check_valid_allocator<allocator_type>::value, "");
427 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
428 "Allocator::value_type must be same type as value_type");
429
430 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector()
431 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) {}
432 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a)
433#if _LIBCPP_STD_VER <= 14
434 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
435#else
436 _NOEXCEPT
437#endif
438 : __end_cap_(nullptr, __a) {
439 }
440
441 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n) {
442 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
443 if (__n > 0) {
444 __vallocate(__n);
445 __construct_at_end(__n);
446 }
447 __guard.__complete();
448 }
449
450#if _LIBCPP_STD_VER >= 14
451 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a)
452 : __end_cap_(nullptr, __a) {
453 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
454 if (__n > 0) {
455 __vallocate(__n);
456 __construct_at_end(__n);
457 }
458 __guard.__complete();
459 }
460#endif
461
462 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x) {
463 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
464 if (__n > 0) {
465 __vallocate(__n);
466 __construct_at_end(__n, __x);
467 }
468 __guard.__complete();
469 }
470
471 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>
472 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
473 vector(size_type __n, const value_type& __x, const allocator_type& __a)
474 : __end_cap_(nullptr, __a) {
475 if (__n > 0) {
476 __vallocate(__n);
477 __construct_at_end(__n, __x);
478 }
479 }
480
481 template <class _InputIterator,
482 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
483 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
484 int> = 0>
485 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last);
486 template <class _InputIterator,
487 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
488 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
489 int> = 0>
490 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
491 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
492
493 template <
494 class _ForwardIterator,
495 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
496 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
497 int> = 0>
498 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last);
499
500 template <
501 class _ForwardIterator,
502 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
503 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
504 int> = 0>
505 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
506 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a);
507
508#if _LIBCPP_STD_VER >= 23
509 template <_ContainerCompatibleRange<_Tp> _Range>
510 _LIBCPP_HIDE_FROM_ABI constexpr vector(
511 from_range_t, _Range&& __range, const allocator_type& __alloc = allocator_type())
512 : __end_cap_(nullptr, __alloc) {
513 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
514 auto __n = static_cast<size_type>(ranges::distance(__range));
515 __init_with_size(ranges::begin(__range), ranges::end(__range), __n);
516
517 } else {
518 __init_with_sentinel(ranges::begin(__range), ranges::end(__range));
519 }
520 }
521#endif
522
523private:
524 class __destroy_vector {
525 public:
526 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __destroy_vector(vector& __vec) : __vec_(__vec) {}
527
528 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {
529 if (__vec_.__begin_ != nullptr) {
530 __vec_.__clear();
531 __vec_.__annotate_delete();
532 __alloc_traits::deallocate(__vec_.__alloc(), __vec_.__begin_, __vec_.capacity());
533 }
534 }
535
536 private:
537 vector& __vec_;
538 };
539
540public:
541 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { __destroy_vector (*this)(); }
542
543 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x);
544 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
545 vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
546 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(const vector& __x);
547
548#ifndef _LIBCPP_CXX03_LANG
549 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(initializer_list<value_type> __il);
550
551 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
552 vector(initializer_list<value_type> __il, const allocator_type& __a);
553
554 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(initializer_list<value_type> __il) {
555 assign(__il.begin(), __il.end());
556 return *this;
557 }
558#endif // !_LIBCPP_CXX03_LANG
559
560 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(vector&& __x)
561#if _LIBCPP_STD_VER >= 17
562 noexcept;
563#else
564 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
565#endif
566
567 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
568 vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
569 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(vector&& __x)
570 _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value);
571
572 template <class _InputIterator,
573 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
574 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
575 int> = 0>
576 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_InputIterator __first, _InputIterator __last);
577 template <
578 class _ForwardIterator,
579 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
580 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
581 int> = 0>
582 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_ForwardIterator __first, _ForwardIterator __last);
583
584#if _LIBCPP_STD_VER >= 23
585 template <_ContainerCompatibleRange<_Tp> _Range>
586 _LIBCPP_HIDE_FROM_ABI constexpr void assign_range(_Range&& __range) {
587 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
588 auto __n = static_cast<size_type>(ranges::distance(__range));
589 __assign_with_size(ranges::begin(__range), ranges::end(__range), __n);
590
591 } else {
592 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));
593 }
594 }
595#endif
596
597 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const_reference __u);
598
599#ifndef _LIBCPP_CXX03_LANG
600 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) {
601 assign(__il.begin(), __il.end());
602 }
603#endif
604
605 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
606 return this->__alloc();
607 }
608
609 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT;
610 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT;
611 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT;
612 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT;
613
614 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT {
615 return reverse_iterator(end());
616 }
617 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {
618 return const_reverse_iterator(end());
619 }
620 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT {
621 return reverse_iterator(begin());
622 }
623 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT {
624 return const_reverse_iterator(begin());
625 }
626
627 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }
628 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }
629 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT {
630 return rbegin();
631 }
632 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
633
634 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT {
635 return static_cast<size_type>(this->__end_ - this->__begin_);
636 }
637 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT {
638 return static_cast<size_type>(__end_cap() - this->__begin_);
639 }
640 _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {
641 return this->__begin_ == this->__end_;
642 }
643 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT;
644 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
645 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
646
647 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT;
648 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const _NOEXCEPT;
649 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n);
650 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const;
651
652 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT {
653 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector");
654 return *this->__begin_;
655 }
656 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT {
657 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector");
658 return *this->__begin_;
659 }
660 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT {
661 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector");
662 return *(this->__end_ - 1);
663 }
664 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT {
665 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector");
666 return *(this->__end_ - 1);
667 }
668
669 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI value_type* data() _NOEXCEPT {
670 return std::__to_address(this->__begin_);
671 }
672
673 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const value_type* data() const _NOEXCEPT {
674 return std::__to_address(this->__begin_);
675 }
676
677 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x);
678
679 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);
680
681 template <class... _Args>
682 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
683#if _LIBCPP_STD_VER >= 17
684 reference
685 emplace_back(_Args&&... __args);
686#else
687 void
688 emplace_back(_Args&&... __args);
689#endif
690
691#if _LIBCPP_STD_VER >= 23
692 template <_ContainerCompatibleRange<_Tp> _Range>
693 _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) {
694 insert_range(end(), std::forward<_Range>(__range));
695 }
696#endif
697
698 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back();
699
700 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, const_reference __x);
701
702 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, value_type&& __x);
703 template <class... _Args>
704 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __position, _Args&&... __args);
705
706 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
707 insert(const_iterator __position, size_type __n, const_reference __x);
708
709 template <class _InputIterator,
710 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
711 is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value,
712 int> = 0>
713 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
714 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
715
716#if _LIBCPP_STD_VER >= 23
717 template <_ContainerCompatibleRange<_Tp> _Range>
718 _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) {
719 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
720 auto __n = static_cast<size_type>(ranges::distance(__range));
721 return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n);
722
723 } else {
724 return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));
725 }
726 }
727#endif
728
729 template <
730 class _ForwardIterator,
731 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
732 is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
733 int> = 0>
734 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
735 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
736
737#ifndef _LIBCPP_CXX03_LANG
738 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
739 insert(const_iterator __position, initializer_list<value_type> __il) {
740 return insert(__position, __il.begin(), __il.end());
741 }
742#endif
743
744 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position);
745 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last);
746
747 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT {
748 size_type __old_size = size();
749 __clear();
750 __annotate_shrink(__old_size);
751 }
752
753 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz);
754 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz, const_reference __x);
755
756 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(vector&)
757#if _LIBCPP_STD_VER >= 14
758 _NOEXCEPT;
759#else
760 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
761#endif
762
763 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
764
765private:
766 pointer __begin_ = nullptr;
767 pointer __end_ = nullptr;
768 __compressed_pair<pointer, allocator_type> __end_cap_ =
769 __compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag());
770
771 // Allocate space for __n objects
772 // throws length_error if __n > max_size()
773 // throws (probably bad_alloc) if memory run out
774 // Precondition: __begin_ == __end_ == __end_cap() == 0
775 // Precondition: __n > 0
776 // Postcondition: capacity() >= __n
777 // Postcondition: size() == 0
778 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
779 if (__n > max_size())
780 __throw_length_error();
781 auto __allocation = std::__allocate_at_least(__alloc(), __n);
782 __begin_ = __allocation.ptr;
783 __end_ = __allocation.ptr;
784 __end_cap() = __begin_ + __allocation.count;
785 __annotate_new(0);
786 }
787
788 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vdeallocate() _NOEXCEPT;
789 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __recommend(size_type __new_size) const;
790 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);
791 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x);
792
793 template <class _InputIterator, class _Sentinel>
794 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
795 __init_with_size(_InputIterator __first, _Sentinel __last, size_type __n) {
796 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
797
798 if (__n > 0) {
799 __vallocate(__n);
800 __construct_at_end(__first, __last, __n);
801 }
802
803 __guard.__complete();
804 }
805
806 template <class _InputIterator, class _Sentinel>
807 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
808 __init_with_sentinel(_InputIterator __first, _Sentinel __last) {
809 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
810
811 for (; __first != __last; ++__first)
812 emplace_back(*__first);
813
814 __guard.__complete();
815 }
816
817 template <class _Iterator, class _Sentinel>
818 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last);
819
820 template <class _ForwardIterator, class _Sentinel>
821 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
822 __assign_with_size(_ForwardIterator __first, _Sentinel __last, difference_type __n);
823
824 template <class _InputIterator, class _Sentinel>
825 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
826 __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last);
827
828 template <class _Iterator, class _Sentinel>
829 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
830 __insert_with_size(const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n);
831
832 template <class _InputIterator, class _Sentinel>
833 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
834 __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n);
835
836 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n);
837 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x);
838
839 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT {
840#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
841 // Bound the iterator according to the capacity, rather than the size.
842 //
843 // Vector guarantees that iterators stay valid as long as no reallocation occurs even if new elements are inserted
844 // into the container; for these cases, we need to make sure that the newly-inserted elements can be accessed
845 // through the bounded iterator without failing checks. The downside is that the bounded iterator won't catch
846 // access that is logically out-of-bounds, i.e., goes beyond the size, but is still within the capacity. With the
847 // current implementation, there is no connection between a bounded iterator and its associated container, so we
848 // don't have a way to update existing valid iterators when the container is resized and thus have to go with
849 // a laxer approach.
850 return std::__make_bounded_iter(
851 std::__wrap_iter<pointer>(__p),
852 std::__wrap_iter<pointer>(this->__begin_),
853 std::__wrap_iter<pointer>(this->__end_cap()));
854#else
855 return iterator(__p);
856#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
857 }
858
859 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT {
860#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
861 // Bound the iterator according to the capacity, rather than the size.
862 return std::__make_bounded_iter(
863 std::__wrap_iter<const_pointer>(__p),
864 std::__wrap_iter<const_pointer>(this->__begin_),
865 std::__wrap_iter<const_pointer>(this->__end_cap()));
866#else
867 return const_iterator(__p);
868#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
869 }
870
871 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
872 __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
873 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer
874 __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
875 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
876 __move_range(pointer __from_s, pointer __from_e, pointer __to);
877 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type)
878 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
879 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, false_type)
880 _NOEXCEPT_(__alloc_traits::is_always_equal::value);
881 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last) _NOEXCEPT {
882 size_type __old_size = size();
883 __base_destruct_at_end(__new_last);
884 __annotate_shrink(__old_size);
885 }
886
887 template <class _Up>
888 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI inline pointer __push_back_slow_path(_Up&& __x);
889
890 template <class... _Args>
891 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI inline pointer __emplace_back_slow_path(_Args&&... __args);
892
893 // The following functions are no-ops outside of AddressSanitizer mode.
894 // We call annotations for every allocator, unless explicitly disabled.
895 //
896 // To disable annotations for a particular allocator, change value of
897 // __asan_annotate_container_with_allocator to false.
898 // For more details, see the "Using libc++" documentation page or
899 // the documentation for __sanitizer_annotate_contiguous_container.
900
901 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
902 __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {
903 std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity(), __old_mid, __new_mid);
904 }
905
906 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {
907 (void)__current_size;
908#ifndef _LIBCPP_HAS_NO_ASAN
909 __annotate_contiguous_container(data() + capacity(), data() + __current_size);
910#endif
911 }
912
913 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {
914#ifndef _LIBCPP_HAS_NO_ASAN
915 __annotate_contiguous_container(data() + size(), data() + capacity());
916#endif
917 }
918
919 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT {
920 (void)__n;
921#ifndef _LIBCPP_HAS_NO_ASAN
922 __annotate_contiguous_container(data() + size(), data() + size() + __n);
923#endif
924 }
925
926 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT {
927 (void)__old_size;
928#ifndef _LIBCPP_HAS_NO_ASAN
929 __annotate_contiguous_container(data() + __old_size, data() + size());
930#endif
931 }
932
933 struct _ConstructTransaction {
934 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n)
935 : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
936#ifndef _LIBCPP_HAS_NO_ASAN
937 __v_.__annotate_increase(__n);
938#endif
939 }
940
941 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
942 __v_.__end_ = __pos_;
943#ifndef _LIBCPP_HAS_NO_ASAN
944 if (__pos_ != __new_end_) {
945 __v_.__annotate_shrink(__new_end_ - __v_.__begin_);
946 }
947#endif
948 }
949
950 vector& __v_;
951 pointer __pos_;
952 const_pointer const __new_end_;
953
954 _ConstructTransaction(_ConstructTransaction const&) = delete;
955 _ConstructTransaction& operator=(_ConstructTransaction const&) = delete;
956 };
957
958 template <class... _Args>
959 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_one_at_end(_Args&&... __args) {
960 _ConstructTransaction __tx(*this, 1);
961 __alloc_traits::construct(this->__alloc(), std::__to_address(__tx.__pos_), std::forward<_Args>(__args)...);
962 ++__tx.__pos_;
963 }
964
965 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT {
966 return this->__end_cap_.second();
967 }
968 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT {
969 return this->__end_cap_.second();
970 }
971 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT {
972 return this->__end_cap_.first();
973 }
974 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const pointer& __end_cap() const _NOEXCEPT {
975 return this->__end_cap_.first();
976 }
977
978 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __clear() _NOEXCEPT {
979 __base_destruct_at_end(this->__begin_);
980 }
981
982 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {
983 pointer __soon_to_be_end = this->__end_;
984 while (__new_last != __soon_to_be_end)
985 __alloc_traits::destroy(__alloc(), std::__to_address(--__soon_to_be_end));
986 this->__end_ = __new_last;
987 }
988
989 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c) {
990 __copy_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_copy_assignment::value>());
991 }
992
993 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector& __c)
994 _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value ||
995 is_nothrow_move_assignable<allocator_type>::value) {
996 __move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
997 }
998
999 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { std::__throw_length_error("vector"); }
1000
1001 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { std::__throw_out_of_range("vector"); }
1002
1003 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c, true_type) {
1004 if (__alloc() != __c.__alloc()) {
1005 __clear();
1006 __annotate_delete();
1007 __alloc_traits::deallocate(__alloc(), this->__begin_, capacity());
1008 this->__begin_ = this->__end_ = __end_cap() = nullptr;
1009 }
1010 __alloc() = __c.__alloc();
1011 }
1012
1013 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector&, false_type) {}
1014
1015 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector& __c, true_type)
1016 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
1017 __alloc() = std::move(__c.__alloc());
1018 }
1019
1020 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector&, false_type) _NOEXCEPT {}
1021};
1022
1023#if _LIBCPP_STD_VER >= 17
1024template <class _InputIterator,
1025 class _Alloc = allocator<__iter_value_type<_InputIterator>>,
1026 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1027 class = enable_if_t<__is_allocator<_Alloc>::value> >
1028vector(_InputIterator, _InputIterator) -> vector<__iter_value_type<_InputIterator>, _Alloc>;
1029
1030template <class _InputIterator,
1031 class _Alloc,
1032 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
1033 class = enable_if_t<__is_allocator<_Alloc>::value> >
1034vector(_InputIterator, _InputIterator, _Alloc) -> vector<__iter_value_type<_InputIterator>, _Alloc>;
1035#endif
1036
1037#if _LIBCPP_STD_VER >= 23
1038template <ranges::input_range _Range,
1039 class _Alloc = allocator<ranges::range_value_t<_Range>>,
1040 class = enable_if_t<__is_allocator<_Alloc>::value> >
1041vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_t<_Range>, _Alloc>;
1042#endif
1043
1044// __swap_out_circular_buffer relocates the objects in [__begin_, __end_) into the front of __v and swaps the buffers of
1045// *this and __v. It is assumed that __v provides space for exactly (__end_ - __begin_) objects in the front. This
1046// function has a strong exception guarantee.
1047template <class _Tp, class _Allocator>
1048_LIBCPP_CONSTEXPR_SINCE_CXX20 void
1049vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) {
1050 __annotate_delete();
1051 auto __new_begin = __v.__begin_ - (__end_ - __begin_);
1052 std::__uninitialized_allocator_relocate(
1053 __alloc(), std::__to_address(__begin_), std::__to_address(__end_), std::__to_address(__new_begin));
1054 __v.__begin_ = __new_begin;
1055 __end_ = __begin_; // All the objects have been destroyed by relocating them.
1056 std::swap(this->__begin_, __v.__begin_);
1057 std::swap(this->__end_, __v.__end_);
1058 std::swap(this->__end_cap(), __v.__end_cap());
1059 __v.__first_ = __v.__begin_;
1060 __annotate_new(size());
1061}
1062
1063// __swap_out_circular_buffer relocates the objects in [__begin_, __p) into the front of __v, the objects in
1064// [__p, __end_) into the back of __v and swaps the buffers of *this and __v. It is assumed that __v provides space for
1065// exactly (__p - __begin_) objects in the front and space for at least (__end_ - __p) objects in the back. This
1066// function has a strong exception guarantee if __begin_ == __p || __end_ == __p.
1067template <class _Tp, class _Allocator>
1068_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer
1069vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) {
1070 __annotate_delete();
1071 pointer __ret = __v.__begin_;
1072
1073 // Relocate [__p, __end_) first to avoid having a hole in [__begin_, __end_)
1074 // in case something in [__begin_, __p) throws.
1075 std::__uninitialized_allocator_relocate(
1076 __alloc(), std::__to_address(__p), std::__to_address(__end_), std::__to_address(__v.__end_));
1077 __v.__end_ += (__end_ - __p);
1078 __end_ = __p; // The objects in [__p, __end_) have been destroyed by relocating them.
1079 auto __new_begin = __v.__begin_ - (__p - __begin_);
1080
1081 std::__uninitialized_allocator_relocate(
1082 __alloc(), std::__to_address(__begin_), std::__to_address(__p), std::__to_address(__new_begin));
1083 __v.__begin_ = __new_begin;
1084 __end_ = __begin_; // All the objects have been destroyed by relocating them.
1085
1086 std::swap(this->__begin_, __v.__begin_);
1087 std::swap(this->__end_, __v.__end_);
1088 std::swap(this->__end_cap(), __v.__end_cap());
1089 __v.__first_ = __v.__begin_;
1090 __annotate_new(size());
1091 return __ret;
1092}
1093
1094template <class _Tp, class _Allocator>
1095_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT {
1096 if (this->__begin_ != nullptr) {
1097 clear();
1098 __annotate_delete();
1099 __alloc_traits::deallocate(this->__alloc(), this->__begin_, capacity());
1100 this->__begin_ = this->__end_ = this->__end_cap() = nullptr;
1101 }
1102}
1103
1104template <class _Tp, class _Allocator>
1105_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::size_type
1106vector<_Tp, _Allocator>::max_size() const _NOEXCEPT {
1107 return std::min<size_type>(__alloc_traits::max_size(this->__alloc()), numeric_limits<difference_type>::max());
1108}
1109
1110// Precondition: __new_size > capacity()
1111template <class _Tp, class _Allocator>
1112_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
1113vector<_Tp, _Allocator>::__recommend(size_type __new_size) const {
1114 const size_type __ms = max_size();
1115 if (__new_size > __ms)
1116 this->__throw_length_error();
1117 const size_type __cap = capacity();
1118 if (__cap >= __ms / 2)
1119 return __ms;
1120 return std::max<size_type>(2 * __cap, __new_size);
1121}
1122
1123// Default constructs __n objects starting at __end_
1124// throws if construction throws
1125// Precondition: __n > 0
1126// Precondition: size() + __n <= capacity()
1127// Postcondition: size() == size() + __n
1128template <class _Tp, class _Allocator>
1129_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__construct_at_end(size_type __n) {
1130 _ConstructTransaction __tx(*this, __n);
1131 const_pointer __new_end = __tx.__new_end_;
1132 for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {
1133 __alloc_traits::construct(this->__alloc(), std::__to_address(__pos));
1134 }
1135}
1136
1137// Copy constructs __n objects starting at __end_ from __x
1138// throws if construction throws
1139// Precondition: __n > 0
1140// Precondition: size() + __n <= capacity()
1141// Postcondition: size() == old size() + __n
1142// Postcondition: [i] == __x for all i in [size() - __n, __n)
1143template <class _Tp, class _Allocator>
1144_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
1145vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) {
1146 _ConstructTransaction __tx(*this, __n);
1147 const_pointer __new_end = __tx.__new_end_;
1148 for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {
1149 __alloc_traits::construct(this->__alloc(), std::__to_address(__pos), __x);
1150 }
1151}
1152
1153template <class _Tp, class _Allocator>
1154template <class _InputIterator, class _Sentinel>
1155_LIBCPP_CONSTEXPR_SINCE_CXX20 void
1156vector<_Tp, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) {
1157 _ConstructTransaction __tx(*this, __n);
1158 __tx.__pos_ = std::__uninitialized_allocator_copy(__alloc(), __first, __last, __tx.__pos_);
1159}
1160
1161// Default constructs __n objects starting at __end_
1162// throws if construction throws
1163// Postcondition: size() == size() + __n
1164// Exception safety: strong.
1165template <class _Tp, class _Allocator>
1166_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n) {
1167 if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n)
1168 this->__construct_at_end(__n);
1169 else {
1170 allocator_type& __a = this->__alloc();
1171 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a);
1172 __v.__construct_at_end(__n);
1173 __swap_out_circular_buffer(__v);
1174 }
1175}
1176
1177// Default constructs __n objects starting at __end_
1178// throws if construction throws
1179// Postcondition: size() == size() + __n
1180// Exception safety: strong.
1181template <class _Tp, class _Allocator>
1182_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) {
1183 if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n)
1184 this->__construct_at_end(__n, __x);
1185 else {
1186 allocator_type& __a = this->__alloc();
1187 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a);
1188 __v.__construct_at_end(__n, __x);
1189 __swap_out_circular_buffer(__v);
1190 }
1191}
1192
1193template <class _Tp, class _Allocator>
1194template <class _InputIterator,
1195 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
1196 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
1197 int> >
1198_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last) {
1199 __init_with_sentinel(__first, __last);
1200}
1201
1202template <class _Tp, class _Allocator>
1203template <class _InputIterator,
1204 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
1205 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
1206 int> >
1207_LIBCPP_CONSTEXPR_SINCE_CXX20
1208vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
1209 : __end_cap_(nullptr, __a) {
1210 __init_with_sentinel(__first, __last);
1211}
1212
1213template <class _Tp, class _Allocator>
1214template <class _ForwardIterator,
1215 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
1216 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
1217 int> >
1218_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last) {
1219 size_type __n = static_cast<size_type>(std::distance(__first, __last));
1220 __init_with_size(__first, __last, __n);
1221}
1222
1223template <class _Tp, class _Allocator>
1224template <class _ForwardIterator,
1225 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
1226 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
1227 int> >
1228_LIBCPP_CONSTEXPR_SINCE_CXX20
1229vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a)
1230 : __end_cap_(nullptr, __a) {
1231 size_type __n = static_cast<size_type>(std::distance(__first, __last));
1232 __init_with_size(__first, __last, __n);
1233}
1234
1235template <class _Tp, class _Allocator>
1236_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(const vector& __x)
1237 : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc())) {
1238 __init_with_size(__x.__begin_, __x.__end_, __x.size());
1239}
1240
1241template <class _Tp, class _Allocator>
1242_LIBCPP_CONSTEXPR_SINCE_CXX20
1243vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
1244 : __end_cap_(nullptr, __a) {
1245 __init_with_size(__x.__begin_, __x.__end_, __x.size());
1246}
1247
1248template <class _Tp, class _Allocator>
1249_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>::vector(vector&& __x)
1250#if _LIBCPP_STD_VER >= 17
1251 noexcept
1252#else
1253 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
1254#endif
1255 : __end_cap_(nullptr, std::move(__x.__alloc())) {
1256 this->__begin_ = __x.__begin_;
1257 this->__end_ = __x.__end_;
1258 this->__end_cap() = __x.__end_cap();
1259 __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
1260}
1261
1262template <class _Tp, class _Allocator>
1263_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI
1264vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a)
1265 : __end_cap_(nullptr, __a) {
1266 if (__a == __x.__alloc()) {
1267 this->__begin_ = __x.__begin_;
1268 this->__end_ = __x.__end_;
1269 this->__end_cap() = __x.__end_cap();
1270 __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
1271 } else {
1272 typedef move_iterator<iterator> _Ip;
1273 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1274 assign(_Ip(__x.begin()), _Ip(__x.end()));
1275 __guard.__complete();
1276 }
1277}
1278
1279#ifndef _LIBCPP_CXX03_LANG
1280
1281template <class _Tp, class _Allocator>
1282_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI
1283vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) {
1284 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1285 if (__il.size() > 0) {
1286 __vallocate(__il.size());
1287 __construct_at_end(__il.begin(), __il.end(), __il.size());
1288 }
1289 __guard.__complete();
1290}
1291
1292template <class _Tp, class _Allocator>
1293_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI
1294vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
1295 : __end_cap_(nullptr, __a) {
1296 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1297 if (__il.size() > 0) {
1298 __vallocate(__il.size());
1299 __construct_at_end(__il.begin(), __il.end(), __il.size());
1300 }
1301 __guard.__complete();
1302}
1303
1304#endif // _LIBCPP_CXX03_LANG
1305
1306template <class _Tp, class _Allocator>
1307_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>&
1308vector<_Tp, _Allocator>::operator=(vector&& __x)
1309 _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
1310 __move_assign(__x, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
1311 return *this;
1312}
1313
1314template <class _Tp, class _Allocator>
1315_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
1316 _NOEXCEPT_(__alloc_traits::is_always_equal::value) {
1317 if (__alloc() != __c.__alloc()) {
1318 typedef move_iterator<iterator> _Ip;
1319 assign(_Ip(__c.begin()), _Ip(__c.end()));
1320 } else
1321 __move_assign(__c, true_type());
1322}
1323
1324template <class _Tp, class _Allocator>
1325_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
1326 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
1327 __vdeallocate();
1328 __move_assign_alloc(__c); // this can throw
1329 this->__begin_ = __c.__begin_;
1330 this->__end_ = __c.__end_;
1331 this->__end_cap() = __c.__end_cap();
1332 __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
1333}
1334
1335template <class _Tp, class _Allocator>
1336_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>&
1337vector<_Tp, _Allocator>::operator=(const vector& __x) {
1338 if (this != std::addressof(__x)) {
1339 __copy_assign_alloc(__x);
1340 assign(__x.__begin_, __x.__end_);
1341 }
1342 return *this;
1343}
1344
1345template <class _Tp, class _Allocator>
1346template <class _InputIterator,
1347 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
1348 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
1349 int> >
1350_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last) {
1351 __assign_with_sentinel(__first, __last);
1352}
1353
1354template <class _Tp, class _Allocator>
1355template <class _Iterator, class _Sentinel>
1356_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
1357vector<_Tp, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __last) {
1358 clear();
1359 for (; __first != __last; ++__first)
1360 emplace_back(*__first);
1361}
1362
1363template <class _Tp, class _Allocator>
1364template <class _ForwardIterator,
1365 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
1366 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
1367 int> >
1368_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) {
1369 __assign_with_size(__first, __last, std::distance(__first, __last));
1370}
1371
1372template <class _Tp, class _Allocator>
1373template <class _ForwardIterator, class _Sentinel>
1374_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
1375vector<_Tp, _Allocator>::__assign_with_size(_ForwardIterator __first, _Sentinel __last, difference_type __n) {
1376 size_type __new_size = static_cast<size_type>(__n);
1377 if (__new_size <= capacity()) {
1378 if (__new_size > size()) {
1379 _ForwardIterator __mid = std::next(__first, size());
1380 std::copy(__first, __mid, this->__begin_);
1381 __construct_at_end(__mid, __last, __new_size - size());
1382 } else {
1383 pointer __m = std::__copy<_ClassicAlgPolicy>(__first, __last, this->__begin_).second;
1384 this->__destruct_at_end(__m);
1385 }
1386 } else {
1387 __vdeallocate();
1388 __vallocate(__recommend(__new_size));
1389 __construct_at_end(__first, __last, __new_size);
1390 }
1391}
1392
1393template <class _Tp, class _Allocator>
1394_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) {
1395 if (__n <= capacity()) {
1396 size_type __s = size();
1397 std::fill_n(this->__begin_, std::min(__n, __s), __u);
1398 if (__n > __s)
1399 __construct_at_end(__n - __s, __u);
1400 else
1401 this->__destruct_at_end(this->__begin_ + __n);
1402 } else {
1403 __vdeallocate();
1404 __vallocate(__recommend(static_cast<size_type>(__n)));
1405 __construct_at_end(__n, __u);
1406 }
1407}
1408
1409template <class _Tp, class _Allocator>
1410_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator
1411vector<_Tp, _Allocator>::begin() _NOEXCEPT {
1412 return __make_iter(this->__begin_);
1413}
1414
1415template <class _Tp, class _Allocator>
1416_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::const_iterator
1417vector<_Tp, _Allocator>::begin() const _NOEXCEPT {
1418 return __make_iter(this->__begin_);
1419}
1420
1421template <class _Tp, class _Allocator>
1422_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator
1423vector<_Tp, _Allocator>::end() _NOEXCEPT {
1424 return __make_iter(this->__end_);
1425}
1426
1427template <class _Tp, class _Allocator>
1428_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::const_iterator
1429vector<_Tp, _Allocator>::end() const _NOEXCEPT {
1430 return __make_iter(this->__end_);
1431}
1432
1433template <class _Tp, class _Allocator>
1434_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::reference
1435vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT {
1436 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds");
1437 return this->__begin_[__n];
1438}
1439
1440template <class _Tp, class _Allocator>
1441_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::const_reference
1442vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT {
1443 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds");
1444 return this->__begin_[__n];
1445}
1446
1447template <class _Tp, class _Allocator>
1448_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::reference vector<_Tp, _Allocator>::at(size_type __n) {
1449 if (__n >= size())
1450 this->__throw_out_of_range();
1451 return this->__begin_[__n];
1452}
1453
1454template <class _Tp, class _Allocator>
1455_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::const_reference
1456vector<_Tp, _Allocator>::at(size_type __n) const {
1457 if (__n >= size())
1458 this->__throw_out_of_range();
1459 return this->__begin_[__n];
1460}
1461
1462template <class _Tp, class _Allocator>
1463_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::reserve(size_type __n) {
1464 if (__n > capacity()) {
1465 if (__n > max_size())
1466 this->__throw_length_error();
1467 allocator_type& __a = this->__alloc();
1468 __split_buffer<value_type, allocator_type&> __v(__n, size(), __a);
1469 __swap_out_circular_buffer(__v);
1470 }
1471}
1472
1473template <class _Tp, class _Allocator>
1474_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT {
1475 if (capacity() > size()) {
1476#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1477 try {
1478#endif // _LIBCPP_HAS_NO_EXCEPTIONS
1479 allocator_type& __a = this->__alloc();
1480 __split_buffer<value_type, allocator_type&> __v(size(), size(), __a);
1481 // The Standard mandates shrink_to_fit() does not increase the capacity.
1482 // With equal capacity keep the existing buffer. This avoids extra work
1483 // due to swapping the elements.
1484 if (__v.capacity() < capacity())
1485 __swap_out_circular_buffer(__v);
1486#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1487 } catch (...) {
1488 }
1489#endif // _LIBCPP_HAS_NO_EXCEPTIONS
1490 }
1491}
1492
1493template <class _Tp, class _Allocator>
1494template <class _Up>
1495_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer
1496vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x) {
1497 allocator_type& __a = this->__alloc();
1498 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
1499 // __v.push_back(std::forward<_Up>(__x));
1500 __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Up>(__x));
1501 __v.__end_++;
1502 __swap_out_circular_buffer(__v);
1503 return this->__end_;
1504}
1505
1506template <class _Tp, class _Allocator>
1507_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void
1508vector<_Tp, _Allocator>::push_back(const_reference __x) {
1509 pointer __end = this->__end_;
1510 if (__end < this->__end_cap()) {
1511 __construct_one_at_end(__x);
1512 ++__end;
1513 } else {
1514 __end = __push_back_slow_path(__x);
1515 }
1516 this->__end_ = __end;
1517}
1518
1519template <class _Tp, class _Allocator>
1520_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void vector<_Tp, _Allocator>::push_back(value_type&& __x) {
1521 pointer __end = this->__end_;
1522 if (__end < this->__end_cap()) {
1523 __construct_one_at_end(std::move(__x));
1524 ++__end;
1525 } else {
1526 __end = __push_back_slow_path(std::move(__x));
1527 }
1528 this->__end_ = __end;
1529}
1530
1531template <class _Tp, class _Allocator>
1532template <class... _Args>
1533_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer
1534vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) {
1535 allocator_type& __a = this->__alloc();
1536 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
1537 // __v.emplace_back(std::forward<_Args>(__args)...);
1538 __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Args>(__args)...);
1539 __v.__end_++;
1540 __swap_out_circular_buffer(__v);
1541 return this->__end_;
1542}
1543
1544template <class _Tp, class _Allocator>
1545template <class... _Args>
1546_LIBCPP_CONSTEXPR_SINCE_CXX20 inline
1547#if _LIBCPP_STD_VER >= 17
1548 typename vector<_Tp, _Allocator>::reference
1549#else309#else
1550 void310# include <__config>
1551#endif
1552 vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) {
1553 pointer __end = this->__end_;
1554 if (__end < this->__end_cap()) {
1555 __construct_one_at_end(std::forward<_Args>(__args)...);
1556 ++__end;
1557 } else {
1558 __end = __emplace_back_slow_path(std::forward<_Args>(__args)...);
1559 }
1560 this->__end_ = __end;
1561#if _LIBCPP_STD_VER >= 17
1562 return *(__end - 1);
1563#endif
1564}
1565
1566template <class _Tp, class _Allocator>
1567_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void vector<_Tp, _Allocator>::pop_back() {
1568 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector::pop_back called on an empty vector");
1569 this->__destruct_at_end(this->__end_ - 1);
1570}
1571
1572template <class _Tp, class _Allocator>
1573_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator
1574vector<_Tp, _Allocator>::erase(const_iterator __position) {
1575 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
1576 __position != end(), "vector::erase(iterator) called with a non-dereferenceable iterator");
1577 difference_type __ps = __position - cbegin();
1578 pointer __p = this->__begin_ + __ps;
1579 this->__destruct_at_end(std::move(__p + 1, this->__end_, __p));
1580 return __make_iter(__p);
1581}
1582
1583template <class _Tp, class _Allocator>
1584_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1585vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) {
1586 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, "vector::erase(first, last) called with invalid range");
1587 pointer __p = this->__begin_ + (__first - begin());
1588 if (__first != __last) {
1589 this->__destruct_at_end(std::move(__p + (__last - __first), this->__end_, __p));
1590 }
1591 return __make_iter(__p);
1592}
1593
1594template <class _Tp, class _Allocator>
1595_LIBCPP_CONSTEXPR_SINCE_CXX20 void
1596vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) {
1597 pointer __old_last = this->__end_;
1598 difference_type __n = __old_last - __to;
1599 {
1600 pointer __i = __from_s + __n;
1601 _ConstructTransaction __tx(*this, __from_e - __i);
1602 for (pointer __pos = __tx.__pos_; __i < __from_e; ++__i, (void)++__pos, __tx.__pos_ = __pos) {
1603 __alloc_traits::construct(this->__alloc(), std::__to_address(__pos), std::move(*__i));
1604 }
1605 }
1606 std::move_backward(__from_s, __from_s + __n, __old_last);
1607}
1608
1609template <class _Tp, class _Allocator>
1610_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1611vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) {
1612 pointer __p = this->__begin_ + (__position - begin());
1613 if (this->__end_ < this->__end_cap()) {
1614 if (__p == this->__end_) {
1615 __construct_one_at_end(__x);
1616 } else {
1617 __move_range(__p, this->__end_, __p + 1);
1618 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
1619 if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x)))
1620 ++__xr;
1621 *__p = *__xr;
1622 }
1623 } else {
1624 allocator_type& __a = this->__alloc();
1625 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
1626 __v.push_back(__x);
1627 __p = __swap_out_circular_buffer(__v, __p);
1628 }
1629 return __make_iter(__p);
1630}
1631
1632template <class _Tp, class _Allocator>
1633_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1634vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) {
1635 pointer __p = this->__begin_ + (__position - begin());
1636 if (this->__end_ < this->__end_cap()) {
1637 if (__p == this->__end_) {
1638 __construct_one_at_end(std::move(__x));
1639 } else {
1640 __move_range(__p, this->__end_, __p + 1);
1641 *__p = std::move(__x);
1642 }
1643 } else {
1644 allocator_type& __a = this->__alloc();
1645 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
1646 __v.push_back(std::move(__x));
1647 __p = __swap_out_circular_buffer(__v, __p);
1648 }
1649 return __make_iter(__p);
1650}
1651
1652template <class _Tp, class _Allocator>
1653template <class... _Args>
1654_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1655vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) {
1656 pointer __p = this->__begin_ + (__position - begin());
1657 if (this->__end_ < this->__end_cap()) {
1658 if (__p == this->__end_) {
1659 __construct_one_at_end(std::forward<_Args>(__args)...);
1660 } else {
1661 __temp_value<value_type, _Allocator> __tmp(this->__alloc(), std::forward<_Args>(__args)...);
1662 __move_range(__p, this->__end_, __p + 1);
1663 *__p = std::move(__tmp.get());
1664 }
1665 } else {
1666 allocator_type& __a = this->__alloc();
1667 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
1668 __v.emplace_back(std::forward<_Args>(__args)...);
1669 __p = __swap_out_circular_buffer(__v, __p);
1670 }
1671 return __make_iter(__p);
1672}
1673
1674template <class _Tp, class _Allocator>
1675_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1676vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) {
1677 pointer __p = this->__begin_ + (__position - begin());
1678 if (__n > 0) {
1679 // We can't compare unrelated pointers inside constant expressions
1680 if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__end_cap() - this->__end_)) {
1681 size_type __old_n = __n;
1682 pointer __old_last = this->__end_;
1683 if (__n > static_cast<size_type>(this->__end_ - __p)) {
1684 size_type __cx = __n - (this->__end_ - __p);
1685 __construct_at_end(__cx, __x);
1686 __n -= __cx;
1687 }
1688 if (__n > 0) {
1689 __move_range(__p, __old_last, __p + __old_n);
1690 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
1691 if (__p <= __xr && __xr < this->__end_)
1692 __xr += __old_n;
1693 std::fill_n(__p, __n, *__xr);
1694 }
1695 } else {
1696 allocator_type& __a = this->__alloc();
1697 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a);
1698 __v.__construct_at_end(__n, __x);
1699 __p = __swap_out_circular_buffer(__v, __p);
1700 }
1701 }
1702 return __make_iter(__p);
1703}
1704template <class _Tp, class _Allocator>
1705template <class _InputIterator,
1706 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
1707 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
1708 int> >
1709_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1710vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) {
1711 return __insert_with_sentinel(__position, __first, __last);
1712}
1713
1714template <class _Tp, class _Allocator>
1715template <class _InputIterator, class _Sentinel>
1716_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator
1717vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last) {
1718 difference_type __off = __position - begin();
1719 pointer __p = this->__begin_ + __off;
1720 allocator_type& __a = this->__alloc();
1721 pointer __old_last = this->__end_;
1722 for (; this->__end_ != this->__end_cap() && __first != __last; ++__first) {
1723 __construct_one_at_end(*__first);
1724 }
1725 __split_buffer<value_type, allocator_type&> __v(__a);
1726 if (__first != __last) {
1727#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1728 try {
1729#endif // _LIBCPP_HAS_NO_EXCEPTIONS
1730 __v.__construct_at_end_with_sentinel(std::move(__first), std::move(__last));
1731 difference_type __old_size = __old_last - this->__begin_;
1732 difference_type __old_p = __p - this->__begin_;
1733 reserve(__recommend(size() + __v.size()));
1734 __p = this->__begin_ + __old_p;
1735 __old_last = this->__begin_ + __old_size;
1736#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1737 } catch (...) {
1738 erase(__make_iter(__old_last), end());
1739 throw;
1740 }
1741#endif // _LIBCPP_HAS_NO_EXCEPTIONS
1742 }
1743 __p = std::rotate(__p, __old_last, this->__end_);
1744 insert(__make_iter(__p), std::make_move_iterator(__v.begin()), std::make_move_iterator(__v.end()));
1745 return begin() + __off;
1746}
1747
1748template <class _Tp, class _Allocator>
1749template <class _ForwardIterator,
1750 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value &&
1751 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
1752 int> >
1753_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1754vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) {
1755 return __insert_with_size(__position, __first, __last, std::distance(__first, __last));
1756}
1757
1758template <class _Tp, class _Allocator>
1759template <class _Iterator, class _Sentinel>
1760_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator
1761vector<_Tp, _Allocator>::__insert_with_size(
1762 const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n) {
1763 auto __insertion_size = __n;
1764 pointer __p = this->__begin_ + (__position - begin());
1765 if (__n > 0) {
1766 if (__n <= this->__end_cap() - this->__end_) {
1767 size_type __old_n = __n;
1768 pointer __old_last = this->__end_;
1769 _Iterator __m = std::next(__first, __n);
1770 difference_type __dx = this->__end_ - __p;
1771 if (__n > __dx) {
1772 __m = __first;
1773 difference_type __diff = this->__end_ - __p;
1774 std::advance(__m, __diff);
1775 __construct_at_end(__m, __last, __n - __diff);
1776 __n = __dx;
1777 }
1778 if (__n > 0) {
1779 __move_range(__p, __old_last, __p + __old_n);
1780 std::copy(__first, __m, __p);
1781 }
1782 } else {
1783 allocator_type& __a = this->__alloc();
1784 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a);
1785 __v.__construct_at_end_with_size(__first, __insertion_size);
1786 __p = __swap_out_circular_buffer(__v, __p);
1787 }
1788 }
1789 return __make_iter(__p);
1790}
1791
1792template <class _Tp, class _Allocator>
1793_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz) {
1794 size_type __cs = size();
1795 if (__cs < __sz)
1796 this->__append(__sz - __cs);
1797 else if (__cs > __sz)
1798 this->__destruct_at_end(this->__begin_ + __sz);
1799}
1800
1801template <class _Tp, class _Allocator>
1802_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) {
1803 size_type __cs = size();
1804 if (__cs < __sz)
1805 this->__append(__sz - __cs, __x);
1806 else if (__cs > __sz)
1807 this->__destruct_at_end(this->__begin_ + __sz);
1808}
1809
1810template <class _Tp, class _Allocator>
1811_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::swap(vector& __x)
1812#if _LIBCPP_STD_VER >= 14
1813 _NOEXCEPT
1814#else
1815 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
1816#endif
1817{
1818 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1819 __alloc_traits::propagate_on_container_swap::value || this->__alloc() == __x.__alloc(),
1820 "vector::swap: Either propagate_on_container_swap must be true"
1821 " or the allocators must compare equal");
1822 std::swap(this->__begin_, __x.__begin_);
1823 std::swap(this->__end_, __x.__end_);
1824 std::swap(this->__end_cap(), __x.__end_cap());
1825 std::__swap_allocator(
1826 this->__alloc(), __x.__alloc(), integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
1827}
1828
1829template <class _Tp, class _Allocator>
1830_LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<_Tp, _Allocator>::__invariants() const {
1831 if (this->__begin_ == nullptr) {
1832 if (this->__end_ != nullptr || this->__end_cap() != nullptr)
1833 return false;
1834 } else {
1835 if (this->__begin_ > this->__end_)
1836 return false;
1837 if (this->__begin_ == this->__end_cap())
1838 return false;
1839 if (this->__end_ > this->__end_cap())
1840 return false;
1841 }
1842 return true;
1843}
1844
1845// vector<bool>
1846
1847template <class _Allocator>
1848class vector<bool, _Allocator>;
1849
1850template <class _Allocator>
1851struct hash<vector<bool, _Allocator> >;
1852
1853template <class _Allocator>
1854struct __has_storage_type<vector<bool, _Allocator> > {
1855 static const bool value = true;
1856};
1857311
1858template <class _Allocator>312# include <__vector/comparison.h>
1859class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator> {313# include <__vector/swap.h>
1860public:314# include <__vector/vector.h>
1861 typedef vector __self;315# include <__vector/vector_bool.h>
1862 typedef bool value_type;
1863 typedef _Allocator allocator_type;
1864 typedef allocator_traits<allocator_type> __alloc_traits;
1865 typedef typename __alloc_traits::size_type size_type;
1866 typedef typename __alloc_traits::difference_type difference_type;
1867 typedef size_type __storage_type;
1868 typedef __bit_iterator<vector, false> pointer;
1869 typedef __bit_iterator<vector, true> const_pointer;
1870 typedef pointer iterator;
1871 typedef const_pointer const_iterator;
1872 typedef std::reverse_iterator<iterator> reverse_iterator;
1873 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
1874
1875private:
1876 typedef __rebind_alloc<__alloc_traits, __storage_type> __storage_allocator;
1877 typedef allocator_traits<__storage_allocator> __storage_traits;
1878 typedef typename __storage_traits::pointer __storage_pointer;
1879 typedef typename __storage_traits::const_pointer __const_storage_pointer;
1880
1881 __storage_pointer __begin_;
1882 size_type __size_;
1883 __compressed_pair<size_type, __storage_allocator> __cap_alloc_;
1884316
1885public:317# if _LIBCPP_STD_VER >= 17
1886 typedef __bit_reference<vector> reference;318# include <__vector/pmr.h>
1887#ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL319# endif
1888 using const_reference = bool;
1889#else
1890 typedef __bit_const_reference<vector> const_reference;
1891#endif
1892
1893private:
1894 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type& __cap() _NOEXCEPT { return __cap_alloc_.first(); }
1895 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const size_type& __cap() const _NOEXCEPT {
1896 return __cap_alloc_.first();
1897 }
1898 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __storage_allocator& __alloc() _NOEXCEPT {
1899 return __cap_alloc_.second();
1900 }
1901 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const __storage_allocator& __alloc() const _NOEXCEPT {
1902 return __cap_alloc_.second();
1903 }
1904
1905 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
1906
1907 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type
1908 __internal_cap_to_external(size_type __n) _NOEXCEPT {
1909 return __n * __bits_per_word;
1910 }
1911 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type
1912 __external_cap_to_internal(size_type __n) _NOEXCEPT {
1913 return (__n - 1) / __bits_per_word + 1;
1914 }
1915320
1916public:321# if _LIBCPP_STD_VER >= 20
1917 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector()322# include <__vector/erase.h>
1918 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);323# endif
1919324
1920 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(const allocator_type& __a)325# if _LIBCPP_STD_VER >= 23
1921#if _LIBCPP_STD_VER <= 14326# include <__vector/vector_bool_formatter.h>
1922 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);327# endif
1923#else
1924 _NOEXCEPT;
1925#endif
1926328
1927private:329# include <version>
1928 class __destroy_vector {
1929 public:
1930 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __destroy_vector(vector& __vec) : __vec_(__vec) {}
1931330
1932 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {331// standard-mandated includes
1933 if (__vec_.__begin_ != nullptr)
1934 __storage_traits::deallocate(__vec_.__alloc(), __vec_.__begin_, __vec_.__cap());
1935 }
1936332
1937 private:333// [iterator.range]
1938 vector& __vec_;334# include <__iterator/access.h>
1939 };335# include <__iterator/data.h>
336# include <__iterator/empty.h>
337# include <__iterator/reverse_access.h>
338# include <__iterator/size.h>
1940339
1941public:340// [vector.syn]
1942 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~vector() { __destroy_vector (*this)(); }341# include <compare>
1943342# include <initializer_list>
1944 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n);
1945#if _LIBCPP_STD_VER >= 14
1946 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n, const allocator_type& __a);
1947#endif
1948 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v);
1949 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1950 vector(size_type __n, const value_type& __v, const allocator_type& __a);
1951 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
1952 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last);
1953 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
1954 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1955 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
1956 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
1957 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last);
1958 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
1959 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1960 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a);
1961
1962#if _LIBCPP_STD_VER >= 23
1963 template <_ContainerCompatibleRange<bool> _Range>
1964 _LIBCPP_HIDE_FROM_ABI constexpr vector(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())
1965 : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {
1966 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
1967 auto __n = static_cast<size_type>(ranges::distance(__range));
1968 __init_with_size(ranges::begin(__range), ranges::end(__range), __n);
1969
1970 } else {
1971 __init_with_sentinel(ranges::begin(__range), ranges::end(__range));
1972 }
1973 }
1974#endif
1975
1976 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v);
1977 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v, const allocator_type& __a);
1978 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(const vector& __v);
1979
1980#ifndef _LIBCPP_CXX03_LANG
1981 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(initializer_list<value_type> __il);
1982 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1983 vector(initializer_list<value_type> __il, const allocator_type& __a);
1984
1985 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(initializer_list<value_type> __il) {
1986 assign(__il.begin(), __il.end());
1987 return *this;
1988 }
1989
1990#endif // !_LIBCPP_CXX03_LANG
1991
1992 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(vector&& __v)
1993#if _LIBCPP_STD_VER >= 17
1994 noexcept;
1995#else
1996 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
1997#endif
1998 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1999 vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
2000 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(vector&& __v)
2001 _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value);
2002
2003 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
2004 void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_InputIterator __first, _InputIterator __last);
2005 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
2006 void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_ForwardIterator __first, _ForwardIterator __last);
2007
2008#if _LIBCPP_STD_VER >= 23
2009 template <_ContainerCompatibleRange<bool> _Range>
2010 _LIBCPP_HIDE_FROM_ABI constexpr void assign_range(_Range&& __range) {
2011 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
2012 auto __n = static_cast<size_type>(ranges::distance(__range));
2013 __assign_with_size(ranges::begin(__range), ranges::end(__range), __n);
2014
2015 } else {
2016 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));
2017 }
2018 }
2019#endif
2020
2021 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void assign(size_type __n, const value_type& __x);
2022
2023#ifndef _LIBCPP_CXX03_LANG
2024 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void assign(initializer_list<value_type> __il) {
2025 assign(__il.begin(), __il.end());
2026 }
2027#endif
2028
2029 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT {
2030 return allocator_type(this->__alloc());
2031 }
2032
2033 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT;
2034 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type capacity() const _NOEXCEPT {
2035 return __internal_cap_to_external(__cap());
2036 }
2037 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT { return __size_; }
2038 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT {
2039 return __size_ == 0;
2040 }
2041 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n);
2042 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;
2043
2044 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { return __make_iter(0); }
2045 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator begin() const _NOEXCEPT { return __make_iter(0); }
2046 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() _NOEXCEPT { return __make_iter(__size_); }
2047 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT {
2048 return __make_iter(__size_);
2049 }
2050
2051 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rbegin() _NOEXCEPT {
2052 return reverse_iterator(end());
2053 }
2054 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rbegin() const _NOEXCEPT {
2055 return const_reverse_iterator(end());
2056 }
2057 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rend() _NOEXCEPT {
2058 return reverse_iterator(begin());
2059 }
2060 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rend() const _NOEXCEPT {
2061 return const_reverse_iterator(begin());
2062 }
2063
2064 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cbegin() const _NOEXCEPT { return __make_iter(0); }
2065 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cend() const _NOEXCEPT {
2066 return __make_iter(__size_);
2067 }
2068 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crbegin() const _NOEXCEPT {
2069 return rbegin();
2070 }
2071 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
2072
2073 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __n) { return __make_ref(__n); }
2074 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __n) const {
2075 return __make_ref(__n);
2076 }
2077 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n);
2078 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const;
2079
2080 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() { return __make_ref(0); }
2081 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const { return __make_ref(0); }
2082 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() { return __make_ref(__size_ - 1); }
2083 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const { return __make_ref(__size_ - 1); }
2084
2085 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(const value_type& __x);
2086#if _LIBCPP_STD_VER >= 14
2087 template <class... _Args>
2088# if _LIBCPP_STD_VER >= 17
2089 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference emplace_back(_Args&&... __args)
2090# else
2091 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args)
2092# endif
2093 {
2094 push_back(value_type(std::forward<_Args>(__args)...));
2095# if _LIBCPP_STD_VER >= 17
2096 return this->back();
2097# endif
2098 }
2099#endif
2100
2101#if _LIBCPP_STD_VER >= 23
2102 template <_ContainerCompatibleRange<bool> _Range>
2103 _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) {
2104 insert_range(end(), std::forward<_Range>(__range));
2105 }
2106#endif
2107
2108 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back() { --__size_; }
2109
2110#if _LIBCPP_STD_VER >= 14
2111 template <class... _Args>
2112 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator emplace(const_iterator __position, _Args&&... __args) {
2113 return insert(__position, value_type(std::forward<_Args>(__args)...));
2114 }
2115#endif
2116
2117 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, const value_type& __x);
2118 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
2119 insert(const_iterator __position, size_type __n, const value_type& __x);
2120 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
2121 iterator _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2122 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
2123 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
2124 iterator _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2125 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
2126
2127#if _LIBCPP_STD_VER >= 23
2128 template <_ContainerCompatibleRange<bool> _Range>
2129 _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) {
2130 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
2131 auto __n = static_cast<size_type>(ranges::distance(__range));
2132 return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n);
2133
2134 } else {
2135 return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));
2136 }
2137 }
2138#endif
2139
2140#ifndef _LIBCPP_CXX03_LANG
2141 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
2142 insert(const_iterator __position, initializer_list<value_type> __il) {
2143 return insert(__position, __il.begin(), __il.end());
2144 }
2145#endif
2146
2147 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __position);
2148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __first, const_iterator __last);
2149
2150 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT { __size_ = 0; }
2151
2152 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(vector&)
2153#if _LIBCPP_STD_VER >= 14
2154 _NOEXCEPT;
2155#else
2156 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
2157#endif
2158 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void swap(reference __x, reference __y) _NOEXCEPT {
2159 std::swap(__x, __y);
2160 }
2161
2162 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __sz, value_type __x = false);
2163 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT;
2164
2165 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const;
2166
2167private:
2168 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { std::__throw_length_error("vector"); }
2169
2170 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { std::__throw_out_of_range("vector"); }
2171
2172 template <class _InputIterator, class _Sentinel>
2173 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
2174 __init_with_size(_InputIterator __first, _Sentinel __last, size_type __n) {
2175 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
2176
2177 if (__n > 0) {
2178 __vallocate(__n);
2179 __construct_at_end(std::move(__first), std::move(__last), __n);
2180 }
2181
2182 __guard.__complete();
2183 }
2184
2185 template <class _InputIterator, class _Sentinel>
2186 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
2187 __init_with_sentinel(_InputIterator __first, _Sentinel __last) {
2188#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2189 try {
2190#endif // _LIBCPP_HAS_NO_EXCEPTIONS
2191 for (; __first != __last; ++__first)
2192 push_back(*__first);
2193#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2194 } catch (...) {
2195 if (__begin_ != nullptr)
2196 __storage_traits::deallocate(__alloc(), __begin_, __cap());
2197 throw;
2198 }
2199#endif // _LIBCPP_HAS_NO_EXCEPTIONS
2200 }
2201
2202 template <class _Iterator, class _Sentinel>
2203 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last);
2204
2205 template <class _ForwardIterator, class _Sentinel>
2206 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
2207 __assign_with_size(_ForwardIterator __first, _Sentinel __last, difference_type __ns);
2208
2209 template <class _InputIterator, class _Sentinel>
2210 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
2211 __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last);
2212
2213 template <class _Iterator, class _Sentinel>
2214 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
2215 __insert_with_size(const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n);
2216
2217 // Allocate space for __n objects
2218 // throws length_error if __n > max_size()
2219 // throws (probably bad_alloc) if memory run out
2220 // Precondition: __begin_ == __end_ == __cap() == 0
2221 // Precondition: __n > 0
2222 // Postcondition: capacity() >= __n
2223 // Postcondition: size() == 0
2224 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vallocate(size_type __n) {
2225 if (__n > max_size())
2226 __throw_length_error();
2227 auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n));
2228 __begin_ = __allocation.ptr;
2229 __size_ = 0;
2230 __cap() = __allocation.count;
2231 if (__libcpp_is_constant_evaluated()) {
2232 for (size_type __i = 0; __i != __cap(); ++__i)
2233 std::__construct_at(std::__to_address(__begin_) + __i);
2234 }
2235 }
2236
2237 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vdeallocate() _NOEXCEPT;
2238 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type __align_it(size_type __new_size) _NOEXCEPT {
2239 return (__new_size + (__bits_per_word - 1)) & ~((size_type)__bits_per_word - 1);
2240 }
2241 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __new_size) const;
2242 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_at_end(size_type __n, bool __x);
2243 template <class _InputIterator, class _Sentinel>
2244 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
2245 __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n);
2246 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append(size_type __n, const_reference __x);
2247 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference __make_ref(size_type __pos) _NOEXCEPT {
2248 return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);
2249 }
2250 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference __make_ref(size_type __pos) const _NOEXCEPT {
2251 return __bit_const_reference<vector>(
2252 __begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);
2253 }
2254 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iter(size_type __pos) _NOEXCEPT {
2255 return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));
2256 }
2257 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_iter(size_type __pos) const _NOEXCEPT {
2258 return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));
2259 }
2260 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT {
2261 return begin() + (__p - cbegin());
2262 }
2263
2264 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector& __v) {
2265 __copy_assign_alloc(
2266 __v, integral_constant<bool, __storage_traits::propagate_on_container_copy_assignment::value>());
2267 }
2268 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector& __c, true_type) {
2269 if (__alloc() != __c.__alloc())
2270 __vdeallocate();
2271 __alloc() = __c.__alloc();
2272 }
2273
2274 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector&, false_type) {}
2275
2276 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, false_type);
2277 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, true_type)
2278 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
2279 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector& __c)
2280 _NOEXCEPT_(!__storage_traits::propagate_on_container_move_assignment::value ||
2281 is_nothrow_move_assignable<allocator_type>::value) {
2282 __move_assign_alloc(
2283 __c, integral_constant<bool, __storage_traits::propagate_on_container_move_assignment::value>());
2284 }
2285 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector& __c, true_type)
2286 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
2287 __alloc() = std::move(__c.__alloc());
2288 }
2289
2290 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector&, false_type) _NOEXCEPT {}
2291
2292 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t __hash_code() const _NOEXCEPT;
2293
2294 friend class __bit_reference<vector>;
2295 friend class __bit_const_reference<vector>;
2296 friend class __bit_iterator<vector, false>;
2297 friend class __bit_iterator<vector, true>;
2298 friend struct __bit_array<vector>;
2299 friend struct _LIBCPP_TEMPLATE_VIS hash<vector>;
2300};
2301343
2302template <class _Allocator>344// [vector.syn], [unord.hash]
2303_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT {345# include <__functional/hash.h>
2304 if (this->__begin_ != nullptr) {
2305 __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap());
2306 this->__begin_ = nullptr;
2307 this->__size_ = this->__cap() = 0;
2308 }
2309}
2310
2311template <class _Allocator>
2312_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type
2313vector<bool, _Allocator>::max_size() const _NOEXCEPT {
2314 size_type __amax = __storage_traits::max_size(__alloc());
2315 size_type __nmax = numeric_limits<size_type>::max() / 2; // end() >= begin(), always
2316 if (__nmax / __bits_per_word <= __amax)
2317 return __nmax;
2318 return __internal_cap_to_external(__amax);
2319}
2320
2321// Precondition: __new_size > capacity()
2322template <class _Allocator>
2323inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type
2324vector<bool, _Allocator>::__recommend(size_type __new_size) const {
2325 const size_type __ms = max_size();
2326 if (__new_size > __ms)
2327 this->__throw_length_error();
2328 const size_type __cap = capacity();
2329 if (__cap >= __ms / 2)
2330 return __ms;
2331 return std::max(2 * __cap, __align_it(__new_size));
2332}
2333
2334// Default constructs __n objects starting at __end_
2335// Precondition: __n > 0
2336// Precondition: size() + __n <= capacity()
2337// Postcondition: size() == size() + __n
2338template <class _Allocator>
2339inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
2340vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) {
2341 size_type __old_size = this->__size_;
2342 this->__size_ += __n;
2343 if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) {
2344 if (this->__size_ <= __bits_per_word)
2345 this->__begin_[0] = __storage_type(0);
2346 else
2347 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
2348 }
2349 std::fill_n(__make_iter(__old_size), __n, __x);
2350}
2351
2352template <class _Allocator>
2353template <class _InputIterator, class _Sentinel>
2354_LIBCPP_CONSTEXPR_SINCE_CXX20 void
2355vector<bool, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) {
2356 size_type __old_size = this->__size_;
2357 this->__size_ += __n;
2358 if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) {
2359 if (this->__size_ <= __bits_per_word)
2360 this->__begin_[0] = __storage_type(0);
2361 else
2362 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
2363 }
2364 std::__copy<_ClassicAlgPolicy>(__first, __last, __make_iter(__old_size));
2365}
2366
2367template <class _Allocator>
2368inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector()
2369 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
2370 : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {}
2371
2372template <class _Allocator>
2373inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const allocator_type& __a)
2374#if _LIBCPP_STD_VER <= 14
2375 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
2376#else
2377 _NOEXCEPT
2378#endif
2379 : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {
2380}
2381
2382template <class _Allocator>
2383_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n)
2384 : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {
2385 if (__n > 0) {
2386 __vallocate(__n);
2387 __construct_at_end(__n, false);
2388 }
2389}
2390
2391#if _LIBCPP_STD_VER >= 14
2392template <class _Allocator>
2393_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
2394 : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {
2395 if (__n > 0) {
2396 __vallocate(__n);
2397 __construct_at_end(__n, false);
2398 }
2399}
2400#endif
2401
2402template <class _Allocator>
2403_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
2404 : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {
2405 if (__n > 0) {
2406 __vallocate(__n);
2407 __construct_at_end(__n, __x);
2408 }
2409}
2410
2411template <class _Allocator>
2412_LIBCPP_CONSTEXPR_SINCE_CXX20
2413vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
2414 : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {
2415 if (__n > 0) {
2416 __vallocate(__n);
2417 __construct_at_end(__n, __x);
2418 }
2419}
2420
2421template <class _Allocator>
2422template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
2423_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last)
2424 : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {
2425 __init_with_sentinel(__first, __last);
2426}
2427
2428template <class _Allocator>
2429template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
2430_LIBCPP_CONSTEXPR_SINCE_CXX20
2431vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
2432 : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {
2433 __init_with_sentinel(__first, __last);
2434}
2435
2436template <class _Allocator>
2437template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
2438_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last)
2439 : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {
2440 auto __n = static_cast<size_type>(std::distance(__first, __last));
2441 __init_with_size(__first, __last, __n);
2442}
2443
2444template <class _Allocator>
2445template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
2446_LIBCPP_CONSTEXPR_SINCE_CXX20
2447vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a)
2448 : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {
2449 auto __n = static_cast<size_type>(std::distance(__first, __last));
2450 __init_with_size(__first, __last, __n);
2451}
2452
2453#ifndef _LIBCPP_CXX03_LANG
2454
2455template <class _Allocator>
2456_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
2457 : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {
2458 size_type __n = static_cast<size_type>(__il.size());
2459 if (__n > 0) {
2460 __vallocate(__n);
2461 __construct_at_end(__il.begin(), __il.end(), __n);
2462 }
2463}
2464
2465template <class _Allocator>
2466_LIBCPP_CONSTEXPR_SINCE_CXX20
2467vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
2468 : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) {
2469 size_type __n = static_cast<size_type>(__il.size());
2470 if (__n > 0) {
2471 __vallocate(__n);
2472 __construct_at_end(__il.begin(), __il.end(), __n);
2473 }
2474}
2475
2476#endif // _LIBCPP_CXX03_LANG
2477
2478template <class _Allocator>
2479_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v)
2480 : __begin_(nullptr),
2481 __size_(0),
2482 __cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc())) {
2483 if (__v.size() > 0) {
2484 __vallocate(__v.size());
2485 __construct_at_end(__v.begin(), __v.end(), __v.size());
2486 }
2487}
2488
2489template <class _Allocator>
2490_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
2491 : __begin_(nullptr), __size_(0), __cap_alloc_(0, __a) {
2492 if (__v.size() > 0) {
2493 __vallocate(__v.size());
2494 __construct_at_end(__v.begin(), __v.end(), __v.size());
2495 }
2496}
2497
2498template <class _Allocator>
2499_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>& vector<bool, _Allocator>::operator=(const vector& __v) {
2500 if (this != std::addressof(__v)) {
2501 __copy_assign_alloc(__v);
2502 if (__v.__size_) {
2503 if (__v.__size_ > capacity()) {
2504 __vdeallocate();
2505 __vallocate(__v.__size_);
2506 }
2507 std::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_);
2508 }
2509 __size_ = __v.__size_;
2510 }
2511 return *this;
2512}
2513
2514template <class _Allocator>
2515inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(vector&& __v)
2516#if _LIBCPP_STD_VER >= 17
2517 _NOEXCEPT
2518#else
2519 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
2520#endif
2521 : __begin_(__v.__begin_),
2522 __size_(__v.__size_),
2523 __cap_alloc_(std::move(__v.__cap_alloc_)) {
2524 __v.__begin_ = nullptr;
2525 __v.__size_ = 0;
2526 __v.__cap() = 0;
2527}
2528
2529template <class _Allocator>
2530_LIBCPP_CONSTEXPR_SINCE_CXX20
2531vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a)
2532 : __begin_(nullptr), __size_(0), __cap_alloc_(0, __a) {
2533 if (__a == allocator_type(__v.__alloc())) {
2534 this->__begin_ = __v.__begin_;
2535 this->__size_ = __v.__size_;
2536 this->__cap() = __v.__cap();
2537 __v.__begin_ = nullptr;
2538 __v.__cap() = __v.__size_ = 0;
2539 } else if (__v.size() > 0) {
2540 __vallocate(__v.size());
2541 __construct_at_end(__v.begin(), __v.end(), __v.size());
2542 }
2543}
2544
2545template <class _Allocator>
2546inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>&
2547vector<bool, _Allocator>::operator=(vector&& __v)
2548 _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
2549 __move_assign(__v, integral_constant<bool, __storage_traits::propagate_on_container_move_assignment::value>());
2550 return *this;
2551}
2552
2553template <class _Allocator>
2554_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__move_assign(vector& __c, false_type) {
2555 if (__alloc() != __c.__alloc())
2556 assign(__c.begin(), __c.end());
2557 else
2558 __move_assign(__c, true_type());
2559}
2560
2561template <class _Allocator>
2562_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
2563 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
2564 __vdeallocate();
2565 __move_assign_alloc(__c);
2566 this->__begin_ = __c.__begin_;
2567 this->__size_ = __c.__size_;
2568 this->__cap() = __c.__cap();
2569 __c.__begin_ = nullptr;
2570 __c.__cap() = __c.__size_ = 0;
2571}
2572
2573template <class _Allocator>
2574_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) {
2575 __size_ = 0;
2576 if (__n > 0) {
2577 size_type __c = capacity();
2578 if (__n <= __c)
2579 __size_ = __n;
2580 else {
2581 vector __v(get_allocator());
2582 __v.reserve(__recommend(__n));
2583 __v.__size_ = __n;
2584 swap(__v);
2585 }
2586 std::fill_n(begin(), __n, __x);
2587 }
2588}
2589
2590template <class _Allocator>
2591template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
2592_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last) {
2593 __assign_with_sentinel(__first, __last);
2594}
2595
2596template <class _Allocator>
2597template <class _Iterator, class _Sentinel>
2598_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
2599vector<bool, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __last) {
2600 clear();
2601 for (; __first != __last; ++__first)
2602 push_back(*__first);
2603}
2604
2605template <class _Allocator>
2606template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
2607_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) {
2608 __assign_with_size(__first, __last, std::distance(__first, __last));
2609}
2610
2611template <class _Allocator>
2612template <class _ForwardIterator, class _Sentinel>
2613_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
2614vector<bool, _Allocator>::__assign_with_size(_ForwardIterator __first, _Sentinel __last, difference_type __ns) {
2615 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__ns >= 0, "invalid range specified");
2616
2617 clear();
2618
2619 const size_t __n = static_cast<size_type>(__ns);
2620 if (__n) {
2621 if (__n > capacity()) {
2622 __vdeallocate();
2623 __vallocate(__n);
2624 }
2625 __construct_at_end(__first, __last, __n);
2626 }
2627}
2628
2629template <class _Allocator>
2630_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::reserve(size_type __n) {
2631 if (__n > capacity()) {
2632 if (__n > max_size())
2633 this->__throw_length_error();
2634 vector __v(this->get_allocator());
2635 __v.__vallocate(__n);
2636 __v.__construct_at_end(this->begin(), this->end(), this->size());
2637 swap(__v);
2638 }
2639}
2640
2641template <class _Allocator>
2642_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT {
2643 if (__external_cap_to_internal(size()) > __cap()) {
2644#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2645 try {
2646#endif // _LIBCPP_HAS_NO_EXCEPTIONS
2647 vector(*this, allocator_type(__alloc())).swap(*this);
2648#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2649 } catch (...) {
2650 }
2651#endif // _LIBCPP_HAS_NO_EXCEPTIONS
2652 }
2653}
2654
2655template <class _Allocator>
2656typename vector<bool, _Allocator>::reference vector<bool, _Allocator>::at(size_type __n) {
2657 if (__n >= size())
2658 this->__throw_out_of_range();
2659 return (*this)[__n];
2660}
2661
2662template <class _Allocator>
2663typename vector<bool, _Allocator>::const_reference vector<bool, _Allocator>::at(size_type __n) const {
2664 if (__n >= size())
2665 this->__throw_out_of_range();
2666 return (*this)[__n];
2667}
2668
2669template <class _Allocator>
2670_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::push_back(const value_type& __x) {
2671 if (this->__size_ == this->capacity())
2672 reserve(__recommend(this->__size_ + 1));
2673 ++this->__size_;
2674 back() = __x;
2675}
2676
2677template <class _Allocator>
2678_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
2679vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x) {
2680 iterator __r;
2681 if (size() < capacity()) {
2682 const_iterator __old_end = end();
2683 ++__size_;
2684 std::copy_backward(__position, __old_end, end());
2685 __r = __const_iterator_cast(__position);
2686 } else {
2687 vector __v(get_allocator());
2688 __v.reserve(__recommend(__size_ + 1));
2689 __v.__size_ = __size_ + 1;
2690 __r = std::copy(cbegin(), __position, __v.begin());
2691 std::copy_backward(__position, cend(), __v.end());
2692 swap(__v);
2693 }
2694 *__r = __x;
2695 return __r;
2696}
2697
2698template <class _Allocator>
2699_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
2700vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x) {
2701 iterator __r;
2702 size_type __c = capacity();
2703 if (__n <= __c && size() <= __c - __n) {
2704 const_iterator __old_end = end();
2705 __size_ += __n;
2706 std::copy_backward(__position, __old_end, end());
2707 __r = __const_iterator_cast(__position);
2708 } else {
2709 vector __v(get_allocator());
2710 __v.reserve(__recommend(__size_ + __n));
2711 __v.__size_ = __size_ + __n;
2712 __r = std::copy(cbegin(), __position, __v.begin());
2713 std::copy_backward(__position, cend(), __v.end());
2714 swap(__v);
2715 }
2716 std::fill_n(__r, __n, __x);
2717 return __r;
2718}
2719
2720template <class _Allocator>
2721template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
2722_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
2723vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) {
2724 return __insert_with_sentinel(__position, __first, __last);
2725}
2726
2727template <class _Allocator>
2728template <class _InputIterator, class _Sentinel>
2729_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<bool, _Allocator>::iterator
2730vector<bool, _Allocator>::__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last) {
2731 difference_type __off = __position - begin();
2732 iterator __p = __const_iterator_cast(__position);
2733 iterator __old_end = end();
2734 for (; size() != capacity() && __first != __last; ++__first) {
2735 ++this->__size_;
2736 back() = *__first;
2737 }
2738 vector __v(get_allocator());
2739 if (__first != __last) {
2740#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2741 try {
2742#endif // _LIBCPP_HAS_NO_EXCEPTIONS
2743 __v.__assign_with_sentinel(std::move(__first), std::move(__last));
2744 difference_type __old_size = static_cast<difference_type>(__old_end - begin());
2745 difference_type __old_p = __p - begin();
2746 reserve(__recommend(size() + __v.size()));
2747 __p = begin() + __old_p;
2748 __old_end = begin() + __old_size;
2749#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
2750 } catch (...) {
2751 erase(__old_end, end());
2752 throw;
2753 }
2754#endif // _LIBCPP_HAS_NO_EXCEPTIONS
2755 }
2756 __p = std::rotate(__p, __old_end, end());
2757 insert(__p, __v.begin(), __v.end());
2758 return begin() + __off;
2759}
2760
2761template <class _Allocator>
2762template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
2763_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
2764vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) {
2765 return __insert_with_size(__position, __first, __last, std::distance(__first, __last));
2766}
2767
2768template <class _Allocator>
2769template <class _ForwardIterator, class _Sentinel>
2770_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<bool, _Allocator>::iterator
2771vector<bool, _Allocator>::__insert_with_size(
2772 const_iterator __position, _ForwardIterator __first, _Sentinel __last, difference_type __n_signed) {
2773 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__n_signed >= 0, "invalid range specified");
2774 const size_type __n = static_cast<size_type>(__n_signed);
2775 iterator __r;
2776 size_type __c = capacity();
2777 if (__n <= __c && size() <= __c - __n) {
2778 const_iterator __old_end = end();
2779 __size_ += __n;
2780 std::copy_backward(__position, __old_end, end());
2781 __r = __const_iterator_cast(__position);
2782 } else {
2783 vector __v(get_allocator());
2784 __v.reserve(__recommend(__size_ + __n));
2785 __v.__size_ = __size_ + __n;
2786 __r = std::copy(cbegin(), __position, __v.begin());
2787 std::copy_backward(__position, cend(), __v.end());
2788 swap(__v);
2789 }
2790 std::__copy<_ClassicAlgPolicy>(__first, __last, __r);
2791 return __r;
2792}
2793
2794template <class _Allocator>
2795inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
2796vector<bool, _Allocator>::erase(const_iterator __position) {
2797 iterator __r = __const_iterator_cast(__position);
2798 std::copy(__position + 1, this->cend(), __r);
2799 --__size_;
2800 return __r;
2801}
2802
2803template <class _Allocator>
2804_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
2805vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last) {
2806 iterator __r = __const_iterator_cast(__first);
2807 difference_type __d = __last - __first;
2808 std::copy(__last, this->cend(), __r);
2809 __size_ -= __d;
2810 return __r;
2811}
2812
2813template <class _Allocator>
2814_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::swap(vector& __x)
2815#if _LIBCPP_STD_VER >= 14
2816 _NOEXCEPT
2817#else
2818 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
2819#endif
2820{
2821 std::swap(this->__begin_, __x.__begin_);
2822 std::swap(this->__size_, __x.__size_);
2823 std::swap(this->__cap(), __x.__cap());
2824 std::__swap_allocator(
2825 this->__alloc(), __x.__alloc(), integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
2826}
2827
2828template <class _Allocator>
2829_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::resize(size_type __sz, value_type __x) {
2830 size_type __cs = size();
2831 if (__cs < __sz) {
2832 iterator __r;
2833 size_type __c = capacity();
2834 size_type __n = __sz - __cs;
2835 if (__n <= __c && __cs <= __c - __n) {
2836 __r = end();
2837 __size_ += __n;
2838 } else {
2839 vector __v(get_allocator());
2840 __v.reserve(__recommend(__size_ + __n));
2841 __v.__size_ = __size_ + __n;
2842 __r = std::copy(cbegin(), cend(), __v.begin());
2843 swap(__v);
2844 }
2845 std::fill_n(__r, __n, __x);
2846 } else
2847 __size_ = __sz;
2848}
2849
2850template <class _Allocator>
2851_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::flip() _NOEXCEPT {
2852 // do middle whole words
2853 size_type __n = __size_;
2854 __storage_pointer __p = __begin_;
2855 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
2856 *__p = ~*__p;
2857 // do last partial word
2858 if (__n > 0) {
2859 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
2860 __storage_type __b = *__p & __m;
2861 *__p &= ~__m;
2862 *__p |= ~__b & __m;
2863 }
2864}
2865
2866template <class _Allocator>
2867_LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<bool, _Allocator>::__invariants() const {
2868 if (this->__begin_ == nullptr) {
2869 if (this->__size_ != 0 || this->__cap() != 0)
2870 return false;
2871 } else {
2872 if (this->__cap() == 0)
2873 return false;
2874 if (this->__size_ > this->capacity())
2875 return false;
2876 }
2877 return true;
2878}
2879
2880template <class _Allocator>
2881_LIBCPP_CONSTEXPR_SINCE_CXX20 size_t vector<bool, _Allocator>::__hash_code() const _NOEXCEPT {
2882 size_t __h = 0;
2883 // do middle whole words
2884 size_type __n = __size_;
2885 __storage_pointer __p = __begin_;
2886 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
2887 __h ^= *__p;
2888 // do last partial word
2889 if (__n > 0) {
2890 const __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
2891 __h ^= *__p & __m;
2892 }
2893 return __h;
2894}
2895
2896template <class _Allocator>
2897struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
2898 : public __unary_function<vector<bool, _Allocator>, size_t> {
2899 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t
2900 operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT {
2901 return __vec.__hash_code();
2902 }
2903};
2904346
2905template <class _Tp, class _Allocator>347# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2906_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI bool348# pragma GCC system_header
2907operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
2908 const typename vector<_Tp, _Allocator>::size_type __sz = __x.size();
2909 return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
2910}
2911
2912#if _LIBCPP_STD_VER <= 17
2913
2914template <class _Tp, class _Allocator>
2915inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
2916 return !(__x == __y);
2917}
2918
2919template <class _Tp, class _Allocator>
2920inline _LIBCPP_HIDE_FROM_ABI bool operator<(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
2921 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
2922}
2923
2924template <class _Tp, class _Allocator>
2925inline _LIBCPP_HIDE_FROM_ABI bool operator>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
2926 return __y < __x;
2927}
2928
2929template <class _Tp, class _Allocator>
2930inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
2931 return !(__x < __y);
2932}
2933
2934template <class _Tp, class _Allocator>
2935inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
2936 return !(__y < __x);
2937}
2938
2939#else // _LIBCPP_STD_VER <= 17
2940
2941template <class _Tp, class _Allocator>
2942_LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
2943operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
2944 return std::lexicographical_compare_three_way(
2945 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
2946}
2947
2948#endif // _LIBCPP_STD_VER <= 17
2949
2950template <class _Tp, class _Allocator>
2951_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void
2952swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
2953 __x.swap(__y);
2954}
2955
2956#if _LIBCPP_STD_VER >= 20
2957template <class _Tp, class _Allocator, class _Up>
2958_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
2959erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
2960 auto __old_size = __c.size();
2961 __c.erase(std::remove(__c.begin(), __c.end(), __v), __c.end());
2962 return __old_size - __c.size();
2963}
2964
2965template <class _Tp, class _Allocator, class _Predicate>
2966_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
2967erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {
2968 auto __old_size = __c.size();
2969 __c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end());
2970 return __old_size - __c.size();
2971}
2972
2973template <>
2974inline constexpr bool __format::__enable_insertable<vector<char>> = true;
2975# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2976template <>
2977inline constexpr bool __format::__enable_insertable<vector<wchar_t>> = true;
2978# endif349# endif
2979350
2980#endif // _LIBCPP_STD_VER >= 20351# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2981352# include <algorithm>
2982#if _LIBCPP_STD_VER >= 23353# include <array>
2983template <class _Tp, class _CharT>354# include <atomic>
2984// Since is-vector-bool-reference is only used once it's inlined here.355# include <cctype>
2985 requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>>356# include <cerrno>
2986struct _LIBCPP_TEMPLATE_VIS formatter<_Tp, _CharT> {357# include <clocale>
2987private:358# include <concepts>
2988 formatter<bool, _CharT> __underlying_;359# include <cstdint>
2989360# include <cstdlib>
2990public:361# include <iosfwd>
2991 template <class _ParseContext>362# if _LIBCPP_HAS_LOCALIZATION
2992 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {363# include <locale>
2993 return __underlying_.parse(__ctx);364# endif
2994 }365# include <string>
2995366# include <string_view>
2996 template <class _FormatContext>367# include <tuple>
2997 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _Tp& __ref, _FormatContext& __ctx) const {368# include <type_traits>
2998 return __underlying_.format(__ref, __ctx);369# include <typeinfo>
2999 }370# include <utility>
3000};
3001#endif // _LIBCPP_STD_VER >= 23
3002
3003_LIBCPP_END_NAMESPACE_STD
3004
3005#if _LIBCPP_STD_VER >= 17
3006_LIBCPP_BEGIN_NAMESPACE_STD
3007namespace pmr {
3008template <class _ValueT>
3009using vector _LIBCPP_AVAILABILITY_PMR = std::vector<_ValueT, polymorphic_allocator<_ValueT>>;
3010} // namespace pmr
3011_LIBCPP_END_NAMESPACE_STD
3012#endif
3013
3014_LIBCPP_POP_MACROS
3015
3016#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
3017# include <algorithm>
3018# include <atomic>
3019# include <concepts>
3020# include <cstdlib>
3021# include <iosfwd>
3022# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
3023# include <locale>
3024# endif371# endif
3025# include <tuple>372#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
3026# include <type_traits>
3027# include <typeinfo>
3028# include <utility>
3029#endif
3030373
3031#endif // _LIBCPP_VECTOR374#endif // _LIBCPP_VECTOR
lib/libcxx/include/version+62-26
...@@ -101,6 +101,8 @@ __cpp_lib_execution 201902L <execution>...@@ -101,6 +101,8 @@ __cpp_lib_execution 201902L <execution>
101 201603L // C++17101 201603L // C++17
102__cpp_lib_expected 202211L <expected>102__cpp_lib_expected 202211L <expected>
103__cpp_lib_filesystem 201703L <filesystem>103__cpp_lib_filesystem 201703L <filesystem>
104__cpp_lib_flat_map 202207L <flat_map>
105__cpp_lib_flat_set 202207L <flat_set>
104__cpp_lib_format 202110L <format>106__cpp_lib_format 202110L <format>
105__cpp_lib_format_path 202403L <filesystem>107__cpp_lib_format_path 202403L <filesystem>
106__cpp_lib_format_ranges 202207L <format>108__cpp_lib_format_ranges 202207L <format>
...@@ -138,6 +140,7 @@ __cpp_lib_ios_noreplace 202207L <ios>...@@ -138,6 +140,7 @@ __cpp_lib_ios_noreplace 202207L <ios>
138__cpp_lib_is_aggregate 201703L <type_traits>140__cpp_lib_is_aggregate 201703L <type_traits>
139__cpp_lib_is_constant_evaluated 201811L <type_traits>141__cpp_lib_is_constant_evaluated 201811L <type_traits>
140__cpp_lib_is_final 201402L <type_traits>142__cpp_lib_is_final 201402L <type_traits>
143__cpp_lib_is_implicit_lifetime 202302L <type_traits>
141__cpp_lib_is_invocable 201703L <type_traits>144__cpp_lib_is_invocable 201703L <type_traits>
142__cpp_lib_is_layout_compatible 201907L <type_traits>145__cpp_lib_is_layout_compatible 201907L <type_traits>
143__cpp_lib_is_nothrow_convertible 201806L <type_traits>146__cpp_lib_is_nothrow_convertible 201806L <type_traits>
...@@ -170,9 +173,11 @@ __cpp_lib_nonmember_container_access 201411L <array> <deque>...@@ -170,9 +173,11 @@ __cpp_lib_nonmember_container_access 201411L <array> <deque>
170 <iterator> <list> <map>173 <iterator> <list> <map>
171 <regex> <set> <string>174 <regex> <set> <string>
172 <unordered_map> <unordered_set> <vector>175 <unordered_map> <unordered_set> <vector>
173__cpp_lib_not_fn 201603L <functional>176__cpp_lib_not_fn 202306L <functional>
177 201603L // C++17
174__cpp_lib_null_iterators 201304L <iterator>178__cpp_lib_null_iterators 201304L <iterator>
175__cpp_lib_optional 202110L <optional>179__cpp_lib_optional 202110L <optional>
180 202106L // C++20
176 201606L // C++17181 201606L // C++17
177__cpp_lib_optional_range_support 202406L <optional>182__cpp_lib_optional_range_support 202406L <optional>
178__cpp_lib_out_ptr 202311L <memory>183__cpp_lib_out_ptr 202311L <memory>
...@@ -182,8 +187,9 @@ __cpp_lib_philox_engine 202406L <random>...@@ -182,8 +187,9 @@ __cpp_lib_philox_engine 202406L <random>
182__cpp_lib_polymorphic_allocator 201902L <memory_resource>187__cpp_lib_polymorphic_allocator 201902L <memory_resource>
183__cpp_lib_print 202207L <ostream> <print>188__cpp_lib_print 202207L <ostream> <print>
184__cpp_lib_quoted_string_io 201304L <iomanip>189__cpp_lib_quoted_string_io 201304L <iomanip>
185__cpp_lib_ranges 202207L <algorithm> <functional> <iterator>190__cpp_lib_ranges 202406L <algorithm> <functional> <iterator>
186 <memory> <ranges>191 <memory> <ranges>
192 202110L // C++20
187__cpp_lib_ranges_as_const 202207L <ranges>193__cpp_lib_ranges_as_const 202207L <ranges>
188__cpp_lib_ranges_as_rvalue 202207L <ranges>194__cpp_lib_ranges_as_rvalue 202207L <ranges>
189__cpp_lib_ranges_chunk 202202L <ranges>195__cpp_lib_ranges_chunk 202202L <ranges>
...@@ -259,16 +265,21 @@ __cpp_lib_uncaught_exceptions 201411L <exception>...@@ -259,16 +265,21 @@ __cpp_lib_uncaught_exceptions 201411L <exception>
259__cpp_lib_unordered_map_try_emplace 201411L <unordered_map>265__cpp_lib_unordered_map_try_emplace 201411L <unordered_map>
260__cpp_lib_unreachable 202202L <utility>266__cpp_lib_unreachable 202202L <utility>
261__cpp_lib_unwrap_ref 201811L <functional>267__cpp_lib_unwrap_ref 201811L <functional>
262__cpp_lib_variant 202102L <variant>268__cpp_lib_variant 202306L <variant>
269 202106L // C++20
270 202102L // C++17
263__cpp_lib_void_t 201411L <type_traits>271__cpp_lib_void_t 201411L <type_traits>
264272
265*/273*/
266274
267#include <__config>275#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
276# include <__cxx03/version>
277#else
278# include <__config>
268279
269#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)280# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
270# pragma GCC system_header281# pragma GCC system_header
271#endif282# endif
272283
273// clang-format off284// clang-format off
274285
...@@ -284,12 +295,12 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -284,12 +295,12 @@ __cpp_lib_void_t 201411L <type_traits>
284# define __cpp_lib_make_reverse_iterator 201402L295# define __cpp_lib_make_reverse_iterator 201402L
285# define __cpp_lib_make_unique 201304L296# define __cpp_lib_make_unique 201304L
286# define __cpp_lib_null_iterators 201304L297# define __cpp_lib_null_iterators 201304L
287# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)298# if _LIBCPP_HAS_LOCALIZATION
288# define __cpp_lib_quoted_string_io 201304L299# define __cpp_lib_quoted_string_io 201304L
289# endif300# endif
290# define __cpp_lib_result_of_sfinae 201210L301# define __cpp_lib_result_of_sfinae 201210L
291# define __cpp_lib_robust_nonmodifying_seq_ops 201304L302# define __cpp_lib_robust_nonmodifying_seq_ops 201304L
292# if !defined(_LIBCPP_HAS_NO_THREADS)303# if _LIBCPP_HAS_THREADS
293# define __cpp_lib_shared_timed_mutex 201402L304# define __cpp_lib_shared_timed_mutex 201402L
294# endif305# endif
295# define __cpp_lib_string_udls 201304L306# define __cpp_lib_string_udls 201304L
...@@ -314,7 +325,7 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -314,7 +325,7 @@ __cpp_lib_void_t 201411L <type_traits>
314# define __cpp_lib_clamp 201603L325# define __cpp_lib_clamp 201603L
315# define __cpp_lib_enable_shared_from_this 201603L326# define __cpp_lib_enable_shared_from_this 201603L
316// # define __cpp_lib_execution 201603L327// # define __cpp_lib_execution 201603L
317# if !defined(_LIBCPP_HAS_NO_FILESYSTEM) && _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY328# if _LIBCPP_HAS_FILESYSTEM && _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY
318# define __cpp_lib_filesystem 201703L329# define __cpp_lib_filesystem 201703L
319# endif330# endif
320# define __cpp_lib_gcd_lcm 201606L331# define __cpp_lib_gcd_lcm 201606L
...@@ -343,10 +354,10 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -343,10 +354,10 @@ __cpp_lib_void_t 201411L <type_traits>
343// # define __cpp_lib_parallel_algorithm 201603L354// # define __cpp_lib_parallel_algorithm 201603L
344# define __cpp_lib_raw_memory_algorithms 201606L355# define __cpp_lib_raw_memory_algorithms 201606L
345# define __cpp_lib_sample 201603L356# define __cpp_lib_sample 201603L
346# if !defined(_LIBCPP_HAS_NO_THREADS)357# if _LIBCPP_HAS_THREADS
347# define __cpp_lib_scoped_lock 201703L358# define __cpp_lib_scoped_lock 201703L
348# endif359# endif
349# if !defined(_LIBCPP_HAS_NO_THREADS)360# if _LIBCPP_HAS_THREADS
350# define __cpp_lib_shared_mutex 201505L361# define __cpp_lib_shared_mutex 201505L
351# endif362# endif
352# define __cpp_lib_shared_ptr_arrays 201611L363# define __cpp_lib_shared_ptr_arrays 201611L
...@@ -367,7 +378,7 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -367,7 +378,7 @@ __cpp_lib_void_t 201411L <type_traits>
367# define __cpp_lib_array_constexpr 201811L378# define __cpp_lib_array_constexpr 201811L
368# define __cpp_lib_assume_aligned 201811L379# define __cpp_lib_assume_aligned 201811L
369# define __cpp_lib_atomic_flag_test 201907L380# define __cpp_lib_atomic_flag_test 201907L
370// # define __cpp_lib_atomic_float 201711L381# define __cpp_lib_atomic_float 201711L
371# define __cpp_lib_atomic_lock_free_type_aliases 201907L382# define __cpp_lib_atomic_lock_free_type_aliases 201907L
372# define __cpp_lib_atomic_ref 201806L383# define __cpp_lib_atomic_ref 201806L
373// # define __cpp_lib_atomic_shared_ptr 201711L384// # define __cpp_lib_atomic_shared_ptr 201711L
...@@ -375,14 +386,14 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -375,14 +386,14 @@ __cpp_lib_void_t 201411L <type_traits>
375# if _LIBCPP_AVAILABILITY_HAS_SYNC386# if _LIBCPP_AVAILABILITY_HAS_SYNC
376# define __cpp_lib_atomic_wait 201907L387# define __cpp_lib_atomic_wait 201907L
377# endif388# endif
378# if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC389# if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_SYNC
379# define __cpp_lib_barrier 201907L390# define __cpp_lib_barrier 201907L
380# endif391# endif
381# define __cpp_lib_bind_front 201907L392# define __cpp_lib_bind_front 201907L
382# define __cpp_lib_bit_cast 201806L393# define __cpp_lib_bit_cast 201806L
383# define __cpp_lib_bitops 201907L394# define __cpp_lib_bitops 201907L
384# define __cpp_lib_bounded_array_traits 201902L395# define __cpp_lib_bounded_array_traits 201902L
385# if !defined(_LIBCPP_HAS_NO_CHAR8_T)396# if _LIBCPP_HAS_CHAR8_T
386# define __cpp_lib_char8_t 201907L397# define __cpp_lib_char8_t 201907L
387# endif398# endif
388# define __cpp_lib_concepts 202002L399# define __cpp_lib_concepts 202002L
...@@ -406,7 +417,9 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -406,7 +417,9 @@ __cpp_lib_void_t 201411L <type_traits>
406# define __cpp_lib_erase_if 202002L417# define __cpp_lib_erase_if 202002L
407# undef __cpp_lib_execution418# undef __cpp_lib_execution
408// # define __cpp_lib_execution 201902L419// # define __cpp_lib_execution 201902L
409# define __cpp_lib_format 202110L420# if _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT
421# define __cpp_lib_format 202110L
422# endif
410# define __cpp_lib_format_uchar 202311L423# define __cpp_lib_format_uchar 202311L
411# define __cpp_lib_generic_unordered_lookup 201811L424# define __cpp_lib_generic_unordered_lookup 201811L
412# define __cpp_lib_int_pow2 202002L425# define __cpp_lib_int_pow2 202002L
...@@ -416,34 +429,36 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -416,34 +429,36 @@ __cpp_lib_void_t 201411L <type_traits>
416// # define __cpp_lib_is_layout_compatible 201907L429// # define __cpp_lib_is_layout_compatible 201907L
417# define __cpp_lib_is_nothrow_convertible 201806L430# define __cpp_lib_is_nothrow_convertible 201806L
418// # define __cpp_lib_is_pointer_interconvertible 201907L431// # define __cpp_lib_is_pointer_interconvertible 201907L
419# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC432# if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_SYNC
420# define __cpp_lib_jthread 201911L433# define __cpp_lib_jthread 201911L
421# endif434# endif
422# if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC435# if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_SYNC
423# define __cpp_lib_latch 201907L436# define __cpp_lib_latch 201907L
424# endif437# endif
425# define __cpp_lib_list_remove_return_type 201806L438# define __cpp_lib_list_remove_return_type 201806L
426# define __cpp_lib_math_constants 201907L439# define __cpp_lib_math_constants 201907L
427# define __cpp_lib_move_iterator_concept 202207L440# define __cpp_lib_move_iterator_concept 202207L
441# undef __cpp_lib_optional
442# define __cpp_lib_optional 202106L
428# if _LIBCPP_AVAILABILITY_HAS_PMR443# if _LIBCPP_AVAILABILITY_HAS_PMR
429# define __cpp_lib_polymorphic_allocator 201902L444# define __cpp_lib_polymorphic_allocator 201902L
430# endif445# endif
431# define __cpp_lib_ranges 202207L446# define __cpp_lib_ranges 202110L
432# define __cpp_lib_remove_cvref 201711L447# define __cpp_lib_remove_cvref 201711L
433# if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC448# if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_SYNC
434# define __cpp_lib_semaphore 201907L449# define __cpp_lib_semaphore 201907L
435# endif450# endif
436# undef __cpp_lib_shared_ptr_arrays451# undef __cpp_lib_shared_ptr_arrays
437# define __cpp_lib_shared_ptr_arrays 201707L452# define __cpp_lib_shared_ptr_arrays 201707L
438# define __cpp_lib_shift 201806L453# define __cpp_lib_shift 201806L
439// # define __cpp_lib_smart_ptr_for_overwrite 202002L454# define __cpp_lib_smart_ptr_for_overwrite 202002L
440# define __cpp_lib_source_location 201907L455# define __cpp_lib_source_location 201907L
441# define __cpp_lib_span 202002L456# define __cpp_lib_span 202002L
442# define __cpp_lib_ssize 201902L457# define __cpp_lib_ssize 201902L
443# define __cpp_lib_starts_ends_with 201711L458# define __cpp_lib_starts_ends_with 201711L
444# undef __cpp_lib_string_view459# undef __cpp_lib_string_view
445# define __cpp_lib_string_view 201803L460# define __cpp_lib_string_view 201803L
446# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)461# if _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM
447# define __cpp_lib_syncbuf 201803L462# define __cpp_lib_syncbuf 201803L
448# endif463# endif
449# define __cpp_lib_three_way_comparison 201907L464# define __cpp_lib_three_way_comparison 201907L
...@@ -451,6 +466,8 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -451,6 +466,8 @@ __cpp_lib_void_t 201411L <type_traits>
451# define __cpp_lib_to_array 201907L466# define __cpp_lib_to_array 201907L
452# define __cpp_lib_type_identity 201806L467# define __cpp_lib_type_identity 201806L
453# define __cpp_lib_unwrap_ref 201811L468# define __cpp_lib_unwrap_ref 201811L
469# undef __cpp_lib_variant
470# define __cpp_lib_variant 202106L
454#endif471#endif
455472
456#if _LIBCPP_STD_VER >= 23473#if _LIBCPP_STD_VER >= 23
...@@ -467,11 +484,16 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -467,11 +484,16 @@ __cpp_lib_void_t 201411L <type_traits>
467# define __cpp_lib_constexpr_typeinfo 202106L484# define __cpp_lib_constexpr_typeinfo 202106L
468# define __cpp_lib_containers_ranges 202202L485# define __cpp_lib_containers_ranges 202202L
469# define __cpp_lib_expected 202211L486# define __cpp_lib_expected 202211L
487# define __cpp_lib_flat_map 202207L
488// # define __cpp_lib_flat_set 202207L
470# define __cpp_lib_format_ranges 202207L489# define __cpp_lib_format_ranges 202207L
471// # define __cpp_lib_formatters 202302L490// # define __cpp_lib_formatters 202302L
472# define __cpp_lib_forward_like 202207L491# define __cpp_lib_forward_like 202207L
473# define __cpp_lib_invoke_r 202106L492# define __cpp_lib_invoke_r 202106L
474# define __cpp_lib_ios_noreplace 202207L493# define __cpp_lib_ios_noreplace 202207L
494# if __has_builtin(__builtin_is_implicit_lifetime)
495# define __cpp_lib_is_implicit_lifetime 202302L
496# endif
475# define __cpp_lib_is_scoped_enum 202011L497# define __cpp_lib_is_scoped_enum 202011L
476# define __cpp_lib_mdspan 202207L498# define __cpp_lib_mdspan 202207L
477# define __cpp_lib_modules 202207L499# define __cpp_lib_modules 202207L
...@@ -479,7 +501,11 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -479,7 +501,11 @@ __cpp_lib_void_t 201411L <type_traits>
479# undef __cpp_lib_optional501# undef __cpp_lib_optional
480# define __cpp_lib_optional 202110L502# define __cpp_lib_optional 202110L
481# define __cpp_lib_out_ptr 202106L503# define __cpp_lib_out_ptr 202106L
482# define __cpp_lib_print 202207L504# if _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT
505# define __cpp_lib_print 202207L
506# endif
507# undef __cpp_lib_ranges
508# define __cpp_lib_ranges 202406L
483// # define __cpp_lib_ranges_as_const 202207L509// # define __cpp_lib_ranges_as_const 202207L
484# define __cpp_lib_ranges_as_rvalue 202207L510# define __cpp_lib_ranges_as_rvalue 202207L
485// # define __cpp_lib_ranges_chunk 202202L511// # define __cpp_lib_ranges_chunk 202202L
...@@ -510,7 +536,9 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -510,7 +536,9 @@ __cpp_lib_void_t 201411L <type_traits>
510# undef __cpp_lib_bind_front536# undef __cpp_lib_bind_front
511# define __cpp_lib_bind_front 202306L537# define __cpp_lib_bind_front 202306L
512# define __cpp_lib_bitset 202306L538# define __cpp_lib_bitset 202306L
513// # define __cpp_lib_constexpr_new 202406L539# if !defined(_LIBCPP_ABI_VCRUNTIME)
540# define __cpp_lib_constexpr_new 202406L
541# endif
514// # define __cpp_lib_constrained_equality 202403L542// # define __cpp_lib_constrained_equality 202403L
515// # define __cpp_lib_copyable_function 202306L543// # define __cpp_lib_copyable_function 202306L
516// # define __cpp_lib_debugging 202311L544// # define __cpp_lib_debugging 202311L
...@@ -524,18 +552,22 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -524,18 +552,22 @@ __cpp_lib_void_t 201411L <type_traits>
524// # define __cpp_lib_freestanding_optional 202311L552// # define __cpp_lib_freestanding_optional 202311L
525// # define __cpp_lib_freestanding_string_view 202311L553// # define __cpp_lib_freestanding_string_view 202311L
526// # define __cpp_lib_freestanding_variant 202311L554// # define __cpp_lib_freestanding_variant 202311L
527# if !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)555# if _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
528# define __cpp_lib_fstream_native_handle 202306L556# define __cpp_lib_fstream_native_handle 202306L
529# endif557# endif
530// # define __cpp_lib_function_ref 202306L558// # define __cpp_lib_function_ref 202306L
531// # define __cpp_lib_generate_random 202403L559// # define __cpp_lib_generate_random 202403L
532// # define __cpp_lib_hazard_pointer 202306L560// # define __cpp_lib_hazard_pointer 202306L
533// # define __cpp_lib_inplace_vector 202406L561// # define __cpp_lib_inplace_vector 202406L
534// # define __cpp_lib_is_virtual_base_of 202406L562# if __has_builtin(__builtin_is_virtual_base_of)
563# define __cpp_lib_is_virtual_base_of 202406L
564# endif
535// # define __cpp_lib_is_within_lifetime 202306L565// # define __cpp_lib_is_within_lifetime 202306L
536// # define __cpp_lib_linalg 202311L566// # define __cpp_lib_linalg 202311L
537# undef __cpp_lib_mdspan567# undef __cpp_lib_mdspan
538# define __cpp_lib_mdspan 202406L568# define __cpp_lib_mdspan 202406L
569# undef __cpp_lib_not_fn
570# define __cpp_lib_not_fn 202306L
539// # define __cpp_lib_optional_range_support 202406L571// # define __cpp_lib_optional_range_support 202406L
540# undef __cpp_lib_out_ptr572# undef __cpp_lib_out_ptr
541# define __cpp_lib_out_ptr 202311L573# define __cpp_lib_out_ptr 202311L
...@@ -559,8 +591,12 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -559,8 +591,12 @@ __cpp_lib_void_t 201411L <type_traits>
559// # define __cpp_lib_to_string 202306L591// # define __cpp_lib_to_string 202306L
560# undef __cpp_lib_tuple_like592# undef __cpp_lib_tuple_like
561// # define __cpp_lib_tuple_like 202311L593// # define __cpp_lib_tuple_like 202311L
594# undef __cpp_lib_variant
595# define __cpp_lib_variant 202306L
562#endif596#endif
563597
598#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
599
564// clang-format on600// clang-format on
565601
566#endif // _LIBCPP_VERSIONH602#endif // _LIBCPP_VERSIONH
lib/libcxx/include/wchar.h+30-34
...@@ -7,17 +7,6 @@...@@ -7,17 +7,6 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#if defined(__need_wint_t) || defined(__need_mbstate_t)
11
12# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
13# pragma GCC system_header
14# endif
15
16# include_next <wchar.h>
17
18#elif !defined(_LIBCPP_WCHAR_H)
19# define _LIBCPP_WCHAR_H
20
21/*10/*
22 wchar.h synopsis11 wchar.h synopsis
2312
...@@ -105,13 +94,10 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,...@@ -105,13 +94,10 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
10594
106*/95*/
10796
97#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
98# include <__cxx03/wchar.h>
99#else
108# include <__config>100# include <__config>
109# include <stddef.h>
110
111# if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
112# error \
113 "The <wchar.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled"
114# endif
115101
116# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)102# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
117# pragma GCC system_header103# pragma GCC system_header
...@@ -119,30 +105,38 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,...@@ -119,30 +105,38 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
119105
120// We define this here to support older versions of glibc <wchar.h> that do106// We define this here to support older versions of glibc <wchar.h> that do
121// not define this for clang.107// not define this for clang.
122# ifdef __cplusplus108# if defined(__cplusplus) && !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
123# define __CORRECT_ISO_CPP_WCHAR_H_PROTO109# define __CORRECT_ISO_CPP_WCHAR_H_PROTO
124# endif110# endif
125111
112// The inclusion of the system's <wchar.h> is intentionally done once outside of any include
113// guards because some code expects to be able to include the underlying system header multiple
114// times to get different definitions based on the macros that are set before inclusion.
126# if __has_include_next(<wchar.h>)115# if __has_include_next(<wchar.h>)
127# include_next <wchar.h>116# include_next <wchar.h>
128# else
129# include <__mbstate_t.h> // make sure we have mbstate_t regardless of the existence of <wchar.h>
130# endif117# endif
131118
119# ifndef _LIBCPP_WCHAR_H
120# define _LIBCPP_WCHAR_H
121
122# include <__mbstate_t.h> // provide mbstate_t
123# include <stddef.h> // provide size_t
124
132// Determine whether we have const-correct overloads for wcschr and friends.125// Determine whether we have const-correct overloads for wcschr and friends.
133# if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)126# if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
134# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
135# elif defined(__GLIBC_PREREQ)
136# if __GLIBC_PREREQ(2, 10)
137# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1127# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
128# elif defined(__GLIBC_PREREQ)
129# if __GLIBC_PREREQ(2, 10)
130# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
131# endif
132# elif defined(_LIBCPP_MSVCRT)
133# if defined(_CRT_CONST_CORRECT_OVERLOADS)
134# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
135# endif
138# endif136# endif
139# elif defined(_LIBCPP_MSVCRT)
140# if defined(_CRT_CONST_CORRECT_OVERLOADS)
141# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
142# endif
143# endif
144137
145# if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)138# if _LIBCPP_HAS_WIDE_CHARACTERS
139# if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
146extern "C++" {140extern "C++" {
147inline _LIBCPP_HIDE_FROM_ABI wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {141inline _LIBCPP_HIDE_FROM_ABI wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {
148 return (wchar_t*)wcschr(__s, __c);142 return (wchar_t*)wcschr(__s, __c);
...@@ -197,15 +191,17 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD wchar_t* wmemchr(wchar_t...@@ -197,15 +191,17 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD wchar_t* wmemchr(wchar_t
197 return __libcpp_wmemchr(__s, __c, __n);191 return __libcpp_wmemchr(__s, __c, __n);
198}192}
199}193}
200# endif194# endif
201195
202# if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__))196# if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__))
203extern "C" {197extern "C" {
204size_t mbsnrtowcs(198size_t mbsnrtowcs(
205 wchar_t* __restrict __dst, const char** __restrict __src, size_t __nmc, size_t __len, mbstate_t* __restrict __ps);199 wchar_t* __restrict __dst, const char** __restrict __src, size_t __nmc, size_t __len, mbstate_t* __restrict __ps);
206size_t wcsnrtombs(200size_t wcsnrtombs(
207 char* __restrict __dst, const wchar_t** __restrict __src, size_t __nwc, size_t __len, mbstate_t* __restrict __ps);201 char* __restrict __dst, const wchar_t** __restrict __src, size_t __nwc, size_t __len, mbstate_t* __restrict __ps);
208} // extern "C"202} // extern "C"
209# endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__)203# endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__)
204# endif // _LIBCPP_HAS_WIDE_CHARACTERS
205# endif // _LIBCPP_WCHAR_H
210206
211#endif // _LIBCPP_WCHAR_H207#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/wctype.h+35-36
...@@ -44,16 +44,14 @@ wctrans_t wctrans(const char* property);...@@ -44,16 +44,14 @@ wctrans_t wctrans(const char* property);
4444
45*/45*/
4646
47#include <__config>47#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
48# include <__cxx03/wctype.h>
49#else
50# include <__config>
4851
49#if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)52# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
50# error \53# pragma GCC system_header
51 "The <wctype.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled"54# endif
52#endif
53
54#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
55# pragma GCC system_header
56#endif
5755
58// TODO:56// TODO:
59// In the future, we should unconditionally include_next <wctype.h> here and instead57// In the future, we should unconditionally include_next <wctype.h> here and instead
...@@ -64,32 +62,33 @@ wctrans_t wctrans(const char* property);...@@ -64,32 +62,33 @@ wctrans_t wctrans(const char* property);
64// nothing (with using_if_exists), and if we include another header that defines one62// nothing (with using_if_exists), and if we include another header that defines one
65// of these declarations (e.g. <wchar.h>), the second `using ::wint_t` with using_if_exists63// of these declarations (e.g. <wchar.h>), the second `using ::wint_t` with using_if_exists
66// will fail because it does not refer to the same declaration.64// will fail because it does not refer to the same declaration.
67#if __has_include_next(<wctype.h>)65# if __has_include_next(<wctype.h>)
68# include_next <wctype.h>66# include_next <wctype.h>
69# define _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H67# define _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H
70#endif68# endif
7169
72#ifdef __cplusplus70# ifdef __cplusplus
7371
74# undef iswalnum72# undef iswalnum
75# undef iswalpha73# undef iswalpha
76# undef iswblank74# undef iswblank
77# undef iswcntrl75# undef iswcntrl
78# undef iswdigit76# undef iswdigit
79# undef iswgraph77# undef iswgraph
80# undef iswlower78# undef iswlower
81# undef iswprint79# undef iswprint
82# undef iswpunct80# undef iswpunct
83# undef iswspace81# undef iswspace
84# undef iswupper82# undef iswupper
85# undef iswxdigit83# undef iswxdigit
86# undef iswctype84# undef iswctype
87# undef wctype85# undef wctype
88# undef towlower86# undef towlower
89# undef towupper87# undef towupper
90# undef towctrans88# undef towctrans
91# undef wctrans89# undef wctrans
9290
93#endif // __cplusplus91# endif // __cplusplus
92#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
9493
95#endif // _LIBCPP_WCTYPE_H94#endif // _LIBCPP_WCTYPE_H
lib/libcxx/libc/hdr/errno_macros.h created+28
...@@ -0,0 +1,28 @@
1//===-- Definition of macros from errno.h ---------------------------------===//
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 LLVM_LIBC_HDR_ERRNO_MACROS_H
10#define LLVM_LIBC_HDR_ERRNO_MACROS_H
11
12#ifdef LIBC_FULL_BUILD
13
14#ifdef __linux__
15#include <linux/errno.h>
16
17#include "include/llvm-libc-macros/error-number-macros.h"
18#else // __linux__
19#include "include/llvm-libc-macros/generic-error-number-macros.h"
20#endif
21
22#else // Overlay mode
23
24#include <errno.h>
25
26#endif // LLVM_LIBC_FULL_BUILD
27
28#endif // LLVM_LIBC_HDR_ERRNO_MACROS_H
lib/libcxx/libc/hdr/fenv_macros.h created+61
...@@ -0,0 +1,61 @@
1//===-- Definition of macros from fenv.h ----------------------------------===//
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 LLVM_LIBC_HDR_FENV_MACROS_H
10#define LLVM_LIBC_HDR_FENV_MACROS_H
11
12#ifdef LIBC_FULL_BUILD
13
14#include "include/llvm-libc-macros/fenv-macros.h"
15
16#else // Overlay mode
17
18#include <fenv.h>
19
20// In some environment, FE_ALL_EXCEPT is set to 0 and the remaining exceptions
21// FE_* are missing.
22#ifndef FE_DIVBYZERO
23#define FE_DIVBYZERO 0
24#endif // FE_DIVBYZERO
25
26#ifndef FE_INEXACT
27#define FE_INEXACT 0
28#endif // FE_INEXACT
29
30#ifndef FE_INVALID
31#define FE_INVALID 0
32#endif // FE_INVALID
33
34#ifndef FE_OVERFLOW
35#define FE_OVERFLOW 0
36#endif // FE_OVERFLOW
37
38#ifndef FE_UNDERFLOW
39#define FE_UNDERFLOW 0
40#endif // FE_UNDERFLOW
41
42// Rounding mode macros might be missing.
43#ifndef FE_DOWNWARD
44#define FE_DOWNWARD 0x400
45#endif // FE_DOWNWARD
46
47#ifndef FE_TONEAREST
48#define FE_TONEAREST 0
49#endif // FE_TONEAREST
50
51#ifndef FE_TOWARDZERO
52#define FE_TOWARDZERO 0xC00
53#endif // FE_TOWARDZERO
54
55#ifndef FE_UPWARD
56#define FE_UPWARD 0x800
57#endif // FE_UPWARD
58
59#endif // LLVM_LIBC_FULL_BUILD
60
61#endif // LLVM_LIBC_HDR_FENV_MACROS_H
lib/libcxx/libc/hdr/float_macros.h created+22
...@@ -0,0 +1,22 @@
1//===-- Definition of macros from math.h ----------------------------------===//
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 LLVM_LIBC_HDR_FLOAT_MACROS_H
10#define LLVM_LIBC_HDR_FLOAT_MACROS_H
11
12#ifdef LIBC_FULL_BUILD
13
14#include "include/llvm-libc-macros/float-macros.h"
15
16#else // Overlay mode
17
18#include <float.h>
19
20#endif // LLVM_LIBC_FULL_BUILD
21
22#endif // LLVM_LIBC_HDR_FLOAT_MACROS_H
lib/libcxx/libc/hdr/limits_macros.h created+22
...@@ -0,0 +1,22 @@
1//===-- Definition of macros from limits.h --------------------------------===//
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 LLVM_LIBC_HDR_LIMITS_MACROS_H
10#define LLVM_LIBC_HDR_LIMITS_MACROS_H
11
12#ifdef LIBC_FULL_BUILD
13
14#include "include/llvm-libc-macros/limits-macros.h"
15
16#else // Overlay mode
17
18#include <limits.h>
19
20#endif // LLVM_LIBC_FULL_BUILD
21
22#endif // LLVM_LIBC_HDR_LIMITS_MACROS_H
lib/libcxx/libc/include/llvm-libc-macros/float-macros.h created+178
...@@ -0,0 +1,178 @@
1//===-- Definition of macros from float.h ---------------------------------===//
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 LLVM_LIBC_MACROS_FLOAT_MACROS_H
10#define LLVM_LIBC_MACROS_FLOAT_MACROS_H
11
12#ifndef FLT_RADIX
13#define FLT_RADIX __FLT_RADIX__
14#endif // FLT_RADIX
15
16#ifndef FLT_EVAL_METHOD
17#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
18#endif // FLT_EVAL_METHOD
19
20#ifndef FLT_ROUNDS
21#if __has_builtin(__builtin_flt_rounds)
22#define FLT_ROUNDS __builtin_flt_rounds()
23#else
24#define FLT_ROUNDS 1
25#endif
26#endif // FLT_ROUNDS
27
28#ifndef FLT_DECIMAL_DIG
29#define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
30#endif // FLT_DECIMAL_DIG
31
32#ifndef DBL_DECIMAL_DIG
33#define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
34#endif // DBL_DECIMAL_DIG
35
36#ifndef LDBL_DECIMAL_DIG
37#define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
38#endif // LDBL_DECIMAL_DIG
39
40#ifndef DECIMAL_DIG
41#define DECIMAL_DIG __DECIMAL_DIG__
42#endif // DECIMAL_DIG
43
44#ifndef FLT_DIG
45#define FLT_DIG __FLT_DIG__
46#endif // FLT_DIG
47
48#ifndef DBL_DIG
49#define DBL_DIG __DBL_DIG__
50#endif // DBL_DIG
51
52#ifndef LDBL_DIG
53#define LDBL_DIG __LDBL_DIG__
54#endif // LDBL_DIG
55
56#ifndef FLT_MANT_DIG
57#define FLT_MANT_DIG __FLT_MANT_DIG__
58#endif // FLT_MANT_DIG
59
60#ifndef DBL_MANT_DIG
61#define DBL_MANT_DIG __DBL_MANT_DIG__
62#endif // DBL_MANT_DIG
63
64#ifndef LDBL_MANT_DIG
65#define LDBL_MANT_DIG __LDBL_MANT_DIG__
66#endif // LDBL_MANT_DIG
67
68#ifndef FLT_MIN
69#define FLT_MIN __FLT_MIN__
70#endif // FLT_MIN
71
72#ifndef DBL_MIN
73#define DBL_MIN __DBL_MIN__
74#endif // DBL_MIN
75
76#ifndef LDBL_MIN
77#define LDBL_MIN __LDBL_MIN__
78#endif // LDBL_MIN
79
80#ifndef FLT_MAX
81#define FLT_MAX __FLT_MAX__
82#endif // FLT_MAX
83
84#ifndef DBL_MAX
85#define DBL_MAX __DBL_MAX__
86#endif // DBL_MAX
87
88#ifndef LDBL_MAX
89#define LDBL_MAX __LDBL_MAX__
90#endif // LDBL_MAX
91
92#ifndef FLT_TRUE_MIN
93#define FLT_TRUE_MIN __FLT_DENORM_MIN__
94#endif // FLT_TRUE_MIN
95
96#ifndef DBL_TRUE_MIN
97#define DBL_TRUE_MIN __DBL_DENORM_MIN__
98#endif // DBL_TRUE_MIN
99
100#ifndef LDBL_TRUE_MIN
101#define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
102#endif // LDBL_TRUE_MIN
103
104#ifndef FLT_EPSILON
105#define FLT_EPSILON __FLT_EPSILON__
106#endif // FLT_EPSILON
107
108#ifndef DBL_EPSILON
109#define DBL_EPSILON __DBL_EPSILON__
110#endif // DBL_EPSILON
111
112#ifndef LDBL_EPSILON
113#define LDBL_EPSILON __LDBL_EPSILON__
114#endif // LDBL_EPSILON
115
116#ifndef FLT_MIN_EXP
117#define FLT_MIN_EXP __FLT_MIN_EXP__
118#endif // FLT_MIN_EXP
119
120#ifndef DBL_MIN_EXP
121#define DBL_MIN_EXP __DBL_MIN_EXP__
122#endif // DBL_MIN_EXP
123
124#ifndef LDBL_MIN_EXP
125#define LDBL_MIN_EXP __LDBL_MIN_EXP__
126#endif // LDBL_MIN_EXP
127
128#ifndef FLT_MIN_10_EXP
129#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
130#endif // FLT_MIN_10_EXP
131
132#ifndef DBL_MIN_10_EXP
133#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
134#endif // DBL_MIN_10_EXP
135
136#ifndef LDBL_MIN_10_EXP
137#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
138#endif // LDBL_MIN_10_EXP
139
140#ifndef FLT_MAX_EXP
141#define FLT_MAX_EXP __FLT_MAX_EXP__
142#endif // FLT_MAX_EXP
143
144#ifndef DBL_MAX_EXP
145#define DBL_MAX_EXP __DBL_MAX_EXP__
146#endif // DBL_MAX_EXP
147
148#ifndef LDBL_MAX_EXP
149#define LDBL_MAX_EXP __LDBL_MAX_EXP__
150#endif // LDBL_MAX_EXP
151
152#ifndef FLT_MAX_10_EXP
153#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
154#endif // FLT_MAX_10_EXP
155
156#ifndef DBL_MAX_10_EXP
157#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
158#endif // DBL_MAX_10_EXP
159
160#ifndef LDBL_MAX_10_EXP
161#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
162#endif // LDBL_MAX_10_EXP
163
164#ifndef FLT_HAS_SUBNORM
165#define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
166#endif // FLT_HAS_SUBNORM
167
168#ifndef DBL_HAS_SUBNORM
169#define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
170#endif // DBL_HAS_SUBNORM
171
172#ifndef LDBL_HAS_SUBNORM
173#define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
174#endif // LDBL_HAS_SUBNORM
175
176// TODO: Add FLT16 and FLT128 constants.
177
178#endif // LLVM_LIBC_MACROS_FLOAT_MACROS_H
lib/libcxx/libc/include/llvm-libc-macros/float16-macros.h created+27
...@@ -0,0 +1,27 @@
1//===-- Detection of _Float16 compiler builtin type -----------------------===//
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 LLVM_LIBC_MACROS_FLOAT16_MACROS_H
10#define LLVM_LIBC_MACROS_FLOAT16_MACROS_H
11
12#include "../llvm-libc-types/float128.h"
13
14#if defined(__FLT16_MANT_DIG__) && \
15 (!defined(__GNUC__) || __GNUC__ >= 13 || defined(__clang__)) && \
16 !defined(__arm__) && !defined(_M_ARM) && !defined(__riscv) && \
17 !defined(_WIN32)
18#define LIBC_TYPES_HAS_FLOAT16
19
20// TODO: This would no longer be required if HdrGen let us guard function
21// declarations with multiple macros.
22#ifdef LIBC_TYPES_HAS_FLOAT128
23#define LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128
24#endif // LIBC_TYPES_HAS_FLOAT128
25#endif
26
27#endif // LLVM_LIBC_MACROS_FLOAT16_MACROS_H
lib/libcxx/libc/include/llvm-libc-macros/stdfix-macros.h created+328
...@@ -0,0 +1,328 @@
1//===-- Definitions from stdfix.h -----------------------------------------===//
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 LLVM_LIBC_MACROS_STDFIX_MACROS_H
10#define LLVM_LIBC_MACROS_STDFIX_MACROS_H
11
12#ifdef __FRACT_FBIT__
13// _Fract and _Accum types are available
14#define LIBC_COMPILER_HAS_FIXED_POINT
15#endif // __FRACT_FBIT__
16
17#ifdef LIBC_COMPILER_HAS_FIXED_POINT
18
19#define fract _Fract
20#define accum _Accum
21#define sat _Sat
22
23// Default values: from ISO/IEC TR 18037:2008 standard - Annex A.3 - Typical
24// desktop processor.
25
26#ifdef __SFRACT_FBIT__
27#define SFRACT_FBIT __SFRACT_FBIT__
28#else
29#define SFRACT_FBIT 7
30#endif // SFRACT_FBIT
31
32#ifdef __SFRACT_MIN__
33#define SFRACT_MIN __SFRACT_MIN__
34#else
35#define SFRACT_MIN (-0.5HR - 0.5HR)
36#endif // SFRACT_MIN
37
38#ifdef __SFRACT_MAX__
39#define SFRACT_MAX __SFRACT_MAX__
40#else
41#define SFRACT_MAX 0x1.FCp-1HR
42#endif // SFRACT_MAX
43
44#ifdef __SFRACT_EPSILON__
45#define SFRACT_EPSILON __SFRACT_EPSILON__
46#else
47#define SFRACT_EPSILON 0x1.0p-7HR
48#endif // SFRACT_EPSILON
49
50#ifdef __USFRACT_FBIT__
51#define USFRACT_FBIT __USFRACT_FBIT__
52#else
53#define USFRACT_FBIT 8
54#endif // USFRACT_FBIT
55
56#define USFRACT_MIN 0.0UHR
57
58#ifdef __USFRACT_MAX__
59#define USFRACT_MAX __USFRACT_MAX__
60#else
61#define USFRACT_MAX 0x1.FEp-1UHR
62#endif // USFRACT_MAX
63
64#ifdef __USFRACT_EPSILON__
65#define USFRACT_EPSILON __USFRACT_EPSILON__
66#else
67#define USFRACT_EPSILON 0x1.0p-8UHR
68#endif // USFRACT_EPSILON
69
70#ifdef __FRACT_FBIT__
71#define FRACT_FBIT __FRACT_FBIT__
72#else
73#define FRACT_FBIT 15
74#endif // FRACT_FBIT
75
76#ifdef __FRACT_MIN__
77#define FRACT_MIN __FRACT_MIN__
78#else
79#define FRACT_MIN (-0.5R - 0.5R)
80#endif // FRACT_MIN
81
82#ifdef __FRACT_MAX__
83#define FRACT_MAX __FRACT_MAX__
84#else
85#define FRACT_MAX 0x1.FFFCp-1R
86#endif // FRACT_MAX
87
88#ifdef __FRACT_EPSILON__
89#define FRACT_EPSILON __FRACT_EPSILON__
90#else
91#define FRACT_EPSILON 0x1.0p-15R
92#endif // FRACT_EPSILON
93
94#ifdef __UFRACT_FBIT__
95#define UFRACT_FBIT __UFRACT_FBIT__
96#else
97#define UFRACT_FBIT 16
98#endif // UFRACT_FBIT
99
100#define UFRACT_MIN 0.0UR
101
102#ifdef __UFRACT_MAX__
103#define UFRACT_MAX __UFRACT_MAX__
104#else
105#define UFRACT_MAX 0x1.FFFEp-1UR
106#endif // UFRACT_MAX
107
108#ifdef __UFRACT_EPSILON__
109#define UFRACT_EPSILON __UFRACT_EPSILON__
110#else
111#define UFRACT_EPSILON 0x1.0p-16UR
112#endif // UFRACT_EPSILON
113
114#ifdef __LFRACT_FBIT__
115#define LFRACT_FBIT __LFRACT_FBIT__
116#else
117#define LFRACT_FBIT 31
118#endif // LFRACT_FBIT
119
120#ifdef __LFRACT_MIN__
121#define LFRACT_MIN __LFRACT_MIN__
122#else
123#define LFRACT_MIN (-0.5LR - 0.5LR)
124#endif // LFRACT_MIN
125
126#ifdef __LFRACT_MAX__
127#define LFRACT_MAX __LFRACT_MAX__
128#else
129#define LFRACT_MAX 0x1.FFFFFFFCp-1LR
130#endif // LFRACT_MAX
131
132#ifdef __LFRACT_EPSILON__
133#define LFRACT_EPSILON __LFRACT_EPSILON__
134#else
135#define LFRACT_EPSILON 0x1.0p-31LR
136#endif // LFRACT_EPSILON
137
138#ifdef __ULFRACT_FBIT__
139#define ULFRACT_FBIT __ULFRACT_FBIT__
140#else
141#define ULFRACT_FBIT 32
142#endif // ULFRACT_FBIT
143
144#define ULFRACT_MIN 0.0ULR
145
146#ifdef __ULFRACT_MAX__
147#define ULFRACT_MAX __ULFRACT_MAX__
148#else
149#define ULFRACT_MAX 0x1.FFFFFFFEp-1ULR
150#endif // ULFRACT_MAX
151
152#ifdef __ULFRACT_EPSILON__
153#define ULFRACT_EPSILON __ULFRACT_EPSILON__
154#else
155#define ULFRACT_EPSILON 0x1.0p-32ULR
156#endif // ULFRACT_EPSILON
157
158#ifdef __SACCUM_FBIT__
159#define SACCUM_FBIT __SACCUM_FBIT__
160#else
161#define SACCUM_FBIT 7
162#endif // SACCUM_FBIT
163
164#ifdef __SACCUM_IBIT__
165#define SACCUM_IBIT __SACCUM_IBIT__
166#else
167#define SACCUM_IBIT 8
168#endif // SACCUM_IBIT
169
170#ifdef __SACCUM_MIN__
171#define SACCUM_MIN __SACCUM_MIN__
172#else
173#define SACCUM_MIN (-0x1.0p+7HK - 0x1.0p+7HK)
174#endif // SACCUM_MIN
175
176#ifdef __SACCUM_MAX__
177#define SACCUM_MAX __SACCUM_MAX__
178#else
179#define SACCUM_MAX 0x1.FFFCp+7HK
180#endif // SACCUM_MAX
181
182#ifdef __SACCUM_EPSILON__
183#define SACCUM_EPSILON __SACCUM_EPSILON__
184#else
185#define SACCUM_EPSILON 0x1.0p-7HK
186#endif // SACCUM_EPSILON
187
188#ifdef __USACCUM_FBIT__
189#define USACCUM_FBIT __USACCUM_FBIT__
190#else
191#define USACCUM_FBIT 8
192#endif // USACCUM_FBIT
193
194#ifdef __USACCUM_IBIT__
195#define USACCUM_IBIT __USACCUM_IBIT__
196#else
197#define USACCUM_IBIT 8
198#endif // USACCUM_IBIT
199
200#define USACCUM_MIN 0.0UHK
201
202#ifdef __USACCUM_MAX__
203#define USACCUM_MAX __USACCUM_MAX__
204#else
205#define USACCUM_MAX 0x1.FFFEp+7UHK
206#endif // USACCUM_MAX
207
208#ifdef __USACCUM_EPSILON__
209#define USACCUM_EPSILON __USACCUM_EPSILON__
210#else
211#define USACCUM_EPSILON 0x1.0p-8UHK
212#endif // USACCUM_EPSILON
213
214#ifdef __ACCUM_FBIT__
215#define ACCUM_FBIT __ACCUM_FBIT__
216#else
217#define ACCUM_FBIT 15
218#endif // ACCUM_FBIT
219
220#ifdef __ACCUM_IBIT__
221#define ACCUM_IBIT __ACCUM_IBIT__
222#else
223#define ACCUM_IBIT 16
224#endif // ACCUM_IBIT
225
226#ifdef __ACCUM_MIN__
227#define ACCUM_MIN __ACCUM_MIN__
228#else
229#define ACCUM_MIN (-0x1.0p+15K - 0x1.0p+15K)
230#endif // ACCUM_MIN
231
232#ifdef __ACCUM_MAX__
233#define ACCUM_MAX __ACCUM_MAX__
234#else
235#define ACCUM_MAX 0x1.FFFFFFFCp+15K
236#endif // ACCUM_MAX
237
238#ifdef __ACCUM_EPSILON__
239#define ACCUM_EPSILON __ACCUM_EPSILON__
240#else
241#define ACCUM_EPSILON 0x1.0p-15K
242#endif // ACCUM_EPSILON
243
244#ifdef __UACCUM_FBIT__
245#define UACCUM_FBIT __UACCUM_FBIT__
246#else
247#define UACCUM_FBIT 16
248#endif // UACCUM_FBIT
249
250#ifdef __UACCUM_IBIT__
251#define UACCUM_IBIT __UACCUM_IBIT__
252#else
253#define UACCUM_IBIT 16
254#endif // UACCUM_IBIT
255
256#define UACCUM_MIN 0.0UK
257
258#ifdef __UACCUM_MAX__
259#define UACCUM_MAX __UACCUM_MAX__
260#else
261#define UACCUM_MAX 0x1.FFFFFFFEp+15UK
262#endif // UACCUM_MAX
263
264#ifdef __UACCUM_EPSILON__
265#define UACCUM_EPSILON __UACCUM_EPSILON__
266#else
267#define UACCUM_EPSILON 0x1.0p-16UK
268#endif // UACCUM_EPSILON
269
270#ifdef __LACCUM_FBIT__
271#define LACCUM_FBIT __LACCUM_FBIT__
272#else
273#define LACCUM_FBIT 31
274#endif // LACCUM_FBIT
275
276#ifdef __LACCUM_IBIT__
277#define LACCUM_IBIT __LACCUM_IBIT__
278#else
279#define LACCUM_IBIT 32
280#endif // LACCUM_IBIT
281
282#ifdef __LACCUM_MIN__
283#define LACCUM_MIN __LACCUM_MIN__
284#else
285#define LACCUM_MIN (-0x1.0p+31LK - 0x1.0p+31LK)
286#endif // LACCUM_MIN
287
288#ifdef __LACCUM_MAX__
289#define LACCUM_MAX __LACCUM_MAX__
290#else
291#define LACCUM_MAX 0x1.FFFFFFFFFFFFFFFCp+31LK
292#endif // LACCUM_MAX
293
294#ifdef __LACCUM_EPSILON__
295#define LACCUM_EPSILON __LACCUM_EPSILON__
296#else
297#define LACCUM_EPSILON 0x1.0p-31LK
298#endif // LACCUM_EPSILON
299
300#ifdef __ULACCUM_FBIT__
301#define ULACCUM_FBIT __ULACCUM_FBIT__
302#else
303#define ULACCUM_FBIT 32
304#endif // ULACCUM_FBIT
305
306#ifdef __ULACCUM_IBIT__
307#define ULACCUM_IBIT __ULACCUM_IBIT__
308#else
309#define ULACCUM_IBIT 32
310#endif // ULACCUM_IBIT
311
312#define ULACCUM_MIN 0.0ULK
313
314#ifdef __ULACCUM_MAX__
315#define ULACCUM_MAX __ULACCUM_MAX__
316#else
317#define ULACCUM_MAX 0x1.FFFFFFFFFFFFFFFEp+31ULK
318#endif // ULACCUM_MAX
319
320#ifdef __ULACCUM_EPSILON__
321#define ULACCUM_EPSILON __ULACCUM_EPSILON__
322#else
323#define ULACCUM_EPSILON 0x1.0p-32ULK
324#endif // ULACCUM_EPSILON
325
326#endif // LIBC_COMPILER_HAS_FIXED_POINT
327
328#endif // LLVM_LIBC_MACROS_STDFIX_MACROS_H
lib/libcxx/libc/include/llvm-libc-types/cfloat128.h created+44
...@@ -0,0 +1,44 @@
1//===-- Definition of cfloat128 type --------------------------------------===//
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 LLVM_LIBC_TYPES_CFLOAT128_H
10#define LLVM_LIBC_TYPES_CFLOAT128_H
11
12#include "../llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG
13
14// Currently, the complex variant of C23 `_Float128` type is only defined as a
15// built-in type in GCC 7 or later, for C and in GCC 13 or later, for C++. For
16// clang, the complex variant of `__float128` is defined instead, and only on
17// x86-64 targets for clang 11 or later.
18//
19// TODO: Update the complex variant of C23 `_Float128` type detection again when
20// clang supports it.
21#ifdef __clang__
22#if (__clang_major__ >= 11) && \
23 (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
24// Use _Complex __float128 type. clang uses __SIZEOF_FLOAT128__ or __FLOAT128__
25// macro to notify the availability of __float128 type:
26// https://reviews.llvm.org/D15120
27#define LIBC_TYPES_HAS_CFLOAT128
28typedef _Complex __float128 cfloat128;
29#endif
30#elif defined(__GNUC__)
31#if (defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)) && \
32 (__GNUC__ >= 13 || (!defined(__cplusplus)))
33#define LIBC_TYPES_HAS_CFLOAT128
34typedef _Complex _Float128 cfloat128;
35#endif
36#endif
37
38#if !defined(LIBC_TYPES_HAS_CFLOAT128) && (LDBL_MANT_DIG == 113)
39#define LIBC_TYPES_HAS_CFLOAT128
40#define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
41typedef _Complex long double cfloat128;
42#endif
43
44#endif // LLVM_LIBC_TYPES_CFLOAT128_H
lib/libcxx/libc/include/llvm-libc-types/cfloat16.h created+21
...@@ -0,0 +1,21 @@
1//===-- Definition of cfloat16 type ---------------------------------------===//
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 LLVM_LIBC_TYPES_CFLOAT16_H
10#define LLVM_LIBC_TYPES_CFLOAT16_H
11
12#if defined(__FLT16_MANT_DIG__) && \
13 (!defined(__GNUC__) || __GNUC__ >= 13 || \
14 (defined(__clang__) && __clang_major__ >= 14)) && \
15 !defined(__arm__) && !defined(_M_ARM) && !defined(__riscv) && \
16 !defined(_WIN32)
17#define LIBC_TYPES_HAS_CFLOAT16
18typedef _Complex _Float16 cfloat16;
19#endif
20
21#endif // LLVM_LIBC_TYPES_CFLOAT16_H
lib/libcxx/libc/include/llvm-libc-types/float128.h created+36
...@@ -0,0 +1,36 @@
1//===-- Definition of float128 type ---------------------------------------===//
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 LLVM_LIBC_TYPES_FLOAT128_H
10#define LLVM_LIBC_TYPES_FLOAT128_H
11
12#include "../llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG
13
14// Currently, C23 `_Float128` type is only defined as a built-in type in GCC 7
15// or later, and only for C. For C++, or for clang, `__float128` is defined
16// instead, and only on x86-64 targets.
17//
18// TODO: Update C23 `_Float128` type detection again when clang supports it.
19// https://github.com/llvm/llvm-project/issues/80195
20#if defined(__STDC_IEC_60559_BFP__) && !defined(__clang__) && \
21 !defined(__cplusplus)
22#define LIBC_TYPES_HAS_FLOAT128
23typedef _Float128 float128;
24#elif defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
25// Use __float128 type. gcc and clang sometime use __SIZEOF_FLOAT128__ to
26// notify the availability of __float128.
27// clang also uses __FLOAT128__ macro to notify the availability of __float128
28// type: https://reviews.llvm.org/D15120
29#define LIBC_TYPES_HAS_FLOAT128
30typedef __float128 float128;
31#elif (LDBL_MANT_DIG == 113)
32#define LIBC_TYPES_HAS_FLOAT128
33typedef long double float128;
34#endif
35
36#endif // LLVM_LIBC_TYPES_FLOAT128_H
lib/libcxx/libc/shared/fp_bits.h created+22
...@@ -0,0 +1,22 @@
1//===-- Floating point number utils -----------------------------*- C++ -*-===//
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 LLVM_LIBC_SHARED_FP_BITS_H
10#define LLVM_LIBC_SHARED_FP_BITS_H
11
12#include "src/__support/FPUtil/FPBits.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace shared {
16
17using fputil::FPBits;
18
19} // namespace shared
20} // namespace LIBC_NAMESPACE_DECL
21
22#endif // LLVM_LIBC_SHARED_FP_BITS_H
lib/libcxx/libc/shared/str_to_float.h created+27
...@@ -0,0 +1,27 @@
1//===-- String to float conversion utils ------------------------*- C++ -*-===//
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 LLVM_LIBC_SHARED_STR_TO_FLOAT_H
10#define LLVM_LIBC_SHARED_STR_TO_FLOAT_H
11
12#include "src/__support/str_to_float.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace shared {
16
17using internal::ExpandedFloat;
18using internal::FloatConvertReturn;
19using internal::RoundDirection;
20
21using internal::binary_exp_to_float;
22using internal::decimal_exp_to_float;
23
24} // namespace shared
25} // namespace LIBC_NAMESPACE_DECL
26
27#endif // LLVM_LIBC_SHARED_STR_TO_FLOAT_H
lib/libcxx/libc/shared/str_to_integer.h created+24
...@@ -0,0 +1,24 @@
1//===-- String to int conversion utils --------------------------*- C++ -*-===//
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 LLVM_LIBC_SHARED_STR_TO_INTEGER_H
10#define LLVM_LIBC_SHARED_STR_TO_INTEGER_H
11
12#include "src/__support/str_to_integer.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace shared {
16
17using LIBC_NAMESPACE::StrToNumResult;
18
19using internal::strtointeger;
20
21} // namespace shared
22} // namespace LIBC_NAMESPACE_DECL
23
24#endif // LLVM_LIBC_SHARED_STR_TO_INTEGER_H
lib/libcxx/libc/src/__support/CPP/array.h created+80
...@@ -0,0 +1,80 @@
1//===-- A self contained equivalent of std::array ---------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_CPP_ARRAY_H
10#define LLVM_LIBC_SRC___SUPPORT_CPP_ARRAY_H
11
12#include "src/__support/CPP/iterator.h" // reverse_iterator
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15#include <stddef.h> // For size_t.
16
17namespace LIBC_NAMESPACE_DECL {
18namespace cpp {
19
20template <class T, size_t N> struct array {
21 static_assert(N != 0,
22 "Cannot create a LIBC_NAMESPACE::cpp::array of size 0.");
23
24 T Data[N];
25 using value_type = T;
26 using iterator = T *;
27 using const_iterator = const T *;
28 using reverse_iterator = cpp::reverse_iterator<iterator>;
29 using const_reverse_iterator = cpp::reverse_iterator<const_iterator>;
30
31 LIBC_INLINE constexpr T *data() { return Data; }
32 LIBC_INLINE constexpr const T *data() const { return Data; }
33
34 LIBC_INLINE constexpr T &front() { return Data[0]; }
35 LIBC_INLINE constexpr const T &front() const { return Data[0]; }
36
37 LIBC_INLINE constexpr T &back() { return Data[N - 1]; }
38 LIBC_INLINE constexpr const T &back() const { return Data[N - 1]; }
39
40 LIBC_INLINE constexpr T &operator[](size_t Index) { return Data[Index]; }
41
42 LIBC_INLINE constexpr const T &operator[](size_t Index) const {
43 return Data[Index];
44 }
45
46 LIBC_INLINE constexpr size_t size() const { return N; }
47
48 LIBC_INLINE constexpr bool empty() const { return N == 0; }
49
50 LIBC_INLINE constexpr iterator begin() { return Data; }
51 LIBC_INLINE constexpr const_iterator begin() const { return Data; }
52 LIBC_INLINE constexpr const_iterator cbegin() const { return begin(); }
53
54 LIBC_INLINE constexpr iterator end() { return Data + N; }
55 LIBC_INLINE constexpr const_iterator end() const { return Data + N; }
56 LIBC_INLINE constexpr const_iterator cend() const { return end(); }
57
58 LIBC_INLINE constexpr reverse_iterator rbegin() {
59 return reverse_iterator{end()};
60 }
61 LIBC_INLINE constexpr const_reverse_iterator rbegin() const {
62 return const_reverse_iterator{end()};
63 }
64 LIBC_INLINE constexpr const_reverse_iterator crbegin() const {
65 return rbegin();
66 }
67
68 LIBC_INLINE constexpr reverse_iterator rend() {
69 return reverse_iterator{begin()};
70 }
71 LIBC_INLINE constexpr const_reverse_iterator rend() const {
72 return const_reverse_iterator{begin()};
73 }
74 LIBC_INLINE constexpr const_reverse_iterator crend() const { return rend(); }
75};
76
77} // namespace cpp
78} // namespace LIBC_NAMESPACE_DECL
79
80#endif // LLVM_LIBC_SRC___SUPPORT_CPP_ARRAY_H
lib/libcxx/libc/src/__support/CPP/bit.h created+298
...@@ -0,0 +1,298 @@
1//===-- Implementation of the C++20 bit header -----------------*- C++ -*-===//
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// This is inspired by LLVM ADT/bit.h header.
9// Some functions are missing, we can add them as needed (popcount, byteswap).
10
11#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
12#define LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
13
14#include "src/__support/CPP/limits.h" // numeric_limits
15#include "src/__support/CPP/type_traits.h"
16#include "src/__support/macros/attributes.h"
17#include "src/__support/macros/config.h"
18#include "src/__support/macros/sanitizer.h"
19
20#include <stdint.h>
21
22namespace LIBC_NAMESPACE_DECL {
23namespace cpp {
24
25#if __has_builtin(__builtin_memcpy_inline)
26#define LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE
27#endif
28
29// This implementation of bit_cast requires trivially-constructible To, to avoid
30// UB in the implementation.
31template <typename To, typename From>
32LIBC_INLINE constexpr cpp::enable_if_t<
33 (sizeof(To) == sizeof(From)) &&
34 cpp::is_trivially_constructible<To>::value &&
35 cpp::is_trivially_copyable<To>::value &&
36 cpp::is_trivially_copyable<From>::value,
37 To>
38bit_cast(const From &from) {
39 MSAN_UNPOISON(&from, sizeof(From));
40#if __has_builtin(__builtin_bit_cast)
41 return __builtin_bit_cast(To, from);
42#else
43 To to;
44 char *dst = reinterpret_cast<char *>(&to);
45 const char *src = reinterpret_cast<const char *>(&from);
46#if __has_builtin(__builtin_memcpy_inline)
47 __builtin_memcpy_inline(dst, src, sizeof(To));
48#else
49 for (unsigned i = 0; i < sizeof(To); ++i)
50 dst[i] = src[i];
51#endif // __has_builtin(__builtin_memcpy_inline)
52 return to;
53#endif // __has_builtin(__builtin_bit_cast)
54}
55
56template <typename T>
57[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>,
58 bool>
59has_single_bit(T value) {
60 return (value != 0) && ((value & (value - 1)) == 0);
61}
62
63// A temporary macro to add template function specialization when compiler
64// builtin is available.
65#define ADD_SPECIALIZATION(NAME, TYPE, BUILTIN) \
66 template <> [[nodiscard]] LIBC_INLINE constexpr int NAME<TYPE>(TYPE value) { \
67 static_assert(cpp::is_unsigned_v<TYPE>); \
68 return value == 0 ? cpp::numeric_limits<TYPE>::digits : BUILTIN(value); \
69 }
70
71/// Count number of 0's from the least significant bit to the most
72/// stopping at the first 1.
73///
74/// Only unsigned integral types are allowed.
75///
76/// Returns cpp::numeric_limits<T>::digits on an input of 0.
77// clang-19+, gcc-14+
78#if __has_builtin(__builtin_ctzg)
79template <typename T>
80[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
81countr_zero(T value) {
82 return __builtin_ctzg(value, cpp::numeric_limits<T>::digits);
83}
84#else
85template <typename T>
86[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
87countr_zero(T value) {
88 if (!value)
89 return cpp::numeric_limits<T>::digits;
90 if (value & 0x1)
91 return 0;
92 // Bisection method.
93 unsigned zero_bits = 0;
94 unsigned shift = cpp::numeric_limits<T>::digits >> 1;
95 T mask = cpp::numeric_limits<T>::max() >> shift;
96 while (shift) {
97 if ((value & mask) == 0) {
98 value >>= shift;
99 zero_bits |= shift;
100 }
101 shift >>= 1;
102 mask >>= shift;
103 }
104 return zero_bits;
105}
106#if __has_builtin(__builtin_ctzs)
107ADD_SPECIALIZATION(countr_zero, unsigned short, __builtin_ctzs)
108#endif
109ADD_SPECIALIZATION(countr_zero, unsigned int, __builtin_ctz)
110ADD_SPECIALIZATION(countr_zero, unsigned long, __builtin_ctzl)
111ADD_SPECIALIZATION(countr_zero, unsigned long long, __builtin_ctzll)
112#endif // __has_builtin(__builtin_ctzg)
113
114/// Count number of 0's from the most significant bit to the least
115/// stopping at the first 1.
116///
117/// Only unsigned integral types are allowed.
118///
119/// Returns cpp::numeric_limits<T>::digits on an input of 0.
120// clang-19+, gcc-14+
121#if __has_builtin(__builtin_clzg)
122template <typename T>
123[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
124countl_zero(T value) {
125 return __builtin_clzg(value, cpp::numeric_limits<T>::digits);
126}
127#else
128template <typename T>
129[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
130countl_zero(T value) {
131 if (!value)
132 return cpp::numeric_limits<T>::digits;
133 // Bisection method.
134 unsigned zero_bits = 0;
135 for (unsigned shift = cpp::numeric_limits<T>::digits >> 1; shift;
136 shift >>= 1) {
137 T tmp = value >> shift;
138 if (tmp)
139 value = tmp;
140 else
141 zero_bits |= shift;
142 }
143 return zero_bits;
144}
145#if __has_builtin(__builtin_clzs)
146ADD_SPECIALIZATION(countl_zero, unsigned short, __builtin_clzs)
147#endif
148ADD_SPECIALIZATION(countl_zero, unsigned int, __builtin_clz)
149ADD_SPECIALIZATION(countl_zero, unsigned long, __builtin_clzl)
150ADD_SPECIALIZATION(countl_zero, unsigned long long, __builtin_clzll)
151#endif // __has_builtin(__builtin_clzg)
152
153#undef ADD_SPECIALIZATION
154
155/// Count the number of ones from the most significant bit to the first
156/// zero bit.
157///
158/// Ex. countl_one(0xFF0FFF00) == 8.
159/// Only unsigned integral types are allowed.
160///
161/// Returns cpp::numeric_limits<T>::digits on an input of all ones.
162template <typename T>
163[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
164countl_one(T value) {
165 return cpp::countl_zero<T>(~value);
166}
167
168/// Count the number of ones from the least significant bit to the first
169/// zero bit.
170///
171/// Ex. countr_one(0x00FF00FF) == 8.
172/// Only unsigned integral types are allowed.
173///
174/// Returns cpp::numeric_limits<T>::digits on an input of all ones.
175template <typename T>
176[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
177countr_one(T value) {
178 return cpp::countr_zero<T>(~value);
179}
180
181/// Returns the number of bits needed to represent value if value is nonzero.
182/// Returns 0 otherwise.
183///
184/// Ex. bit_width(5) == 3.
185template <typename T>
186[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
187bit_width(T value) {
188 return cpp::numeric_limits<T>::digits - cpp::countl_zero(value);
189}
190
191/// Returns the largest integral power of two no greater than value if value is
192/// nonzero. Returns 0 otherwise.
193///
194/// Ex. bit_floor(5) == 4.
195template <typename T>
196[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T>
197bit_floor(T value) {
198 if (!value)
199 return 0;
200 return static_cast<T>(T(1) << (cpp::bit_width(value) - 1));
201}
202
203/// Returns the smallest integral power of two no smaller than value if value is
204/// nonzero. Returns 1 otherwise.
205///
206/// Ex. bit_ceil(5) == 8.
207///
208/// The return value is undefined if the input is larger than the largest power
209/// of two representable in T.
210template <typename T>
211[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T>
212bit_ceil(T value) {
213 if (value < 2)
214 return 1;
215 return static_cast<T>(T(1) << cpp::bit_width(value - 1U));
216}
217
218// Rotate algorithms make use of "Safe, Efficient, and Portable Rotate in C/C++"
219// from https://blog.regehr.org/archives/1063.
220
221// Forward-declare rotr so that rotl can use it.
222template <typename T>
223[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T>
224rotr(T value, int rotate);
225
226template <typename T>
227[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T>
228rotl(T value, int rotate) {
229 constexpr unsigned N = cpp::numeric_limits<T>::digits;
230 rotate = rotate % N;
231 if (!rotate)
232 return value;
233 if (rotate < 0)
234 return cpp::rotr<T>(value, -rotate);
235 return (value << rotate) | (value >> (N - rotate));
236}
237
238template <typename T>
239[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T>
240rotr(T value, int rotate) {
241 constexpr unsigned N = cpp::numeric_limits<T>::digits;
242 rotate = rotate % N;
243 if (!rotate)
244 return value;
245 if (rotate < 0)
246 return cpp::rotl<T>(value, -rotate);
247 return (value >> rotate) | (value << (N - rotate));
248}
249
250// TODO: Do we need this function at all? How is it different from
251// 'static_cast'?
252template <class To, class From>
253LIBC_INLINE constexpr To bit_or_static_cast(const From &from) {
254 if constexpr (sizeof(To) == sizeof(From)) {
255 return bit_cast<To>(from);
256 } else {
257 return static_cast<To>(from);
258 }
259}
260
261/// Count number of 1's aka population count or Hamming weight.
262///
263/// Only unsigned integral types are allowed.
264// clang-19+, gcc-14+
265#if __has_builtin(__builtin_popcountg)
266template <typename T>
267[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
268popcount(T value) {
269 return __builtin_popcountg(value);
270}
271#else // !__has_builtin(__builtin_popcountg)
272template <typename T>
273[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
274popcount(T value) {
275 int count = 0;
276 while (value) {
277 value &= value - 1;
278 ++count;
279 }
280 return count;
281}
282#define ADD_SPECIALIZATION(TYPE, BUILTIN) \
283 template <> \
284 [[nodiscard]] LIBC_INLINE constexpr int popcount<TYPE>(TYPE value) { \
285 return BUILTIN(value); \
286 }
287ADD_SPECIALIZATION(unsigned char, __builtin_popcount)
288ADD_SPECIALIZATION(unsigned short, __builtin_popcount)
289ADD_SPECIALIZATION(unsigned, __builtin_popcount)
290ADD_SPECIALIZATION(unsigned long, __builtin_popcountl)
291ADD_SPECIALIZATION(unsigned long long, __builtin_popcountll)
292#endif // __builtin_popcountg
293#undef ADD_SPECIALIZATION
294
295} // namespace cpp
296} // namespace LIBC_NAMESPACE_DECL
297
298#endif // LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
lib/libcxx/libc/src/__support/CPP/iterator.h created+99
...@@ -0,0 +1,99 @@
1//===-- Standalone implementation of iterator -------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_CPP_ITERATOR_H
10#define LLVM_LIBC_SRC___SUPPORT_CPP_ITERATOR_H
11
12#include "src/__support/CPP/type_traits/enable_if.h"
13#include "src/__support/CPP/type_traits/is_convertible.h"
14#include "src/__support/CPP/type_traits/is_same.h"
15#include "src/__support/macros/attributes.h"
16#include "src/__support/macros/config.h"
17
18namespace LIBC_NAMESPACE_DECL {
19namespace cpp {
20
21template <typename T> struct iterator_traits;
22template <typename T> struct iterator_traits<T *> {
23 using reference = T &;
24 using value_type = T;
25};
26
27template <typename Iter> class reverse_iterator {
28 Iter current;
29
30public:
31 using reference = typename iterator_traits<Iter>::reference;
32 using value_type = typename iterator_traits<Iter>::value_type;
33 using iterator_type = Iter;
34
35 LIBC_INLINE reverse_iterator() : current() {}
36 LIBC_INLINE constexpr explicit reverse_iterator(Iter it) : current(it) {}
37
38 template <typename Other,
39 cpp::enable_if_t<!cpp::is_same_v<Iter, Other> &&
40 cpp::is_convertible_v<const Other &, Iter>,
41 int> = 0>
42 LIBC_INLINE constexpr explicit reverse_iterator(const Other &it)
43 : current(it) {}
44
45 LIBC_INLINE friend constexpr bool operator==(const reverse_iterator &lhs,
46 const reverse_iterator &rhs) {
47 return lhs.base() == rhs.base();
48 }
49
50 LIBC_INLINE friend constexpr bool operator!=(const reverse_iterator &lhs,
51 const reverse_iterator &rhs) {
52 return lhs.base() != rhs.base();
53 }
54
55 LIBC_INLINE friend constexpr bool operator<(const reverse_iterator &lhs,
56 const reverse_iterator &rhs) {
57 return lhs.base() > rhs.base();
58 }
59
60 LIBC_INLINE friend constexpr bool operator<=(const reverse_iterator &lhs,
61 const reverse_iterator &rhs) {
62 return lhs.base() >= rhs.base();
63 }
64
65 LIBC_INLINE friend constexpr bool operator>(const reverse_iterator &lhs,
66 const reverse_iterator &rhs) {
67 return lhs.base() < rhs.base();
68 }
69
70 LIBC_INLINE friend constexpr bool operator>=(const reverse_iterator &lhs,
71 const reverse_iterator &rhs) {
72 return lhs.base() <= rhs.base();
73 }
74
75 LIBC_INLINE constexpr iterator_type base() const { return current; }
76
77 LIBC_INLINE constexpr reference operator*() const {
78 Iter tmp = current;
79 return *--tmp;
80 }
81 LIBC_INLINE constexpr reverse_iterator operator--() {
82 ++current;
83 return *this;
84 }
85 LIBC_INLINE constexpr reverse_iterator &operator++() {
86 --current;
87 return *this;
88 }
89 LIBC_INLINE constexpr reverse_iterator operator++(int) {
90 reverse_iterator tmp(*this);
91 --current;
92 return tmp;
93 }
94};
95
96} // namespace cpp
97} // namespace LIBC_NAMESPACE_DECL
98
99#endif // LLVM_LIBC_SRC___SUPPORT_CPP_ITERATOR_H
lib/libcxx/libc/src/__support/CPP/limits.h created+92
...@@ -0,0 +1,92 @@
1//===-- A self contained equivalent of std::limits --------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_CPP_LIMITS_H
10#define LLVM_LIBC_SRC___SUPPORT_CPP_LIMITS_H
11
12#include "hdr/limits_macros.h" // CHAR_BIT
13#include "src/__support/CPP/type_traits/is_integral.h"
14#include "src/__support/CPP/type_traits/is_signed.h"
15#include "src/__support/macros/attributes.h" // LIBC_INLINE
16#include "src/__support/macros/config.h"
17#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
18
19namespace LIBC_NAMESPACE_DECL {
20namespace cpp {
21
22namespace internal {
23
24template <typename T, T min_value, T max_value> struct integer_impl {
25 static_assert(cpp::is_integral_v<T>);
26 LIBC_INLINE static constexpr T max() { return max_value; }
27 LIBC_INLINE static constexpr T min() { return min_value; }
28 LIBC_INLINE_VAR static constexpr int digits =
29 CHAR_BIT * sizeof(T) - cpp::is_signed_v<T>;
30};
31
32} // namespace internal
33
34template <class T> struct numeric_limits {};
35
36// TODO: Add numeric_limits specializations as needed for new types.
37template <>
38struct numeric_limits<short>
39 : public internal::integer_impl<short, SHRT_MIN, SHRT_MAX> {};
40
41template <>
42struct numeric_limits<unsigned short>
43 : public internal::integer_impl<unsigned short, 0, USHRT_MAX> {};
44
45template <>
46struct numeric_limits<int>
47 : public internal::integer_impl<int, INT_MIN, INT_MAX> {};
48
49template <>
50struct numeric_limits<unsigned int>
51 : public internal::integer_impl<unsigned int, 0, UINT_MAX> {};
52
53template <>
54struct numeric_limits<long>
55 : public internal::integer_impl<long, LONG_MIN, LONG_MAX> {};
56
57template <>
58struct numeric_limits<unsigned long>
59 : public internal::integer_impl<unsigned long, 0, ULONG_MAX> {};
60
61template <>
62struct numeric_limits<long long>
63 : public internal::integer_impl<long long, LLONG_MIN, LLONG_MAX> {};
64
65template <>
66struct numeric_limits<unsigned long long>
67 : public internal::integer_impl<unsigned long long, 0, ULLONG_MAX> {};
68
69template <>
70struct numeric_limits<char>
71 : public internal::integer_impl<char, CHAR_MIN, CHAR_MAX> {};
72
73template <>
74struct numeric_limits<signed char>
75 : public internal::integer_impl<signed char, SCHAR_MIN, SCHAR_MAX> {};
76
77template <>
78struct numeric_limits<unsigned char>
79 : public internal::integer_impl<unsigned char, 0, UCHAR_MAX> {};
80
81#ifdef LIBC_TYPES_HAS_INT128
82// On platform where UInt128 resolves to __uint128_t, this specialization
83// provides the limits of UInt128.
84template <>
85struct numeric_limits<__uint128_t>
86 : public internal::integer_impl<__uint128_t, 0, ~__uint128_t(0)> {};
87#endif
88
89} // namespace cpp
90} // namespace LIBC_NAMESPACE_DECL
91
92#endif // LLVM_LIBC_SRC___SUPPORT_CPP_LIMITS_H
lib/libcxx/libc/src/__support/CPP/optional.h created+139
...@@ -0,0 +1,139 @@
1//===-- Standalone implementation of std::optional --------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_CPP_OPTIONAL_H
10#define LLVM_LIBC_SRC___SUPPORT_CPP_OPTIONAL_H
11
12#include "src/__support/CPP/type_traits.h"
13#include "src/__support/CPP/utility.h"
14#include "src/__support/macros/attributes.h"
15#include "src/__support/macros/config.h"
16
17namespace LIBC_NAMESPACE_DECL {
18namespace cpp {
19
20// Trivial nullopt_t struct.
21struct nullopt_t {
22 LIBC_INLINE constexpr explicit nullopt_t() = default;
23};
24
25// nullopt that can be used and returned.
26LIBC_INLINE_VAR constexpr nullopt_t nullopt{};
27
28// This is very simple implementation of the std::optional class. It makes
29// several assumptions that the underlying type is trivially constructible,
30// copyable, or movable.
31template <typename T> class optional {
32 template <typename U, bool = !is_trivially_destructible<U>::value>
33 struct OptionalStorage {
34 union {
35 char empty;
36 U stored_value;
37 };
38
39 bool in_use = false;
40
41 LIBC_INLINE ~OptionalStorage() { reset(); }
42
43 LIBC_INLINE constexpr OptionalStorage() : empty() {}
44
45 template <typename... Args>
46 LIBC_INLINE constexpr explicit OptionalStorage(in_place_t, Args &&...args)
47 : stored_value(forward<Args>(args)...) {}
48
49 LIBC_INLINE constexpr void reset() {
50 if (in_use)
51 stored_value.~U();
52 in_use = false;
53 }
54 };
55
56 // The only difference is that this type U doesn't have a nontrivial
57 // destructor.
58 template <typename U> struct OptionalStorage<U, false> {
59 union {
60 char empty;
61 U stored_value;
62 };
63
64 bool in_use = false;
65
66 LIBC_INLINE constexpr OptionalStorage() : empty() {}
67
68 template <typename... Args>
69 LIBC_INLINE constexpr explicit OptionalStorage(in_place_t, Args &&...args)
70 : stored_value(forward<Args>(args)...) {}
71
72 LIBC_INLINE constexpr void reset() { in_use = false; }
73 };
74
75 OptionalStorage<T> storage;
76
77public:
78 LIBC_INLINE constexpr optional() = default;
79 LIBC_INLINE constexpr optional(nullopt_t) {}
80
81 LIBC_INLINE constexpr optional(const T &t) : storage(in_place, t) {
82 storage.in_use = true;
83 }
84 LIBC_INLINE constexpr optional(const optional &) = default;
85
86 LIBC_INLINE constexpr optional(T &&t) : storage(in_place, move(t)) {
87 storage.in_use = true;
88 }
89 LIBC_INLINE constexpr optional(optional &&O) = default;
90
91 template <typename... ArgTypes>
92 LIBC_INLINE constexpr optional(in_place_t, ArgTypes &&...Args)
93 : storage(in_place, forward<ArgTypes>(Args)...) {
94 storage.in_use = true;
95 }
96
97 LIBC_INLINE constexpr optional &operator=(T &&t) {
98 storage = move(t);
99 return *this;
100 }
101 LIBC_INLINE constexpr optional &operator=(optional &&) = default;
102
103 LIBC_INLINE constexpr optional &operator=(const T &t) {
104 storage = t;
105 return *this;
106 }
107 LIBC_INLINE constexpr optional &operator=(const optional &) = default;
108
109 LIBC_INLINE constexpr void reset() { storage.reset(); }
110
111 LIBC_INLINE constexpr const T &value() const & {
112 return storage.stored_value;
113 }
114
115 LIBC_INLINE constexpr T &value() & { return storage.stored_value; }
116
117 LIBC_INLINE constexpr explicit operator bool() const {
118 return storage.in_use;
119 }
120 LIBC_INLINE constexpr bool has_value() const { return storage.in_use; }
121 LIBC_INLINE constexpr const T *operator->() const {
122 return &storage.stored_value;
123 }
124 LIBC_INLINE constexpr T *operator->() { return &storage.stored_value; }
125 LIBC_INLINE constexpr const T &operator*() const & {
126 return storage.stored_value;
127 }
128 LIBC_INLINE constexpr T &operator*() & { return storage.stored_value; }
129
130 LIBC_INLINE constexpr T &&value() && { return move(storage.stored_value); }
131 LIBC_INLINE constexpr T &&operator*() && {
132 return move(storage.stored_value);
133 }
134};
135
136} // namespace cpp
137} // namespace LIBC_NAMESPACE_DECL
138
139#endif // LLVM_LIBC_SRC___SUPPORT_CPP_OPTIONAL_H
lib/libcxx/libc/src/__support/CPP/string_view.h created+220
...@@ -0,0 +1,220 @@
1//===-- Standalone implementation std::string_view --------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_CPP_STRING_VIEW_H
10#define LLVM_LIBC_SRC___SUPPORT_CPP_STRING_VIEW_H
11
12#include "src/__support/common.h"
13#include "src/__support/macros/config.h"
14
15#include <stddef.h>
16
17namespace LIBC_NAMESPACE_DECL {
18namespace cpp {
19
20// This is very simple alternate of the std::string_view class. There is no
21// bounds check performed in any of the methods. The callers are expected to
22// do the checks before invoking the methods.
23//
24// This class will be extended as needed in future.
25class string_view {
26private:
27 const char *Data;
28 size_t Len;
29
30 LIBC_INLINE static size_t min(size_t A, size_t B) { return A <= B ? A : B; }
31
32 LIBC_INLINE static int compareMemory(const char *Lhs, const char *Rhs,
33 size_t Length) {
34 for (size_t i = 0; i < Length; ++i)
35 if (int Diff = (int)Lhs[i] - (int)Rhs[i])
36 return Diff;
37 return 0;
38 }
39
40 LIBC_INLINE static constexpr size_t length(const char *Str) {
41 for (const char *End = Str;; ++End)
42 if (*End == '\0')
43 return End - Str;
44 }
45
46 LIBC_INLINE bool equals(string_view Other) const {
47 return (Len == Other.Len &&
48 compareMemory(Data, Other.Data, Other.Len) == 0);
49 }
50
51public:
52 using value_type = char;
53 using size_type = size_t;
54 using difference_type = ptrdiff_t;
55 using pointer = char *;
56 using const_pointer = const char *;
57 using reference = char &;
58 using const_reference = const char &;
59 using const_iterator = char *;
60 using iterator = const_iterator;
61
62 // special value equal to the maximum value representable by the type
63 // size_type.
64 LIBC_INLINE_VAR static constexpr size_t npos = -1;
65
66 LIBC_INLINE constexpr string_view() : Data(nullptr), Len(0) {}
67
68 // Assumes Str is a null-terminated string. The length of the string does
69 // not include the terminating null character.
70 // Preconditions: [Str, Str + ​length(Str)) is a valid range.
71 LIBC_INLINE constexpr string_view(const char *Str)
72 : Data(Str), Len(length(Str)) {}
73
74 // Preconditions: [Str, Str + N) is a valid range.
75 LIBC_INLINE constexpr string_view(const char *Str, size_t N)
76 : Data(Str), Len(N) {}
77
78 LIBC_INLINE constexpr const char *data() const { return Data; }
79
80 // Returns the size of the string_view.
81 LIBC_INLINE constexpr size_t size() const { return Len; }
82
83 // Returns whether the string_view is empty.
84 LIBC_INLINE constexpr bool empty() const { return Len == 0; }
85
86 // Returns an iterator to the first character of the view.
87 LIBC_INLINE const char *begin() const { return Data; }
88
89 // Returns an iterator to the character following the last character of the
90 // view.
91 LIBC_INLINE const char *end() const { return Data + Len; }
92
93 // Returns a const reference to the character at specified location pos.
94 // No bounds checking is performed: the behavior is undefined if pos >=
95 // size().
96 LIBC_INLINE constexpr const char &operator[](size_t Index) const {
97 return Data[Index];
98 }
99
100 /// compare - Compare two strings; the result is -1, 0, or 1 if this string
101 /// is lexicographically less than, equal to, or greater than the \p Other.
102 LIBC_INLINE int compare(string_view Other) const {
103 // Check the prefix for a mismatch.
104 if (int Res = compareMemory(Data, Other.Data, min(Len, Other.Len)))
105 return Res < 0 ? -1 : 1;
106 // Otherwise the prefixes match, so we only need to check the lengths.
107 if (Len == Other.Len)
108 return 0;
109 return Len < Other.Len ? -1 : 1;
110 }
111
112 LIBC_INLINE bool operator==(string_view Other) const { return equals(Other); }
113 LIBC_INLINE bool operator!=(string_view Other) const {
114 return !(*this == Other);
115 }
116 LIBC_INLINE bool operator<(string_view Other) const {
117 return compare(Other) == -1;
118 }
119 LIBC_INLINE bool operator<=(string_view Other) const {
120 return compare(Other) != 1;
121 }
122 LIBC_INLINE bool operator>(string_view Other) const {
123 return compare(Other) == 1;
124 }
125 LIBC_INLINE bool operator>=(string_view Other) const {
126 return compare(Other) != -1;
127 }
128
129 // Moves the start of the view forward by n characters.
130 // The behavior is undefined if n > size().
131 LIBC_INLINE void remove_prefix(size_t N) {
132 Len -= N;
133 Data += N;
134 }
135
136 // Moves the end of the view back by n characters.
137 // The behavior is undefined if n > size().
138 LIBC_INLINE void remove_suffix(size_t N) { Len -= N; }
139
140 // Check if this string starts with the given Prefix.
141 LIBC_INLINE bool starts_with(string_view Prefix) const {
142 return Len >= Prefix.Len &&
143 compareMemory(Data, Prefix.Data, Prefix.Len) == 0;
144 }
145
146 // Check if this string starts with the given Prefix.
147 LIBC_INLINE bool starts_with(const char Prefix) const {
148 return !empty() && front() == Prefix;
149 }
150
151 // Check if this string ends with the given Prefix.
152 LIBC_INLINE bool ends_with(const char Suffix) const {
153 return !empty() && back() == Suffix;
154 }
155
156 // Check if this string ends with the given Suffix.
157 LIBC_INLINE bool ends_with(string_view Suffix) const {
158 return Len >= Suffix.Len &&
159 compareMemory(end() - Suffix.Len, Suffix.Data, Suffix.Len) == 0;
160 }
161
162 // Return a reference to the substring from [Start, Start + N).
163 //
164 // Start The index of the starting character in the substring; if the index is
165 // npos or greater than the length of the string then the empty substring will
166 // be returned.
167 //
168 // N The number of characters to included in the substring. If N exceeds the
169 // number of characters remaining in the string, the string suffix (starting
170 // with Start) will be returned.
171 LIBC_INLINE string_view substr(size_t Start, size_t N = npos) const {
172 Start = min(Start, Len);
173 return string_view(Data + Start, min(N, Len - Start));
174 }
175
176 // front - Get the first character in the string.
177 LIBC_INLINE char front() const { return Data[0]; }
178
179 // back - Get the last character in the string.
180 LIBC_INLINE char back() const { return Data[Len - 1]; }
181
182 // Finds the first occurence of c in this view, starting at position From.
183 LIBC_INLINE constexpr size_t find_first_of(const char c,
184 size_t From = 0) const {
185 for (size_t Pos = From; Pos < size(); ++Pos)
186 if ((*this)[Pos] == c)
187 return Pos;
188 return npos;
189 }
190
191 // Finds the last occurence of c in this view, ending at position End.
192 LIBC_INLINE constexpr size_t find_last_of(const char c,
193 size_t End = npos) const {
194 End = End >= size() ? size() : End + 1;
195 for (; End > 0; --End)
196 if ((*this)[End - 1] == c)
197 return End - 1;
198 return npos;
199 }
200
201 // Finds the first character not equal to c in this view, starting at position
202 // From.
203 LIBC_INLINE constexpr size_t find_first_not_of(const char c,
204 size_t From = 0) const {
205 for (size_t Pos = From; Pos < size(); ++Pos)
206 if ((*this)[Pos] != c)
207 return Pos;
208 return npos;
209 }
210
211 // Check if this view contains the given character.
212 LIBC_INLINE constexpr bool contains(char c) const {
213 return find_first_of(c) != npos;
214 }
215};
216
217} // namespace cpp
218} // namespace LIBC_NAMESPACE_DECL
219
220#endif // LLVM_LIBC_SRC___SUPPORT_CPP_STRING_VIEW_H
lib/libcxx/libc/src/__support/CPP/type_traits.h created+70
...@@ -0,0 +1,70 @@
1//===-- Self contained C++ type_traits --------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_H
10#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_H
11
12#include "src/__support/CPP/type_traits/add_lvalue_reference.h"
13#include "src/__support/CPP/type_traits/add_pointer.h"
14#include "src/__support/CPP/type_traits/add_rvalue_reference.h"
15#include "src/__support/CPP/type_traits/aligned_storage.h"
16#include "src/__support/CPP/type_traits/bool_constant.h"
17#include "src/__support/CPP/type_traits/conditional.h"
18#include "src/__support/CPP/type_traits/decay.h"
19#include "src/__support/CPP/type_traits/enable_if.h"
20#include "src/__support/CPP/type_traits/false_type.h"
21#include "src/__support/CPP/type_traits/has_unique_object_representations.h"
22#include "src/__support/CPP/type_traits/integral_constant.h"
23#include "src/__support/CPP/type_traits/invoke.h"
24#include "src/__support/CPP/type_traits/invoke_result.h"
25#include "src/__support/CPP/type_traits/is_arithmetic.h"
26#include "src/__support/CPP/type_traits/is_array.h"
27#include "src/__support/CPP/type_traits/is_base_of.h"
28#include "src/__support/CPP/type_traits/is_class.h"
29#include "src/__support/CPP/type_traits/is_complex.h"
30#include "src/__support/CPP/type_traits/is_const.h"
31#include "src/__support/CPP/type_traits/is_constant_evaluated.h"
32#include "src/__support/CPP/type_traits/is_convertible.h"
33#include "src/__support/CPP/type_traits/is_copy_assignable.h"
34#include "src/__support/CPP/type_traits/is_copy_constructible.h"
35#include "src/__support/CPP/type_traits/is_destructible.h"
36#include "src/__support/CPP/type_traits/is_enum.h"
37#include "src/__support/CPP/type_traits/is_fixed_point.h"
38#include "src/__support/CPP/type_traits/is_floating_point.h"
39#include "src/__support/CPP/type_traits/is_function.h"
40#include "src/__support/CPP/type_traits/is_integral.h"
41#include "src/__support/CPP/type_traits/is_lvalue_reference.h"
42#include "src/__support/CPP/type_traits/is_member_pointer.h"
43#include "src/__support/CPP/type_traits/is_move_assignable.h"
44#include "src/__support/CPP/type_traits/is_move_constructible.h"
45#include "src/__support/CPP/type_traits/is_null_pointer.h"
46#include "src/__support/CPP/type_traits/is_object.h"
47#include "src/__support/CPP/type_traits/is_pointer.h"
48#include "src/__support/CPP/type_traits/is_reference.h"
49#include "src/__support/CPP/type_traits/is_rvalue_reference.h"
50#include "src/__support/CPP/type_traits/is_same.h"
51#include "src/__support/CPP/type_traits/is_scalar.h"
52#include "src/__support/CPP/type_traits/is_signed.h"
53#include "src/__support/CPP/type_traits/is_trivially_constructible.h"
54#include "src/__support/CPP/type_traits/is_trivially_copyable.h"
55#include "src/__support/CPP/type_traits/is_trivially_destructible.h"
56#include "src/__support/CPP/type_traits/is_union.h"
57#include "src/__support/CPP/type_traits/is_unsigned.h"
58#include "src/__support/CPP/type_traits/is_void.h"
59#include "src/__support/CPP/type_traits/make_signed.h"
60#include "src/__support/CPP/type_traits/make_unsigned.h"
61#include "src/__support/CPP/type_traits/remove_all_extents.h"
62#include "src/__support/CPP/type_traits/remove_cv.h"
63#include "src/__support/CPP/type_traits/remove_cvref.h"
64#include "src/__support/CPP/type_traits/remove_extent.h"
65#include "src/__support/CPP/type_traits/remove_reference.h"
66#include "src/__support/CPP/type_traits/true_type.h"
67#include "src/__support/CPP/type_traits/type_identity.h"
68#include "src/__support/CPP/type_traits/void_t.h"
69
70#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_H
lib/libcxx/libc/src/__support/CPP/type_traits/add_lvalue_reference.h created+33
...@@ -0,0 +1,33 @@
1//===-- add_lvalue_reference type_traits ------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
10
11#include "src/__support/CPP/type_traits/type_identity.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// add_lvalue_reference
18namespace detail {
19template <class T> // Note that `cv void&` is a substitution failure
20auto try_add_lvalue_reference(int) -> cpp::type_identity<T &>;
21template <class T> // Handle T = cv void case
22auto try_add_lvalue_reference(...) -> cpp::type_identity<T>;
23} // namespace detail
24template <class T>
25struct add_lvalue_reference : decltype(detail::try_add_lvalue_reference<T>(0)) {
26};
27template <class T>
28using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;
29
30} // namespace cpp
31} // namespace LIBC_NAMESPACE_DECL
32
33#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
lib/libcxx/libc/src/__support/CPP/type_traits/add_pointer.h created+30
...@@ -0,0 +1,30 @@
1//===-- add_pointer type_traits ---------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H
10
11#include "src/__support/CPP/type_traits/remove_reference.h"
12#include "src/__support/CPP/type_traits/type_identity.h"
13#include "src/__support/macros/config.h"
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18// add_pointer
19namespace detail {
20template <class T>
21auto try_add_pointer(int) -> cpp::type_identity<cpp::remove_reference_t<T> *>;
22template <class T> auto try_add_pointer(...) -> cpp::type_identity<T>;
23} // namespace detail
24template <class T>
25struct add_pointer : decltype(detail::try_add_pointer<T>(0)) {};
26template <class T> using add_pointer_t = typename add_pointer<T>::type;
27} // namespace cpp
28} // namespace LIBC_NAMESPACE_DECL
29
30#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H
lib/libcxx/libc/src/__support/CPP/type_traits/add_rvalue_reference.h created+32
...@@ -0,0 +1,32 @@
1//===-- add_rvalue_reference type_traits ------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
10
11#include "src/__support/CPP/type_traits/type_identity.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// add_rvalue_reference
18namespace detail {
19template <class T>
20auto try_add_rvalue_reference(int) -> cpp::type_identity<T &&>;
21template <class T> auto try_add_rvalue_reference(...) -> cpp::type_identity<T>;
22} // namespace detail
23template <class T>
24struct add_rvalue_reference : decltype(detail::try_add_rvalue_reference<T>(0)) {
25};
26template <class T>
27using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
28
29} // namespace cpp
30} // namespace LIBC_NAMESPACE_DECL
31
32#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
lib/libcxx/libc/src/__support/CPP/type_traits/aligned_storage.h created+30
...@@ -0,0 +1,30 @@
1//===-- aligned_storage type_traits --------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALIGNED_STORAGE_H
10#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALIGNED_STORAGE_H
11
12#include "src/__support/macros/config.h"
13#include <stddef.h> // size_t
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18template <size_t Len, size_t Align> struct aligned_storage {
19 struct type {
20 alignas(Align) unsigned char data[Len];
21 };
22};
23
24template <size_t Len, size_t Align>
25using aligned_storage_t = typename aligned_storage<Len, Align>::type;
26
27} // namespace cpp
28} // namespace LIBC_NAMESPACE_DECL
29
30#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALIGNED_STORAGE_H
lib/libcxx/libc/src/__support/CPP/type_traits/always_false.h created+32
...@@ -0,0 +1,32 @@
1//===-- convenient static_assert(false) helper ------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALWAYS_FALSE_H
10#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALWAYS_FALSE_H
11
12#include "src/__support/macros/attributes.h"
13#include "src/__support/macros/config.h"
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18// This is technically not part of the standard but it come often enough that
19// it's convenient to have around.
20//
21// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2593r0.html#valid-workaround
22//
23// This will be fixed in C++23 according to [CWG
24// 2518](https://cplusplus.github.io/CWG/issues/2518.html).
25
26// Usage `static_assert(cpp::always_false<T>, "error message");`
27template <typename...> LIBC_INLINE_VAR constexpr bool always_false = false;
28
29} // namespace cpp
30} // namespace LIBC_NAMESPACE_DECL
31
32#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALWAYS_FALSE_H
lib/libcxx/libc/src/__support/CPP/type_traits/bool_constant.h created+23
...@@ -0,0 +1,23 @@
1//===-- bool_constant type_traits -------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H
10
11#include "src/__support/CPP/type_traits/integral_constant.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// bool_constant
18template <bool V> using bool_constant = cpp::integral_constant<bool, V>;
19
20} // namespace cpp
21} // namespace LIBC_NAMESPACE_DECL
22
23#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H
lib/libcxx/libc/src/__support/CPP/type_traits/conditional.h created+28
...@@ -0,0 +1,28 @@
1//===-- conditional type_traits ---------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H
10
11#include "src/__support/CPP/type_traits/type_identity.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// conditional
18template <bool B, typename T, typename F>
19struct conditional : type_identity<T> {};
20template <typename T, typename F>
21struct conditional<false, T, F> : type_identity<F> {};
22template <bool B, typename T, typename F>
23using conditional_t = typename conditional<B, T, F>::type;
24
25} // namespace cpp
26} // namespace LIBC_NAMESPACE_DECL
27
28#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H
lib/libcxx/libc/src/__support/CPP/type_traits/decay.h created+40
...@@ -0,0 +1,40 @@
1//===-- decay type_traits ---------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_DECAY_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_DECAY_H
10
11#include "src/__support/macros/attributes.h"
12
13#include "src/__support/CPP/type_traits/add_pointer.h"
14#include "src/__support/CPP/type_traits/conditional.h"
15#include "src/__support/CPP/type_traits/is_array.h"
16#include "src/__support/CPP/type_traits/is_function.h"
17#include "src/__support/CPP/type_traits/remove_cv.h"
18#include "src/__support/CPP/type_traits/remove_extent.h"
19#include "src/__support/CPP/type_traits/remove_reference.h"
20#include "src/__support/macros/config.h"
21
22namespace LIBC_NAMESPACE_DECL {
23namespace cpp {
24
25// decay
26template <class T> class decay {
27 using U = cpp::remove_reference_t<T>;
28
29public:
30 using type = conditional_t<
31 cpp::is_array_v<U>, cpp::add_pointer_t<cpp::remove_extent_t<U>>,
32 cpp::conditional_t<cpp::is_function_v<U>, cpp::add_pointer_t<U>,
33 cpp::remove_cv_t<U>>>;
34};
35template <class T> using decay_t = typename decay<T>::type;
36
37} // namespace cpp
38} // namespace LIBC_NAMESPACE_DECL
39
40#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_DECAY_H
lib/libcxx/libc/src/__support/CPP/type_traits/enable_if.h created+26
...@@ -0,0 +1,26 @@
1//===-- enable_if type_traits -----------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H
10
11#include "src/__support/CPP/type_traits/type_identity.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// enable_if
18template <bool B, typename T = void> struct enable_if;
19template <typename T> struct enable_if<true, T> : type_identity<T> {};
20template <bool B, typename T = void>
21using enable_if_t = typename enable_if<B, T>::type;
22
23} // namespace cpp
24} // namespace LIBC_NAMESPACE_DECL
25
26#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H
lib/libcxx/libc/src/__support/CPP/type_traits/false_type.h created+23
...@@ -0,0 +1,23 @@
1//===-- false_type type_traits ----------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// false_type
18using false_type = cpp::bool_constant<false>;
19
20} // namespace cpp
21} // namespace LIBC_NAMESPACE_DECL
22
23#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H
lib/libcxx/libc/src/__support/CPP/type_traits/has_unique_object_representations.h created+30
...@@ -0,0 +1,30 @@
1//===-- has_unique_object_representations type_traits ------------*- C++-*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATIONS_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATIONS_H
10
11#include "src/__support/CPP/type_traits/integral_constant.h"
12#include "src/__support/CPP/type_traits/remove_all_extents.h"
13#include "src/__support/macros/config.h"
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18template <class T>
19struct has_unique_object_representations
20 : public integral_constant<bool, __has_unique_object_representations(
21 remove_all_extents_t<T>)> {};
22
23template <class T>
24LIBC_INLINE_VAR constexpr bool has_unique_object_representations_v =
25 has_unique_object_representations<T>::value;
26
27} // namespace cpp
28} // namespace LIBC_NAMESPACE_DECL
29
30#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATIONS_H
lib/libcxx/libc/src/__support/CPP/type_traits/integral_constant.h created+26
...@@ -0,0 +1,26 @@
1//===-- integral_constant type_traits ---------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H
10
11#include "src/__support/macros/attributes.h" // LIBC_INLINE_VAR
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// integral_constant
18template <typename T, T v> struct integral_constant {
19 using value_type = T;
20 LIBC_INLINE_VAR static constexpr T value = v;
21};
22
23} // namespace cpp
24} // namespace LIBC_NAMESPACE_DECL
25
26#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H
lib/libcxx/libc/src/__support/CPP/type_traits/invoke.h created+67
...@@ -0,0 +1,67 @@
1//===-- invoke type_traits --------------------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_H
10#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_H
11
12#include "src/__support/CPP/type_traits/always_false.h"
13#include "src/__support/CPP/type_traits/decay.h"
14#include "src/__support/CPP/type_traits/enable_if.h"
15#include "src/__support/CPP/type_traits/is_base_of.h"
16#include "src/__support/CPP/type_traits/is_pointer.h"
17#include "src/__support/CPP/type_traits/is_same.h"
18#include "src/__support/CPP/utility/forward.h"
19#include "src/__support/macros/attributes.h" // LIBC_INLINE
20#include "src/__support/macros/config.h"
21
22namespace LIBC_NAMESPACE_DECL {
23namespace cpp {
24
25namespace detail {
26
27// Catch all function and functor types.
28template <class FunctionPtrType> struct invoke_dispatcher {
29 template <class T, class... Args,
30 typename = cpp::enable_if_t<
31 cpp::is_same_v<cpp::decay_t<T>, FunctionPtrType>>>
32 LIBC_INLINE static decltype(auto) call(T &&fun, Args &&...args) {
33 return cpp::forward<T>(fun)(cpp::forward<Args>(args)...);
34 }
35};
36
37// Catch pointer to member function types.
38template <class Class, class FunctionReturnType>
39struct invoke_dispatcher<FunctionReturnType Class::*> {
40 using FunctionPtrType = FunctionReturnType Class::*;
41
42 template <class T, class... Args, class DecayT = cpp::decay_t<T>>
43 LIBC_INLINE static decltype(auto) call(FunctionPtrType fun, T &&t1,
44 Args &&...args) {
45 if constexpr (cpp::is_base_of_v<Class, DecayT>) {
46 // T is a (possibly cv ref) type.
47 return (cpp::forward<T>(t1).*fun)(cpp::forward<Args>(args)...);
48 } else if constexpr (cpp::is_pointer_v<T>) {
49 // T is a pointer type.
50 return (*cpp::forward<T>(t1).*fun)(cpp::forward<Args>(args)...);
51 } else {
52 static_assert(cpp::always_false<T>);
53 }
54 }
55};
56
57} // namespace detail
58template <class Function, class... Args>
59decltype(auto) invoke(Function &&fun, Args &&...args) {
60 return detail::invoke_dispatcher<cpp::decay_t<Function>>::call(
61 cpp::forward<Function>(fun), cpp::forward<Args>(args)...);
62}
63
64} // namespace cpp
65} // namespace LIBC_NAMESPACE_DECL
66
67#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_H
lib/libcxx/libc/src/__support/CPP/type_traits/invoke_result.h created+29
...@@ -0,0 +1,29 @@
1//===-- invoke_result type_traits -------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_RESULT_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_RESULT_H
10
11#include "src/__support/CPP/type_traits/invoke.h"
12#include "src/__support/CPP/type_traits/type_identity.h"
13#include "src/__support/CPP/utility/declval.h"
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19template <class F, class... Args>
20struct invoke_result : cpp::type_identity<decltype(cpp::invoke(
21 cpp::declval<F>(), cpp::declval<Args>()...))> {};
22
23template <class F, class... Args>
24using invoke_result_t = typename invoke_result<F, Args...>::type;
25
26} // namespace cpp
27} // namespace LIBC_NAMESPACE_DECL
28
29#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_RESULT_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_arithmetic.h created+30
...@@ -0,0 +1,30 @@
1//===-- is_arithmetic type_traits -------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/CPP/type_traits/is_floating_point.h"
13#include "src/__support/CPP/type_traits/is_integral.h"
14#include "src/__support/macros/attributes.h"
15#include "src/__support/macros/config.h"
16
17namespace LIBC_NAMESPACE_DECL {
18namespace cpp {
19
20// is_arithmetic
21template <typename T>
22struct is_arithmetic : cpp::bool_constant<(cpp::is_integral_v<T> ||
23 cpp::is_floating_point_v<T>)> {};
24template <typename T>
25LIBC_INLINE_VAR constexpr bool is_arithmetic_v = is_arithmetic<T>::value;
26
27} // namespace cpp
28} // namespace LIBC_NAMESPACE_DECL
29
30#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_array.h created+31
...@@ -0,0 +1,31 @@
1//===-- is_array type_traits ------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H
10
11#include "src/__support/CPP/type_traits/false_type.h"
12#include "src/__support/CPP/type_traits/true_type.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15
16#include <stddef.h> // For size_t
17
18namespace LIBC_NAMESPACE_DECL {
19namespace cpp {
20
21// is_array
22template <class T> struct is_array : false_type {};
23template <class T> struct is_array<T[]> : true_type {};
24template <class T, size_t N> struct is_array<T[N]> : true_type {};
25template <class T>
26LIBC_INLINE_VAR constexpr bool is_array_v = is_array<T>::value;
27
28} // namespace cpp
29} // namespace LIBC_NAMESPACE_DECL
30
31#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_base_of.h created+47
...@@ -0,0 +1,47 @@
1//===-- is_base_of type_traits ----------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H
10
11#include "src/__support/CPP/type_traits/add_rvalue_reference.h"
12#include "src/__support/CPP/type_traits/false_type.h"
13#include "src/__support/CPP/type_traits/is_class.h"
14#include "src/__support/CPP/type_traits/remove_all_extents.h"
15#include "src/__support/CPP/type_traits/true_type.h"
16#include "src/__support/macros/attributes.h"
17#include "src/__support/macros/config.h"
18
19namespace LIBC_NAMESPACE_DECL {
20namespace cpp {
21
22// is_base_of
23namespace detail {
24template <typename B> cpp::true_type __test_ptr_conv(const volatile B *);
25template <typename> cpp::false_type __test_ptr_conv(const volatile void *);
26
27template <typename B, typename D>
28auto is_base_of(int) -> decltype(__test_ptr_conv<B>(static_cast<D *>(nullptr)));
29
30template <typename, typename>
31auto is_base_of(...) -> cpp::true_type; // private or ambiguous base
32
33} // namespace detail
34
35template <typename Base, typename Derived>
36struct is_base_of
37 : cpp::bool_constant<
38 cpp::is_class_v<Base> &&
39 cpp::is_class_v<Derived> &&decltype(detail::is_base_of<Base, Derived>(
40 0))::value> {};
41template <typename Base, typename Derived>
42LIBC_INLINE_VAR constexpr bool is_base_of_v = is_base_of<Base, Derived>::value;
43
44} // namespace cpp
45} // namespace LIBC_NAMESPACE_DECL
46
47#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_class.h created+32
...@@ -0,0 +1,32 @@
1//===-- is_class type_traits ------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/CPP/type_traits/false_type.h"
13#include "src/__support/CPP/type_traits/is_union.h"
14#include "src/__support/macros/attributes.h"
15#include "src/__support/macros/config.h"
16
17namespace LIBC_NAMESPACE_DECL {
18namespace cpp {
19
20// is_class
21namespace detail {
22template <class T> cpp::bool_constant<!cpp::is_union_v<T>> test(int T::*);
23template <class> cpp::false_type test(...);
24} // namespace detail
25template <class T> struct is_class : decltype(detail::test<T>(nullptr)) {};
26template <typename T>
27LIBC_INLINE_VAR constexpr bool is_class_v = is_class<T>::value;
28
29} // namespace cpp
30} // namespace LIBC_NAMESPACE_DECL
31
32#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_complex.h created+53
...@@ -0,0 +1,53 @@
1//===-- is_complex type_traits ----------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H
10
11#include "src/__support/CPP/type_traits/is_same.h"
12#include "src/__support/CPP/type_traits/remove_cv.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15// LIBC_TYPES_HAS_CFLOAT16 && LIBC_TYPES_HAS_CFLOAT128
16#include "src/__support/macros/properties/complex_types.h"
17
18namespace LIBC_NAMESPACE_DECL {
19namespace cpp {
20
21// is_complex
22template <typename T> struct is_complex {
23private:
24 template <typename Head, typename... Args>
25 LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() {
26 return (... || is_same_v<remove_cv_t<Head>, Args>);
27 }
28
29public:
30 LIBC_INLINE_VAR static constexpr bool value =
31 __is_unqualified_any_of<T, _Complex float, _Complex double,
32 _Complex long double
33#ifdef LIBC_TYPES_HAS_CFLOAT16
34 ,
35 cfloat16
36#endif
37#ifdef LIBC_TYPES_HAS_CFLOAT128
38 ,
39 cfloat128
40#endif
41 >();
42};
43template <typename T>
44LIBC_INLINE_VAR constexpr bool is_complex_v = is_complex<T>::value;
45template <typename T1, typename T2>
46LIBC_INLINE_VAR constexpr bool is_complex_type_same() {
47 return is_same_v<remove_cv_t<T1>, T2>;
48}
49
50} // namespace cpp
51} // namespace LIBC_NAMESPACE_DECL
52
53#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_const.h created+28
...@@ -0,0 +1,28 @@
1//===-- is_const type_traits ------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H
10
11#include "src/__support/CPP/type_traits/false_type.h"
12#include "src/__support/CPP/type_traits/true_type.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19// is_const
20template <class T> struct is_const : cpp::false_type {};
21template <class T> struct is_const<const T> : cpp::true_type {};
22template <class T>
23LIBC_INLINE_VAR constexpr bool is_const_v = is_const<T>::value;
24
25} // namespace cpp
26} // namespace LIBC_NAMESPACE_DECL
27
28#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_constant_evaluated.h created+24
...@@ -0,0 +1,24 @@
1//===-- is_constant_evaluated type_traits -----------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTANT_EVALUATED_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTANT_EVALUATED_H
10
11#include "src/__support/macros/attributes.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17LIBC_INLINE constexpr bool is_constant_evaluated() {
18 return __builtin_is_constant_evaluated();
19}
20
21} // namespace cpp
22} // namespace LIBC_NAMESPACE_DECL
23
24#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTANT_EVALUATED_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_convertible.h created+48
...@@ -0,0 +1,48 @@
1//===-- is_convertible type_traits ------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H
10
11#include "src/__support/CPP/type_traits/is_void.h"
12#include "src/__support/CPP/utility/declval.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19// is_convertible
20namespace detail {
21template <class T>
22auto test_returnable(int)
23 -> decltype(void(static_cast<T (*)()>(nullptr)), cpp::true_type{});
24template <class> auto test_returnable(...) -> cpp::false_type;
25
26template <class From, class To>
27auto test_implicitly_convertible(int)
28 -> decltype(void(cpp::declval<void (&)(To)>()(cpp::declval<From>())),
29 cpp::true_type{});
30template <class, class>
31auto test_implicitly_convertible(...) -> cpp::false_type;
32} // namespace detail
33
34template <class From, class To>
35struct is_convertible
36 : cpp::bool_constant<
37 (decltype(detail::test_returnable<To>(0))::value &&
38 decltype(detail::test_implicitly_convertible<From, To>(0))::value) ||
39 (cpp::is_void_v<From> && cpp::is_void_v<To>)> {};
40
41template <class From, class To>
42LIBC_INLINE_VAR constexpr bool is_convertible_v =
43 is_convertible<From, To>::value;
44
45} // namespace cpp
46} // namespace LIBC_NAMESPACE_DECL
47
48#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_copy_assignable.h created+32
...@@ -0,0 +1,32 @@
1//===-- is_copy_assignable type_traits --------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_ASSIGNABLE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_ASSIGNABLE_H
10
11#include "src/__support/CPP/type_traits/add_lvalue_reference.h"
12#include "src/__support/CPP/type_traits/integral_constant.h"
13#include "src/__support/macros/config.h"
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18// is copy assignable
19template <class T>
20struct is_copy_assignable
21 : public integral_constant<
22 bool, __is_assignable(cpp::add_lvalue_reference_t<T>,
23 cpp::add_lvalue_reference_t<const T>)> {};
24
25template <class T>
26LIBC_INLINE_VAR constexpr bool is_copy_assignable_v =
27 is_copy_assignable<T>::value;
28
29} // namespace cpp
30} // namespace LIBC_NAMESPACE_DECL
31
32#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_ASSIGNABLE_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_copy_constructible.h created+31
...@@ -0,0 +1,31 @@
1//===-- is_copy_constructible type_traits -----------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H
10
11#include "src/__support/CPP/type_traits/add_lvalue_reference.h"
12#include "src/__support/CPP/type_traits/integral_constant.h"
13#include "src/__support/macros/config.h"
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18// is copy constructible
19template <class T>
20struct is_copy_constructible
21 : public integral_constant<
22 bool, __is_constructible(T, cpp::add_lvalue_reference_t<const T>)> {};
23
24template <class T>
25LIBC_INLINE_VAR constexpr bool is_copy_constructible_v =
26 is_copy_constructible<T>::value;
27
28} // namespace cpp
29} // namespace LIBC_NAMESPACE_DECL
30
31#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_destructible.h created+68
...@@ -0,0 +1,68 @@
1//===-- is_destructible type_traits -----------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_DESTRUCTIBLE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_DESTRUCTIBLE_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/CPP/type_traits/false_type.h"
13#include "src/__support/CPP/type_traits/is_function.h"
14#include "src/__support/CPP/type_traits/is_reference.h"
15#include "src/__support/CPP/type_traits/remove_all_extents.h"
16#include "src/__support/CPP/type_traits/true_type.h"
17#include "src/__support/CPP/type_traits/type_identity.h"
18#include "src/__support/macros/attributes.h"
19#include "src/__support/macros/config.h"
20
21namespace LIBC_NAMESPACE_DECL {
22namespace cpp {
23
24// is_destructible
25#if __has_builtin(__is_destructible)
26template <typename T>
27struct is_destructible : bool_constant<__is_destructible(T)> {};
28#else
29// if it's a reference, return true
30// if it's a function, return false
31// if it's void, return false
32// if it's an array of unknown bound, return false
33// Otherwise, return "declval<T&>().~T()" is well-formed
34// where T is remove_all_extents<T>::type
35template <typename> struct __is_destructible_apply : cpp::type_identity<int> {};
36template <typename T> struct __is_destructor_wellformed {
37 template <typename T1>
38 static cpp::true_type __test(
39 typename __is_destructible_apply<decltype(declval<T1 &>().~T1())>::type);
40 template <typename T1> static cpp::false_type __test(...);
41 static const bool value = decltype(__test<T>(12))::value;
42};
43template <typename T, bool> struct __destructible_imp;
44template <typename T>
45struct __destructible_imp<T, false>
46 : public bool_constant<
47 __is_destructor_wellformed<cpp::remove_all_extents_t<T>>::value> {};
48template <typename T>
49struct __destructible_imp<T, true> : public cpp::true_type {};
50template <typename T, bool> struct __destructible_false;
51template <typename T>
52struct __destructible_false<T, false>
53 : public __destructible_imp<T, is_reference<T>::value> {};
54template <typename T>
55struct __destructible_false<T, true> : public cpp::false_type {};
56template <typename T>
57struct is_destructible : public __destructible_false<T, is_function<T>::value> {
58};
59template <typename T> struct is_destructible<T[]> : public false_type {};
60template <> struct is_destructible<void> : public false_type {};
61#endif
62template <class T>
63LIBC_INLINE_VAR constexpr bool is_destructible_v = is_destructible<T>::value;
64
65} // namespace cpp
66} // namespace LIBC_NAMESPACE_DECL
67
68#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_DESTRUCTIBLE_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_enum.h created+26
...@@ -0,0 +1,26 @@
1//===-- is_enum type_traits -------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/macros/attributes.h"
13#include "src/__support/macros/config.h"
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18// is_enum
19template <typename T> struct is_enum : bool_constant<__is_enum(T)> {};
20template <typename T>
21LIBC_INLINE_VAR constexpr bool is_enum_v = is_enum<T>::value;
22
23} // namespace cpp
24} // namespace LIBC_NAMESPACE_DECL
25
26#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_fixed_point.h created+49
...@@ -0,0 +1,49 @@
1//===-- is_fixed_point type_traits ------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FIXED_POINT_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FIXED_POINT_H
10
11#include "src/__support/CPP/type_traits/is_same.h"
12#include "src/__support/CPP/type_traits/remove_cv.h"
13#include "src/__support/macros/attributes.h"
14
15#include "include/llvm-libc-macros/stdfix-macros.h"
16#include "src/__support/macros/config.h"
17
18namespace LIBC_NAMESPACE_DECL {
19namespace cpp {
20
21// is_fixed_point
22#ifdef LIBC_COMPILER_HAS_FIXED_POINT
23template <typename T> struct is_fixed_point {
24private:
25 template <typename Head, typename... Args>
26 LIBC_INLINE static constexpr bool __is_unqualified_any_of() {
27 return (... || is_same_v<remove_cv_t<Head>, Args>);
28 }
29
30public:
31 LIBC_INLINE_VAR static constexpr bool value = __is_unqualified_any_of<
32 T, short fract, fract, long fract, unsigned short fract, unsigned fract,
33 unsigned long fract, short accum, accum, long accum, unsigned short accum,
34 unsigned accum, unsigned long accum, short sat fract, sat fract,
35 long sat fract, unsigned short sat fract, unsigned sat fract,
36 unsigned long sat fract, short sat accum, sat accum, long sat accum,
37 unsigned short sat accum, unsigned sat accum, unsigned long sat accum>();
38};
39#else
40template <typename T> struct is_fixed_point : false_type {};
41#endif // LIBC_COMPILER_HAS_FIXED_POINT
42
43template <typename T>
44LIBC_INLINE_VAR constexpr bool is_fixed_point_v = is_fixed_point<T>::value;
45
46} // namespace cpp
47} // namespace LIBC_NAMESPACE_DECL
48
49#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FIXED_POINT_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_floating_point.h created+48
...@@ -0,0 +1,48 @@
1//===-- is_floating_point type_traits ---------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H
10
11#include "src/__support/CPP/type_traits/is_same.h"
12#include "src/__support/CPP/type_traits/remove_cv.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_FLOAT128
16
17namespace LIBC_NAMESPACE_DECL {
18namespace cpp {
19
20// is_floating_point
21template <typename T> struct is_floating_point {
22private:
23 template <typename Head, typename... Args>
24 LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() {
25 return (... || is_same_v<remove_cv_t<Head>, Args>);
26 }
27
28public:
29 LIBC_INLINE_VAR static constexpr bool value =
30 __is_unqualified_any_of<T, float, double, long double
31#ifdef LIBC_TYPES_HAS_FLOAT16
32 ,
33 float16
34#endif
35#ifdef LIBC_TYPES_HAS_FLOAT128
36 ,
37 float128
38#endif
39 >();
40};
41template <typename T>
42LIBC_INLINE_VAR constexpr bool is_floating_point_v =
43 is_floating_point<T>::value;
44
45} // namespace cpp
46} // namespace LIBC_NAMESPACE_DECL
47
48#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_function.h created+35
...@@ -0,0 +1,35 @@
1//===-- is_function type_traits ---------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/CPP/type_traits/is_const.h"
13#include "src/__support/CPP/type_traits/is_reference.h"
14#include "src/__support/macros/attributes.h"
15#include "src/__support/macros/config.h"
16
17namespace LIBC_NAMESPACE_DECL {
18namespace cpp {
19
20// is_function
21#if __has_builtin(__is_function)
22template <typename T>
23struct is_function : integral_constant<bool, __is_function(T)> {};
24#else
25template <typename T>
26struct is_function
27 : public bool_constant<!(is_reference_v<T> || is_const_v<const T>)> {};
28#endif
29template <class T>
30LIBC_INLINE_VAR constexpr bool is_function_v = is_function<T>::value;
31
32} // namespace cpp
33} // namespace LIBC_NAMESPACE_DECL
34
35#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_integral.h created+43
...@@ -0,0 +1,43 @@
1//===-- is_integral type_traits ---------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H
10
11#include "src/__support/CPP/type_traits/is_same.h"
12#include "src/__support/CPP/type_traits/remove_cv.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
16
17namespace LIBC_NAMESPACE_DECL {
18namespace cpp {
19
20// is_integral
21template <typename T> struct is_integral {
22private:
23 template <typename Head, typename... Args>
24 LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() {
25 return (... || is_same_v<remove_cv_t<Head>, Args>);
26 }
27
28public:
29 LIBC_INLINE_VAR static constexpr bool value = __is_unqualified_any_of<
30 T,
31#ifdef LIBC_TYPES_HAS_INT128
32 __int128_t, __uint128_t,
33#endif
34 char, signed char, unsigned char, short, unsigned short, int,
35 unsigned int, long, unsigned long, long long, unsigned long long, bool>();
36};
37template <typename T>
38LIBC_INLINE_VAR constexpr bool is_integral_v = is_integral<T>::value;
39
40} // namespace cpp
41} // namespace LIBC_NAMESPACE_DECL
42
43#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_lvalue_reference.h created+35
...@@ -0,0 +1,35 @@
1//===-- is_lvalue_reference type_traits -------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/CPP/type_traits/false_type.h"
13#include "src/__support/CPP/type_traits/true_type.h"
14#include "src/__support/macros/attributes.h"
15#include "src/__support/macros/config.h"
16
17namespace LIBC_NAMESPACE_DECL {
18namespace cpp {
19
20// is_lvalue_reference
21#if __has_builtin(__is_lvalue_reference)
22template <typename T>
23struct is_lvalue_reference : bool_constant<__is_lvalue_reference(T)> {};
24#else
25template <typename T> struct is_lvalue_reference : public false_type {};
26template <typename T> struct is_lvalue_reference<T &> : public true_type {};
27#endif
28template <class T>
29LIBC_INLINE_VAR constexpr bool is_lvalue_reference_v =
30 is_lvalue_reference<T>::value;
31
32} // namespace cpp
33} // namespace LIBC_NAMESPACE_DECL
34
35#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_member_pointer.h created+33
...@@ -0,0 +1,33 @@
1//===-- is_member_pointer type_traits ---------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MEMBER_POINTER_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MEMBER_POINTER_H
10
11#include "src/__support/CPP/type_traits/false_type.h"
12#include "src/__support/CPP/type_traits/remove_cv.h"
13#include "src/__support/CPP/type_traits/true_type.h"
14#include "src/__support/macros/attributes.h"
15#include "src/__support/macros/config.h"
16
17namespace LIBC_NAMESPACE_DECL {
18namespace cpp {
19
20// is_member_pointer
21template <class T> struct is_member_pointer_helper : cpp::false_type {};
22template <class T, class U>
23struct is_member_pointer_helper<T U::*> : cpp::true_type {};
24template <class T>
25struct is_member_pointer : is_member_pointer_helper<cpp::remove_cv_t<T>> {};
26template <class T>
27LIBC_INLINE_VAR constexpr bool is_member_pointer_v =
28 is_member_pointer<T>::value;
29
30} // namespace cpp
31} // namespace LIBC_NAMESPACE_DECL
32
33#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MEMBER_POINTER_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_move_assignable.h created+33
...@@ -0,0 +1,33 @@
1//===-- is_move_assignable type_traits --------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H
10
11#include "src/__support/CPP/type_traits/add_lvalue_reference.h"
12#include "src/__support/CPP/type_traits/add_rvalue_reference.h"
13#include "src/__support/CPP/type_traits/integral_constant.h"
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19// is move assignable
20template <class T>
21struct is_move_assignable
22 : public integral_constant<bool, __is_assignable(
23 cpp::add_lvalue_reference_t<T>,
24 cpp::add_rvalue_reference_t<T>)> {};
25
26template <class T>
27LIBC_INLINE_VAR constexpr bool is_move_assignable_v =
28 is_move_assignable<T>::value;
29
30} // namespace cpp
31} // namespace LIBC_NAMESPACE_DECL
32
33#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_move_constructible.h created+31
...@@ -0,0 +1,31 @@
1//===-- is_move_constructible type_traits ------------------------*- C++-*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H
10
11#include "src/__support/CPP/type_traits/add_rvalue_reference.h"
12#include "src/__support/CPP/type_traits/integral_constant.h"
13#include "src/__support/macros/config.h"
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18// is move constructible
19template <class T>
20struct is_move_constructible
21 : public integral_constant<bool, __is_constructible(
22 T, cpp::add_rvalue_reference_t<T>)> {};
23
24template <class T>
25LIBC_INLINE_VAR constexpr bool is_move_constructible_v =
26 is_move_constructible<T>::value;
27
28} // namespace cpp
29} // namespace LIBC_NAMESPACE_DECL
30
31#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_null_pointer.h created+29
...@@ -0,0 +1,29 @@
1//===-- is_null_pointer type_traits -----------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H
10
11#include "src/__support/CPP/type_traits/is_same.h"
12#include "src/__support/CPP/type_traits/remove_cv.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19// is_null_pointer
20using nullptr_t = decltype(nullptr);
21template <class T>
22struct is_null_pointer : cpp::is_same<cpp::nullptr_t, cpp::remove_cv_t<T>> {};
23template <class T>
24LIBC_INLINE_VAR constexpr bool is_null_pointer_v = is_null_pointer<T>::value;
25
26} // namespace cpp
27} // namespace LIBC_NAMESPACE_DECL
28
29#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_object.h created+33
...@@ -0,0 +1,33 @@
1//===-- is_object type_traits -----------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_OBJECT_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_OBJECT_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/CPP/type_traits/is_array.h"
13#include "src/__support/CPP/type_traits/is_class.h"
14#include "src/__support/CPP/type_traits/is_scalar.h"
15#include "src/__support/CPP/type_traits/is_union.h"
16#include "src/__support/macros/attributes.h"
17#include "src/__support/macros/config.h"
18
19namespace LIBC_NAMESPACE_DECL {
20namespace cpp {
21
22// is_object
23template <class T>
24struct is_object
25 : cpp::bool_constant<cpp::is_scalar_v<T> || cpp::is_array_v<T> ||
26 cpp::is_union_v<T> || cpp::is_class_v<T>> {};
27template <class T>
28LIBC_INLINE_VAR constexpr bool is_object_v = is_object<T>::value;
29
30} // namespace cpp
31} // namespace LIBC_NAMESPACE_DECL
32
33#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_OBJECT_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_pointer.h created+31
...@@ -0,0 +1,31 @@
1//===-- is_pointer type_traits ----------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H
10
11#include "src/__support/CPP/type_traits/false_type.h"
12#include "src/__support/CPP/type_traits/true_type.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19// is_pointer
20template <typename T> struct is_pointer : cpp::false_type {};
21template <typename T> struct is_pointer<T *> : cpp::true_type {};
22template <typename T> struct is_pointer<T *const> : cpp::true_type {};
23template <typename T> struct is_pointer<T *volatile> : cpp::true_type {};
24template <typename T> struct is_pointer<T *const volatile> : cpp::true_type {};
25template <typename T>
26LIBC_INLINE_VAR constexpr bool is_pointer_v = is_pointer<T>::value;
27
28} // namespace cpp
29} // namespace LIBC_NAMESPACE_DECL
30
31#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_reference.h created+34
...@@ -0,0 +1,34 @@
1//===-- is_reference type_traits --------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/CPP/type_traits/false_type.h"
13#include "src/__support/CPP/type_traits/true_type.h"
14#include "src/__support/macros/attributes.h"
15#include "src/__support/macros/config.h"
16
17namespace LIBC_NAMESPACE_DECL {
18namespace cpp {
19
20// is_reference
21#if __has_builtin(__is_reference)
22template <typename T> struct is_reference : bool_constant<__is_reference(T)> {};
23#else
24template <typename T> struct is_reference : public false_type {};
25template <typename T> struct is_reference<T &> : public true_type {};
26template <typename T> struct is_reference<T &&> : public true_type {};
27#endif
28template <class T>
29LIBC_INLINE_VAR constexpr bool is_reference_v = is_reference<T>::value;
30
31} // namespace cpp
32} // namespace LIBC_NAMESPACE_DECL
33
34#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_rvalue_reference.h created+35
...@@ -0,0 +1,35 @@
1//===-- is_rvalue_reference type_traits -------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/CPP/type_traits/false_type.h"
13#include "src/__support/CPP/type_traits/true_type.h"
14#include "src/__support/macros/attributes.h"
15#include "src/__support/macros/config.h"
16
17namespace LIBC_NAMESPACE_DECL {
18namespace cpp {
19
20// is_rvalue_reference
21#if __has_builtin(__is_rvalue_reference)
22template <typename T>
23struct is_rvalue_reference : bool_constant<__is_rvalue_reference(T)> {};
24#else
25template <typename T> struct is_rvalue_reference : public false_type {};
26template <typename T> struct is_rvalue_reference<T &&> : public true_type {};
27#endif
28template <class T>
29LIBC_INLINE_VAR constexpr bool is_rvalue_reference_v =
30 is_rvalue_reference<T>::value;
31
32} // namespace cpp
33} // namespace LIBC_NAMESPACE_DECL
34
35#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_same.h created+28
...@@ -0,0 +1,28 @@
1//===-- is_same type_traits -------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H
10
11#include "src/__support/CPP/type_traits/false_type.h"
12#include "src/__support/CPP/type_traits/true_type.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19// is_same
20template <typename T, typename U> struct is_same : cpp::false_type {};
21template <typename T> struct is_same<T, T> : cpp::true_type {};
22template <typename T, typename U>
23LIBC_INLINE_VAR constexpr bool is_same_v = is_same<T, U>::value;
24
25} // namespace cpp
26} // namespace LIBC_NAMESPACE_DECL
27
28#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_scalar.h created+35
...@@ -0,0 +1,35 @@
1//===-- is_scalar type_traits -----------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SCALAR_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SCALAR_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/CPP/type_traits/is_arithmetic.h"
13#include "src/__support/CPP/type_traits/is_enum.h"
14#include "src/__support/CPP/type_traits/is_member_pointer.h"
15#include "src/__support/CPP/type_traits/is_null_pointer.h"
16#include "src/__support/CPP/type_traits/is_pointer.h"
17#include "src/__support/macros/attributes.h"
18#include "src/__support/macros/config.h"
19
20namespace LIBC_NAMESPACE_DECL {
21namespace cpp {
22
23// is_scalar
24template <class T>
25struct is_scalar
26 : cpp::bool_constant<cpp::is_arithmetic_v<T> || cpp::is_enum_v<T> ||
27 cpp::is_pointer_v<T> || cpp::is_member_pointer_v<T> ||
28 cpp::is_null_pointer_v<T>> {};
29template <class T>
30LIBC_INLINE_VAR constexpr bool is_scalar_v = is_scalar<T>::value;
31
32} // namespace cpp
33} // namespace LIBC_NAMESPACE_DECL
34
35#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SCALAR_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_signed.h created+31
...@@ -0,0 +1,31 @@
1//===-- is_signed type_traits -----------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/CPP/type_traits/is_arithmetic.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19// is_signed
20template <typename T>
21struct is_signed : bool_constant<(is_arithmetic_v<T> && (T(-1) < T(0)))> {
22 LIBC_INLINE constexpr operator bool() const { return is_signed::value; }
23 LIBC_INLINE constexpr bool operator()() const { return is_signed::value; }
24};
25template <typename T>
26LIBC_INLINE_VAR constexpr bool is_signed_v = is_signed<T>::value;
27
28} // namespace cpp
29} // namespace LIBC_NAMESPACE_DECL
30
31#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_trivially_constructible.h created+25
...@@ -0,0 +1,25 @@
1//===-- is_trivially_constructible type_traits ------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
10
11#include "src/__support/CPP/type_traits/integral_constant.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// is_trivially_constructible
18template <class T, class... Args>
19struct is_trivially_constructible
20 : integral_constant<bool, __is_trivially_constructible(T, Args...)> {};
21
22} // namespace cpp
23} // namespace LIBC_NAMESPACE_DECL
24
25#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_trivially_copyable.h created+29
...@@ -0,0 +1,29 @@
1//===-- is_trivially_copyable type_traits -----------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H
10
11#include "src/__support/CPP/type_traits/integral_constant.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// is_trivially_copyable
18template <class T>
19struct is_trivially_copyable
20 : public integral_constant<bool, __is_trivially_copyable(T)> {};
21
22template <class T>
23LIBC_INLINE_VAR constexpr bool is_trivially_copyable_v =
24 is_trivially_copyable<T>::value;
25
26} // namespace cpp
27} // namespace LIBC_NAMESPACE_DECL
28
29#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_trivially_destructible.h created+37
...@@ -0,0 +1,37 @@
1//===-- is_trivially_destructible type_traits -------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/CPP/type_traits/is_destructible.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19// is_trivially_destructible
20#if __has_builtin(__is_trivially_destructible)
21template <typename T>
22struct is_trivially_destructible
23 : public bool_constant<__is_trivially_destructible(T)> {};
24#else
25template <typename T>
26struct is_trivially_destructible
27 : public bool_constant<cpp::is_destructible_v<T> &&__has_trivial_destructor(
28 T)> {};
29#endif // __has_builtin(__is_trivially_destructible)
30template <typename T>
31LIBC_INLINE_VAR constexpr bool is_trivially_destructible_v =
32 is_trivially_destructible<T>::value;
33
34} // namespace cpp
35} // namespace LIBC_NAMESPACE_DECL
36
37#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_union.h created+26
...@@ -0,0 +1,26 @@
1//===-- is_union type_traits ------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/macros/attributes.h"
13#include "src/__support/macros/config.h"
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18// is_union
19template <class T> struct is_union : bool_constant<__is_union(T)> {};
20template <typename T>
21LIBC_INLINE_VAR constexpr bool is_union_v = is_union<T>::value;
22
23} // namespace cpp
24} // namespace LIBC_NAMESPACE_DECL
25
26#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_unsigned.h created+31
...@@ -0,0 +1,31 @@
1//===-- is_unsigned type_traits ---------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNSIGNED_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNSIGNED_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/CPP/type_traits/is_arithmetic.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19// is_unsigned
20template <typename T>
21struct is_unsigned : bool_constant<(is_arithmetic_v<T> && (T(-1) > T(0)))> {
22 LIBC_INLINE constexpr operator bool() const { return is_unsigned::value; }
23 LIBC_INLINE constexpr bool operator()() const { return is_unsigned::value; }
24};
25template <typename T>
26LIBC_INLINE_VAR constexpr bool is_unsigned_v = is_unsigned<T>::value;
27
28} // namespace cpp
29} // namespace LIBC_NAMESPACE_DECL
30
31#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNSIGNED_H
lib/libcxx/libc/src/__support/CPP/type_traits/is_void.h created+27
...@@ -0,0 +1,27 @@
1//===-- is_void type_traits -------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H
10
11#include "src/__support/CPP/type_traits/is_same.h"
12#include "src/__support/CPP/type_traits/remove_cv.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19// is_void
20template <typename T> struct is_void : is_same<void, remove_cv_t<T>> {};
21template <typename T>
22LIBC_INLINE_VAR constexpr bool is_void_v = is_void<T>::value;
23
24} // namespace cpp
25} // namespace LIBC_NAMESPACE_DECL
26
27#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H
lib/libcxx/libc/src/__support/CPP/type_traits/make_signed.h created+41
...@@ -0,0 +1,41 @@
1//===-- make_signed type_traits ---------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H
10
11#include "src/__support/CPP/type_traits/type_identity.h"
12#include "src/__support/macros/config.h"
13#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18// make_signed
19template <typename T> struct make_signed;
20template <> struct make_signed<char> : type_identity<char> {};
21template <> struct make_signed<signed char> : type_identity<char> {};
22template <> struct make_signed<short> : type_identity<short> {};
23template <> struct make_signed<int> : type_identity<int> {};
24template <> struct make_signed<long> : type_identity<long> {};
25template <> struct make_signed<long long> : type_identity<long long> {};
26template <> struct make_signed<unsigned char> : type_identity<char> {};
27template <> struct make_signed<unsigned short> : type_identity<short> {};
28template <> struct make_signed<unsigned int> : type_identity<int> {};
29template <> struct make_signed<unsigned long> : type_identity<long> {};
30template <>
31struct make_signed<unsigned long long> : type_identity<long long> {};
32#ifdef LIBC_TYPES_HAS_INT128
33template <> struct make_signed<__int128_t> : type_identity<__int128_t> {};
34template <> struct make_signed<__uint128_t> : type_identity<__int128_t> {};
35#endif
36template <typename T> using make_signed_t = typename make_signed<T>::type;
37
38} // namespace cpp
39} // namespace LIBC_NAMESPACE_DECL
40
41#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H
lib/libcxx/libc/src/__support/CPP/type_traits/make_unsigned.h created+46
...@@ -0,0 +1,46 @@
1//===-- make_unsigned type_traits -------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_UNSIGNED_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_UNSIGNED_H
10
11#include "src/__support/CPP/type_traits/type_identity.h"
12#include "src/__support/macros/config.h"
13#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18// make_unsigned
19
20template <typename T> struct make_unsigned;
21template <> struct make_unsigned<char> : type_identity<unsigned char> {};
22template <> struct make_unsigned<signed char> : type_identity<unsigned char> {};
23template <> struct make_unsigned<short> : type_identity<unsigned short> {};
24template <> struct make_unsigned<int> : type_identity<unsigned int> {};
25template <> struct make_unsigned<long> : type_identity<unsigned long> {};
26template <>
27struct make_unsigned<long long> : type_identity<unsigned long long> {};
28template <>
29struct make_unsigned<unsigned char> : type_identity<unsigned char> {};
30template <>
31struct make_unsigned<unsigned short> : type_identity<unsigned short> {};
32template <> struct make_unsigned<unsigned int> : type_identity<unsigned int> {};
33template <>
34struct make_unsigned<unsigned long> : type_identity<unsigned long> {};
35template <>
36struct make_unsigned<unsigned long long> : type_identity<unsigned long long> {};
37#ifdef LIBC_TYPES_HAS_INT128
38template <> struct make_unsigned<__int128_t> : type_identity<__uint128_t> {};
39template <> struct make_unsigned<__uint128_t> : type_identity<__uint128_t> {};
40#endif
41template <typename T> using make_unsigned_t = typename make_unsigned<T>::type;
42
43} // namespace cpp
44} // namespace LIBC_NAMESPACE_DECL
45
46#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_UNSIGNED_H
lib/libcxx/libc/src/__support/CPP/type_traits/remove_all_extents.h created+41
...@@ -0,0 +1,41 @@
1//===-- remove_all_extents type_traits --------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
10
11#include "src/__support/CPP/type_traits/type_identity.h"
12#include "src/__support/macros/config.h"
13
14#include <stddef.h> // size_t
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19// remove_all_extents
20#if __has_builtin(__remove_all_extents)
21template <typename T> using remove_all_extents_t = __remove_all_extents(T);
22template <typename T>
23struct remove_all_extents : cpp::type_identity<remove_all_extents_t<T>> {};
24#else
25template <typename T> struct remove_all_extents {
26 using type = T;
27};
28template <typename T> struct remove_all_extents<T[]> {
29 using type = typename remove_all_extents<T>::type;
30};
31template <typename T, size_t _Np> struct remove_all_extents<T[_Np]> {
32 using type = typename remove_all_extents<T>::type;
33};
34template <typename T>
35using remove_all_extents_t = typename remove_all_extents<T>::type;
36#endif
37
38} // namespace cpp
39} // namespace LIBC_NAMESPACE_DECL
40
41#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
lib/libcxx/libc/src/__support/CPP/type_traits/remove_cv.h created+28
...@@ -0,0 +1,28 @@
1//===-- remove_cv type_traits -----------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H
10
11#include "src/__support/CPP/type_traits/type_identity.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// remove_cv
18template <class T> struct remove_cv : cpp::type_identity<T> {};
19template <class T> struct remove_cv<const T> : cpp::type_identity<T> {};
20template <class T> struct remove_cv<volatile T> : cpp::type_identity<T> {};
21template <class T>
22struct remove_cv<const volatile T> : cpp::type_identity<T> {};
23template <class T> using remove_cv_t = typename remove_cv<T>::type;
24
25} // namespace cpp
26} // namespace LIBC_NAMESPACE_DECL
27
28#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H
lib/libcxx/libc/src/__support/CPP/type_traits/remove_cvref.h created+27
...@@ -0,0 +1,27 @@
1//===-- remove_cvref type_traits --------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H
10
11#include "src/__support/CPP/type_traits/remove_cv.h"
12#include "src/__support/CPP/type_traits/remove_reference.h"
13#include "src/__support/macros/config.h"
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18// remove_cvref
19template <typename T> struct remove_cvref {
20 using type = remove_cv_t<remove_reference_t<T>>;
21};
22template <typename T> using remove_cvref_t = typename remove_cvref<T>::type;
23
24} // namespace cpp
25} // namespace LIBC_NAMESPACE_DECL
26
27#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H
lib/libcxx/libc/src/__support/CPP/type_traits/remove_extent.h created+28
...@@ -0,0 +1,28 @@
1//===-- remove_extent type_traits -------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H
10
11#include "src/__support/CPP/type_traits/type_identity.h"
12#include "src/__support/macros/config.h"
13#include "stddef.h" // size_t
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18// remove_extent
19template <class T> struct remove_extent : cpp::type_identity<T> {};
20template <class T> struct remove_extent<T[]> : cpp::type_identity<T> {};
21template <class T, size_t N>
22struct remove_extent<T[N]> : cpp::type_identity<T> {};
23template <class T> using remove_extent_t = typename remove_extent<T>::type;
24
25} // namespace cpp
26} // namespace LIBC_NAMESPACE_DECL
27
28#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H
lib/libcxx/libc/src/__support/CPP/type_traits/remove_reference.h created+27
...@@ -0,0 +1,27 @@
1//===-- remove_reference type_traits ----------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H
10
11#include "src/__support/CPP/type_traits/type_identity.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// remove_reference
18template <class T> struct remove_reference : cpp::type_identity<T> {};
19template <class T> struct remove_reference<T &> : cpp::type_identity<T> {};
20template <class T> struct remove_reference<T &&> : cpp::type_identity<T> {};
21template <class T>
22using remove_reference_t = typename remove_reference<T>::type;
23
24} // namespace cpp
25} // namespace LIBC_NAMESPACE_DECL
26
27#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H
lib/libcxx/libc/src/__support/CPP/type_traits/true_type.h created+23
...@@ -0,0 +1,23 @@
1//===-- true_type type_traits -----------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H
10
11#include "src/__support/CPP/type_traits/bool_constant.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// true_type
18using true_type = cpp::bool_constant<true>;
19
20} // namespace cpp
21} // namespace LIBC_NAMESPACE_DECL
22
23#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H
lib/libcxx/libc/src/__support/CPP/type_traits/type_identity.h created+24
...@@ -0,0 +1,24 @@
1//===-- type_identity type_traits -------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H
10
11#include "src/__support/macros/config.h"
12
13namespace LIBC_NAMESPACE_DECL {
14namespace cpp {
15
16// type_identity
17template <typename T> struct type_identity {
18 using type = T;
19};
20
21} // namespace cpp
22} // namespace LIBC_NAMESPACE_DECL
23
24#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H
lib/libcxx/libc/src/__support/CPP/type_traits/void_t.h created+29
...@@ -0,0 +1,29 @@
1//===-- void_t type_traits --------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_VOID_T_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_VOID_T_H
10
11#include "src/__support/CPP/type_traits/type_identity.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// void_t
18
19namespace detail {
20template <typename... Ts> struct make_void : cpp::type_identity<void> {};
21} // namespace detail
22
23template <typename... Ts>
24using void_t = typename detail::make_void<Ts...>::type;
25
26} // namespace cpp
27} // namespace LIBC_NAMESPACE_DECL
28
29#endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_VOID_T_H
lib/libcxx/libc/src/__support/CPP/utility.h created+18
...@@ -0,0 +1,18 @@
1//===-- Analogous to <utility> ----------------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_H
10#define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_H
11
12#include "src/__support/CPP/utility/declval.h"
13#include "src/__support/CPP/utility/forward.h"
14#include "src/__support/CPP/utility/in_place.h"
15#include "src/__support/CPP/utility/integer_sequence.h"
16#include "src/__support/CPP/utility/move.h"
17
18#endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_H
lib/libcxx/libc/src/__support/CPP/utility/declval.h created+27
...@@ -0,0 +1,27 @@
1//===-- declval utility -----------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_DECLVAL_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_DECLVAL_H
10
11#include "src/__support/CPP/type_traits/add_rvalue_reference.h"
12#include "src/__support/CPP/type_traits/always_false.h"
13#include "src/__support/macros/config.h"
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18// declval
19template <typename T> cpp::add_rvalue_reference_t<T> declval() {
20 static_assert(cpp::always_false<T>,
21 "declval not allowed in an evaluated context");
22}
23
24} // namespace cpp
25} // namespace LIBC_NAMESPACE_DECL
26
27#endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_DECLVAL_H
lib/libcxx/libc/src/__support/CPP/utility/forward.h created+35
...@@ -0,0 +1,35 @@
1//===-- forward utility -----------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_FORWARD_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_FORWARD_H
10
11#include "src/__support/CPP/type_traits/is_lvalue_reference.h"
12#include "src/__support/CPP/type_traits/remove_reference.h"
13#include "src/__support/macros/attributes.h"
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19// forward
20template <typename T>
21LIBC_INLINE constexpr T &&forward(remove_reference_t<T> &value) {
22 return static_cast<T &&>(value);
23}
24
25template <typename T>
26LIBC_INLINE constexpr T &&forward(remove_reference_t<T> &&value) {
27 static_assert(!is_lvalue_reference_v<T>,
28 "cannot forward an rvalue as an lvalue");
29 return static_cast<T &&>(value);
30}
31
32} // namespace cpp
33} // namespace LIBC_NAMESPACE_DECL
34
35#endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_FORWARD_H
lib/libcxx/libc/src/__support/CPP/utility/in_place.h created+39
...@@ -0,0 +1,39 @@
1//===-- in_place utility ----------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_IN_PLACE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_IN_PLACE_H
10
11#include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR
12#include "src/__support/macros/config.h"
13
14#include <stddef.h> // size_t
15
16namespace LIBC_NAMESPACE_DECL {
17namespace cpp {
18
19// in_place
20struct in_place_t {
21 LIBC_INLINE explicit in_place_t() = default;
22};
23LIBC_INLINE_VAR constexpr in_place_t in_place{};
24
25template <class T> struct in_place_type_t {
26 LIBC_INLINE explicit in_place_type_t() = default;
27};
28template <class T> LIBC_INLINE_VAR constexpr in_place_type_t<T> in_place_type{};
29
30template <size_t IDX> struct in_place_index_t {
31 LIBC_INLINE explicit in_place_index_t() = default;
32};
33template <size_t IDX>
34LIBC_INLINE_VAR constexpr in_place_index_t<IDX> in_place_index{};
35
36} // namespace cpp
37} // namespace LIBC_NAMESPACE_DECL
38
39#endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_IN_PLACE_H
lib/libcxx/libc/src/__support/CPP/utility/integer_sequence.h created+40
...@@ -0,0 +1,40 @@
1//===-- integer_sequence utility --------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H
10
11#include "src/__support/CPP/type_traits/is_integral.h"
12#include "src/__support/macros/config.h"
13
14namespace LIBC_NAMESPACE_DECL {
15namespace cpp {
16
17// integer_sequence
18template <typename T, T... Ints> struct integer_sequence {
19 static_assert(cpp::is_integral_v<T>);
20 template <T Next> using append = integer_sequence<T, Ints..., Next>;
21};
22
23namespace detail {
24template <typename T, int N> struct make_integer_sequence {
25 using type =
26 typename make_integer_sequence<T, N - 1>::type::template append<N>;
27};
28template <typename T> struct make_integer_sequence<T, -1> {
29 using type = integer_sequence<T>;
30};
31} // namespace detail
32
33template <typename T, int N>
34using make_integer_sequence =
35 typename detail::make_integer_sequence<T, N - 1>::type;
36
37} // namespace cpp
38} // namespace LIBC_NAMESPACE_DECL
39
40#endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H
lib/libcxx/libc/src/__support/CPP/utility/move.h created+27
...@@ -0,0 +1,27 @@
1//===-- move utility --------------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_MOVE_H
9#define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_MOVE_H
10
11#include "src/__support/CPP/type_traits/remove_reference.h"
12#include "src/__support/macros/attributes.h" // LIBC_INLINE
13#include "src/__support/macros/config.h"
14
15namespace LIBC_NAMESPACE_DECL {
16namespace cpp {
17
18// move
19template <class T>
20LIBC_INLINE constexpr cpp::remove_reference_t<T> &&move(T &&t) {
21 return static_cast<typename cpp::remove_reference_t<T> &&>(t);
22}
23
24} // namespace cpp
25} // namespace LIBC_NAMESPACE_DECL
26
27#endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_MOVE_H
lib/libcxx/libc/src/__support/FPUtil/FPBits.h created+846
...@@ -0,0 +1,846 @@
1//===-- Abstract class for bit manipulation of float numbers. ---*- C++ -*-===//
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// -----------------------------------------------------------------------------
10// **** WARNING ****
11// This file is shared with libc++. You should also be careful when adding
12// dependencies to this file, since it needs to build for all libc++ targets.
13// -----------------------------------------------------------------------------
14
15#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_FPBITS_H
16#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_FPBITS_H
17
18#include "src/__support/CPP/bit.h"
19#include "src/__support/CPP/type_traits.h"
20#include "src/__support/common.h"
21#include "src/__support/libc_assert.h" // LIBC_ASSERT
22#include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR
23#include "src/__support/macros/config.h"
24#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_FLOAT128
25#include "src/__support/math_extras.h" // mask_trailing_ones
26#include "src/__support/sign.h" // Sign
27#include "src/__support/uint128.h"
28
29#include <stdint.h>
30
31namespace LIBC_NAMESPACE_DECL {
32namespace fputil {
33
34// The supported floating point types.
35enum class FPType {
36 IEEE754_Binary16,
37 IEEE754_Binary32,
38 IEEE754_Binary64,
39 IEEE754_Binary128,
40 X86_Binary80,
41};
42
43// The classes hierarchy is as follows:
44//
45// ┌───────────────────┐
46// │ FPLayout<FPType> │
47// └─────────â–²─────────┘
48// │
49// ┌─────────┴─────────┐
50// │ FPStorage<FPType> │
51// └─────────â–²─────────┘
52// │
53// ┌────────────┴─────────────┐
54// │ │
55// ┌────────┴─────────┐ ┌──────────────┴──────────────────┐
56// │ FPRepSem<FPType> │ │ FPRepSem<FPType::X86_Binary80 │
57// └────────â–²─────────┘ └──────────────â–²──────────────────┘
58// │ │
59// └────────────┬─────────────┘
60// │
61// ┌───────┴───────┐
62// │ FPRepImpl<T> │
63// └───────â–²───────┘
64// │
65// ┌────────┴────────┐
66// ┌─────┴─────┐ ┌─────┴─────┐
67// │ FPRep<T> │ │ FPBits<T> │
68// └───────────┘ └───────────┘
69//
70// - 'FPLayout' defines only a few constants, namely the 'StorageType' and
71// length of the sign, the exponent, fraction and significand parts.
72// - 'FPStorage' builds more constants on top of those from 'FPLayout' like
73// exponent bias and masks. It also holds the bit representation of the
74// floating point as a 'StorageType' type and defines tools to assemble or
75// test these parts.
76// - 'FPRepSem' defines functions to interact semantically with the floating
77// point representation. The default implementation is the one for 'IEEE754',
78// a specialization is provided for X86 Extended Precision.
79// - 'FPRepImpl' derives from 'FPRepSem' and adds functions that are common to
80// all implementations or build on the ones in 'FPRepSem'.
81// - 'FPRep' exposes all functions from 'FPRepImpl' and returns 'FPRep'
82// instances when using Builders (static functions to create values).
83// - 'FPBits' exposes all the functions from 'FPRepImpl' but operates on the
84// native C++ floating point type instead of 'FPType'. An additional 'get_val'
85// function allows getting the C++ floating point type value back. Builders
86// called from 'FPBits' return 'FPBits' instances.
87
88namespace internal {
89
90// Defines the layout (sign, exponent, significand) of a floating point type in
91// memory. It also defines its associated StorageType, i.e., the unsigned
92// integer type used to manipulate its representation.
93// Additionally we provide the fractional part length, i.e., the number of bits
94// after the decimal dot when the number is in normal form.
95template <FPType> struct FPLayout {};
96
97template <> struct FPLayout<FPType::IEEE754_Binary16> {
98 using StorageType = uint16_t;
99 LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1;
100 LIBC_INLINE_VAR static constexpr int EXP_LEN = 5;
101 LIBC_INLINE_VAR static constexpr int SIG_LEN = 10;
102 LIBC_INLINE_VAR static constexpr int FRACTION_LEN = SIG_LEN;
103};
104
105template <> struct FPLayout<FPType::IEEE754_Binary32> {
106 using StorageType = uint32_t;
107 LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1;
108 LIBC_INLINE_VAR static constexpr int EXP_LEN = 8;
109 LIBC_INLINE_VAR static constexpr int SIG_LEN = 23;
110 LIBC_INLINE_VAR static constexpr int FRACTION_LEN = SIG_LEN;
111};
112
113template <> struct FPLayout<FPType::IEEE754_Binary64> {
114 using StorageType = uint64_t;
115 LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1;
116 LIBC_INLINE_VAR static constexpr int EXP_LEN = 11;
117 LIBC_INLINE_VAR static constexpr int SIG_LEN = 52;
118 LIBC_INLINE_VAR static constexpr int FRACTION_LEN = SIG_LEN;
119};
120
121template <> struct FPLayout<FPType::IEEE754_Binary128> {
122 using StorageType = UInt128;
123 LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1;
124 LIBC_INLINE_VAR static constexpr int EXP_LEN = 15;
125 LIBC_INLINE_VAR static constexpr int SIG_LEN = 112;
126 LIBC_INLINE_VAR static constexpr int FRACTION_LEN = SIG_LEN;
127};
128
129template <> struct FPLayout<FPType::X86_Binary80> {
130#if __SIZEOF_LONG_DOUBLE__ == 12
131 using StorageType = UInt<__SIZEOF_LONG_DOUBLE__ * CHAR_BIT>;
132#else
133 using StorageType = UInt128;
134#endif
135 LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1;
136 LIBC_INLINE_VAR static constexpr int EXP_LEN = 15;
137 LIBC_INLINE_VAR static constexpr int SIG_LEN = 64;
138 LIBC_INLINE_VAR static constexpr int FRACTION_LEN = SIG_LEN - 1;
139};
140
141// FPStorage derives useful constants from the FPLayout above.
142template <FPType fp_type> struct FPStorage : public FPLayout<fp_type> {
143 using UP = FPLayout<fp_type>;
144
145 using UP::EXP_LEN; // The number of bits for the *exponent* part
146 using UP::SIG_LEN; // The number of bits for the *significand* part
147 using UP::SIGN_LEN; // The number of bits for the *sign* part
148 // For convenience, the sum of `SIG_LEN`, `EXP_LEN`, and `SIGN_LEN`.
149 LIBC_INLINE_VAR static constexpr int TOTAL_LEN = SIGN_LEN + EXP_LEN + SIG_LEN;
150
151 // The number of bits after the decimal dot when the number is in normal form.
152 using UP::FRACTION_LEN;
153
154 // An unsigned integer that is wide enough to contain all of the floating
155 // point bits.
156 using StorageType = typename UP::StorageType;
157
158 // The number of bits in StorageType.
159 LIBC_INLINE_VAR static constexpr int STORAGE_LEN =
160 sizeof(StorageType) * CHAR_BIT;
161 static_assert(STORAGE_LEN >= TOTAL_LEN);
162
163 // The exponent bias. Always positive.
164 LIBC_INLINE_VAR static constexpr int32_t EXP_BIAS =
165 (1U << (EXP_LEN - 1U)) - 1U;
166 static_assert(EXP_BIAS > 0);
167
168 // The bit pattern that keeps only the *significand* part.
169 LIBC_INLINE_VAR static constexpr StorageType SIG_MASK =
170 mask_trailing_ones<StorageType, SIG_LEN>();
171 // The bit pattern that keeps only the *exponent* part.
172 LIBC_INLINE_VAR static constexpr StorageType EXP_MASK =
173 mask_trailing_ones<StorageType, EXP_LEN>() << SIG_LEN;
174 // The bit pattern that keeps only the *sign* part.
175 LIBC_INLINE_VAR static constexpr StorageType SIGN_MASK =
176 mask_trailing_ones<StorageType, SIGN_LEN>() << (EXP_LEN + SIG_LEN);
177 // The bit pattern that keeps only the *exponent + significand* part.
178 LIBC_INLINE_VAR static constexpr StorageType EXP_SIG_MASK =
179 mask_trailing_ones<StorageType, EXP_LEN + SIG_LEN>();
180 // The bit pattern that keeps only the *sign + exponent + significand* part.
181 LIBC_INLINE_VAR static constexpr StorageType FP_MASK =
182 mask_trailing_ones<StorageType, TOTAL_LEN>();
183 // The bit pattern that keeps only the *fraction* part.
184 // i.e., the *significand* without the leading one.
185 LIBC_INLINE_VAR static constexpr StorageType FRACTION_MASK =
186 mask_trailing_ones<StorageType, FRACTION_LEN>();
187
188 static_assert((SIG_MASK & EXP_MASK & SIGN_MASK) == 0, "masks disjoint");
189 static_assert((SIG_MASK | EXP_MASK | SIGN_MASK) == FP_MASK, "masks cover");
190
191protected:
192 // Merge bits from 'a' and 'b' values according to 'mask'.
193 // Use 'a' bits when corresponding 'mask' bits are zeroes and 'b' bits when
194 // corresponding bits are ones.
195 LIBC_INLINE static constexpr StorageType merge(StorageType a, StorageType b,
196 StorageType mask) {
197 // https://graphics.stanford.edu/~seander/bithacks.html#MaskedMerge
198 return a ^ ((a ^ b) & mask);
199 }
200
201 // A stongly typed integer that prevents mixing and matching integers with
202 // different semantics.
203 template <typename T> struct TypedInt {
204 using value_type = T;
205 LIBC_INLINE constexpr explicit TypedInt(T value) : value(value) {}
206 LIBC_INLINE constexpr TypedInt(const TypedInt &value) = default;
207 LIBC_INLINE constexpr TypedInt &operator=(const TypedInt &value) = default;
208
209 LIBC_INLINE constexpr explicit operator T() const { return value; }
210
211 LIBC_INLINE constexpr StorageType to_storage_type() const {
212 return StorageType(value);
213 }
214
215 LIBC_INLINE friend constexpr bool operator==(TypedInt a, TypedInt b) {
216 return a.value == b.value;
217 }
218 LIBC_INLINE friend constexpr bool operator!=(TypedInt a, TypedInt b) {
219 return a.value != b.value;
220 }
221
222 protected:
223 T value;
224 };
225
226 // An opaque type to store a floating point exponent.
227 // We define special values but it is valid to create arbitrary values as long
228 // as they are in the range [min, max].
229 struct Exponent : public TypedInt<int32_t> {
230 using UP = TypedInt<int32_t>;
231 using UP::UP;
232 LIBC_INLINE static constexpr auto subnormal() {
233 return Exponent(-EXP_BIAS);
234 }
235 LIBC_INLINE static constexpr auto min() { return Exponent(1 - EXP_BIAS); }
236 LIBC_INLINE static constexpr auto zero() { return Exponent(0); }
237 LIBC_INLINE static constexpr auto max() { return Exponent(EXP_BIAS); }
238 LIBC_INLINE static constexpr auto inf() { return Exponent(EXP_BIAS + 1); }
239 };
240
241 // An opaque type to store a floating point biased exponent.
242 // We define special values but it is valid to create arbitrary values as long
243 // as they are in the range [zero, bits_all_ones].
244 // Values greater than bits_all_ones are truncated.
245 struct BiasedExponent : public TypedInt<uint32_t> {
246 using UP = TypedInt<uint32_t>;
247 using UP::UP;
248
249 LIBC_INLINE constexpr BiasedExponent(Exponent exp)
250 : UP(static_cast<int32_t>(exp) + EXP_BIAS) {}
251
252 // Cast operator to get convert from BiasedExponent to Exponent.
253 LIBC_INLINE constexpr operator Exponent() const {
254 return Exponent(UP::value - EXP_BIAS);
255 }
256
257 LIBC_INLINE constexpr BiasedExponent &operator++() {
258 LIBC_ASSERT(*this != BiasedExponent(Exponent::inf()));
259 ++UP::value;
260 return *this;
261 }
262
263 LIBC_INLINE constexpr BiasedExponent &operator--() {
264 LIBC_ASSERT(*this != BiasedExponent(Exponent::subnormal()));
265 --UP::value;
266 return *this;
267 }
268 };
269
270 // An opaque type to store a floating point significand.
271 // We define special values but it is valid to create arbitrary values as long
272 // as they are in the range [zero, bits_all_ones].
273 // Note that the semantics of the Significand are implementation dependent.
274 // Values greater than bits_all_ones are truncated.
275 struct Significand : public TypedInt<StorageType> {
276 using UP = TypedInt<StorageType>;
277 using UP::UP;
278
279 LIBC_INLINE friend constexpr Significand operator|(const Significand a,
280 const Significand b) {
281 return Significand(
282 StorageType(a.to_storage_type() | b.to_storage_type()));
283 }
284 LIBC_INLINE friend constexpr Significand operator^(const Significand a,
285 const Significand b) {
286 return Significand(
287 StorageType(a.to_storage_type() ^ b.to_storage_type()));
288 }
289 LIBC_INLINE friend constexpr Significand operator>>(const Significand a,
290 int shift) {
291 return Significand(StorageType(a.to_storage_type() >> shift));
292 }
293
294 LIBC_INLINE static constexpr auto zero() {
295 return Significand(StorageType(0));
296 }
297 LIBC_INLINE static constexpr auto lsb() {
298 return Significand(StorageType(1));
299 }
300 LIBC_INLINE static constexpr auto msb() {
301 return Significand(StorageType(1) << (SIG_LEN - 1));
302 }
303 LIBC_INLINE static constexpr auto bits_all_ones() {
304 return Significand(SIG_MASK);
305 }
306 };
307
308 LIBC_INLINE static constexpr StorageType encode(BiasedExponent exp) {
309 return (exp.to_storage_type() << SIG_LEN) & EXP_MASK;
310 }
311
312 LIBC_INLINE static constexpr StorageType encode(Significand value) {
313 return value.to_storage_type() & SIG_MASK;
314 }
315
316 LIBC_INLINE static constexpr StorageType encode(BiasedExponent exp,
317 Significand sig) {
318 return encode(exp) | encode(sig);
319 }
320
321 LIBC_INLINE static constexpr StorageType encode(Sign sign, BiasedExponent exp,
322 Significand sig) {
323 if (sign.is_neg())
324 return SIGN_MASK | encode(exp, sig);
325 return encode(exp, sig);
326 }
327
328 // The floating point number representation as an unsigned integer.
329 StorageType bits{};
330
331 LIBC_INLINE constexpr FPStorage() : bits(0) {}
332 LIBC_INLINE constexpr FPStorage(StorageType value) : bits(value) {}
333
334 // Observers
335 LIBC_INLINE constexpr StorageType exp_bits() const { return bits & EXP_MASK; }
336 LIBC_INLINE constexpr StorageType sig_bits() const { return bits & SIG_MASK; }
337 LIBC_INLINE constexpr StorageType exp_sig_bits() const {
338 return bits & EXP_SIG_MASK;
339 }
340
341 // Parts
342 LIBC_INLINE constexpr BiasedExponent biased_exponent() const {
343 return BiasedExponent(static_cast<uint32_t>(exp_bits() >> SIG_LEN));
344 }
345 LIBC_INLINE constexpr void set_biased_exponent(BiasedExponent biased) {
346 bits = merge(bits, encode(biased), EXP_MASK);
347 }
348
349public:
350 LIBC_INLINE constexpr Sign sign() const {
351 return (bits & SIGN_MASK) ? Sign::NEG : Sign::POS;
352 }
353 LIBC_INLINE constexpr void set_sign(Sign signVal) {
354 if (sign() != signVal)
355 bits ^= SIGN_MASK;
356 }
357};
358
359// This layer defines all functions that are specific to how the the floating
360// point type is encoded. It enables constructions, modification and observation
361// of values manipulated as 'StorageType'.
362template <FPType fp_type, typename RetT>
363struct FPRepSem : public FPStorage<fp_type> {
364 using UP = FPStorage<fp_type>;
365 using typename UP::StorageType;
366 using UP::FRACTION_LEN;
367 using UP::FRACTION_MASK;
368
369protected:
370 using typename UP::Exponent;
371 using typename UP::Significand;
372 using UP::bits;
373 using UP::encode;
374 using UP::exp_bits;
375 using UP::exp_sig_bits;
376 using UP::sig_bits;
377 using UP::UP;
378
379public:
380 // Builders
381 LIBC_INLINE static constexpr RetT zero(Sign sign = Sign::POS) {
382 return RetT(encode(sign, Exponent::subnormal(), Significand::zero()));
383 }
384 LIBC_INLINE static constexpr RetT one(Sign sign = Sign::POS) {
385 return RetT(encode(sign, Exponent::zero(), Significand::zero()));
386 }
387 LIBC_INLINE static constexpr RetT min_subnormal(Sign sign = Sign::POS) {
388 return RetT(encode(sign, Exponent::subnormal(), Significand::lsb()));
389 }
390 LIBC_INLINE static constexpr RetT max_subnormal(Sign sign = Sign::POS) {
391 return RetT(
392 encode(sign, Exponent::subnormal(), Significand::bits_all_ones()));
393 }
394 LIBC_INLINE static constexpr RetT min_normal(Sign sign = Sign::POS) {
395 return RetT(encode(sign, Exponent::min(), Significand::zero()));
396 }
397 LIBC_INLINE static constexpr RetT max_normal(Sign sign = Sign::POS) {
398 return RetT(encode(sign, Exponent::max(), Significand::bits_all_ones()));
399 }
400 LIBC_INLINE static constexpr RetT inf(Sign sign = Sign::POS) {
401 return RetT(encode(sign, Exponent::inf(), Significand::zero()));
402 }
403 LIBC_INLINE static constexpr RetT signaling_nan(Sign sign = Sign::POS,
404 StorageType v = 0) {
405 return RetT(encode(sign, Exponent::inf(),
406 (v ? Significand(v) : (Significand::msb() >> 1))));
407 }
408 LIBC_INLINE static constexpr RetT quiet_nan(Sign sign = Sign::POS,
409 StorageType v = 0) {
410 return RetT(
411 encode(sign, Exponent::inf(), Significand::msb() | Significand(v)));
412 }
413
414 // Observers
415 LIBC_INLINE constexpr bool is_zero() const { return exp_sig_bits() == 0; }
416 LIBC_INLINE constexpr bool is_nan() const {
417 return exp_sig_bits() > encode(Exponent::inf(), Significand::zero());
418 }
419 LIBC_INLINE constexpr bool is_quiet_nan() const {
420 return exp_sig_bits() >= encode(Exponent::inf(), Significand::msb());
421 }
422 LIBC_INLINE constexpr bool is_signaling_nan() const {
423 return is_nan() && !is_quiet_nan();
424 }
425 LIBC_INLINE constexpr bool is_inf() const {
426 return exp_sig_bits() == encode(Exponent::inf(), Significand::zero());
427 }
428 LIBC_INLINE constexpr bool is_finite() const {
429 return exp_bits() != encode(Exponent::inf());
430 }
431 LIBC_INLINE
432 constexpr bool is_subnormal() const {
433 return exp_bits() == encode(Exponent::subnormal());
434 }
435 LIBC_INLINE constexpr bool is_normal() const {
436 return is_finite() && !is_subnormal();
437 }
438 LIBC_INLINE constexpr RetT next_toward_inf() const {
439 if (is_finite())
440 return RetT(bits + StorageType(1));
441 return RetT(bits);
442 }
443
444 // Returns the mantissa with the implicit bit set iff the current
445 // value is a valid normal number.
446 LIBC_INLINE constexpr StorageType get_explicit_mantissa() const {
447 if (is_subnormal())
448 return sig_bits();
449 return (StorageType(1) << UP::SIG_LEN) | sig_bits();
450 }
451};
452
453// Specialization for the X86 Extended Precision type.
454template <typename RetT>
455struct FPRepSem<FPType::X86_Binary80, RetT>
456 : public FPStorage<FPType::X86_Binary80> {
457 using UP = FPStorage<FPType::X86_Binary80>;
458 using typename UP::StorageType;
459 using UP::FRACTION_LEN;
460 using UP::FRACTION_MASK;
461
462 // The x86 80 bit float represents the leading digit of the mantissa
463 // explicitly. This is the mask for that bit.
464 static constexpr StorageType EXPLICIT_BIT_MASK = StorageType(1)
465 << FRACTION_LEN;
466 // The X80 significand is made of an explicit bit and the fractional part.
467 static_assert((EXPLICIT_BIT_MASK & FRACTION_MASK) == 0,
468 "the explicit bit and the fractional part should not overlap");
469 static_assert((EXPLICIT_BIT_MASK | FRACTION_MASK) == SIG_MASK,
470 "the explicit bit and the fractional part should cover the "
471 "whole significand");
472
473protected:
474 using typename UP::Exponent;
475 using typename UP::Significand;
476 using UP::encode;
477 using UP::UP;
478
479public:
480 // Builders
481 LIBC_INLINE static constexpr RetT zero(Sign sign = Sign::POS) {
482 return RetT(encode(sign, Exponent::subnormal(), Significand::zero()));
483 }
484 LIBC_INLINE static constexpr RetT one(Sign sign = Sign::POS) {
485 return RetT(encode(sign, Exponent::zero(), Significand::msb()));
486 }
487 LIBC_INLINE static constexpr RetT min_subnormal(Sign sign = Sign::POS) {
488 return RetT(encode(sign, Exponent::subnormal(), Significand::lsb()));
489 }
490 LIBC_INLINE static constexpr RetT max_subnormal(Sign sign = Sign::POS) {
491 return RetT(encode(sign, Exponent::subnormal(),
492 Significand::bits_all_ones() ^ Significand::msb()));
493 }
494 LIBC_INLINE static constexpr RetT min_normal(Sign sign = Sign::POS) {
495 return RetT(encode(sign, Exponent::min(), Significand::msb()));
496 }
497 LIBC_INLINE static constexpr RetT max_normal(Sign sign = Sign::POS) {
498 return RetT(encode(sign, Exponent::max(), Significand::bits_all_ones()));
499 }
500 LIBC_INLINE static constexpr RetT inf(Sign sign = Sign::POS) {
501 return RetT(encode(sign, Exponent::inf(), Significand::msb()));
502 }
503 LIBC_INLINE static constexpr RetT signaling_nan(Sign sign = Sign::POS,
504 StorageType v = 0) {
505 return RetT(encode(sign, Exponent::inf(),
506 Significand::msb() |
507 (v ? Significand(v) : (Significand::msb() >> 2))));
508 }
509 LIBC_INLINE static constexpr RetT quiet_nan(Sign sign = Sign::POS,
510 StorageType v = 0) {
511 return RetT(encode(sign, Exponent::inf(),
512 Significand::msb() | (Significand::msb() >> 1) |
513 Significand(v)));
514 }
515
516 // Observers
517 LIBC_INLINE constexpr bool is_zero() const { return exp_sig_bits() == 0; }
518 LIBC_INLINE constexpr bool is_nan() const {
519 // Most encoding forms from the table found in
520 // https://en.wikipedia.org/wiki/Extended_precision#x86_extended_precision_format
521 // are interpreted as NaN.
522 // More precisely :
523 // - Pseudo-Infinity
524 // - Pseudo Not a Number
525 // - Signalling Not a Number
526 // - Floating-point Indefinite
527 // - Quiet Not a Number
528 // - Unnormal
529 // This can be reduced to the following logic:
530 if (exp_bits() == encode(Exponent::inf()))
531 return !is_inf();
532 if (exp_bits() != encode(Exponent::subnormal()))
533 return (sig_bits() & encode(Significand::msb())) == 0;
534 return false;
535 }
536 LIBC_INLINE constexpr bool is_quiet_nan() const {
537 return exp_sig_bits() >=
538 encode(Exponent::inf(),
539 Significand::msb() | (Significand::msb() >> 1));
540 }
541 LIBC_INLINE constexpr bool is_signaling_nan() const {
542 return is_nan() && !is_quiet_nan();
543 }
544 LIBC_INLINE constexpr bool is_inf() const {
545 return exp_sig_bits() == encode(Exponent::inf(), Significand::msb());
546 }
547 LIBC_INLINE constexpr bool is_finite() const {
548 return !is_inf() && !is_nan();
549 }
550 LIBC_INLINE
551 constexpr bool is_subnormal() const {
552 return exp_bits() == encode(Exponent::subnormal());
553 }
554 LIBC_INLINE constexpr bool is_normal() const {
555 const auto exp = exp_bits();
556 if (exp == encode(Exponent::subnormal()) || exp == encode(Exponent::inf()))
557 return false;
558 return get_implicit_bit();
559 }
560 LIBC_INLINE constexpr RetT next_toward_inf() const {
561 if (is_finite()) {
562 if (exp_sig_bits() == max_normal().uintval()) {
563 return inf(sign());
564 } else if (exp_sig_bits() == max_subnormal().uintval()) {
565 return min_normal(sign());
566 } else if (sig_bits() == SIG_MASK) {
567 return RetT(encode(sign(), ++biased_exponent(), Significand::zero()));
568 } else {
569 return RetT(bits + StorageType(1));
570 }
571 }
572 return RetT(bits);
573 }
574
575 LIBC_INLINE constexpr StorageType get_explicit_mantissa() const {
576 return sig_bits();
577 }
578
579 // This functions is specific to FPRepSem<FPType::X86_Binary80>.
580 // TODO: Remove if possible.
581 LIBC_INLINE constexpr bool get_implicit_bit() const {
582 return static_cast<bool>(bits & EXPLICIT_BIT_MASK);
583 }
584
585 // This functions is specific to FPRepSem<FPType::X86_Binary80>.
586 // TODO: Remove if possible.
587 LIBC_INLINE constexpr void set_implicit_bit(bool implicitVal) {
588 if (get_implicit_bit() != implicitVal)
589 bits ^= EXPLICIT_BIT_MASK;
590 }
591};
592
593// 'FPRepImpl' is the bottom of the class hierarchy that only deals with
594// 'FPType'. The operations dealing with specific float semantics are
595// implemented by 'FPRepSem' above and specialized when needed.
596//
597// The 'RetT' type is being propagated up to 'FPRepSem' so that the functions
598// creating new values (Builders) can return the appropriate type. That is, when
599// creating a value through 'FPBits' below the builder will return an 'FPBits'
600// value.
601// FPBits<float>::zero(); // returns an FPBits<>
602//
603// When we don't care about specific C++ floating point type we can use
604// 'FPRep' and specify the 'FPType' directly.
605// FPRep<FPType::IEEE754_Binary32:>::zero() // returns an FPRep<>
606template <FPType fp_type, typename RetT>
607struct FPRepImpl : public FPRepSem<fp_type, RetT> {
608 using UP = FPRepSem<fp_type, RetT>;
609 using StorageType = typename UP::StorageType;
610
611protected:
612 using UP::bits;
613 using UP::encode;
614 using UP::exp_bits;
615 using UP::exp_sig_bits;
616
617 using typename UP::BiasedExponent;
618 using typename UP::Exponent;
619 using typename UP::Significand;
620
621 using UP::FP_MASK;
622
623public:
624 // Constants.
625 using UP::EXP_BIAS;
626 using UP::EXP_MASK;
627 using UP::FRACTION_MASK;
628 using UP::SIG_LEN;
629 using UP::SIG_MASK;
630 using UP::SIGN_MASK;
631 LIBC_INLINE_VAR static constexpr int MAX_BIASED_EXPONENT =
632 (1 << UP::EXP_LEN) - 1;
633
634 // CTors
635 LIBC_INLINE constexpr FPRepImpl() = default;
636 LIBC_INLINE constexpr explicit FPRepImpl(StorageType x) : UP(x) {}
637
638 // Comparison
639 LIBC_INLINE constexpr friend bool operator==(FPRepImpl a, FPRepImpl b) {
640 return a.uintval() == b.uintval();
641 }
642 LIBC_INLINE constexpr friend bool operator!=(FPRepImpl a, FPRepImpl b) {
643 return a.uintval() != b.uintval();
644 }
645
646 // Representation
647 LIBC_INLINE constexpr StorageType uintval() const { return bits & FP_MASK; }
648 LIBC_INLINE constexpr void set_uintval(StorageType value) {
649 bits = (value & FP_MASK);
650 }
651
652 // Builders
653 using UP::inf;
654 using UP::max_normal;
655 using UP::max_subnormal;
656 using UP::min_normal;
657 using UP::min_subnormal;
658 using UP::one;
659 using UP::quiet_nan;
660 using UP::signaling_nan;
661 using UP::zero;
662
663 // Modifiers
664 LIBC_INLINE constexpr RetT abs() const {
665 return RetT(static_cast<StorageType>(bits & UP::EXP_SIG_MASK));
666 }
667
668 // Observers
669 using UP::get_explicit_mantissa;
670 using UP::is_finite;
671 using UP::is_inf;
672 using UP::is_nan;
673 using UP::is_normal;
674 using UP::is_quiet_nan;
675 using UP::is_signaling_nan;
676 using UP::is_subnormal;
677 using UP::is_zero;
678 using UP::next_toward_inf;
679 using UP::sign;
680 LIBC_INLINE constexpr bool is_inf_or_nan() const { return !is_finite(); }
681 LIBC_INLINE constexpr bool is_neg() const { return sign().is_neg(); }
682 LIBC_INLINE constexpr bool is_pos() const { return sign().is_pos(); }
683
684 LIBC_INLINE constexpr uint16_t get_biased_exponent() const {
685 return static_cast<uint16_t>(static_cast<uint32_t>(UP::biased_exponent()));
686 }
687
688 LIBC_INLINE constexpr void set_biased_exponent(StorageType biased) {
689 UP::set_biased_exponent(BiasedExponent((int32_t)biased));
690 }
691
692 LIBC_INLINE constexpr int get_exponent() const {
693 return static_cast<int32_t>(Exponent(UP::biased_exponent()));
694 }
695
696 // If the number is subnormal, the exponent is treated as if it were the
697 // minimum exponent for a normal number. This is to keep continuity between
698 // the normal and subnormal ranges, but it causes problems for functions where
699 // values are calculated from the exponent, since just subtracting the bias
700 // will give a slightly incorrect result. Additionally, zero has an exponent
701 // of zero, and that should actually be treated as zero.
702 LIBC_INLINE constexpr int get_explicit_exponent() const {
703 Exponent exponent(UP::biased_exponent());
704 if (is_zero())
705 exponent = Exponent::zero();
706 if (exponent == Exponent::subnormal())
707 exponent = Exponent::min();
708 return static_cast<int32_t>(exponent);
709 }
710
711 LIBC_INLINE constexpr StorageType get_mantissa() const {
712 return bits & FRACTION_MASK;
713 }
714
715 LIBC_INLINE constexpr void set_mantissa(StorageType mantVal) {
716 bits = UP::merge(bits, mantVal, FRACTION_MASK);
717 }
718
719 LIBC_INLINE constexpr void set_significand(StorageType sigVal) {
720 bits = UP::merge(bits, sigVal, SIG_MASK);
721 }
722 // Unsafe function to create a floating point representation.
723 // It simply packs the sign, biased exponent and mantissa values without
724 // checking bound nor normalization.
725 //
726 // WARNING: For X86 Extended Precision, implicit bit needs to be set correctly
727 // in the 'mantissa' by the caller. This function will not check for its
728 // validity.
729 //
730 // FIXME: Use an uint32_t for 'biased_exp'.
731 LIBC_INLINE static constexpr RetT
732 create_value(Sign sign, StorageType biased_exp, StorageType mantissa) {
733 return RetT(encode(sign, BiasedExponent(static_cast<uint32_t>(biased_exp)),
734 Significand(mantissa)));
735 }
736
737 // The function converts integer number and unbiased exponent to proper
738 // float T type:
739 // Result = number * 2^(ep+1 - exponent_bias)
740 // Be careful!
741 // 1) "ep" is the raw exponent value.
742 // 2) The function adds +1 to ep for seamless normalized to denormalized
743 // transition.
744 // 3) The function does not check exponent high limit.
745 // 4) "number" zero value is not processed correctly.
746 // 5) Number is unsigned, so the result can be only positive.
747 LIBC_INLINE static constexpr RetT make_value(StorageType number, int ep) {
748 FPRepImpl result(0);
749 int lz =
750 UP::FRACTION_LEN + 1 - (UP::STORAGE_LEN - cpp::countl_zero(number));
751
752 number <<= lz;
753 ep -= lz;
754
755 if (LIBC_LIKELY(ep >= 0)) {
756 // Implicit number bit will be removed by mask
757 result.set_significand(number);
758 result.set_biased_exponent(static_cast<StorageType>(ep + 1));
759 } else {
760 result.set_significand(number >> -ep);
761 }
762 return RetT(result.uintval());
763 }
764};
765
766// A generic class to manipulate floating point formats.
767// It derives its functionality to FPRepImpl above.
768template <FPType fp_type>
769struct FPRep : public FPRepImpl<fp_type, FPRep<fp_type>> {
770 using UP = FPRepImpl<fp_type, FPRep<fp_type>>;
771 using StorageType = typename UP::StorageType;
772 using UP::UP;
773
774 LIBC_INLINE constexpr explicit operator StorageType() const {
775 return UP::uintval();
776 }
777};
778
779} // namespace internal
780
781// Returns the FPType corresponding to C++ type T on the host.
782template <typename T> LIBC_INLINE static constexpr FPType get_fp_type() {
783 using UnqualT = cpp::remove_cv_t<T>;
784 if constexpr (cpp::is_same_v<UnqualT, float> && __FLT_MANT_DIG__ == 24)
785 return FPType::IEEE754_Binary32;
786 else if constexpr (cpp::is_same_v<UnqualT, double> && __DBL_MANT_DIG__ == 53)
787 return FPType::IEEE754_Binary64;
788 else if constexpr (cpp::is_same_v<UnqualT, long double>) {
789 if constexpr (__LDBL_MANT_DIG__ == 53)
790 return FPType::IEEE754_Binary64;
791 else if constexpr (__LDBL_MANT_DIG__ == 64)
792 return FPType::X86_Binary80;
793 else if constexpr (__LDBL_MANT_DIG__ == 113)
794 return FPType::IEEE754_Binary128;
795 }
796#if defined(LIBC_TYPES_HAS_FLOAT16)
797 else if constexpr (cpp::is_same_v<UnqualT, float16>)
798 return FPType::IEEE754_Binary16;
799#endif
800#if defined(LIBC_TYPES_HAS_FLOAT128)
801 else if constexpr (cpp::is_same_v<UnqualT, float128>)
802 return FPType::IEEE754_Binary128;
803#endif
804 else
805 static_assert(cpp::always_false<UnqualT>, "Unsupported type");
806}
807
808// -----------------------------------------------------------------------------
809// **** WARNING ****
810// This interface is shared with libc++, if you change this interface you need
811// to update it in both libc and libc++. You should also be careful when adding
812// dependencies to this file, since it needs to build for all libc++ targets.
813// -----------------------------------------------------------------------------
814// A generic class to manipulate C++ floating point formats.
815// It derives its functionality to FPRepImpl above.
816template <typename T>
817struct FPBits final : public internal::FPRepImpl<get_fp_type<T>(), FPBits<T>> {
818 static_assert(cpp::is_floating_point_v<T>,
819 "FPBits instantiated with invalid type.");
820 using UP = internal::FPRepImpl<get_fp_type<T>(), FPBits<T>>;
821 using StorageType = typename UP::StorageType;
822
823 // Constructors.
824 LIBC_INLINE constexpr FPBits() = default;
825
826 template <typename XType> LIBC_INLINE constexpr explicit FPBits(XType x) {
827 using Unqual = typename cpp::remove_cv_t<XType>;
828 if constexpr (cpp::is_same_v<Unqual, T>) {
829 UP::bits = cpp::bit_cast<StorageType>(x);
830 } else if constexpr (cpp::is_same_v<Unqual, StorageType>) {
831 UP::bits = x;
832 } else {
833 // We don't want accidental type promotions/conversions, so we require
834 // exact type match.
835 static_assert(cpp::always_false<XType>);
836 }
837 }
838
839 // Floating-point conversions.
840 LIBC_INLINE constexpr T get_val() const { return cpp::bit_cast<T>(UP::bits); }
841};
842
843} // namespace fputil
844} // namespace LIBC_NAMESPACE_DECL
845
846#endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_FPBITS_H
lib/libcxx/libc/src/__support/FPUtil/rounding_mode.h created+81
...@@ -0,0 +1,81 @@
1//===---- Free-standing function to detect rounding mode --------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H
10#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H
11
12#include "hdr/fenv_macros.h"
13#include "src/__support/macros/attributes.h" // LIBC_INLINE
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17namespace fputil {
18
19// Quick free-standing test whether fegetround() == FE_UPWARD.
20// Using the following observation:
21// 1.0f + 2^-25 = 1.0f for FE_TONEAREST, FE_DOWNWARD, FE_TOWARDZERO
22// = 0x1.000002f for FE_UPWARD.
23LIBC_INLINE bool fenv_is_round_up() {
24 volatile float x = 0x1.0p-25f;
25 return (1.0f + x != 1.0f);
26}
27
28// Quick free-standing test whether fegetround() == FE_DOWNWARD.
29// Using the following observation:
30// -1.0f - 2^-25 = -1.0f for FE_TONEAREST, FE_UPWARD, FE_TOWARDZERO
31// = -0x1.000002f for FE_DOWNWARD.
32LIBC_INLINE bool fenv_is_round_down() {
33 volatile float x = 0x1.0p-25f;
34 return (-1.0f - x != -1.0f);
35}
36
37// Quick free-standing test whether fegetround() == FE_TONEAREST.
38// Using the following observation:
39// 1.5f + 2^-24 = 1.5f for FE_TONEAREST, FE_DOWNWARD, FE_TOWARDZERO
40// = 0x1.100002p0f for FE_UPWARD,
41// 1.5f - 2^-24 = 1.5f for FE_TONEAREST, FE_UPWARD
42// = 0x1.0ffffep-1f for FE_DOWNWARD, FE_TOWARDZERO
43LIBC_INLINE bool fenv_is_round_to_nearest() {
44 static volatile float x = 0x1.0p-24f;
45 float y = x;
46 return (1.5f + y == 1.5f - y);
47}
48
49// Quick free-standing test whether fegetround() == FE_TOWARDZERO.
50// Using the following observation:
51// 1.0f + 2^-23 + 2^-24 = 0x1.000002p0f for FE_DOWNWARD, FE_TOWARDZERO
52// = 0x1.000004p0f for FE_TONEAREST, FE_UPWARD,
53// -1.0f - 2^-24 = -1.0f for FE_TONEAREST, FE_UPWARD, FE_TOWARDZERO
54// = -0x1.000002p0f for FE_DOWNWARD
55// So:
56// (0x1.000002p0f + 2^-24) + (-1.0f - 2^-24) = 2^-23 for FE_TOWARDZERO
57// = 2^-22 for FE_TONEAREST, FE_UPWARD
58// = 0 for FE_DOWNWARD
59LIBC_INLINE bool fenv_is_round_to_zero() {
60 static volatile float x = 0x1.0p-24f;
61 float y = x;
62 return ((0x1.000002p0f + y) + (-1.0f - y) == 0x1.0p-23f);
63}
64
65// Quick free standing get rounding mode based on the above observations.
66LIBC_INLINE int quick_get_round() {
67 static volatile float x = 0x1.0p-24f;
68 float y = x;
69 float z = (0x1.000002p0f + y) + (-1.0f - y);
70
71 if (z == 0.0f)
72 return FE_DOWNWARD;
73 if (z == 0x1.0p-23f)
74 return FE_TOWARDZERO;
75 return (2.0f + y == 2.0f) ? FE_TONEAREST : FE_UPWARD;
76}
77
78} // namespace fputil
79} // namespace LIBC_NAMESPACE_DECL
80
81#endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H
lib/libcxx/libc/src/__support/big_int.h created+1384
...@@ -0,0 +1,1384 @@
1//===-- A class to manipulate wide integers. --------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_BIG_INT_H
10#define LLVM_LIBC_SRC___SUPPORT_BIG_INT_H
11
12#include "src/__support/CPP/array.h"
13#include "src/__support/CPP/bit.h" // countl_zero
14#include "src/__support/CPP/limits.h"
15#include "src/__support/CPP/optional.h"
16#include "src/__support/CPP/type_traits.h"
17#include "src/__support/macros/attributes.h" // LIBC_INLINE
18#include "src/__support/macros/config.h"
19#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
20#include "src/__support/macros/properties/compiler.h" // LIBC_COMPILER_IS_CLANG
21#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128, LIBC_TYPES_HAS_INT64
22#include "src/__support/math_extras.h" // add_with_carry, sub_with_borrow
23#include "src/__support/number_pair.h"
24
25#include <stddef.h> // For size_t
26#include <stdint.h>
27
28namespace LIBC_NAMESPACE_DECL {
29
30namespace multiword {
31
32// A type trait mapping unsigned integers to their half-width unsigned
33// counterparts.
34template <typename T> struct half_width;
35template <> struct half_width<uint16_t> : cpp::type_identity<uint8_t> {};
36template <> struct half_width<uint32_t> : cpp::type_identity<uint16_t> {};
37#ifdef LIBC_TYPES_HAS_INT64
38template <> struct half_width<uint64_t> : cpp::type_identity<uint32_t> {};
39#ifdef LIBC_TYPES_HAS_INT128
40template <> struct half_width<__uint128_t> : cpp::type_identity<uint64_t> {};
41#endif // LIBC_TYPES_HAS_INT128
42#endif // LIBC_TYPES_HAS_INT64
43template <typename T> using half_width_t = typename half_width<T>::type;
44
45// An array of two elements that can be used in multiword operations.
46template <typename T> struct DoubleWide final : cpp::array<T, 2> {
47 using UP = cpp::array<T, 2>;
48 using UP::UP;
49 LIBC_INLINE constexpr DoubleWide(T lo, T hi) : UP({lo, hi}) {}
50};
51
52// Converts an unsigned value into a DoubleWide<half_width_t<T>>.
53template <typename T> LIBC_INLINE constexpr auto split(T value) {
54 static_assert(cpp::is_unsigned_v<T>);
55 using half_type = half_width_t<T>;
56 return DoubleWide<half_type>(
57 half_type(value),
58 half_type(value >> cpp::numeric_limits<half_type>::digits));
59}
60
61// The low part of a DoubleWide value.
62template <typename T> LIBC_INLINE constexpr T lo(const DoubleWide<T> &value) {
63 return value[0];
64}
65// The high part of a DoubleWide value.
66template <typename T> LIBC_INLINE constexpr T hi(const DoubleWide<T> &value) {
67 return value[1];
68}
69// The low part of an unsigned value.
70template <typename T> LIBC_INLINE constexpr half_width_t<T> lo(T value) {
71 return lo(split(value));
72}
73// The high part of an unsigned value.
74template <typename T> LIBC_INLINE constexpr half_width_t<T> hi(T value) {
75 return hi(split(value));
76}
77
78// Returns 'a' times 'b' in a DoubleWide<word>. Cannot overflow by construction.
79template <typename word>
80LIBC_INLINE constexpr DoubleWide<word> mul2(word a, word b) {
81 if constexpr (cpp::is_same_v<word, uint8_t>) {
82 return split<uint16_t>(uint16_t(a) * uint16_t(b));
83 } else if constexpr (cpp::is_same_v<word, uint16_t>) {
84 return split<uint32_t>(uint32_t(a) * uint32_t(b));
85 }
86#ifdef LIBC_TYPES_HAS_INT64
87 else if constexpr (cpp::is_same_v<word, uint32_t>) {
88 return split<uint64_t>(uint64_t(a) * uint64_t(b));
89 }
90#endif
91#ifdef LIBC_TYPES_HAS_INT128
92 else if constexpr (cpp::is_same_v<word, uint64_t>) {
93 return split<__uint128_t>(__uint128_t(a) * __uint128_t(b));
94 }
95#endif
96 else {
97 using half_word = half_width_t<word>;
98 const auto shiftl = [](word value) -> word {
99 return value << cpp::numeric_limits<half_word>::digits;
100 };
101 const auto shiftr = [](word value) -> word {
102 return value >> cpp::numeric_limits<half_word>::digits;
103 };
104 // Here we do a one digit multiplication where 'a' and 'b' are of type
105 // word. We split 'a' and 'b' into half words and perform the classic long
106 // multiplication with 'a' and 'b' being two-digit numbers.
107
108 // a a_hi a_lo
109 // x b => x b_hi b_lo
110 // ---- -----------
111 // c result
112 // We convert 'lo' and 'hi' from 'half_word' to 'word' so multiplication
113 // doesn't overflow.
114 const word a_lo = lo(a);
115 const word b_lo = lo(b);
116 const word a_hi = hi(a);
117 const word b_hi = hi(b);
118 const word step1 = b_lo * a_lo; // no overflow;
119 const word step2 = b_lo * a_hi; // no overflow;
120 const word step3 = b_hi * a_lo; // no overflow;
121 const word step4 = b_hi * a_hi; // no overflow;
122 word lo_digit = step1;
123 word hi_digit = step4;
124 const word no_carry = 0;
125 word carry;
126 word _; // unused carry variable.
127 lo_digit = add_with_carry<word>(lo_digit, shiftl(step2), no_carry, carry);
128 hi_digit = add_with_carry<word>(hi_digit, shiftr(step2), carry, _);
129 lo_digit = add_with_carry<word>(lo_digit, shiftl(step3), no_carry, carry);
130 hi_digit = add_with_carry<word>(hi_digit, shiftr(step3), carry, _);
131 return DoubleWide<word>(lo_digit, hi_digit);
132 }
133}
134
135// In-place 'dst op= rhs' with operation with carry propagation. Returns carry.
136template <typename Function, typename word, size_t N, size_t M>
137LIBC_INLINE constexpr word inplace_binop(Function op_with_carry,
138 cpp::array<word, N> &dst,
139 const cpp::array<word, M> &rhs) {
140 static_assert(N >= M);
141 word carry_out = 0;
142 for (size_t i = 0; i < N; ++i) {
143 const bool has_rhs_value = i < M;
144 const word rhs_value = has_rhs_value ? rhs[i] : 0;
145 const word carry_in = carry_out;
146 dst[i] = op_with_carry(dst[i], rhs_value, carry_in, carry_out);
147 // stop early when rhs is over and no carry is to be propagated.
148 if (!has_rhs_value && carry_out == 0)
149 break;
150 }
151 return carry_out;
152}
153
154// In-place addition. Returns carry.
155template <typename word, size_t N, size_t M>
156LIBC_INLINE constexpr word add_with_carry(cpp::array<word, N> &dst,
157 const cpp::array<word, M> &rhs) {
158 return inplace_binop(LIBC_NAMESPACE::add_with_carry<word>, dst, rhs);
159}
160
161// In-place subtraction. Returns borrow.
162template <typename word, size_t N, size_t M>
163LIBC_INLINE constexpr word sub_with_borrow(cpp::array<word, N> &dst,
164 const cpp::array<word, M> &rhs) {
165 return inplace_binop(LIBC_NAMESPACE::sub_with_borrow<word>, dst, rhs);
166}
167
168// In-place multiply-add. Returns carry.
169// i.e., 'dst += b * c'
170template <typename word, size_t N>
171LIBC_INLINE constexpr word mul_add_with_carry(cpp::array<word, N> &dst, word b,
172 word c) {
173 return add_with_carry(dst, mul2(b, c));
174}
175
176// An array of two elements serving as an accumulator during multiword
177// computations.
178template <typename T> struct Accumulator final : cpp::array<T, 2> {
179 using UP = cpp::array<T, 2>;
180 LIBC_INLINE constexpr Accumulator() : UP({0, 0}) {}
181 LIBC_INLINE constexpr T advance(T carry_in) {
182 auto result = UP::front();
183 UP::front() = UP::back();
184 UP::back() = carry_in;
185 return result;
186 }
187 LIBC_INLINE constexpr T sum() const { return UP::front(); }
188 LIBC_INLINE constexpr T carry() const { return UP::back(); }
189};
190
191// In-place multiplication by a single word. Returns carry.
192template <typename word, size_t N>
193LIBC_INLINE constexpr word scalar_multiply_with_carry(cpp::array<word, N> &dst,
194 word x) {
195 Accumulator<word> acc;
196 for (auto &val : dst) {
197 const word carry = mul_add_with_carry(acc, val, x);
198 val = acc.advance(carry);
199 }
200 return acc.carry();
201}
202
203// Multiplication of 'lhs' by 'rhs' into 'dst'. Returns carry.
204// This function is safe to use for signed numbers.
205// https://stackoverflow.com/a/20793834
206// https://pages.cs.wisc.edu/%7Emarkhill/cs354/Fall2008/beyond354/int.mult.html
207template <typename word, size_t O, size_t M, size_t N>
208LIBC_INLINE constexpr word multiply_with_carry(cpp::array<word, O> &dst,
209 const cpp::array<word, M> &lhs,
210 const cpp::array<word, N> &rhs) {
211 static_assert(O >= M + N);
212 Accumulator<word> acc;
213 for (size_t i = 0; i < O; ++i) {
214 const size_t lower_idx = i < N ? 0 : i - N + 1;
215 const size_t upper_idx = i < M ? i : M - 1;
216 word carry = 0;
217 for (size_t j = lower_idx; j <= upper_idx; ++j)
218 carry += mul_add_with_carry(acc, lhs[j], rhs[i - j]);
219 dst[i] = acc.advance(carry);
220 }
221 return acc.carry();
222}
223
224template <typename word, size_t N>
225LIBC_INLINE constexpr void quick_mul_hi(cpp::array<word, N> &dst,
226 const cpp::array<word, N> &lhs,
227 const cpp::array<word, N> &rhs) {
228 Accumulator<word> acc;
229 word carry = 0;
230 // First round of accumulation for those at N - 1 in the full product.
231 for (size_t i = 0; i < N; ++i)
232 carry += mul_add_with_carry(acc, lhs[i], rhs[N - 1 - i]);
233 for (size_t i = N; i < 2 * N - 1; ++i) {
234 acc.advance(carry);
235 carry = 0;
236 for (size_t j = i - N + 1; j < N; ++j)
237 carry += mul_add_with_carry(acc, lhs[j], rhs[i - j]);
238 dst[i - N] = acc.sum();
239 }
240 dst.back() = acc.carry();
241}
242
243template <typename word, size_t N>
244LIBC_INLINE constexpr bool is_negative(cpp::array<word, N> &array) {
245 using signed_word = cpp::make_signed_t<word>;
246 return cpp::bit_cast<signed_word>(array.back()) < 0;
247}
248
249// An enum for the shift function below.
250enum Direction { LEFT, RIGHT };
251
252// A bitwise shift on an array of elements.
253// 'offset' must be less than TOTAL_BITS (i.e., sizeof(word) * CHAR_BIT * N)
254// otherwise the behavior is undefined.
255template <Direction direction, bool is_signed, typename word, size_t N>
256LIBC_INLINE constexpr cpp::array<word, N> shift(cpp::array<word, N> array,
257 size_t offset) {
258 static_assert(direction == LEFT || direction == RIGHT);
259 constexpr size_t WORD_BITS = cpp::numeric_limits<word>::digits;
260#ifdef LIBC_TYPES_HAS_INT128
261 constexpr size_t TOTAL_BITS = N * WORD_BITS;
262 if constexpr (TOTAL_BITS == 128) {
263 using type = cpp::conditional_t<is_signed, __int128_t, __uint128_t>;
264 auto tmp = cpp::bit_cast<type>(array);
265 if constexpr (direction == LEFT)
266 tmp <<= offset;
267 else
268 tmp >>= offset;
269 return cpp::bit_cast<cpp::array<word, N>>(tmp);
270 }
271#endif
272 if (LIBC_UNLIKELY(offset == 0))
273 return array;
274 const bool is_neg = is_signed && is_negative(array);
275 constexpr auto at = [](size_t index) -> int {
276 // reverse iteration when direction == LEFT.
277 if constexpr (direction == LEFT)
278 return int(N) - int(index) - 1;
279 return int(index);
280 };
281 const auto safe_get_at = [&](size_t index) -> word {
282 // return appropriate value when accessing out of bound elements.
283 const int i = at(index);
284 if (i < 0)
285 return 0;
286 if (i >= int(N))
287 return is_neg ? -1 : 0;
288 return array[i];
289 };
290 const size_t index_offset = offset / WORD_BITS;
291 const size_t bit_offset = offset % WORD_BITS;
292#ifdef LIBC_COMPILER_IS_CLANG
293 __builtin_assume(index_offset < N);
294#endif
295 cpp::array<word, N> out = {};
296 for (size_t index = 0; index < N; ++index) {
297 const word part1 = safe_get_at(index + index_offset);
298 const word part2 = safe_get_at(index + index_offset + 1);
299 word &dst = out[at(index)];
300 if (bit_offset == 0)
301 dst = part1; // no crosstalk between parts.
302 else if constexpr (direction == LEFT)
303 dst = static_cast<word>((part1 << bit_offset) |
304 (part2 >> (WORD_BITS - bit_offset)));
305 else
306 dst = static_cast<word>((part1 >> bit_offset) |
307 (part2 << (WORD_BITS - bit_offset)));
308 }
309 return out;
310}
311
312#define DECLARE_COUNTBIT(NAME, INDEX_EXPR) \
313 template <typename word, size_t N> \
314 LIBC_INLINE constexpr int NAME(const cpp::array<word, N> &val) { \
315 int bit_count = 0; \
316 for (size_t i = 0; i < N; ++i) { \
317 const int word_count = cpp::NAME<word>(val[INDEX_EXPR]); \
318 bit_count += word_count; \
319 if (word_count != cpp::numeric_limits<word>::digits) \
320 break; \
321 } \
322 return bit_count; \
323 }
324
325DECLARE_COUNTBIT(countr_zero, i) // iterating forward
326DECLARE_COUNTBIT(countr_one, i) // iterating forward
327DECLARE_COUNTBIT(countl_zero, N - i - 1) // iterating backward
328DECLARE_COUNTBIT(countl_one, N - i - 1) // iterating backward
329
330} // namespace multiword
331
332template <size_t Bits, bool Signed, typename WordType = uint64_t>
333struct BigInt {
334private:
335 static_assert(cpp::is_integral_v<WordType> && cpp::is_unsigned_v<WordType>,
336 "WordType must be unsigned integer.");
337
338 struct Division {
339 BigInt quotient;
340 BigInt remainder;
341 };
342
343public:
344 using word_type = WordType;
345 using unsigned_type = BigInt<Bits, false, word_type>;
346 using signed_type = BigInt<Bits, true, word_type>;
347
348 LIBC_INLINE_VAR static constexpr bool SIGNED = Signed;
349 LIBC_INLINE_VAR static constexpr size_t BITS = Bits;
350 LIBC_INLINE_VAR
351 static constexpr size_t WORD_SIZE = sizeof(WordType) * CHAR_BIT;
352
353 static_assert(Bits > 0 && Bits % WORD_SIZE == 0,
354 "Number of bits in BigInt should be a multiple of WORD_SIZE.");
355
356 LIBC_INLINE_VAR static constexpr size_t WORD_COUNT = Bits / WORD_SIZE;
357
358 cpp::array<WordType, WORD_COUNT> val{}; // zero initialized.
359
360 LIBC_INLINE constexpr BigInt() = default;
361
362 LIBC_INLINE constexpr BigInt(const BigInt &other) = default;
363
364 template <size_t OtherBits, bool OtherSigned, typename OtherWordType>
365 LIBC_INLINE constexpr BigInt(
366 const BigInt<OtherBits, OtherSigned, OtherWordType> &other) {
367 using BigIntOther = BigInt<OtherBits, OtherSigned, OtherWordType>;
368 const bool should_sign_extend = Signed && other.is_neg();
369
370 static_assert(!(Bits == OtherBits && WORD_SIZE != BigIntOther::WORD_SIZE) &&
371 "This is currently untested for casting between bigints with "
372 "the same bit width but different word sizes.");
373
374 if constexpr (BigIntOther::WORD_SIZE < WORD_SIZE) {
375 // OtherWordType is smaller
376 constexpr size_t WORD_SIZE_RATIO = WORD_SIZE / BigIntOther::WORD_SIZE;
377 static_assert(
378 (WORD_SIZE % BigIntOther::WORD_SIZE) == 0 &&
379 "Word types must be multiples of each other for correct conversion.");
380 if constexpr (OtherBits >= Bits) { // truncate
381 // for each big word
382 for (size_t i = 0; i < WORD_COUNT; ++i) {
383 WordType cur_word = 0;
384 // combine WORD_SIZE_RATIO small words into a big word
385 for (size_t j = 0; j < WORD_SIZE_RATIO; ++j)
386 cur_word |= static_cast<WordType>(other[(i * WORD_SIZE_RATIO) + j])
387 << (BigIntOther::WORD_SIZE * j);
388
389 val[i] = cur_word;
390 }
391 } else { // zero or sign extend
392 size_t i = 0;
393 WordType cur_word = 0;
394 // for each small word
395 for (; i < BigIntOther::WORD_COUNT; ++i) {
396 // combine WORD_SIZE_RATIO small words into a big word
397 cur_word |= static_cast<WordType>(other[i])
398 << (BigIntOther::WORD_SIZE * (i % WORD_SIZE_RATIO));
399 // if we've completed a big word, copy it into place and reset
400 if ((i % WORD_SIZE_RATIO) == WORD_SIZE_RATIO - 1) {
401 val[i / WORD_SIZE_RATIO] = cur_word;
402 cur_word = 0;
403 }
404 }
405 // Pretend there are extra words of the correct sign extension as needed
406
407 const WordType extension_bits =
408 should_sign_extend ? cpp::numeric_limits<WordType>::max()
409 : cpp::numeric_limits<WordType>::min();
410 if ((i % WORD_SIZE_RATIO) != 0) {
411 cur_word |= static_cast<WordType>(extension_bits)
412 << (BigIntOther::WORD_SIZE * (i % WORD_SIZE_RATIO));
413 }
414 // Copy the last word into place.
415 val[(i / WORD_SIZE_RATIO)] = cur_word;
416 extend((i / WORD_SIZE_RATIO) + 1, should_sign_extend);
417 }
418 } else if constexpr (BigIntOther::WORD_SIZE == WORD_SIZE) {
419 if constexpr (OtherBits >= Bits) { // truncate
420 for (size_t i = 0; i < WORD_COUNT; ++i)
421 val[i] = other[i];
422 } else { // zero or sign extend
423 size_t i = 0;
424 for (; i < BigIntOther::WORD_COUNT; ++i)
425 val[i] = other[i];
426 extend(i, should_sign_extend);
427 }
428 } else {
429 // OtherWordType is bigger.
430 constexpr size_t WORD_SIZE_RATIO = BigIntOther::WORD_SIZE / WORD_SIZE;
431 static_assert(
432 (BigIntOther::WORD_SIZE % WORD_SIZE) == 0 &&
433 "Word types must be multiples of each other for correct conversion.");
434 if constexpr (OtherBits >= Bits) { // truncate
435 // for each small word
436 for (size_t i = 0; i < WORD_COUNT; ++i) {
437 // split each big word into WORD_SIZE_RATIO small words
438 val[i] = static_cast<WordType>(other[i / WORD_SIZE_RATIO] >>
439 ((i % WORD_SIZE_RATIO) * WORD_SIZE));
440 }
441 } else { // zero or sign extend
442 size_t i = 0;
443 // for each big word
444 for (; i < BigIntOther::WORD_COUNT; ++i) {
445 // split each big word into WORD_SIZE_RATIO small words
446 for (size_t j = 0; j < WORD_SIZE_RATIO; ++j)
447 val[(i * WORD_SIZE_RATIO) + j] =
448 static_cast<WordType>(other[i] >> (j * WORD_SIZE));
449 }
450 extend(i * WORD_SIZE_RATIO, should_sign_extend);
451 }
452 }
453 }
454
455 // Construct a BigInt from a C array.
456 template <size_t N> LIBC_INLINE constexpr BigInt(const WordType (&nums)[N]) {
457 static_assert(N == WORD_COUNT);
458 for (size_t i = 0; i < WORD_COUNT; ++i)
459 val[i] = nums[i];
460 }
461
462 LIBC_INLINE constexpr explicit BigInt(
463 const cpp::array<WordType, WORD_COUNT> &words) {
464 val = words;
465 }
466
467 // Initialize the first word to |v| and the rest to 0.
468 template <typename T, typename = cpp::enable_if_t<cpp::is_integral_v<T> &&
469 !cpp::is_same_v<T, bool>>>
470 LIBC_INLINE constexpr BigInt(T v) {
471 constexpr size_t T_SIZE = sizeof(T) * CHAR_BIT;
472 const bool is_neg = v < 0;
473 for (size_t i = 0; i < WORD_COUNT; ++i) {
474 if (v == 0) {
475 extend(i, is_neg);
476 return;
477 }
478 val[i] = static_cast<WordType>(v);
479 if constexpr (T_SIZE > WORD_SIZE)
480 v >>= WORD_SIZE;
481 else
482 v = 0;
483 }
484 }
485 LIBC_INLINE constexpr BigInt &operator=(const BigInt &other) = default;
486
487 // constants
488 LIBC_INLINE static constexpr BigInt zero() { return BigInt(); }
489 LIBC_INLINE static constexpr BigInt one() { return BigInt(1); }
490 LIBC_INLINE static constexpr BigInt all_ones() { return ~zero(); }
491 LIBC_INLINE static constexpr BigInt min() {
492 BigInt out;
493 if constexpr (SIGNED)
494 out.set_msb();
495 return out;
496 }
497 LIBC_INLINE static constexpr BigInt max() {
498 BigInt out = all_ones();
499 if constexpr (SIGNED)
500 out.clear_msb();
501 return out;
502 }
503
504 // TODO: Reuse the Sign type.
505 LIBC_INLINE constexpr bool is_neg() const { return SIGNED && get_msb(); }
506
507 template <size_t OtherBits, bool OtherSigned, typename OtherWordType>
508 LIBC_INLINE constexpr explicit
509 operator BigInt<OtherBits, OtherSigned, OtherWordType>() const {
510 return BigInt<OtherBits, OtherSigned, OtherWordType>(this);
511 }
512
513 template <typename T> LIBC_INLINE constexpr explicit operator T() const {
514 return to<T>();
515 }
516
517 template <typename T>
518 LIBC_INLINE constexpr cpp::enable_if_t<
519 cpp::is_integral_v<T> && !cpp::is_same_v<T, bool>, T>
520 to() const {
521 constexpr size_t T_SIZE = sizeof(T) * CHAR_BIT;
522 T lo = static_cast<T>(val[0]);
523 if constexpr (T_SIZE <= WORD_SIZE)
524 return lo;
525 constexpr size_t MAX_COUNT =
526 T_SIZE > Bits ? WORD_COUNT : T_SIZE / WORD_SIZE;
527 for (size_t i = 1; i < MAX_COUNT; ++i)
528 lo += static_cast<T>(static_cast<T>(val[i]) << (WORD_SIZE * i));
529 if constexpr (Signed && (T_SIZE > Bits)) {
530 // Extend sign for negative numbers.
531 constexpr T MASK = (~T(0) << Bits);
532 if (is_neg())
533 lo |= MASK;
534 }
535 return lo;
536 }
537
538 LIBC_INLINE constexpr explicit operator bool() const { return !is_zero(); }
539
540 LIBC_INLINE constexpr bool is_zero() const {
541 for (auto part : val)
542 if (part != 0)
543 return false;
544 return true;
545 }
546
547 // Add 'rhs' to this number and store the result in this number.
548 // Returns the carry value produced by the addition operation.
549 LIBC_INLINE constexpr WordType add_overflow(const BigInt &rhs) {
550 return multiword::add_with_carry(val, rhs.val);
551 }
552
553 LIBC_INLINE constexpr BigInt operator+(const BigInt &other) const {
554 BigInt result = *this;
555 result.add_overflow(other);
556 return result;
557 }
558
559 // This will only apply when initializing a variable from constant values, so
560 // it will always use the constexpr version of add_with_carry.
561 LIBC_INLINE constexpr BigInt operator+(BigInt &&other) const {
562 // We use addition commutativity to reuse 'other' and prevent allocation.
563 other.add_overflow(*this); // Returned carry value is ignored.
564 return other;
565 }
566
567 LIBC_INLINE constexpr BigInt &operator+=(const BigInt &other) {
568 add_overflow(other); // Returned carry value is ignored.
569 return *this;
570 }
571
572 // Subtract 'rhs' to this number and store the result in this number.
573 // Returns the carry value produced by the subtraction operation.
574 LIBC_INLINE constexpr WordType sub_overflow(const BigInt &rhs) {
575 return multiword::sub_with_borrow(val, rhs.val);
576 }
577
578 LIBC_INLINE constexpr BigInt operator-(const BigInt &other) const {
579 BigInt result = *this;
580 result.sub_overflow(other); // Returned carry value is ignored.
581 return result;
582 }
583
584 LIBC_INLINE constexpr BigInt operator-(BigInt &&other) const {
585 BigInt result = *this;
586 result.sub_overflow(other); // Returned carry value is ignored.
587 return result;
588 }
589
590 LIBC_INLINE constexpr BigInt &operator-=(const BigInt &other) {
591 // TODO(lntue): Set overflow flag / errno when carry is true.
592 sub_overflow(other); // Returned carry value is ignored.
593 return *this;
594 }
595
596 // Multiply this number with x and store the result in this number.
597 LIBC_INLINE constexpr WordType mul(WordType x) {
598 return multiword::scalar_multiply_with_carry(val, x);
599 }
600
601 // Return the full product.
602 template <size_t OtherBits>
603 LIBC_INLINE constexpr auto
604 ful_mul(const BigInt<OtherBits, Signed, WordType> &other) const {
605 BigInt<Bits + OtherBits, Signed, WordType> result;
606 multiword::multiply_with_carry(result.val, val, other.val);
607 return result;
608 }
609
610 LIBC_INLINE constexpr BigInt operator*(const BigInt &other) const {
611 // Perform full mul and truncate.
612 return BigInt(ful_mul(other));
613 }
614
615 // Fast hi part of the full product. The normal product `operator*` returns
616 // `Bits` least significant bits of the full product, while this function will
617 // approximate `Bits` most significant bits of the full product with errors
618 // bounded by:
619 // 0 <= (a.full_mul(b) >> Bits) - a.quick_mul_hi(b)) <= WORD_COUNT - 1.
620 //
621 // An example usage of this is to quickly (but less accurately) compute the
622 // product of (normalized) mantissas of floating point numbers:
623 // (mant_1, mant_2) -> quick_mul_hi -> normalize leading bit
624 // is much more efficient than:
625 // (mant_1, mant_2) -> ful_mul -> normalize leading bit
626 // -> convert back to same Bits width by shifting/rounding,
627 // especially for higher precisions.
628 //
629 // Performance summary:
630 // Number of 64-bit x 64-bit -> 128-bit multiplications performed.
631 // Bits WORD_COUNT ful_mul quick_mul_hi Error bound
632 // 128 2 4 3 1
633 // 196 3 9 6 2
634 // 256 4 16 10 3
635 // 512 8 64 36 7
636 LIBC_INLINE constexpr BigInt quick_mul_hi(const BigInt &other) const {
637 BigInt result;
638 multiword::quick_mul_hi(result.val, val, other.val);
639 return result;
640 }
641
642 // BigInt(x).pow_n(n) computes x ^ n.
643 // Note 0 ^ 0 == 1.
644 LIBC_INLINE constexpr void pow_n(uint64_t power) {
645 static_assert(!Signed);
646 BigInt result = one();
647 BigInt cur_power = *this;
648 while (power > 0) {
649 if ((power % 2) > 0)
650 result *= cur_power;
651 power >>= 1;
652 cur_power *= cur_power;
653 }
654 *this = result;
655 }
656
657 // Performs inplace signed / unsigned division. Returns remainder if not
658 // dividing by zero.
659 // For signed numbers it behaves like C++ signed integer division.
660 // That is by truncating the fractionnal part
661 // https://stackoverflow.com/a/3602857
662 LIBC_INLINE constexpr cpp::optional<BigInt> div(const BigInt &divider) {
663 if (LIBC_UNLIKELY(divider.is_zero()))
664 return cpp::nullopt;
665 if (LIBC_UNLIKELY(divider == BigInt::one()))
666 return BigInt::zero();
667 Division result;
668 if constexpr (SIGNED)
669 result = divide_signed(*this, divider);
670 else
671 result = divide_unsigned(*this, divider);
672 *this = result.quotient;
673 return result.remainder;
674 }
675
676 // Efficiently perform BigInt / (x * 2^e), where x is a half-word-size
677 // unsigned integer, and return the remainder. The main idea is as follow:
678 // Let q = y / (x * 2^e) be the quotient, and
679 // r = y % (x * 2^e) be the remainder.
680 // First, notice that:
681 // r % (2^e) = y % (2^e),
682 // so we just need to focus on all the bits of y that is >= 2^e.
683 // To speed up the shift-and-add steps, we only use x as the divisor, and
684 // performing 32-bit shiftings instead of bit-by-bit shiftings.
685 // Since the remainder of each division step < x < 2^(WORD_SIZE / 2), the
686 // computation of each step is now properly contained within WordType.
687 // And finally we perform some extra alignment steps for the remaining bits.
688 LIBC_INLINE constexpr cpp::optional<BigInt>
689 div_uint_half_times_pow_2(multiword::half_width_t<WordType> x, size_t e) {
690 BigInt remainder;
691 if (x == 0)
692 return cpp::nullopt;
693 if (e >= Bits) {
694 remainder = *this;
695 *this = BigInt<Bits, false, WordType>();
696 return remainder;
697 }
698 BigInt quotient;
699 WordType x_word = static_cast<WordType>(x);
700 constexpr size_t LOG2_WORD_SIZE = cpp::bit_width(WORD_SIZE) - 1;
701 constexpr size_t HALF_WORD_SIZE = WORD_SIZE >> 1;
702 constexpr WordType HALF_MASK = ((WordType(1) << HALF_WORD_SIZE) - 1);
703 // lower = smallest multiple of WORD_SIZE that is >= e.
704 size_t lower = ((e >> LOG2_WORD_SIZE) + ((e & (WORD_SIZE - 1)) != 0))
705 << LOG2_WORD_SIZE;
706 // lower_pos is the index of the closest WORD_SIZE-bit chunk >= 2^e.
707 size_t lower_pos = lower / WORD_SIZE;
708 // Keep track of current remainder mod x * 2^(32*i)
709 WordType rem = 0;
710 // pos is the index of the current 64-bit chunk that we are processing.
711 size_t pos = WORD_COUNT;
712
713 // TODO: look into if constexpr(Bits > 256) skip leading zeroes.
714
715 for (size_t q_pos = WORD_COUNT - lower_pos; q_pos > 0; --q_pos) {
716 // q_pos is 1 + the index of the current WORD_SIZE-bit chunk of the
717 // quotient being processed. Performing the division / modulus with
718 // divisor:
719 // x * 2^(WORD_SIZE*q_pos - WORD_SIZE/2),
720 // i.e. using the upper (WORD_SIZE/2)-bit of the current WORD_SIZE-bit
721 // chunk.
722 rem <<= HALF_WORD_SIZE;
723 rem += val[--pos] >> HALF_WORD_SIZE;
724 WordType q_tmp = rem / x_word;
725 rem %= x_word;
726
727 // Performing the division / modulus with divisor:
728 // x * 2^(WORD_SIZE*(q_pos - 1)),
729 // i.e. using the lower (WORD_SIZE/2)-bit of the current WORD_SIZE-bit
730 // chunk.
731 rem <<= HALF_WORD_SIZE;
732 rem += val[pos] & HALF_MASK;
733 quotient.val[q_pos - 1] = (q_tmp << HALF_WORD_SIZE) + rem / x_word;
734 rem %= x_word;
735 }
736
737 // So far, what we have is:
738 // quotient = y / (x * 2^lower), and
739 // rem = (y % (x * 2^lower)) / 2^lower.
740 // If (lower > e), we will need to perform an extra adjustment of the
741 // quotient and remainder, namely:
742 // y / (x * 2^e) = [ y / (x * 2^lower) ] * 2^(lower - e) +
743 // + (rem * 2^(lower - e)) / x
744 // (y % (x * 2^e)) / 2^e = (rem * 2^(lower - e)) % x
745 size_t last_shift = lower - e;
746
747 if (last_shift > 0) {
748 // quotient * 2^(lower - e)
749 quotient <<= last_shift;
750 WordType q_tmp = 0;
751 WordType d = val[--pos];
752 if (last_shift >= HALF_WORD_SIZE) {
753 // The shifting (rem * 2^(lower - e)) might overflow WordTyoe, so we
754 // perform a HALF_WORD_SIZE-bit shift first.
755 rem <<= HALF_WORD_SIZE;
756 rem += d >> HALF_WORD_SIZE;
757 d &= HALF_MASK;
758 q_tmp = rem / x_word;
759 rem %= x_word;
760 last_shift -= HALF_WORD_SIZE;
761 } else {
762 // Only use the upper HALF_WORD_SIZE-bit of the current WORD_SIZE-bit
763 // chunk.
764 d >>= HALF_WORD_SIZE;
765 }
766
767 if (last_shift > 0) {
768 rem <<= HALF_WORD_SIZE;
769 rem += d;
770 q_tmp <<= last_shift;
771 x_word <<= HALF_WORD_SIZE - last_shift;
772 q_tmp += rem / x_word;
773 rem %= x_word;
774 }
775
776 quotient.val[0] += q_tmp;
777
778 if (lower - e <= HALF_WORD_SIZE) {
779 // The remainder rem * 2^(lower - e) might overflow to the higher
780 // WORD_SIZE-bit chunk.
781 if (pos < WORD_COUNT - 1) {
782 remainder[pos + 1] = rem >> HALF_WORD_SIZE;
783 }
784 remainder[pos] = (rem << HALF_WORD_SIZE) + (val[pos] & HALF_MASK);
785 } else {
786 remainder[pos] = rem;
787 }
788
789 } else {
790 remainder[pos] = rem;
791 }
792
793 // Set the remaining lower bits of the remainder.
794 for (; pos > 0; --pos) {
795 remainder[pos - 1] = val[pos - 1];
796 }
797
798 *this = quotient;
799 return remainder;
800 }
801
802 LIBC_INLINE constexpr BigInt operator/(const BigInt &other) const {
803 BigInt result(*this);
804 result.div(other);
805 return result;
806 }
807
808 LIBC_INLINE constexpr BigInt &operator/=(const BigInt &other) {
809 div(other);
810 return *this;
811 }
812
813 LIBC_INLINE constexpr BigInt operator%(const BigInt &other) const {
814 BigInt result(*this);
815 return *result.div(other);
816 }
817
818 LIBC_INLINE constexpr BigInt operator%=(const BigInt &other) {
819 *this = *this % other;
820 return *this;
821 }
822
823 LIBC_INLINE constexpr BigInt &operator*=(const BigInt &other) {
824 *this = *this * other;
825 return *this;
826 }
827
828 LIBC_INLINE constexpr BigInt &operator<<=(size_t s) {
829 val = multiword::shift<multiword::LEFT, SIGNED>(val, s);
830 return *this;
831 }
832
833 LIBC_INLINE constexpr BigInt operator<<(size_t s) const {
834 return BigInt(multiword::shift<multiword::LEFT, SIGNED>(val, s));
835 }
836
837 LIBC_INLINE constexpr BigInt &operator>>=(size_t s) {
838 val = multiword::shift<multiword::RIGHT, SIGNED>(val, s);
839 return *this;
840 }
841
842 LIBC_INLINE constexpr BigInt operator>>(size_t s) const {
843 return BigInt(multiword::shift<multiword::RIGHT, SIGNED>(val, s));
844 }
845
846#define DEFINE_BINOP(OP) \
847 LIBC_INLINE friend constexpr BigInt operator OP(const BigInt &lhs, \
848 const BigInt &rhs) { \
849 BigInt result; \
850 for (size_t i = 0; i < WORD_COUNT; ++i) \
851 result[i] = lhs[i] OP rhs[i]; \
852 return result; \
853 } \
854 LIBC_INLINE friend constexpr BigInt operator OP##=(BigInt &lhs, \
855 const BigInt &rhs) { \
856 for (size_t i = 0; i < WORD_COUNT; ++i) \
857 lhs[i] OP## = rhs[i]; \
858 return lhs; \
859 }
860
861 DEFINE_BINOP(&) // & and &=
862 DEFINE_BINOP(|) // | and |=
863 DEFINE_BINOP(^) // ^ and ^=
864#undef DEFINE_BINOP
865
866 LIBC_INLINE constexpr BigInt operator~() const {
867 BigInt result;
868 for (size_t i = 0; i < WORD_COUNT; ++i)
869 result[i] = ~val[i];
870 return result;
871 }
872
873 LIBC_INLINE constexpr BigInt operator-() const {
874 BigInt result(*this);
875 result.negate();
876 return result;
877 }
878
879 LIBC_INLINE friend constexpr bool operator==(const BigInt &lhs,
880 const BigInt &rhs) {
881 for (size_t i = 0; i < WORD_COUNT; ++i)
882 if (lhs.val[i] != rhs.val[i])
883 return false;
884 return true;
885 }
886
887 LIBC_INLINE friend constexpr bool operator!=(const BigInt &lhs,
888 const BigInt &rhs) {
889 return !(lhs == rhs);
890 }
891
892 LIBC_INLINE friend constexpr bool operator>(const BigInt &lhs,
893 const BigInt &rhs) {
894 return cmp(lhs, rhs) > 0;
895 }
896 LIBC_INLINE friend constexpr bool operator>=(const BigInt &lhs,
897 const BigInt &rhs) {
898 return cmp(lhs, rhs) >= 0;
899 }
900 LIBC_INLINE friend constexpr bool operator<(const BigInt &lhs,
901 const BigInt &rhs) {
902 return cmp(lhs, rhs) < 0;
903 }
904 LIBC_INLINE friend constexpr bool operator<=(const BigInt &lhs,
905 const BigInt &rhs) {
906 return cmp(lhs, rhs) <= 0;
907 }
908
909 LIBC_INLINE constexpr BigInt &operator++() {
910 increment();
911 return *this;
912 }
913
914 LIBC_INLINE constexpr BigInt operator++(int) {
915 BigInt oldval(*this);
916 increment();
917 return oldval;
918 }
919
920 LIBC_INLINE constexpr BigInt &operator--() {
921 decrement();
922 return *this;
923 }
924
925 LIBC_INLINE constexpr BigInt operator--(int) {
926 BigInt oldval(*this);
927 decrement();
928 return oldval;
929 }
930
931 // Return the i-th word of the number.
932 LIBC_INLINE constexpr const WordType &operator[](size_t i) const {
933 return val[i];
934 }
935
936 // Return the i-th word of the number.
937 LIBC_INLINE constexpr WordType &operator[](size_t i) { return val[i]; }
938
939private:
940 LIBC_INLINE friend constexpr int cmp(const BigInt &lhs, const BigInt &rhs) {
941 constexpr auto compare = [](WordType a, WordType b) {
942 return a == b ? 0 : a > b ? 1 : -1;
943 };
944 if constexpr (Signed) {
945 const bool lhs_is_neg = lhs.is_neg();
946 const bool rhs_is_neg = rhs.is_neg();
947 if (lhs_is_neg != rhs_is_neg)
948 return rhs_is_neg ? 1 : -1;
949 }
950 for (size_t i = WORD_COUNT; i-- > 0;)
951 if (auto cmp = compare(lhs[i], rhs[i]); cmp != 0)
952 return cmp;
953 return 0;
954 }
955
956 LIBC_INLINE constexpr void bitwise_not() {
957 for (auto &part : val)
958 part = ~part;
959 }
960
961 LIBC_INLINE constexpr void negate() {
962 bitwise_not();
963 increment();
964 }
965
966 LIBC_INLINE constexpr void increment() {
967 multiword::add_with_carry(val, cpp::array<WordType, 1>{1});
968 }
969
970 LIBC_INLINE constexpr void decrement() {
971 multiword::add_with_carry(val, cpp::array<WordType, 1>{1});
972 }
973
974 LIBC_INLINE constexpr void extend(size_t index, bool is_neg) {
975 const WordType value = is_neg ? cpp::numeric_limits<WordType>::max()
976 : cpp::numeric_limits<WordType>::min();
977 for (size_t i = index; i < WORD_COUNT; ++i)
978 val[i] = value;
979 }
980
981 LIBC_INLINE constexpr bool get_msb() const {
982 return val.back() >> (WORD_SIZE - 1);
983 }
984
985 LIBC_INLINE constexpr void set_msb() {
986 val.back() |= mask_leading_ones<WordType, 1>();
987 }
988
989 LIBC_INLINE constexpr void clear_msb() {
990 val.back() &= mask_trailing_ones<WordType, WORD_SIZE - 1>();
991 }
992
993 LIBC_INLINE constexpr void set_bit(size_t i) {
994 const size_t word_index = i / WORD_SIZE;
995 val[word_index] |= WordType(1) << (i % WORD_SIZE);
996 }
997
998 LIBC_INLINE constexpr static Division divide_unsigned(const BigInt &dividend,
999 const BigInt &divider) {
1000 BigInt remainder = dividend;
1001 BigInt quotient;
1002 if (remainder >= divider) {
1003 BigInt subtractor = divider;
1004 int cur_bit = multiword::countl_zero(subtractor.val) -
1005 multiword::countl_zero(remainder.val);
1006 subtractor <<= cur_bit;
1007 for (; cur_bit >= 0 && remainder > 0; --cur_bit, subtractor >>= 1) {
1008 if (remainder < subtractor)
1009 continue;
1010 remainder -= subtractor;
1011 quotient.set_bit(cur_bit);
1012 }
1013 }
1014 return Division{quotient, remainder};
1015 }
1016
1017 LIBC_INLINE constexpr static Division divide_signed(const BigInt &dividend,
1018 const BigInt &divider) {
1019 // Special case because it is not possible to negate the min value of a
1020 // signed integer.
1021 if (dividend == min() && divider == min())
1022 return Division{one(), zero()};
1023 // 1. Convert the dividend and divisor to unsigned representation.
1024 unsigned_type udividend(dividend);
1025 unsigned_type udivider(divider);
1026 // 2. Negate the dividend if it's negative, and similarly for the divisor.
1027 const bool dividend_is_neg = dividend.is_neg();
1028 const bool divider_is_neg = divider.is_neg();
1029 if (dividend_is_neg)
1030 udividend.negate();
1031 if (divider_is_neg)
1032 udivider.negate();
1033 // 3. Use unsigned multiword division algorithm.
1034 const auto unsigned_result = divide_unsigned(udividend, udivider);
1035 // 4. Convert the quotient and remainder to signed representation.
1036 Division result;
1037 result.quotient = signed_type(unsigned_result.quotient);
1038 result.remainder = signed_type(unsigned_result.remainder);
1039 // 5. Negate the quotient if the dividend and divisor had opposite signs.
1040 if (dividend_is_neg != divider_is_neg)
1041 result.quotient.negate();
1042 // 6. Negate the remainder if the dividend was negative.
1043 if (dividend_is_neg)
1044 result.remainder.negate();
1045 return result;
1046 }
1047
1048 friend signed_type;
1049 friend unsigned_type;
1050};
1051
1052namespace internal {
1053// We default BigInt's WordType to 'uint64_t' or 'uint32_t' depending on type
1054// availability.
1055template <size_t Bits>
1056struct WordTypeSelector : cpp::type_identity<
1057#ifdef LIBC_TYPES_HAS_INT64
1058 uint64_t
1059#else
1060 uint32_t
1061#endif // LIBC_TYPES_HAS_INT64
1062 > {
1063};
1064// Except if we request 16 or 32 bits explicitly.
1065template <> struct WordTypeSelector<16> : cpp::type_identity<uint16_t> {};
1066template <> struct WordTypeSelector<32> : cpp::type_identity<uint32_t> {};
1067template <> struct WordTypeSelector<96> : cpp::type_identity<uint32_t> {};
1068
1069template <size_t Bits>
1070using WordTypeSelectorT = typename WordTypeSelector<Bits>::type;
1071} // namespace internal
1072
1073template <size_t Bits>
1074using UInt = BigInt<Bits, false, internal::WordTypeSelectorT<Bits>>;
1075
1076template <size_t Bits>
1077using Int = BigInt<Bits, true, internal::WordTypeSelectorT<Bits>>;
1078
1079// Provides limits of BigInt.
1080template <size_t Bits, bool Signed, typename T>
1081struct cpp::numeric_limits<BigInt<Bits, Signed, T>> {
1082 LIBC_INLINE static constexpr BigInt<Bits, Signed, T> max() {
1083 return BigInt<Bits, Signed, T>::max();
1084 }
1085 LIBC_INLINE static constexpr BigInt<Bits, Signed, T> min() {
1086 return BigInt<Bits, Signed, T>::min();
1087 }
1088 // Meant to match std::numeric_limits interface.
1089 // NOLINTNEXTLINE(readability-identifier-naming)
1090 LIBC_INLINE_VAR static constexpr int digits = Bits - Signed;
1091};
1092
1093// type traits to determine whether a T is a BigInt.
1094template <typename T> struct is_big_int : cpp::false_type {};
1095
1096template <size_t Bits, bool Signed, typename T>
1097struct is_big_int<BigInt<Bits, Signed, T>> : cpp::true_type {};
1098
1099template <class T>
1100LIBC_INLINE_VAR constexpr bool is_big_int_v = is_big_int<T>::value;
1101
1102// extensions of type traits to include BigInt
1103
1104// is_integral_or_big_int
1105template <typename T>
1106struct is_integral_or_big_int
1107 : cpp::bool_constant<(cpp::is_integral_v<T> || is_big_int_v<T>)> {};
1108
1109template <typename T>
1110LIBC_INLINE_VAR constexpr bool is_integral_or_big_int_v =
1111 is_integral_or_big_int<T>::value;
1112
1113// make_big_int_unsigned
1114template <typename T> struct make_big_int_unsigned;
1115
1116template <size_t Bits, bool Signed, typename T>
1117struct make_big_int_unsigned<BigInt<Bits, Signed, T>>
1118 : cpp::type_identity<BigInt<Bits, false, T>> {};
1119
1120template <typename T>
1121using make_big_int_unsigned_t = typename make_big_int_unsigned<T>::type;
1122
1123// make_big_int_signed
1124template <typename T> struct make_big_int_signed;
1125
1126template <size_t Bits, bool Signed, typename T>
1127struct make_big_int_signed<BigInt<Bits, Signed, T>>
1128 : cpp::type_identity<BigInt<Bits, true, T>> {};
1129
1130template <typename T>
1131using make_big_int_signed_t = typename make_big_int_signed<T>::type;
1132
1133// make_integral_or_big_int_unsigned
1134template <typename T, class = void> struct make_integral_or_big_int_unsigned;
1135
1136template <typename T>
1137struct make_integral_or_big_int_unsigned<
1138 T, cpp::enable_if_t<cpp::is_integral_v<T>>> : cpp::make_unsigned<T> {};
1139
1140template <typename T>
1141struct make_integral_or_big_int_unsigned<T, cpp::enable_if_t<is_big_int_v<T>>>
1142 : make_big_int_unsigned<T> {};
1143
1144template <typename T>
1145using make_integral_or_big_int_unsigned_t =
1146 typename make_integral_or_big_int_unsigned<T>::type;
1147
1148// make_integral_or_big_int_signed
1149template <typename T, class = void> struct make_integral_or_big_int_signed;
1150
1151template <typename T>
1152struct make_integral_or_big_int_signed<T,
1153 cpp::enable_if_t<cpp::is_integral_v<T>>>
1154 : cpp::make_signed<T> {};
1155
1156template <typename T>
1157struct make_integral_or_big_int_signed<T, cpp::enable_if_t<is_big_int_v<T>>>
1158 : make_big_int_signed<T> {};
1159
1160template <typename T>
1161using make_integral_or_big_int_signed_t =
1162 typename make_integral_or_big_int_signed<T>::type;
1163
1164// is_unsigned_integral_or_big_int
1165template <typename T>
1166struct is_unsigned_integral_or_big_int
1167 : cpp::bool_constant<
1168 cpp::is_same_v<T, make_integral_or_big_int_unsigned_t<T>>> {};
1169
1170template <typename T>
1171// Meant to look like <type_traits> helper variable templates.
1172// NOLINTNEXTLINE(readability-identifier-naming)
1173LIBC_INLINE_VAR constexpr bool is_unsigned_integral_or_big_int_v =
1174 is_unsigned_integral_or_big_int<T>::value;
1175
1176namespace cpp {
1177
1178// Specialization of cpp::bit_cast ('bit.h') from T to BigInt.
1179template <typename To, typename From>
1180LIBC_INLINE constexpr cpp::enable_if_t<
1181 (sizeof(To) == sizeof(From)) && cpp::is_trivially_copyable<To>::value &&
1182 cpp::is_trivially_copyable<From>::value && is_big_int<To>::value,
1183 To>
1184bit_cast(const From &from) {
1185 To out;
1186 using Storage = decltype(out.val);
1187 out.val = cpp::bit_cast<Storage>(from);
1188 return out;
1189}
1190
1191// Specialization of cpp::bit_cast ('bit.h') from BigInt to T.
1192template <typename To, size_t Bits>
1193LIBC_INLINE constexpr cpp::enable_if_t<
1194 sizeof(To) == sizeof(UInt<Bits>) &&
1195 cpp::is_trivially_constructible<To>::value &&
1196 cpp::is_trivially_copyable<To>::value &&
1197 cpp::is_trivially_copyable<UInt<Bits>>::value,
1198 To>
1199bit_cast(const UInt<Bits> &from) {
1200 return cpp::bit_cast<To>(from.val);
1201}
1202
1203// Specialization of cpp::popcount ('bit.h') for BigInt.
1204template <typename T>
1205[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
1206popcount(T value) {
1207 int bits = 0;
1208 for (auto word : value.val)
1209 if (word)
1210 bits += popcount(word);
1211 return bits;
1212}
1213
1214// Specialization of cpp::has_single_bit ('bit.h') for BigInt.
1215template <typename T>
1216[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, bool>
1217has_single_bit(T value) {
1218 int bits = 0;
1219 for (auto word : value.val) {
1220 if (word == 0)
1221 continue;
1222 bits += popcount(word);
1223 if (bits > 1)
1224 return false;
1225 }
1226 return bits == 1;
1227}
1228
1229// Specialization of cpp::countr_zero ('bit.h') for BigInt.
1230template <typename T>
1231[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
1232countr_zero(const T &value) {
1233 return multiword::countr_zero(value.val);
1234}
1235
1236// Specialization of cpp::countl_zero ('bit.h') for BigInt.
1237template <typename T>
1238[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
1239countl_zero(const T &value) {
1240 return multiword::countl_zero(value.val);
1241}
1242
1243// Specialization of cpp::countl_one ('bit.h') for BigInt.
1244template <typename T>
1245[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
1246countl_one(T value) {
1247 return multiword::countl_one(value.val);
1248}
1249
1250// Specialization of cpp::countr_one ('bit.h') for BigInt.
1251template <typename T>
1252[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
1253countr_one(T value) {
1254 return multiword::countr_one(value.val);
1255}
1256
1257// Specialization of cpp::bit_width ('bit.h') for BigInt.
1258template <typename T>
1259[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
1260bit_width(T value) {
1261 return cpp::numeric_limits<T>::digits - cpp::countl_zero(value);
1262}
1263
1264// Forward-declare rotr so that rotl can use it.
1265template <typename T>
1266[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
1267rotr(T value, int rotate);
1268
1269// Specialization of cpp::rotl ('bit.h') for BigInt.
1270template <typename T>
1271[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
1272rotl(T value, int rotate) {
1273 constexpr unsigned N = cpp::numeric_limits<T>::digits;
1274 rotate = rotate % N;
1275 if (!rotate)
1276 return value;
1277 if (rotate < 0)
1278 return cpp::rotr<T>(value, -rotate);
1279 return (value << rotate) | (value >> (N - rotate));
1280}
1281
1282// Specialization of cpp::rotr ('bit.h') for BigInt.
1283template <typename T>
1284[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
1285rotr(T value, int rotate) {
1286 constexpr unsigned N = cpp::numeric_limits<T>::digits;
1287 rotate = rotate % N;
1288 if (!rotate)
1289 return value;
1290 if (rotate < 0)
1291 return cpp::rotl<T>(value, -rotate);
1292 return (value >> rotate) | (value << (N - rotate));
1293}
1294
1295} // namespace cpp
1296
1297// Specialization of mask_trailing_ones ('math_extras.h') for BigInt.
1298template <typename T, size_t count>
1299LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
1300mask_trailing_ones() {
1301 static_assert(!T::SIGNED && count <= T::BITS);
1302 if (count == T::BITS)
1303 return T::all_ones();
1304 constexpr size_t QUOTIENT = count / T::WORD_SIZE;
1305 constexpr size_t REMAINDER = count % T::WORD_SIZE;
1306 T out; // zero initialized
1307 for (size_t i = 0; i <= QUOTIENT; ++i)
1308 out[i] = i < QUOTIENT
1309 ? -1
1310 : mask_trailing_ones<typename T::word_type, REMAINDER>();
1311 return out;
1312}
1313
1314// Specialization of mask_leading_ones ('math_extras.h') for BigInt.
1315template <typename T, size_t count>
1316LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T> mask_leading_ones() {
1317 static_assert(!T::SIGNED && count <= T::BITS);
1318 if (count == T::BITS)
1319 return T::all_ones();
1320 constexpr size_t QUOTIENT = (T::BITS - count - 1U) / T::WORD_SIZE;
1321 constexpr size_t REMAINDER = count % T::WORD_SIZE;
1322 T out; // zero initialized
1323 for (size_t i = QUOTIENT; i < T::WORD_COUNT; ++i)
1324 out[i] = i > QUOTIENT
1325 ? -1
1326 : mask_leading_ones<typename T::word_type, REMAINDER>();
1327 return out;
1328}
1329
1330// Specialization of mask_trailing_zeros ('math_extras.h') for BigInt.
1331template <typename T, size_t count>
1332LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
1333mask_trailing_zeros() {
1334 return mask_leading_ones<T, T::BITS - count>();
1335}
1336
1337// Specialization of mask_leading_zeros ('math_extras.h') for BigInt.
1338template <typename T, size_t count>
1339LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
1340mask_leading_zeros() {
1341 return mask_trailing_ones<T, T::BITS - count>();
1342}
1343
1344// Specialization of count_zeros ('math_extras.h') for BigInt.
1345template <typename T>
1346[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
1347count_zeros(T value) {
1348 return cpp::popcount(~value);
1349}
1350
1351// Specialization of first_leading_zero ('math_extras.h') for BigInt.
1352template <typename T>
1353[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
1354first_leading_zero(T value) {
1355 return value == cpp::numeric_limits<T>::max() ? 0
1356 : cpp::countl_one(value) + 1;
1357}
1358
1359// Specialization of first_leading_one ('math_extras.h') for BigInt.
1360template <typename T>
1361[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
1362first_leading_one(T value) {
1363 return first_leading_zero(~value);
1364}
1365
1366// Specialization of first_trailing_zero ('math_extras.h') for BigInt.
1367template <typename T>
1368[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
1369first_trailing_zero(T value) {
1370 return value == cpp::numeric_limits<T>::max() ? 0
1371 : cpp::countr_zero(~value) + 1;
1372}
1373
1374// Specialization of first_trailing_one ('math_extras.h') for BigInt.
1375template <typename T>
1376[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
1377first_trailing_one(T value) {
1378 return value == cpp::numeric_limits<T>::max() ? 0
1379 : cpp::countr_zero(value) + 1;
1380}
1381
1382} // namespace LIBC_NAMESPACE_DECL
1383
1384#endif // LLVM_LIBC_SRC___SUPPORT_BIG_INT_H
lib/libcxx/libc/src/__support/common.h created+82
...@@ -0,0 +1,82 @@
1//===-- Common internal contructs -------------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_COMMON_H
10#define LLVM_LIBC_SRC___SUPPORT_COMMON_H
11
12#ifndef LIBC_NAMESPACE
13#error "LIBC_NAMESPACE macro is not defined."
14#endif
15
16#include "src/__support/macros/attributes.h"
17#include "src/__support/macros/config.h"
18#include "src/__support/macros/properties/architectures.h"
19
20#ifndef LLVM_LIBC_FUNCTION_ATTR
21#define LLVM_LIBC_FUNCTION_ATTR
22#endif
23
24// clang-format off
25// Allow each function `func` to have extra attributes specified by defining:
26// `LLVM_LIBC_FUNCTION_ATTR_func` macro, which should always start with
27// "LLVM_LIBC_EMPTY, "
28//
29// For examples:
30// #define LLVM_LIBC_FUNCTION_ATTR_memcpy LLVM_LIBC_EMPTY, [[gnu::weak]]
31// #define LLVM_LIBC_FUNCTION_ATTR_memchr LLVM_LIBC_EMPTY, [[gnu::weak]] [[gnu::visibility("default")]]
32// clang-format on
33#define LLVM_LIBC_EMPTY
34
35#define GET_SECOND(first, second, ...) second
36#define EXPAND_THEN_SECOND(name) GET_SECOND(name, LLVM_LIBC_EMPTY)
37
38#define LLVM_LIBC_ATTR(name) EXPAND_THEN_SECOND(LLVM_LIBC_FUNCTION_ATTR_##name)
39
40// MacOS needs to be excluded because it does not support aliasing.
41#if defined(LIBC_COPT_PUBLIC_PACKAGING) && (!defined(__APPLE__))
42#define LLVM_LIBC_FUNCTION_IMPL(type, name, arglist) \
43 LLVM_LIBC_ATTR(name) \
44 LLVM_LIBC_FUNCTION_ATTR decltype(LIBC_NAMESPACE::name) \
45 __##name##_impl__ __asm__(#name); \
46 decltype(LIBC_NAMESPACE::name) name [[gnu::alias(#name)]]; \
47 type __##name##_impl__ arglist
48#else
49#define LLVM_LIBC_FUNCTION_IMPL(type, name, arglist) type name arglist
50#endif
51
52// This extra layer of macro allows `name` to be a macro to rename a function.
53#define LLVM_LIBC_FUNCTION(type, name, arglist) \
54 LLVM_LIBC_FUNCTION_IMPL(type, name, arglist)
55
56namespace LIBC_NAMESPACE_DECL {
57namespace internal {
58LIBC_INLINE constexpr bool same_string(char const *lhs, char const *rhs) {
59 for (; *lhs || *rhs; ++lhs, ++rhs)
60 if (*lhs != *rhs)
61 return false;
62 return true;
63}
64} // namespace internal
65} // namespace LIBC_NAMESPACE_DECL
66
67#define __LIBC_MACRO_TO_STRING(str) #str
68#define LIBC_MACRO_TO_STRING(str) __LIBC_MACRO_TO_STRING(str)
69
70// LLVM_LIBC_IS_DEFINED checks whether a particular macro is defined.
71// Usage: constexpr bool kUseAvx = LLVM_LIBC_IS_DEFINED(__AVX__);
72//
73// This works by comparing the stringified version of the macro with and without
74// evaluation. If FOO is not undefined both stringifications yield "FOO". If FOO
75// is defined, one stringification yields "FOO" while the other yields its
76// stringified value "1".
77#define LLVM_LIBC_IS_DEFINED(macro) \
78 !LIBC_NAMESPACE::internal::same_string( \
79 LLVM_LIBC_IS_DEFINED__EVAL_AND_STRINGIZE(macro), #macro)
80#define LLVM_LIBC_IS_DEFINED__EVAL_AND_STRINGIZE(s) #s
81
82#endif // LLVM_LIBC_SRC___SUPPORT_COMMON_H
lib/libcxx/libc/src/__support/ctype_utils.h created+584
...@@ -0,0 +1,584 @@
1//===-- Collection of utils for implementing ctype functions-------*-C++-*-===//
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 LLVM_LIBC_SRC___SUPPORT_CTYPE_UTILS_H
10#define LLVM_LIBC_SRC___SUPPORT_CTYPE_UTILS_H
11
12#include "src/__support/macros/attributes.h"
13#include "src/__support/macros/config.h"
14
15namespace LIBC_NAMESPACE_DECL {
16namespace internal {
17
18// -----------------------------------------------------------------------------
19// ****************** WARNING ******************
20// ****************** DO NOT TRY TO OPTIMIZE THESE FUNCTIONS! ******************
21// -----------------------------------------------------------------------------
22// This switch/case form is easier for the compiler to understand, and is
23// optimized into a form that is almost always the same as or better than
24// versions written by hand (see https://godbolt.org/z/qvrebqvvr). Also this
25// form makes these functions encoding independent. If you want to rewrite these
26// functions, make sure you have benchmarks to show your new solution is faster,
27// as well as a way to support non-ASCII character encodings.
28
29// Similarly, do not change these functions to use case ranges. e.g.
30// bool islower(int ch) {
31// switch(ch) {
32// case 'a'...'z':
33// return true;
34// }
35// }
36// This assumes the character ranges are contiguous, which they aren't in
37// EBCDIC. Technically we could use some smaller ranges, but that's even harder
38// to read.
39
40LIBC_INLINE static constexpr bool islower(int ch) {
41 switch (ch) {
42 case 'a':
43 case 'b':
44 case 'c':
45 case 'd':
46 case 'e':
47 case 'f':
48 case 'g':
49 case 'h':
50 case 'i':
51 case 'j':
52 case 'k':
53 case 'l':
54 case 'm':
55 case 'n':
56 case 'o':
57 case 'p':
58 case 'q':
59 case 'r':
60 case 's':
61 case 't':
62 case 'u':
63 case 'v':
64 case 'w':
65 case 'x':
66 case 'y':
67 case 'z':
68 return true;
69 default:
70 return false;
71 }
72}
73
74LIBC_INLINE static constexpr bool isupper(int ch) {
75 switch (ch) {
76 case 'A':
77 case 'B':
78 case 'C':
79 case 'D':
80 case 'E':
81 case 'F':
82 case 'G':
83 case 'H':
84 case 'I':
85 case 'J':
86 case 'K':
87 case 'L':
88 case 'M':
89 case 'N':
90 case 'O':
91 case 'P':
92 case 'Q':
93 case 'R':
94 case 'S':
95 case 'T':
96 case 'U':
97 case 'V':
98 case 'W':
99 case 'X':
100 case 'Y':
101 case 'Z':
102 return true;
103 default:
104 return false;
105 }
106}
107
108LIBC_INLINE static constexpr bool isdigit(int ch) {
109 switch (ch) {
110 case '0':
111 case '1':
112 case '2':
113 case '3':
114 case '4':
115 case '5':
116 case '6':
117 case '7':
118 case '8':
119 case '9':
120 return true;
121 default:
122 return false;
123 }
124}
125
126LIBC_INLINE static constexpr int tolower(int ch) {
127 switch (ch) {
128 case 'A':
129 return 'a';
130 case 'B':
131 return 'b';
132 case 'C':
133 return 'c';
134 case 'D':
135 return 'd';
136 case 'E':
137 return 'e';
138 case 'F':
139 return 'f';
140 case 'G':
141 return 'g';
142 case 'H':
143 return 'h';
144 case 'I':
145 return 'i';
146 case 'J':
147 return 'j';
148 case 'K':
149 return 'k';
150 case 'L':
151 return 'l';
152 case 'M':
153 return 'm';
154 case 'N':
155 return 'n';
156 case 'O':
157 return 'o';
158 case 'P':
159 return 'p';
160 case 'Q':
161 return 'q';
162 case 'R':
163 return 'r';
164 case 'S':
165 return 's';
166 case 'T':
167 return 't';
168 case 'U':
169 return 'u';
170 case 'V':
171 return 'v';
172 case 'W':
173 return 'w';
174 case 'X':
175 return 'x';
176 case 'Y':
177 return 'y';
178 case 'Z':
179 return 'z';
180 default:
181 return ch;
182 }
183}
184
185LIBC_INLINE static constexpr int toupper(int ch) {
186 switch (ch) {
187 case 'a':
188 return 'A';
189 case 'b':
190 return 'B';
191 case 'c':
192 return 'C';
193 case 'd':
194 return 'D';
195 case 'e':
196 return 'E';
197 case 'f':
198 return 'F';
199 case 'g':
200 return 'G';
201 case 'h':
202 return 'H';
203 case 'i':
204 return 'I';
205 case 'j':
206 return 'J';
207 case 'k':
208 return 'K';
209 case 'l':
210 return 'L';
211 case 'm':
212 return 'M';
213 case 'n':
214 return 'N';
215 case 'o':
216 return 'O';
217 case 'p':
218 return 'P';
219 case 'q':
220 return 'Q';
221 case 'r':
222 return 'R';
223 case 's':
224 return 'S';
225 case 't':
226 return 'T';
227 case 'u':
228 return 'U';
229 case 'v':
230 return 'V';
231 case 'w':
232 return 'W';
233 case 'x':
234 return 'X';
235 case 'y':
236 return 'Y';
237 case 'z':
238 return 'Z';
239 default:
240 return ch;
241 }
242}
243
244LIBC_INLINE static constexpr bool isalpha(int ch) {
245 switch (ch) {
246 case 'a':
247 case 'b':
248 case 'c':
249 case 'd':
250 case 'e':
251 case 'f':
252 case 'g':
253 case 'h':
254 case 'i':
255 case 'j':
256 case 'k':
257 case 'l':
258 case 'm':
259 case 'n':
260 case 'o':
261 case 'p':
262 case 'q':
263 case 'r':
264 case 's':
265 case 't':
266 case 'u':
267 case 'v':
268 case 'w':
269 case 'x':
270 case 'y':
271 case 'z':
272 case 'A':
273 case 'B':
274 case 'C':
275 case 'D':
276 case 'E':
277 case 'F':
278 case 'G':
279 case 'H':
280 case 'I':
281 case 'J':
282 case 'K':
283 case 'L':
284 case 'M':
285 case 'N':
286 case 'O':
287 case 'P':
288 case 'Q':
289 case 'R':
290 case 'S':
291 case 'T':
292 case 'U':
293 case 'V':
294 case 'W':
295 case 'X':
296 case 'Y':
297 case 'Z':
298 return true;
299 default:
300 return false;
301 }
302}
303
304LIBC_INLINE static constexpr bool isalnum(int ch) {
305 switch (ch) {
306 case 'a':
307 case 'b':
308 case 'c':
309 case 'd':
310 case 'e':
311 case 'f':
312 case 'g':
313 case 'h':
314 case 'i':
315 case 'j':
316 case 'k':
317 case 'l':
318 case 'm':
319 case 'n':
320 case 'o':
321 case 'p':
322 case 'q':
323 case 'r':
324 case 's':
325 case 't':
326 case 'u':
327 case 'v':
328 case 'w':
329 case 'x':
330 case 'y':
331 case 'z':
332 case 'A':
333 case 'B':
334 case 'C':
335 case 'D':
336 case 'E':
337 case 'F':
338 case 'G':
339 case 'H':
340 case 'I':
341 case 'J':
342 case 'K':
343 case 'L':
344 case 'M':
345 case 'N':
346 case 'O':
347 case 'P':
348 case 'Q':
349 case 'R':
350 case 'S':
351 case 'T':
352 case 'U':
353 case 'V':
354 case 'W':
355 case 'X':
356 case 'Y':
357 case 'Z':
358 case '0':
359 case '1':
360 case '2':
361 case '3':
362 case '4':
363 case '5':
364 case '6':
365 case '7':
366 case '8':
367 case '9':
368 return true;
369 default:
370 return false;
371 }
372}
373
374LIBC_INLINE static constexpr int b36_char_to_int(int ch) {
375 switch (ch) {
376 case '0':
377 return 0;
378 case '1':
379 return 1;
380 case '2':
381 return 2;
382 case '3':
383 return 3;
384 case '4':
385 return 4;
386 case '5':
387 return 5;
388 case '6':
389 return 6;
390 case '7':
391 return 7;
392 case '8':
393 return 8;
394 case '9':
395 return 9;
396 case 'a':
397 case 'A':
398 return 10;
399 case 'b':
400 case 'B':
401 return 11;
402 case 'c':
403 case 'C':
404 return 12;
405 case 'd':
406 case 'D':
407 return 13;
408 case 'e':
409 case 'E':
410 return 14;
411 case 'f':
412 case 'F':
413 return 15;
414 case 'g':
415 case 'G':
416 return 16;
417 case 'h':
418 case 'H':
419 return 17;
420 case 'i':
421 case 'I':
422 return 18;
423 case 'j':
424 case 'J':
425 return 19;
426 case 'k':
427 case 'K':
428 return 20;
429 case 'l':
430 case 'L':
431 return 21;
432 case 'm':
433 case 'M':
434 return 22;
435 case 'n':
436 case 'N':
437 return 23;
438 case 'o':
439 case 'O':
440 return 24;
441 case 'p':
442 case 'P':
443 return 25;
444 case 'q':
445 case 'Q':
446 return 26;
447 case 'r':
448 case 'R':
449 return 27;
450 case 's':
451 case 'S':
452 return 28;
453 case 't':
454 case 'T':
455 return 29;
456 case 'u':
457 case 'U':
458 return 30;
459 case 'v':
460 case 'V':
461 return 31;
462 case 'w':
463 case 'W':
464 return 32;
465 case 'x':
466 case 'X':
467 return 33;
468 case 'y':
469 case 'Y':
470 return 34;
471 case 'z':
472 case 'Z':
473 return 35;
474 default:
475 return 0;
476 }
477}
478
479LIBC_INLINE static constexpr int int_to_b36_char(int num) {
480 // Can't actually use LIBC_ASSERT here because it depends on integer_to_string
481 // which depends on this.
482
483 // LIBC_ASSERT(num < 36);
484 switch (num) {
485 case 0:
486 return '0';
487 case 1:
488 return '1';
489 case 2:
490 return '2';
491 case 3:
492 return '3';
493 case 4:
494 return '4';
495 case 5:
496 return '5';
497 case 6:
498 return '6';
499 case 7:
500 return '7';
501 case 8:
502 return '8';
503 case 9:
504 return '9';
505 case 10:
506 return 'a';
507 case 11:
508 return 'b';
509 case 12:
510 return 'c';
511 case 13:
512 return 'd';
513 case 14:
514 return 'e';
515 case 15:
516 return 'f';
517 case 16:
518 return 'g';
519 case 17:
520 return 'h';
521 case 18:
522 return 'i';
523 case 19:
524 return 'j';
525 case 20:
526 return 'k';
527 case 21:
528 return 'l';
529 case 22:
530 return 'm';
531 case 23:
532 return 'n';
533 case 24:
534 return 'o';
535 case 25:
536 return 'p';
537 case 26:
538 return 'q';
539 case 27:
540 return 'r';
541 case 28:
542 return 's';
543 case 29:
544 return 't';
545 case 30:
546 return 'u';
547 case 31:
548 return 'v';
549 case 32:
550 return 'w';
551 case 33:
552 return 'x';
553 case 34:
554 return 'y';
555 case 35:
556 return 'z';
557 default:
558 return '!';
559 }
560}
561
562LIBC_INLINE static constexpr bool isspace(int ch) {
563 switch (ch) {
564 case ' ':
565 case '\t':
566 case '\n':
567 case '\v':
568 case '\f':
569 case '\r':
570 return true;
571 default:
572 return false;
573 }
574}
575
576// not yet encoding independent.
577LIBC_INLINE static constexpr bool isgraph(int ch) {
578 return 0x20 < ch && ch < 0x7f;
579}
580
581} // namespace internal
582} // namespace LIBC_NAMESPACE_DECL
583
584#endif // LLVM_LIBC_SRC___SUPPORT_CTYPE_UTILS_H
lib/libcxx/libc/src/__support/detailed_powers_of_ten.h created+740
...@@ -0,0 +1,740 @@
1//===-- detailed powers of ten ----------------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_DETAILED_POWERS_OF_TEN_H
10#define LLVM_LIBC_SRC___SUPPORT_DETAILED_POWERS_OF_TEN_H
11
12#include "src/__support/common.h"
13#include "src/__support/macros/config.h"
14
15#include <stdint.h>
16
17namespace LIBC_NAMESPACE_DECL {
18namespace internal {
19
20// TODO(michaelrj): write a script that will generate this table.
21
22// This table was generated by
23// https://github.com/google/wuffs/blob/788479dd64f35cb6b4e998a851acb06ee962435b/script/print-mpb-powers-of-10.go
24// and contains the 128 bit mantissa approximations of the powers of 10 from
25// -348 to 347. The exponents are implied by a linear expression with slope
26// 217706.0/65536.0 ≈ log(10)/log(2). This is used by the Eisel-Lemire algorithm
27// in str_to_float.h.
28
29constexpr int32_t DETAILED_POWERS_OF_TEN_MIN_EXP_10 = -348;
30constexpr int32_t DETAILED_POWERS_OF_TEN_MAX_EXP_10 = 347;
31
32// This rescales the base 10 exponent by a factor of log(10)/log(2).
33LIBC_INLINE int32_t exp10_to_exp2(int32_t exp10) {
34 // Valid if exp10 < 646 456 636.
35 return static_cast<int32_t>((217706 * static_cast<int64_t>(exp10)) >> 16);
36}
37
38static constexpr uint64_t DETAILED_POWERS_OF_TEN[696][2] = {
39 {0x1732C869CD60E453, 0xFA8FD5A0081C0288}, // 1e-348
40 {0x0E7FBD42205C8EB4, 0x9C99E58405118195}, // 1e-347
41 {0x521FAC92A873B261, 0xC3C05EE50655E1FA}, // 1e-346
42 {0xE6A797B752909EF9, 0xF4B0769E47EB5A78}, // 1e-345
43 {0x9028BED2939A635C, 0x98EE4A22ECF3188B}, // 1e-344
44 {0x7432EE873880FC33, 0xBF29DCABA82FDEAE}, // 1e-343
45 {0x113FAA2906A13B3F, 0xEEF453D6923BD65A}, // 1e-342
46 {0x4AC7CA59A424C507, 0x9558B4661B6565F8}, // 1e-341
47 {0x5D79BCF00D2DF649, 0xBAAEE17FA23EBF76}, // 1e-340
48 {0xF4D82C2C107973DC, 0xE95A99DF8ACE6F53}, // 1e-339
49 {0x79071B9B8A4BE869, 0x91D8A02BB6C10594}, // 1e-338
50 {0x9748E2826CDEE284, 0xB64EC836A47146F9}, // 1e-337
51 {0xFD1B1B2308169B25, 0xE3E27A444D8D98B7}, // 1e-336
52 {0xFE30F0F5E50E20F7, 0x8E6D8C6AB0787F72}, // 1e-335
53 {0xBDBD2D335E51A935, 0xB208EF855C969F4F}, // 1e-334
54 {0xAD2C788035E61382, 0xDE8B2B66B3BC4723}, // 1e-333
55 {0x4C3BCB5021AFCC31, 0x8B16FB203055AC76}, // 1e-332
56 {0xDF4ABE242A1BBF3D, 0xADDCB9E83C6B1793}, // 1e-331
57 {0xD71D6DAD34A2AF0D, 0xD953E8624B85DD78}, // 1e-330
58 {0x8672648C40E5AD68, 0x87D4713D6F33AA6B}, // 1e-329
59 {0x680EFDAF511F18C2, 0xA9C98D8CCB009506}, // 1e-328
60 {0x0212BD1B2566DEF2, 0xD43BF0EFFDC0BA48}, // 1e-327
61 {0x014BB630F7604B57, 0x84A57695FE98746D}, // 1e-326
62 {0x419EA3BD35385E2D, 0xA5CED43B7E3E9188}, // 1e-325
63 {0x52064CAC828675B9, 0xCF42894A5DCE35EA}, // 1e-324
64 {0x7343EFEBD1940993, 0x818995CE7AA0E1B2}, // 1e-323
65 {0x1014EBE6C5F90BF8, 0xA1EBFB4219491A1F}, // 1e-322
66 {0xD41A26E077774EF6, 0xCA66FA129F9B60A6}, // 1e-321
67 {0x8920B098955522B4, 0xFD00B897478238D0}, // 1e-320
68 {0x55B46E5F5D5535B0, 0x9E20735E8CB16382}, // 1e-319
69 {0xEB2189F734AA831D, 0xC5A890362FDDBC62}, // 1e-318
70 {0xA5E9EC7501D523E4, 0xF712B443BBD52B7B}, // 1e-317
71 {0x47B233C92125366E, 0x9A6BB0AA55653B2D}, // 1e-316
72 {0x999EC0BB696E840A, 0xC1069CD4EABE89F8}, // 1e-315
73 {0xC00670EA43CA250D, 0xF148440A256E2C76}, // 1e-314
74 {0x380406926A5E5728, 0x96CD2A865764DBCA}, // 1e-313
75 {0xC605083704F5ECF2, 0xBC807527ED3E12BC}, // 1e-312
76 {0xF7864A44C633682E, 0xEBA09271E88D976B}, // 1e-311
77 {0x7AB3EE6AFBE0211D, 0x93445B8731587EA3}, // 1e-310
78 {0x5960EA05BAD82964, 0xB8157268FDAE9E4C}, // 1e-309
79 {0x6FB92487298E33BD, 0xE61ACF033D1A45DF}, // 1e-308
80 {0xA5D3B6D479F8E056, 0x8FD0C16206306BAB}, // 1e-307
81 {0x8F48A4899877186C, 0xB3C4F1BA87BC8696}, // 1e-306
82 {0x331ACDABFE94DE87, 0xE0B62E2929ABA83C}, // 1e-305
83 {0x9FF0C08B7F1D0B14, 0x8C71DCD9BA0B4925}, // 1e-304
84 {0x07ECF0AE5EE44DD9, 0xAF8E5410288E1B6F}, // 1e-303
85 {0xC9E82CD9F69D6150, 0xDB71E91432B1A24A}, // 1e-302
86 {0xBE311C083A225CD2, 0x892731AC9FAF056E}, // 1e-301
87 {0x6DBD630A48AAF406, 0xAB70FE17C79AC6CA}, // 1e-300
88 {0x092CBBCCDAD5B108, 0xD64D3D9DB981787D}, // 1e-299
89 {0x25BBF56008C58EA5, 0x85F0468293F0EB4E}, // 1e-298
90 {0xAF2AF2B80AF6F24E, 0xA76C582338ED2621}, // 1e-297
91 {0x1AF5AF660DB4AEE1, 0xD1476E2C07286FAA}, // 1e-296
92 {0x50D98D9FC890ED4D, 0x82CCA4DB847945CA}, // 1e-295
93 {0xE50FF107BAB528A0, 0xA37FCE126597973C}, // 1e-294
94 {0x1E53ED49A96272C8, 0xCC5FC196FEFD7D0C}, // 1e-293
95 {0x25E8E89C13BB0F7A, 0xFF77B1FCBEBCDC4F}, // 1e-292
96 {0x77B191618C54E9AC, 0x9FAACF3DF73609B1}, // 1e-291
97 {0xD59DF5B9EF6A2417, 0xC795830D75038C1D}, // 1e-290
98 {0x4B0573286B44AD1D, 0xF97AE3D0D2446F25}, // 1e-289
99 {0x4EE367F9430AEC32, 0x9BECCE62836AC577}, // 1e-288
100 {0x229C41F793CDA73F, 0xC2E801FB244576D5}, // 1e-287
101 {0x6B43527578C1110F, 0xF3A20279ED56D48A}, // 1e-286
102 {0x830A13896B78AAA9, 0x9845418C345644D6}, // 1e-285
103 {0x23CC986BC656D553, 0xBE5691EF416BD60C}, // 1e-284
104 {0x2CBFBE86B7EC8AA8, 0xEDEC366B11C6CB8F}, // 1e-283
105 {0x7BF7D71432F3D6A9, 0x94B3A202EB1C3F39}, // 1e-282
106 {0xDAF5CCD93FB0CC53, 0xB9E08A83A5E34F07}, // 1e-281
107 {0xD1B3400F8F9CFF68, 0xE858AD248F5C22C9}, // 1e-280
108 {0x23100809B9C21FA1, 0x91376C36D99995BE}, // 1e-279
109 {0xABD40A0C2832A78A, 0xB58547448FFFFB2D}, // 1e-278
110 {0x16C90C8F323F516C, 0xE2E69915B3FFF9F9}, // 1e-277
111 {0xAE3DA7D97F6792E3, 0x8DD01FAD907FFC3B}, // 1e-276
112 {0x99CD11CFDF41779C, 0xB1442798F49FFB4A}, // 1e-275
113 {0x40405643D711D583, 0xDD95317F31C7FA1D}, // 1e-274
114 {0x482835EA666B2572, 0x8A7D3EEF7F1CFC52}, // 1e-273
115 {0xDA3243650005EECF, 0xAD1C8EAB5EE43B66}, // 1e-272
116 {0x90BED43E40076A82, 0xD863B256369D4A40}, // 1e-271
117 {0x5A7744A6E804A291, 0x873E4F75E2224E68}, // 1e-270
118 {0x711515D0A205CB36, 0xA90DE3535AAAE202}, // 1e-269
119 {0x0D5A5B44CA873E03, 0xD3515C2831559A83}, // 1e-268
120 {0xE858790AFE9486C2, 0x8412D9991ED58091}, // 1e-267
121 {0x626E974DBE39A872, 0xA5178FFF668AE0B6}, // 1e-266
122 {0xFB0A3D212DC8128F, 0xCE5D73FF402D98E3}, // 1e-265
123 {0x7CE66634BC9D0B99, 0x80FA687F881C7F8E}, // 1e-264
124 {0x1C1FFFC1EBC44E80, 0xA139029F6A239F72}, // 1e-263
125 {0xA327FFB266B56220, 0xC987434744AC874E}, // 1e-262
126 {0x4BF1FF9F0062BAA8, 0xFBE9141915D7A922}, // 1e-261
127 {0x6F773FC3603DB4A9, 0x9D71AC8FADA6C9B5}, // 1e-260
128 {0xCB550FB4384D21D3, 0xC4CE17B399107C22}, // 1e-259
129 {0x7E2A53A146606A48, 0xF6019DA07F549B2B}, // 1e-258
130 {0x2EDA7444CBFC426D, 0x99C102844F94E0FB}, // 1e-257
131 {0xFA911155FEFB5308, 0xC0314325637A1939}, // 1e-256
132 {0x793555AB7EBA27CA, 0xF03D93EEBC589F88}, // 1e-255
133 {0x4BC1558B2F3458DE, 0x96267C7535B763B5}, // 1e-254
134 {0x9EB1AAEDFB016F16, 0xBBB01B9283253CA2}, // 1e-253
135 {0x465E15A979C1CADC, 0xEA9C227723EE8BCB}, // 1e-252
136 {0x0BFACD89EC191EC9, 0x92A1958A7675175F}, // 1e-251
137 {0xCEF980EC671F667B, 0xB749FAED14125D36}, // 1e-250
138 {0x82B7E12780E7401A, 0xE51C79A85916F484}, // 1e-249
139 {0xD1B2ECB8B0908810, 0x8F31CC0937AE58D2}, // 1e-248
140 {0x861FA7E6DCB4AA15, 0xB2FE3F0B8599EF07}, // 1e-247
141 {0x67A791E093E1D49A, 0xDFBDCECE67006AC9}, // 1e-246
142 {0xE0C8BB2C5C6D24E0, 0x8BD6A141006042BD}, // 1e-245
143 {0x58FAE9F773886E18, 0xAECC49914078536D}, // 1e-244
144 {0xAF39A475506A899E, 0xDA7F5BF590966848}, // 1e-243
145 {0x6D8406C952429603, 0x888F99797A5E012D}, // 1e-242
146 {0xC8E5087BA6D33B83, 0xAAB37FD7D8F58178}, // 1e-241
147 {0xFB1E4A9A90880A64, 0xD5605FCDCF32E1D6}, // 1e-240
148 {0x5CF2EEA09A55067F, 0x855C3BE0A17FCD26}, // 1e-239
149 {0xF42FAA48C0EA481E, 0xA6B34AD8C9DFC06F}, // 1e-238
150 {0xF13B94DAF124DA26, 0xD0601D8EFC57B08B}, // 1e-237
151 {0x76C53D08D6B70858, 0x823C12795DB6CE57}, // 1e-236
152 {0x54768C4B0C64CA6E, 0xA2CB1717B52481ED}, // 1e-235
153 {0xA9942F5DCF7DFD09, 0xCB7DDCDDA26DA268}, // 1e-234
154 {0xD3F93B35435D7C4C, 0xFE5D54150B090B02}, // 1e-233
155 {0xC47BC5014A1A6DAF, 0x9EFA548D26E5A6E1}, // 1e-232
156 {0x359AB6419CA1091B, 0xC6B8E9B0709F109A}, // 1e-231
157 {0xC30163D203C94B62, 0xF867241C8CC6D4C0}, // 1e-230
158 {0x79E0DE63425DCF1D, 0x9B407691D7FC44F8}, // 1e-229
159 {0x985915FC12F542E4, 0xC21094364DFB5636}, // 1e-228
160 {0x3E6F5B7B17B2939D, 0xF294B943E17A2BC4}, // 1e-227
161 {0xA705992CEECF9C42, 0x979CF3CA6CEC5B5A}, // 1e-226
162 {0x50C6FF782A838353, 0xBD8430BD08277231}, // 1e-225
163 {0xA4F8BF5635246428, 0xECE53CEC4A314EBD}, // 1e-224
164 {0x871B7795E136BE99, 0x940F4613AE5ED136}, // 1e-223
165 {0x28E2557B59846E3F, 0xB913179899F68584}, // 1e-222
166 {0x331AEADA2FE589CF, 0xE757DD7EC07426E5}, // 1e-221
167 {0x3FF0D2C85DEF7621, 0x9096EA6F3848984F}, // 1e-220
168 {0x0FED077A756B53A9, 0xB4BCA50B065ABE63}, // 1e-219
169 {0xD3E8495912C62894, 0xE1EBCE4DC7F16DFB}, // 1e-218
170 {0x64712DD7ABBBD95C, 0x8D3360F09CF6E4BD}, // 1e-217
171 {0xBD8D794D96AACFB3, 0xB080392CC4349DEC}, // 1e-216
172 {0xECF0D7A0FC5583A0, 0xDCA04777F541C567}, // 1e-215
173 {0xF41686C49DB57244, 0x89E42CAAF9491B60}, // 1e-214
174 {0x311C2875C522CED5, 0xAC5D37D5B79B6239}, // 1e-213
175 {0x7D633293366B828B, 0xD77485CB25823AC7}, // 1e-212
176 {0xAE5DFF9C02033197, 0x86A8D39EF77164BC}, // 1e-211
177 {0xD9F57F830283FDFC, 0xA8530886B54DBDEB}, // 1e-210
178 {0xD072DF63C324FD7B, 0xD267CAA862A12D66}, // 1e-209
179 {0x4247CB9E59F71E6D, 0x8380DEA93DA4BC60}, // 1e-208
180 {0x52D9BE85F074E608, 0xA46116538D0DEB78}, // 1e-207
181 {0x67902E276C921F8B, 0xCD795BE870516656}, // 1e-206
182 {0x00BA1CD8A3DB53B6, 0x806BD9714632DFF6}, // 1e-205
183 {0x80E8A40ECCD228A4, 0xA086CFCD97BF97F3}, // 1e-204
184 {0x6122CD128006B2CD, 0xC8A883C0FDAF7DF0}, // 1e-203
185 {0x796B805720085F81, 0xFAD2A4B13D1B5D6C}, // 1e-202
186 {0xCBE3303674053BB0, 0x9CC3A6EEC6311A63}, // 1e-201
187 {0xBEDBFC4411068A9C, 0xC3F490AA77BD60FC}, // 1e-200
188 {0xEE92FB5515482D44, 0xF4F1B4D515ACB93B}, // 1e-199
189 {0x751BDD152D4D1C4A, 0x991711052D8BF3C5}, // 1e-198
190 {0xD262D45A78A0635D, 0xBF5CD54678EEF0B6}, // 1e-197
191 {0x86FB897116C87C34, 0xEF340A98172AACE4}, // 1e-196
192 {0xD45D35E6AE3D4DA0, 0x9580869F0E7AAC0E}, // 1e-195
193 {0x8974836059CCA109, 0xBAE0A846D2195712}, // 1e-194
194 {0x2BD1A438703FC94B, 0xE998D258869FACD7}, // 1e-193
195 {0x7B6306A34627DDCF, 0x91FF83775423CC06}, // 1e-192
196 {0x1A3BC84C17B1D542, 0xB67F6455292CBF08}, // 1e-191
197 {0x20CABA5F1D9E4A93, 0xE41F3D6A7377EECA}, // 1e-190
198 {0x547EB47B7282EE9C, 0x8E938662882AF53E}, // 1e-189
199 {0xE99E619A4F23AA43, 0xB23867FB2A35B28D}, // 1e-188
200 {0x6405FA00E2EC94D4, 0xDEC681F9F4C31F31}, // 1e-187
201 {0xDE83BC408DD3DD04, 0x8B3C113C38F9F37E}, // 1e-186
202 {0x9624AB50B148D445, 0xAE0B158B4738705E}, // 1e-185
203 {0x3BADD624DD9B0957, 0xD98DDAEE19068C76}, // 1e-184
204 {0xE54CA5D70A80E5D6, 0x87F8A8D4CFA417C9}, // 1e-183
205 {0x5E9FCF4CCD211F4C, 0xA9F6D30A038D1DBC}, // 1e-182
206 {0x7647C3200069671F, 0xD47487CC8470652B}, // 1e-181
207 {0x29ECD9F40041E073, 0x84C8D4DFD2C63F3B}, // 1e-180
208 {0xF468107100525890, 0xA5FB0A17C777CF09}, // 1e-179
209 {0x7182148D4066EEB4, 0xCF79CC9DB955C2CC}, // 1e-178
210 {0xC6F14CD848405530, 0x81AC1FE293D599BF}, // 1e-177
211 {0xB8ADA00E5A506A7C, 0xA21727DB38CB002F}, // 1e-176
212 {0xA6D90811F0E4851C, 0xCA9CF1D206FDC03B}, // 1e-175
213 {0x908F4A166D1DA663, 0xFD442E4688BD304A}, // 1e-174
214 {0x9A598E4E043287FE, 0x9E4A9CEC15763E2E}, // 1e-173
215 {0x40EFF1E1853F29FD, 0xC5DD44271AD3CDBA}, // 1e-172
216 {0xD12BEE59E68EF47C, 0xF7549530E188C128}, // 1e-171
217 {0x82BB74F8301958CE, 0x9A94DD3E8CF578B9}, // 1e-170
218 {0xE36A52363C1FAF01, 0xC13A148E3032D6E7}, // 1e-169
219 {0xDC44E6C3CB279AC1, 0xF18899B1BC3F8CA1}, // 1e-168
220 {0x29AB103A5EF8C0B9, 0x96F5600F15A7B7E5}, // 1e-167
221 {0x7415D448F6B6F0E7, 0xBCB2B812DB11A5DE}, // 1e-166
222 {0x111B495B3464AD21, 0xEBDF661791D60F56}, // 1e-165
223 {0xCAB10DD900BEEC34, 0x936B9FCEBB25C995}, // 1e-164
224 {0x3D5D514F40EEA742, 0xB84687C269EF3BFB}, // 1e-163
225 {0x0CB4A5A3112A5112, 0xE65829B3046B0AFA}, // 1e-162
226 {0x47F0E785EABA72AB, 0x8FF71A0FE2C2E6DC}, // 1e-161
227 {0x59ED216765690F56, 0xB3F4E093DB73A093}, // 1e-160
228 {0x306869C13EC3532C, 0xE0F218B8D25088B8}, // 1e-159
229 {0x1E414218C73A13FB, 0x8C974F7383725573}, // 1e-158
230 {0xE5D1929EF90898FA, 0xAFBD2350644EEACF}, // 1e-157
231 {0xDF45F746B74ABF39, 0xDBAC6C247D62A583}, // 1e-156
232 {0x6B8BBA8C328EB783, 0x894BC396CE5DA772}, // 1e-155
233 {0x066EA92F3F326564, 0xAB9EB47C81F5114F}, // 1e-154
234 {0xC80A537B0EFEFEBD, 0xD686619BA27255A2}, // 1e-153
235 {0xBD06742CE95F5F36, 0x8613FD0145877585}, // 1e-152
236 {0x2C48113823B73704, 0xA798FC4196E952E7}, // 1e-151
237 {0xF75A15862CA504C5, 0xD17F3B51FCA3A7A0}, // 1e-150
238 {0x9A984D73DBE722FB, 0x82EF85133DE648C4}, // 1e-149
239 {0xC13E60D0D2E0EBBA, 0xA3AB66580D5FDAF5}, // 1e-148
240 {0x318DF905079926A8, 0xCC963FEE10B7D1B3}, // 1e-147
241 {0xFDF17746497F7052, 0xFFBBCFE994E5C61F}, // 1e-146
242 {0xFEB6EA8BEDEFA633, 0x9FD561F1FD0F9BD3}, // 1e-145
243 {0xFE64A52EE96B8FC0, 0xC7CABA6E7C5382C8}, // 1e-144
244 {0x3DFDCE7AA3C673B0, 0xF9BD690A1B68637B}, // 1e-143
245 {0x06BEA10CA65C084E, 0x9C1661A651213E2D}, // 1e-142
246 {0x486E494FCFF30A62, 0xC31BFA0FE5698DB8}, // 1e-141
247 {0x5A89DBA3C3EFCCFA, 0xF3E2F893DEC3F126}, // 1e-140
248 {0xF89629465A75E01C, 0x986DDB5C6B3A76B7}, // 1e-139
249 {0xF6BBB397F1135823, 0xBE89523386091465}, // 1e-138
250 {0x746AA07DED582E2C, 0xEE2BA6C0678B597F}, // 1e-137
251 {0xA8C2A44EB4571CDC, 0x94DB483840B717EF}, // 1e-136
252 {0x92F34D62616CE413, 0xBA121A4650E4DDEB}, // 1e-135
253 {0x77B020BAF9C81D17, 0xE896A0D7E51E1566}, // 1e-134
254 {0x0ACE1474DC1D122E, 0x915E2486EF32CD60}, // 1e-133
255 {0x0D819992132456BA, 0xB5B5ADA8AAFF80B8}, // 1e-132
256 {0x10E1FFF697ED6C69, 0xE3231912D5BF60E6}, // 1e-131
257 {0xCA8D3FFA1EF463C1, 0x8DF5EFABC5979C8F}, // 1e-130
258 {0xBD308FF8A6B17CB2, 0xB1736B96B6FD83B3}, // 1e-129
259 {0xAC7CB3F6D05DDBDE, 0xDDD0467C64BCE4A0}, // 1e-128
260 {0x6BCDF07A423AA96B, 0x8AA22C0DBEF60EE4}, // 1e-127
261 {0x86C16C98D2C953C6, 0xAD4AB7112EB3929D}, // 1e-126
262 {0xE871C7BF077BA8B7, 0xD89D64D57A607744}, // 1e-125
263 {0x11471CD764AD4972, 0x87625F056C7C4A8B}, // 1e-124
264 {0xD598E40D3DD89BCF, 0xA93AF6C6C79B5D2D}, // 1e-123
265 {0x4AFF1D108D4EC2C3, 0xD389B47879823479}, // 1e-122
266 {0xCEDF722A585139BA, 0x843610CB4BF160CB}, // 1e-121
267 {0xC2974EB4EE658828, 0xA54394FE1EEDB8FE}, // 1e-120
268 {0x733D226229FEEA32, 0xCE947A3DA6A9273E}, // 1e-119
269 {0x0806357D5A3F525F, 0x811CCC668829B887}, // 1e-118
270 {0xCA07C2DCB0CF26F7, 0xA163FF802A3426A8}, // 1e-117
271 {0xFC89B393DD02F0B5, 0xC9BCFF6034C13052}, // 1e-116
272 {0xBBAC2078D443ACE2, 0xFC2C3F3841F17C67}, // 1e-115
273 {0xD54B944B84AA4C0D, 0x9D9BA7832936EDC0}, // 1e-114
274 {0x0A9E795E65D4DF11, 0xC5029163F384A931}, // 1e-113
275 {0x4D4617B5FF4A16D5, 0xF64335BCF065D37D}, // 1e-112
276 {0x504BCED1BF8E4E45, 0x99EA0196163FA42E}, // 1e-111
277 {0xE45EC2862F71E1D6, 0xC06481FB9BCF8D39}, // 1e-110
278 {0x5D767327BB4E5A4C, 0xF07DA27A82C37088}, // 1e-109
279 {0x3A6A07F8D510F86F, 0x964E858C91BA2655}, // 1e-108
280 {0x890489F70A55368B, 0xBBE226EFB628AFEA}, // 1e-107
281 {0x2B45AC74CCEA842E, 0xEADAB0ABA3B2DBE5}, // 1e-106
282 {0x3B0B8BC90012929D, 0x92C8AE6B464FC96F}, // 1e-105
283 {0x09CE6EBB40173744, 0xB77ADA0617E3BBCB}, // 1e-104
284 {0xCC420A6A101D0515, 0xE55990879DDCAABD}, // 1e-103
285 {0x9FA946824A12232D, 0x8F57FA54C2A9EAB6}, // 1e-102
286 {0x47939822DC96ABF9, 0xB32DF8E9F3546564}, // 1e-101
287 {0x59787E2B93BC56F7, 0xDFF9772470297EBD}, // 1e-100
288 {0x57EB4EDB3C55B65A, 0x8BFBEA76C619EF36}, // 1e-99
289 {0xEDE622920B6B23F1, 0xAEFAE51477A06B03}, // 1e-98
290 {0xE95FAB368E45ECED, 0xDAB99E59958885C4}, // 1e-97
291 {0x11DBCB0218EBB414, 0x88B402F7FD75539B}, // 1e-96
292 {0xD652BDC29F26A119, 0xAAE103B5FCD2A881}, // 1e-95
293 {0x4BE76D3346F0495F, 0xD59944A37C0752A2}, // 1e-94
294 {0x6F70A4400C562DDB, 0x857FCAE62D8493A5}, // 1e-93
295 {0xCB4CCD500F6BB952, 0xA6DFBD9FB8E5B88E}, // 1e-92
296 {0x7E2000A41346A7A7, 0xD097AD07A71F26B2}, // 1e-91
297 {0x8ED400668C0C28C8, 0x825ECC24C873782F}, // 1e-90
298 {0x728900802F0F32FA, 0xA2F67F2DFA90563B}, // 1e-89
299 {0x4F2B40A03AD2FFB9, 0xCBB41EF979346BCA}, // 1e-88
300 {0xE2F610C84987BFA8, 0xFEA126B7D78186BC}, // 1e-87
301 {0x0DD9CA7D2DF4D7C9, 0x9F24B832E6B0F436}, // 1e-86
302 {0x91503D1C79720DBB, 0xC6EDE63FA05D3143}, // 1e-85
303 {0x75A44C6397CE912A, 0xF8A95FCF88747D94}, // 1e-84
304 {0xC986AFBE3EE11ABA, 0x9B69DBE1B548CE7C}, // 1e-83
305 {0xFBE85BADCE996168, 0xC24452DA229B021B}, // 1e-82
306 {0xFAE27299423FB9C3, 0xF2D56790AB41C2A2}, // 1e-81
307 {0xDCCD879FC967D41A, 0x97C560BA6B0919A5}, // 1e-80
308 {0x5400E987BBC1C920, 0xBDB6B8E905CB600F}, // 1e-79
309 {0x290123E9AAB23B68, 0xED246723473E3813}, // 1e-78
310 {0xF9A0B6720AAF6521, 0x9436C0760C86E30B}, // 1e-77
311 {0xF808E40E8D5B3E69, 0xB94470938FA89BCE}, // 1e-76
312 {0xB60B1D1230B20E04, 0xE7958CB87392C2C2}, // 1e-75
313 {0xB1C6F22B5E6F48C2, 0x90BD77F3483BB9B9}, // 1e-74
314 {0x1E38AEB6360B1AF3, 0xB4ECD5F01A4AA828}, // 1e-73
315 {0x25C6DA63C38DE1B0, 0xE2280B6C20DD5232}, // 1e-72
316 {0x579C487E5A38AD0E, 0x8D590723948A535F}, // 1e-71
317 {0x2D835A9DF0C6D851, 0xB0AF48EC79ACE837}, // 1e-70
318 {0xF8E431456CF88E65, 0xDCDB1B2798182244}, // 1e-69
319 {0x1B8E9ECB641B58FF, 0x8A08F0F8BF0F156B}, // 1e-68
320 {0xE272467E3D222F3F, 0xAC8B2D36EED2DAC5}, // 1e-67
321 {0x5B0ED81DCC6ABB0F, 0xD7ADF884AA879177}, // 1e-66
322 {0x98E947129FC2B4E9, 0x86CCBB52EA94BAEA}, // 1e-65
323 {0x3F2398D747B36224, 0xA87FEA27A539E9A5}, // 1e-64
324 {0x8EEC7F0D19A03AAD, 0xD29FE4B18E88640E}, // 1e-63
325 {0x1953CF68300424AC, 0x83A3EEEEF9153E89}, // 1e-62
326 {0x5FA8C3423C052DD7, 0xA48CEAAAB75A8E2B}, // 1e-61
327 {0x3792F412CB06794D, 0xCDB02555653131B6}, // 1e-60
328 {0xE2BBD88BBEE40BD0, 0x808E17555F3EBF11}, // 1e-59
329 {0x5B6ACEAEAE9D0EC4, 0xA0B19D2AB70E6ED6}, // 1e-58
330 {0xF245825A5A445275, 0xC8DE047564D20A8B}, // 1e-57
331 {0xEED6E2F0F0D56712, 0xFB158592BE068D2E}, // 1e-56
332 {0x55464DD69685606B, 0x9CED737BB6C4183D}, // 1e-55
333 {0xAA97E14C3C26B886, 0xC428D05AA4751E4C}, // 1e-54
334 {0xD53DD99F4B3066A8, 0xF53304714D9265DF}, // 1e-53
335 {0xE546A8038EFE4029, 0x993FE2C6D07B7FAB}, // 1e-52
336 {0xDE98520472BDD033, 0xBF8FDB78849A5F96}, // 1e-51
337 {0x963E66858F6D4440, 0xEF73D256A5C0F77C}, // 1e-50
338 {0xDDE7001379A44AA8, 0x95A8637627989AAD}, // 1e-49
339 {0x5560C018580D5D52, 0xBB127C53B17EC159}, // 1e-48
340 {0xAAB8F01E6E10B4A6, 0xE9D71B689DDE71AF}, // 1e-47
341 {0xCAB3961304CA70E8, 0x9226712162AB070D}, // 1e-46
342 {0x3D607B97C5FD0D22, 0xB6B00D69BB55C8D1}, // 1e-45
343 {0x8CB89A7DB77C506A, 0xE45C10C42A2B3B05}, // 1e-44
344 {0x77F3608E92ADB242, 0x8EB98A7A9A5B04E3}, // 1e-43
345 {0x55F038B237591ED3, 0xB267ED1940F1C61C}, // 1e-42
346 {0x6B6C46DEC52F6688, 0xDF01E85F912E37A3}, // 1e-41
347 {0x2323AC4B3B3DA015, 0x8B61313BBABCE2C6}, // 1e-40
348 {0xABEC975E0A0D081A, 0xAE397D8AA96C1B77}, // 1e-39
349 {0x96E7BD358C904A21, 0xD9C7DCED53C72255}, // 1e-38
350 {0x7E50D64177DA2E54, 0x881CEA14545C7575}, // 1e-37
351 {0xDDE50BD1D5D0B9E9, 0xAA242499697392D2}, // 1e-36
352 {0x955E4EC64B44E864, 0xD4AD2DBFC3D07787}, // 1e-35
353 {0xBD5AF13BEF0B113E, 0x84EC3C97DA624AB4}, // 1e-34
354 {0xECB1AD8AEACDD58E, 0xA6274BBDD0FADD61}, // 1e-33
355 {0x67DE18EDA5814AF2, 0xCFB11EAD453994BA}, // 1e-32
356 {0x80EACF948770CED7, 0x81CEB32C4B43FCF4}, // 1e-31
357 {0xA1258379A94D028D, 0xA2425FF75E14FC31}, // 1e-30
358 {0x096EE45813A04330, 0xCAD2F7F5359A3B3E}, // 1e-29
359 {0x8BCA9D6E188853FC, 0xFD87B5F28300CA0D}, // 1e-28
360 {0x775EA264CF55347D, 0x9E74D1B791E07E48}, // 1e-27
361 {0x95364AFE032A819D, 0xC612062576589DDA}, // 1e-26
362 {0x3A83DDBD83F52204, 0xF79687AED3EEC551}, // 1e-25
363 {0xC4926A9672793542, 0x9ABE14CD44753B52}, // 1e-24
364 {0x75B7053C0F178293, 0xC16D9A0095928A27}, // 1e-23
365 {0x5324C68B12DD6338, 0xF1C90080BAF72CB1}, // 1e-22
366 {0xD3F6FC16EBCA5E03, 0x971DA05074DA7BEE}, // 1e-21
367 {0x88F4BB1CA6BCF584, 0xBCE5086492111AEA}, // 1e-20
368 {0x2B31E9E3D06C32E5, 0xEC1E4A7DB69561A5}, // 1e-19
369 {0x3AFF322E62439FCF, 0x9392EE8E921D5D07}, // 1e-18
370 {0x09BEFEB9FAD487C2, 0xB877AA3236A4B449}, // 1e-17
371 {0x4C2EBE687989A9B3, 0xE69594BEC44DE15B}, // 1e-16
372 {0x0F9D37014BF60A10, 0x901D7CF73AB0ACD9}, // 1e-15
373 {0x538484C19EF38C94, 0xB424DC35095CD80F}, // 1e-14
374 {0x2865A5F206B06FB9, 0xE12E13424BB40E13}, // 1e-13
375 {0xF93F87B7442E45D3, 0x8CBCCC096F5088CB}, // 1e-12
376 {0xF78F69A51539D748, 0xAFEBFF0BCB24AAFE}, // 1e-11
377 {0xB573440E5A884D1B, 0xDBE6FECEBDEDD5BE}, // 1e-10
378 {0x31680A88F8953030, 0x89705F4136B4A597}, // 1e-9
379 {0xFDC20D2B36BA7C3D, 0xABCC77118461CEFC}, // 1e-8
380 {0x3D32907604691B4C, 0xD6BF94D5E57A42BC}, // 1e-7
381 {0xA63F9A49C2C1B10F, 0x8637BD05AF6C69B5}, // 1e-6
382 {0x0FCF80DC33721D53, 0xA7C5AC471B478423}, // 1e-5
383 {0xD3C36113404EA4A8, 0xD1B71758E219652B}, // 1e-4
384 {0x645A1CAC083126E9, 0x83126E978D4FDF3B}, // 1e-3
385 {0x3D70A3D70A3D70A3, 0xA3D70A3D70A3D70A}, // 1e-2
386 {0xCCCCCCCCCCCCCCCC, 0xCCCCCCCCCCCCCCCC}, // 1e-1
387 {0x0000000000000000, 0x8000000000000000}, // 1e0
388 {0x0000000000000000, 0xA000000000000000}, // 1e1
389 {0x0000000000000000, 0xC800000000000000}, // 1e2
390 {0x0000000000000000, 0xFA00000000000000}, // 1e3
391 {0x0000000000000000, 0x9C40000000000000}, // 1e4
392 {0x0000000000000000, 0xC350000000000000}, // 1e5
393 {0x0000000000000000, 0xF424000000000000}, // 1e6
394 {0x0000000000000000, 0x9896800000000000}, // 1e7
395 {0x0000000000000000, 0xBEBC200000000000}, // 1e8
396 {0x0000000000000000, 0xEE6B280000000000}, // 1e9
397 {0x0000000000000000, 0x9502F90000000000}, // 1e10
398 {0x0000000000000000, 0xBA43B74000000000}, // 1e11
399 {0x0000000000000000, 0xE8D4A51000000000}, // 1e12
400 {0x0000000000000000, 0x9184E72A00000000}, // 1e13
401 {0x0000000000000000, 0xB5E620F480000000}, // 1e14
402 {0x0000000000000000, 0xE35FA931A0000000}, // 1e15
403 {0x0000000000000000, 0x8E1BC9BF04000000}, // 1e16
404 {0x0000000000000000, 0xB1A2BC2EC5000000}, // 1e17
405 {0x0000000000000000, 0xDE0B6B3A76400000}, // 1e18
406 {0x0000000000000000, 0x8AC7230489E80000}, // 1e19
407 {0x0000000000000000, 0xAD78EBC5AC620000}, // 1e20
408 {0x0000000000000000, 0xD8D726B7177A8000}, // 1e21
409 {0x0000000000000000, 0x878678326EAC9000}, // 1e22
410 {0x0000000000000000, 0xA968163F0A57B400}, // 1e23
411 {0x0000000000000000, 0xD3C21BCECCEDA100}, // 1e24
412 {0x0000000000000000, 0x84595161401484A0}, // 1e25
413 {0x0000000000000000, 0xA56FA5B99019A5C8}, // 1e26
414 {0x0000000000000000, 0xCECB8F27F4200F3A}, // 1e27
415 {0x4000000000000000, 0x813F3978F8940984}, // 1e28
416 {0x5000000000000000, 0xA18F07D736B90BE5}, // 1e29
417 {0xA400000000000000, 0xC9F2C9CD04674EDE}, // 1e30
418 {0x4D00000000000000, 0xFC6F7C4045812296}, // 1e31
419 {0xF020000000000000, 0x9DC5ADA82B70B59D}, // 1e32
420 {0x6C28000000000000, 0xC5371912364CE305}, // 1e33
421 {0xC732000000000000, 0xF684DF56C3E01BC6}, // 1e34
422 {0x3C7F400000000000, 0x9A130B963A6C115C}, // 1e35
423 {0x4B9F100000000000, 0xC097CE7BC90715B3}, // 1e36
424 {0x1E86D40000000000, 0xF0BDC21ABB48DB20}, // 1e37
425 {0x1314448000000000, 0x96769950B50D88F4}, // 1e38
426 {0x17D955A000000000, 0xBC143FA4E250EB31}, // 1e39
427 {0x5DCFAB0800000000, 0xEB194F8E1AE525FD}, // 1e40
428 {0x5AA1CAE500000000, 0x92EFD1B8D0CF37BE}, // 1e41
429 {0xF14A3D9E40000000, 0xB7ABC627050305AD}, // 1e42
430 {0x6D9CCD05D0000000, 0xE596B7B0C643C719}, // 1e43
431 {0xE4820023A2000000, 0x8F7E32CE7BEA5C6F}, // 1e44
432 {0xDDA2802C8A800000, 0xB35DBF821AE4F38B}, // 1e45
433 {0xD50B2037AD200000, 0xE0352F62A19E306E}, // 1e46
434 {0x4526F422CC340000, 0x8C213D9DA502DE45}, // 1e47
435 {0x9670B12B7F410000, 0xAF298D050E4395D6}, // 1e48
436 {0x3C0CDD765F114000, 0xDAF3F04651D47B4C}, // 1e49
437 {0xA5880A69FB6AC800, 0x88D8762BF324CD0F}, // 1e50
438 {0x8EEA0D047A457A00, 0xAB0E93B6EFEE0053}, // 1e51
439 {0x72A4904598D6D880, 0xD5D238A4ABE98068}, // 1e52
440 {0x47A6DA2B7F864750, 0x85A36366EB71F041}, // 1e53
441 {0x999090B65F67D924, 0xA70C3C40A64E6C51}, // 1e54
442 {0xFFF4B4E3F741CF6D, 0xD0CF4B50CFE20765}, // 1e55
443 {0xBFF8F10E7A8921A4, 0x82818F1281ED449F}, // 1e56
444 {0xAFF72D52192B6A0D, 0xA321F2D7226895C7}, // 1e57
445 {0x9BF4F8A69F764490, 0xCBEA6F8CEB02BB39}, // 1e58
446 {0x02F236D04753D5B4, 0xFEE50B7025C36A08}, // 1e59
447 {0x01D762422C946590, 0x9F4F2726179A2245}, // 1e60
448 {0x424D3AD2B7B97EF5, 0xC722F0EF9D80AAD6}, // 1e61
449 {0xD2E0898765A7DEB2, 0xF8EBAD2B84E0D58B}, // 1e62
450 {0x63CC55F49F88EB2F, 0x9B934C3B330C8577}, // 1e63
451 {0x3CBF6B71C76B25FB, 0xC2781F49FFCFA6D5}, // 1e64
452 {0x8BEF464E3945EF7A, 0xF316271C7FC3908A}, // 1e65
453 {0x97758BF0E3CBB5AC, 0x97EDD871CFDA3A56}, // 1e66
454 {0x3D52EEED1CBEA317, 0xBDE94E8E43D0C8EC}, // 1e67
455 {0x4CA7AAA863EE4BDD, 0xED63A231D4C4FB27}, // 1e68
456 {0x8FE8CAA93E74EF6A, 0x945E455F24FB1CF8}, // 1e69
457 {0xB3E2FD538E122B44, 0xB975D6B6EE39E436}, // 1e70
458 {0x60DBBCA87196B616, 0xE7D34C64A9C85D44}, // 1e71
459 {0xBC8955E946FE31CD, 0x90E40FBEEA1D3A4A}, // 1e72
460 {0x6BABAB6398BDBE41, 0xB51D13AEA4A488DD}, // 1e73
461 {0xC696963C7EED2DD1, 0xE264589A4DCDAB14}, // 1e74
462 {0xFC1E1DE5CF543CA2, 0x8D7EB76070A08AEC}, // 1e75
463 {0x3B25A55F43294BCB, 0xB0DE65388CC8ADA8}, // 1e76
464 {0x49EF0EB713F39EBE, 0xDD15FE86AFFAD912}, // 1e77
465 {0x6E3569326C784337, 0x8A2DBF142DFCC7AB}, // 1e78
466 {0x49C2C37F07965404, 0xACB92ED9397BF996}, // 1e79
467 {0xDC33745EC97BE906, 0xD7E77A8F87DAF7FB}, // 1e80
468 {0x69A028BB3DED71A3, 0x86F0AC99B4E8DAFD}, // 1e81
469 {0xC40832EA0D68CE0C, 0xA8ACD7C0222311BC}, // 1e82
470 {0xF50A3FA490C30190, 0xD2D80DB02AABD62B}, // 1e83
471 {0x792667C6DA79E0FA, 0x83C7088E1AAB65DB}, // 1e84
472 {0x577001B891185938, 0xA4B8CAB1A1563F52}, // 1e85
473 {0xED4C0226B55E6F86, 0xCDE6FD5E09ABCF26}, // 1e86
474 {0x544F8158315B05B4, 0x80B05E5AC60B6178}, // 1e87
475 {0x696361AE3DB1C721, 0xA0DC75F1778E39D6}, // 1e88
476 {0x03BC3A19CD1E38E9, 0xC913936DD571C84C}, // 1e89
477 {0x04AB48A04065C723, 0xFB5878494ACE3A5F}, // 1e90
478 {0x62EB0D64283F9C76, 0x9D174B2DCEC0E47B}, // 1e91
479 {0x3BA5D0BD324F8394, 0xC45D1DF942711D9A}, // 1e92
480 {0xCA8F44EC7EE36479, 0xF5746577930D6500}, // 1e93
481 {0x7E998B13CF4E1ECB, 0x9968BF6ABBE85F20}, // 1e94
482 {0x9E3FEDD8C321A67E, 0xBFC2EF456AE276E8}, // 1e95
483 {0xC5CFE94EF3EA101E, 0xEFB3AB16C59B14A2}, // 1e96
484 {0xBBA1F1D158724A12, 0x95D04AEE3B80ECE5}, // 1e97
485 {0x2A8A6E45AE8EDC97, 0xBB445DA9CA61281F}, // 1e98
486 {0xF52D09D71A3293BD, 0xEA1575143CF97226}, // 1e99
487 {0x593C2626705F9C56, 0x924D692CA61BE758}, // 1e100
488 {0x6F8B2FB00C77836C, 0xB6E0C377CFA2E12E}, // 1e101
489 {0x0B6DFB9C0F956447, 0xE498F455C38B997A}, // 1e102
490 {0x4724BD4189BD5EAC, 0x8EDF98B59A373FEC}, // 1e103
491 {0x58EDEC91EC2CB657, 0xB2977EE300C50FE7}, // 1e104
492 {0x2F2967B66737E3ED, 0xDF3D5E9BC0F653E1}, // 1e105
493 {0xBD79E0D20082EE74, 0x8B865B215899F46C}, // 1e106
494 {0xECD8590680A3AA11, 0xAE67F1E9AEC07187}, // 1e107
495 {0xE80E6F4820CC9495, 0xDA01EE641A708DE9}, // 1e108
496 {0x3109058D147FDCDD, 0x884134FE908658B2}, // 1e109
497 {0xBD4B46F0599FD415, 0xAA51823E34A7EEDE}, // 1e110
498 {0x6C9E18AC7007C91A, 0xD4E5E2CDC1D1EA96}, // 1e111
499 {0x03E2CF6BC604DDB0, 0x850FADC09923329E}, // 1e112
500 {0x84DB8346B786151C, 0xA6539930BF6BFF45}, // 1e113
501 {0xE612641865679A63, 0xCFE87F7CEF46FF16}, // 1e114
502 {0x4FCB7E8F3F60C07E, 0x81F14FAE158C5F6E}, // 1e115
503 {0xE3BE5E330F38F09D, 0xA26DA3999AEF7749}, // 1e116
504 {0x5CADF5BFD3072CC5, 0xCB090C8001AB551C}, // 1e117
505 {0x73D9732FC7C8F7F6, 0xFDCB4FA002162A63}, // 1e118
506 {0x2867E7FDDCDD9AFA, 0x9E9F11C4014DDA7E}, // 1e119
507 {0xB281E1FD541501B8, 0xC646D63501A1511D}, // 1e120
508 {0x1F225A7CA91A4226, 0xF7D88BC24209A565}, // 1e121
509 {0x3375788DE9B06958, 0x9AE757596946075F}, // 1e122
510 {0x0052D6B1641C83AE, 0xC1A12D2FC3978937}, // 1e123
511 {0xC0678C5DBD23A49A, 0xF209787BB47D6B84}, // 1e124
512 {0xF840B7BA963646E0, 0x9745EB4D50CE6332}, // 1e125
513 {0xB650E5A93BC3D898, 0xBD176620A501FBFF}, // 1e126
514 {0xA3E51F138AB4CEBE, 0xEC5D3FA8CE427AFF}, // 1e127
515 {0xC66F336C36B10137, 0x93BA47C980E98CDF}, // 1e128
516 {0xB80B0047445D4184, 0xB8A8D9BBE123F017}, // 1e129
517 {0xA60DC059157491E5, 0xE6D3102AD96CEC1D}, // 1e130
518 {0x87C89837AD68DB2F, 0x9043EA1AC7E41392}, // 1e131
519 {0x29BABE4598C311FB, 0xB454E4A179DD1877}, // 1e132
520 {0xF4296DD6FEF3D67A, 0xE16A1DC9D8545E94}, // 1e133
521 {0x1899E4A65F58660C, 0x8CE2529E2734BB1D}, // 1e134
522 {0x5EC05DCFF72E7F8F, 0xB01AE745B101E9E4}, // 1e135
523 {0x76707543F4FA1F73, 0xDC21A1171D42645D}, // 1e136
524 {0x6A06494A791C53A8, 0x899504AE72497EBA}, // 1e137
525 {0x0487DB9D17636892, 0xABFA45DA0EDBDE69}, // 1e138
526 {0x45A9D2845D3C42B6, 0xD6F8D7509292D603}, // 1e139
527 {0x0B8A2392BA45A9B2, 0x865B86925B9BC5C2}, // 1e140
528 {0x8E6CAC7768D7141E, 0xA7F26836F282B732}, // 1e141
529 {0x3207D795430CD926, 0xD1EF0244AF2364FF}, // 1e142
530 {0x7F44E6BD49E807B8, 0x8335616AED761F1F}, // 1e143
531 {0x5F16206C9C6209A6, 0xA402B9C5A8D3A6E7}, // 1e144
532 {0x36DBA887C37A8C0F, 0xCD036837130890A1}, // 1e145
533 {0xC2494954DA2C9789, 0x802221226BE55A64}, // 1e146
534 {0xF2DB9BAA10B7BD6C, 0xA02AA96B06DEB0FD}, // 1e147
535 {0x6F92829494E5ACC7, 0xC83553C5C8965D3D}, // 1e148
536 {0xCB772339BA1F17F9, 0xFA42A8B73ABBF48C}, // 1e149
537 {0xFF2A760414536EFB, 0x9C69A97284B578D7}, // 1e150
538 {0xFEF5138519684ABA, 0xC38413CF25E2D70D}, // 1e151
539 {0x7EB258665FC25D69, 0xF46518C2EF5B8CD1}, // 1e152
540 {0xEF2F773FFBD97A61, 0x98BF2F79D5993802}, // 1e153
541 {0xAAFB550FFACFD8FA, 0xBEEEFB584AFF8603}, // 1e154
542 {0x95BA2A53F983CF38, 0xEEAABA2E5DBF6784}, // 1e155
543 {0xDD945A747BF26183, 0x952AB45CFA97A0B2}, // 1e156
544 {0x94F971119AEEF9E4, 0xBA756174393D88DF}, // 1e157
545 {0x7A37CD5601AAB85D, 0xE912B9D1478CEB17}, // 1e158
546 {0xAC62E055C10AB33A, 0x91ABB422CCB812EE}, // 1e159
547 {0x577B986B314D6009, 0xB616A12B7FE617AA}, // 1e160
548 {0xED5A7E85FDA0B80B, 0xE39C49765FDF9D94}, // 1e161
549 {0x14588F13BE847307, 0x8E41ADE9FBEBC27D}, // 1e162
550 {0x596EB2D8AE258FC8, 0xB1D219647AE6B31C}, // 1e163
551 {0x6FCA5F8ED9AEF3BB, 0xDE469FBD99A05FE3}, // 1e164
552 {0x25DE7BB9480D5854, 0x8AEC23D680043BEE}, // 1e165
553 {0xAF561AA79A10AE6A, 0xADA72CCC20054AE9}, // 1e166
554 {0x1B2BA1518094DA04, 0xD910F7FF28069DA4}, // 1e167
555 {0x90FB44D2F05D0842, 0x87AA9AFF79042286}, // 1e168
556 {0x353A1607AC744A53, 0xA99541BF57452B28}, // 1e169
557 {0x42889B8997915CE8, 0xD3FA922F2D1675F2}, // 1e170
558 {0x69956135FEBADA11, 0x847C9B5D7C2E09B7}, // 1e171
559 {0x43FAB9837E699095, 0xA59BC234DB398C25}, // 1e172
560 {0x94F967E45E03F4BB, 0xCF02B2C21207EF2E}, // 1e173
561 {0x1D1BE0EEBAC278F5, 0x8161AFB94B44F57D}, // 1e174
562 {0x6462D92A69731732, 0xA1BA1BA79E1632DC}, // 1e175
563 {0x7D7B8F7503CFDCFE, 0xCA28A291859BBF93}, // 1e176
564 {0x5CDA735244C3D43E, 0xFCB2CB35E702AF78}, // 1e177
565 {0x3A0888136AFA64A7, 0x9DEFBF01B061ADAB}, // 1e178
566 {0x088AAA1845B8FDD0, 0xC56BAEC21C7A1916}, // 1e179
567 {0x8AAD549E57273D45, 0xF6C69A72A3989F5B}, // 1e180
568 {0x36AC54E2F678864B, 0x9A3C2087A63F6399}, // 1e181
569 {0x84576A1BB416A7DD, 0xC0CB28A98FCF3C7F}, // 1e182
570 {0x656D44A2A11C51D5, 0xF0FDF2D3F3C30B9F}, // 1e183
571 {0x9F644AE5A4B1B325, 0x969EB7C47859E743}, // 1e184
572 {0x873D5D9F0DDE1FEE, 0xBC4665B596706114}, // 1e185
573 {0xA90CB506D155A7EA, 0xEB57FF22FC0C7959}, // 1e186
574 {0x09A7F12442D588F2, 0x9316FF75DD87CBD8}, // 1e187
575 {0x0C11ED6D538AEB2F, 0xB7DCBF5354E9BECE}, // 1e188
576 {0x8F1668C8A86DA5FA, 0xE5D3EF282A242E81}, // 1e189
577 {0xF96E017D694487BC, 0x8FA475791A569D10}, // 1e190
578 {0x37C981DCC395A9AC, 0xB38D92D760EC4455}, // 1e191
579 {0x85BBE253F47B1417, 0xE070F78D3927556A}, // 1e192
580 {0x93956D7478CCEC8E, 0x8C469AB843B89562}, // 1e193
581 {0x387AC8D1970027B2, 0xAF58416654A6BABB}, // 1e194
582 {0x06997B05FCC0319E, 0xDB2E51BFE9D0696A}, // 1e195
583 {0x441FECE3BDF81F03, 0x88FCF317F22241E2}, // 1e196
584 {0xD527E81CAD7626C3, 0xAB3C2FDDEEAAD25A}, // 1e197
585 {0x8A71E223D8D3B074, 0xD60B3BD56A5586F1}, // 1e198
586 {0xF6872D5667844E49, 0x85C7056562757456}, // 1e199
587 {0xB428F8AC016561DB, 0xA738C6BEBB12D16C}, // 1e200
588 {0xE13336D701BEBA52, 0xD106F86E69D785C7}, // 1e201
589 {0xECC0024661173473, 0x82A45B450226B39C}, // 1e202
590 {0x27F002D7F95D0190, 0xA34D721642B06084}, // 1e203
591 {0x31EC038DF7B441F4, 0xCC20CE9BD35C78A5}, // 1e204
592 {0x7E67047175A15271, 0xFF290242C83396CE}, // 1e205
593 {0x0F0062C6E984D386, 0x9F79A169BD203E41}, // 1e206
594 {0x52C07B78A3E60868, 0xC75809C42C684DD1}, // 1e207
595 {0xA7709A56CCDF8A82, 0xF92E0C3537826145}, // 1e208
596 {0x88A66076400BB691, 0x9BBCC7A142B17CCB}, // 1e209
597 {0x6ACFF893D00EA435, 0xC2ABF989935DDBFE}, // 1e210
598 {0x0583F6B8C4124D43, 0xF356F7EBF83552FE}, // 1e211
599 {0xC3727A337A8B704A, 0x98165AF37B2153DE}, // 1e212
600 {0x744F18C0592E4C5C, 0xBE1BF1B059E9A8D6}, // 1e213
601 {0x1162DEF06F79DF73, 0xEDA2EE1C7064130C}, // 1e214
602 {0x8ADDCB5645AC2BA8, 0x9485D4D1C63E8BE7}, // 1e215
603 {0x6D953E2BD7173692, 0xB9A74A0637CE2EE1}, // 1e216
604 {0xC8FA8DB6CCDD0437, 0xE8111C87C5C1BA99}, // 1e217
605 {0x1D9C9892400A22A2, 0x910AB1D4DB9914A0}, // 1e218
606 {0x2503BEB6D00CAB4B, 0xB54D5E4A127F59C8}, // 1e219
607 {0x2E44AE64840FD61D, 0xE2A0B5DC971F303A}, // 1e220
608 {0x5CEAECFED289E5D2, 0x8DA471A9DE737E24}, // 1e221
609 {0x7425A83E872C5F47, 0xB10D8E1456105DAD}, // 1e222
610 {0xD12F124E28F77719, 0xDD50F1996B947518}, // 1e223
611 {0x82BD6B70D99AAA6F, 0x8A5296FFE33CC92F}, // 1e224
612 {0x636CC64D1001550B, 0xACE73CBFDC0BFB7B}, // 1e225
613 {0x3C47F7E05401AA4E, 0xD8210BEFD30EFA5A}, // 1e226
614 {0x65ACFAEC34810A71, 0x8714A775E3E95C78}, // 1e227
615 {0x7F1839A741A14D0D, 0xA8D9D1535CE3B396}, // 1e228
616 {0x1EDE48111209A050, 0xD31045A8341CA07C}, // 1e229
617 {0x934AED0AAB460432, 0x83EA2B892091E44D}, // 1e230
618 {0xF81DA84D5617853F, 0xA4E4B66B68B65D60}, // 1e231
619 {0x36251260AB9D668E, 0xCE1DE40642E3F4B9}, // 1e232
620 {0xC1D72B7C6B426019, 0x80D2AE83E9CE78F3}, // 1e233
621 {0xB24CF65B8612F81F, 0xA1075A24E4421730}, // 1e234
622 {0xDEE033F26797B627, 0xC94930AE1D529CFC}, // 1e235
623 {0x169840EF017DA3B1, 0xFB9B7CD9A4A7443C}, // 1e236
624 {0x8E1F289560EE864E, 0x9D412E0806E88AA5}, // 1e237
625 {0xF1A6F2BAB92A27E2, 0xC491798A08A2AD4E}, // 1e238
626 {0xAE10AF696774B1DB, 0xF5B5D7EC8ACB58A2}, // 1e239
627 {0xACCA6DA1E0A8EF29, 0x9991A6F3D6BF1765}, // 1e240
628 {0x17FD090A58D32AF3, 0xBFF610B0CC6EDD3F}, // 1e241
629 {0xDDFC4B4CEF07F5B0, 0xEFF394DCFF8A948E}, // 1e242
630 {0x4ABDAF101564F98E, 0x95F83D0A1FB69CD9}, // 1e243
631 {0x9D6D1AD41ABE37F1, 0xBB764C4CA7A4440F}, // 1e244
632 {0x84C86189216DC5ED, 0xEA53DF5FD18D5513}, // 1e245
633 {0x32FD3CF5B4E49BB4, 0x92746B9BE2F8552C}, // 1e246
634 {0x3FBC8C33221DC2A1, 0xB7118682DBB66A77}, // 1e247
635 {0x0FABAF3FEAA5334A, 0xE4D5E82392A40515}, // 1e248
636 {0x29CB4D87F2A7400E, 0x8F05B1163BA6832D}, // 1e249
637 {0x743E20E9EF511012, 0xB2C71D5BCA9023F8}, // 1e250
638 {0x914DA9246B255416, 0xDF78E4B2BD342CF6}, // 1e251
639 {0x1AD089B6C2F7548E, 0x8BAB8EEFB6409C1A}, // 1e252
640 {0xA184AC2473B529B1, 0xAE9672ABA3D0C320}, // 1e253
641 {0xC9E5D72D90A2741E, 0xDA3C0F568CC4F3E8}, // 1e254
642 {0x7E2FA67C7A658892, 0x8865899617FB1871}, // 1e255
643 {0xDDBB901B98FEEAB7, 0xAA7EEBFB9DF9DE8D}, // 1e256
644 {0x552A74227F3EA565, 0xD51EA6FA85785631}, // 1e257
645 {0xD53A88958F87275F, 0x8533285C936B35DE}, // 1e258
646 {0x8A892ABAF368F137, 0xA67FF273B8460356}, // 1e259
647 {0x2D2B7569B0432D85, 0xD01FEF10A657842C}, // 1e260
648 {0x9C3B29620E29FC73, 0x8213F56A67F6B29B}, // 1e261
649 {0x8349F3BA91B47B8F, 0xA298F2C501F45F42}, // 1e262
650 {0x241C70A936219A73, 0xCB3F2F7642717713}, // 1e263
651 {0xED238CD383AA0110, 0xFE0EFB53D30DD4D7}, // 1e264
652 {0xF4363804324A40AA, 0x9EC95D1463E8A506}, // 1e265
653 {0xB143C6053EDCD0D5, 0xC67BB4597CE2CE48}, // 1e266
654 {0xDD94B7868E94050A, 0xF81AA16FDC1B81DA}, // 1e267
655 {0xCA7CF2B4191C8326, 0x9B10A4E5E9913128}, // 1e268
656 {0xFD1C2F611F63A3F0, 0xC1D4CE1F63F57D72}, // 1e269
657 {0xBC633B39673C8CEC, 0xF24A01A73CF2DCCF}, // 1e270
658 {0xD5BE0503E085D813, 0x976E41088617CA01}, // 1e271
659 {0x4B2D8644D8A74E18, 0xBD49D14AA79DBC82}, // 1e272
660 {0xDDF8E7D60ED1219E, 0xEC9C459D51852BA2}, // 1e273
661 {0xCABB90E5C942B503, 0x93E1AB8252F33B45}, // 1e274
662 {0x3D6A751F3B936243, 0xB8DA1662E7B00A17}, // 1e275
663 {0x0CC512670A783AD4, 0xE7109BFBA19C0C9D}, // 1e276
664 {0x27FB2B80668B24C5, 0x906A617D450187E2}, // 1e277
665 {0xB1F9F660802DEDF6, 0xB484F9DC9641E9DA}, // 1e278
666 {0x5E7873F8A0396973, 0xE1A63853BBD26451}, // 1e279
667 {0xDB0B487B6423E1E8, 0x8D07E33455637EB2}, // 1e280
668 {0x91CE1A9A3D2CDA62, 0xB049DC016ABC5E5F}, // 1e281
669 {0x7641A140CC7810FB, 0xDC5C5301C56B75F7}, // 1e282
670 {0xA9E904C87FCB0A9D, 0x89B9B3E11B6329BA}, // 1e283
671 {0x546345FA9FBDCD44, 0xAC2820D9623BF429}, // 1e284
672 {0xA97C177947AD4095, 0xD732290FBACAF133}, // 1e285
673 {0x49ED8EABCCCC485D, 0x867F59A9D4BED6C0}, // 1e286
674 {0x5C68F256BFFF5A74, 0xA81F301449EE8C70}, // 1e287
675 {0x73832EEC6FFF3111, 0xD226FC195C6A2F8C}, // 1e288
676 {0xC831FD53C5FF7EAB, 0x83585D8FD9C25DB7}, // 1e289
677 {0xBA3E7CA8B77F5E55, 0xA42E74F3D032F525}, // 1e290
678 {0x28CE1BD2E55F35EB, 0xCD3A1230C43FB26F}, // 1e291
679 {0x7980D163CF5B81B3, 0x80444B5E7AA7CF85}, // 1e292
680 {0xD7E105BCC332621F, 0xA0555E361951C366}, // 1e293
681 {0x8DD9472BF3FEFAA7, 0xC86AB5C39FA63440}, // 1e294
682 {0xB14F98F6F0FEB951, 0xFA856334878FC150}, // 1e295
683 {0x6ED1BF9A569F33D3, 0x9C935E00D4B9D8D2}, // 1e296
684 {0x0A862F80EC4700C8, 0xC3B8358109E84F07}, // 1e297
685 {0xCD27BB612758C0FA, 0xF4A642E14C6262C8}, // 1e298
686 {0x8038D51CB897789C, 0x98E7E9CCCFBD7DBD}, // 1e299
687 {0xE0470A63E6BD56C3, 0xBF21E44003ACDD2C}, // 1e300
688 {0x1858CCFCE06CAC74, 0xEEEA5D5004981478}, // 1e301
689 {0x0F37801E0C43EBC8, 0x95527A5202DF0CCB}, // 1e302
690 {0xD30560258F54E6BA, 0xBAA718E68396CFFD}, // 1e303
691 {0x47C6B82EF32A2069, 0xE950DF20247C83FD}, // 1e304
692 {0x4CDC331D57FA5441, 0x91D28B7416CDD27E}, // 1e305
693 {0xE0133FE4ADF8E952, 0xB6472E511C81471D}, // 1e306
694 {0x58180FDDD97723A6, 0xE3D8F9E563A198E5}, // 1e307
695 {0x570F09EAA7EA7648, 0x8E679C2F5E44FF8F}, // 1e308
696 {0x2CD2CC6551E513DA, 0xB201833B35D63F73}, // 1e309
697 {0xF8077F7EA65E58D1, 0xDE81E40A034BCF4F}, // 1e310
698 {0xFB04AFAF27FAF782, 0x8B112E86420F6191}, // 1e311
699 {0x79C5DB9AF1F9B563, 0xADD57A27D29339F6}, // 1e312
700 {0x18375281AE7822BC, 0xD94AD8B1C7380874}, // 1e313
701 {0x8F2293910D0B15B5, 0x87CEC76F1C830548}, // 1e314
702 {0xB2EB3875504DDB22, 0xA9C2794AE3A3C69A}, // 1e315
703 {0x5FA60692A46151EB, 0xD433179D9C8CB841}, // 1e316
704 {0xDBC7C41BA6BCD333, 0x849FEEC281D7F328}, // 1e317
705 {0x12B9B522906C0800, 0xA5C7EA73224DEFF3}, // 1e318
706 {0xD768226B34870A00, 0xCF39E50FEAE16BEF}, // 1e319
707 {0xE6A1158300D46640, 0x81842F29F2CCE375}, // 1e320
708 {0x60495AE3C1097FD0, 0xA1E53AF46F801C53}, // 1e321
709 {0x385BB19CB14BDFC4, 0xCA5E89B18B602368}, // 1e322
710 {0x46729E03DD9ED7B5, 0xFCF62C1DEE382C42}, // 1e323
711 {0x6C07A2C26A8346D1, 0x9E19DB92B4E31BA9}, // 1e324
712 {0xC7098B7305241885, 0xC5A05277621BE293}, // 1e325
713 {0xB8CBEE4FC66D1EA7, 0xF70867153AA2DB38}, // 1e326
714 {0x737F74F1DC043328, 0x9A65406D44A5C903}, // 1e327
715 {0x505F522E53053FF2, 0xC0FE908895CF3B44}, // 1e328
716 {0x647726B9E7C68FEF, 0xF13E34AABB430A15}, // 1e329
717 {0x5ECA783430DC19F5, 0x96C6E0EAB509E64D}, // 1e330
718 {0xB67D16413D132072, 0xBC789925624C5FE0}, // 1e331
719 {0xE41C5BD18C57E88F, 0xEB96BF6EBADF77D8}, // 1e332
720 {0x8E91B962F7B6F159, 0x933E37A534CBAAE7}, // 1e333
721 {0x723627BBB5A4ADB0, 0xB80DC58E81FE95A1}, // 1e334
722 {0xCEC3B1AAA30DD91C, 0xE61136F2227E3B09}, // 1e335
723 {0x213A4F0AA5E8A7B1, 0x8FCAC257558EE4E6}, // 1e336
724 {0xA988E2CD4F62D19D, 0xB3BD72ED2AF29E1F}, // 1e337
725 {0x93EB1B80A33B8605, 0xE0ACCFA875AF45A7}, // 1e338
726 {0xBC72F130660533C3, 0x8C6C01C9498D8B88}, // 1e339
727 {0xEB8FAD7C7F8680B4, 0xAF87023B9BF0EE6A}, // 1e340
728 {0xA67398DB9F6820E1, 0xDB68C2CA82ED2A05}, // 1e341
729 {0x88083F8943A1148C, 0x892179BE91D43A43}, // 1e342
730 {0x6A0A4F6B948959B0, 0xAB69D82E364948D4}, // 1e343
731 {0x848CE34679ABB01C, 0xD6444E39C3DB9B09}, // 1e344
732 {0xF2D80E0C0C0B4E11, 0x85EAB0E41A6940E5}, // 1e345
733 {0x6F8E118F0F0E2195, 0xA7655D1D2103911F}, // 1e346
734 {0x4B7195F2D2D1A9FB, 0xD13EB46469447567}, // 1e347
735};
736
737} // namespace internal
738} // namespace LIBC_NAMESPACE_DECL
739
740#endif // LLVM_LIBC_SRC___SUPPORT_DETAILED_POWERS_OF_TEN_H
lib/libcxx/libc/src/__support/high_precision_decimal.h created+442
...@@ -0,0 +1,442 @@
1//===-- High Precision Decimal ----------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See httpss//llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// -----------------------------------------------------------------------------
10// **** WARNING ****
11// This file is shared with libc++. You should also be careful when adding
12// dependencies to this file, since it needs to build for all libc++ targets.
13// -----------------------------------------------------------------------------
14
15#ifndef LLVM_LIBC_SRC___SUPPORT_HIGH_PRECISION_DECIMAL_H
16#define LLVM_LIBC_SRC___SUPPORT_HIGH_PRECISION_DECIMAL_H
17
18#include "src/__support/CPP/limits.h"
19#include "src/__support/ctype_utils.h"
20#include "src/__support/macros/config.h"
21#include "src/__support/str_to_integer.h"
22#include <stdint.h>
23
24namespace LIBC_NAMESPACE_DECL {
25namespace internal {
26
27struct LShiftTableEntry {
28 uint32_t new_digits;
29 char const *power_of_five;
30};
31
32// -----------------------------------------------------------------------------
33// **** WARNING ****
34// This interface is shared with libc++, if you change this interface you need
35// to update it in both libc and libc++.
36// -----------------------------------------------------------------------------
37// This is used in both this file and in the main str_to_float.h.
38// TODO: Figure out where to put this.
39enum class RoundDirection { Up, Down, Nearest };
40
41// This is based on the HPD data structure described as part of the Simple
42// Decimal Conversion algorithm by Nigel Tao, described at this link:
43// https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html
44class HighPrecisionDecimal {
45
46 // This precomputed table speeds up left shifts by having the number of new
47 // digits that will be added by multiplying 5^i by 2^i. If the number is less
48 // than 5^i then it will add one fewer digit. There are only 60 entries since
49 // that's the max shift amount.
50 // This table was generated by the script at
51 // libc/utils/mathtools/GenerateHPDConstants.py
52 static constexpr LShiftTableEntry LEFT_SHIFT_DIGIT_TABLE[] = {
53 {0, ""},
54 {1, "5"},
55 {1, "25"},
56 {1, "125"},
57 {2, "625"},
58 {2, "3125"},
59 {2, "15625"},
60 {3, "78125"},
61 {3, "390625"},
62 {3, "1953125"},
63 {4, "9765625"},
64 {4, "48828125"},
65 {4, "244140625"},
66 {4, "1220703125"},
67 {5, "6103515625"},
68 {5, "30517578125"},
69 {5, "152587890625"},
70 {6, "762939453125"},
71 {6, "3814697265625"},
72 {6, "19073486328125"},
73 {7, "95367431640625"},
74 {7, "476837158203125"},
75 {7, "2384185791015625"},
76 {7, "11920928955078125"},
77 {8, "59604644775390625"},
78 {8, "298023223876953125"},
79 {8, "1490116119384765625"},
80 {9, "7450580596923828125"},
81 {9, "37252902984619140625"},
82 {9, "186264514923095703125"},
83 {10, "931322574615478515625"},
84 {10, "4656612873077392578125"},
85 {10, "23283064365386962890625"},
86 {10, "116415321826934814453125"},
87 {11, "582076609134674072265625"},
88 {11, "2910383045673370361328125"},
89 {11, "14551915228366851806640625"},
90 {12, "72759576141834259033203125"},
91 {12, "363797880709171295166015625"},
92 {12, "1818989403545856475830078125"},
93 {13, "9094947017729282379150390625"},
94 {13, "45474735088646411895751953125"},
95 {13, "227373675443232059478759765625"},
96 {13, "1136868377216160297393798828125"},
97 {14, "5684341886080801486968994140625"},
98 {14, "28421709430404007434844970703125"},
99 {14, "142108547152020037174224853515625"},
100 {15, "710542735760100185871124267578125"},
101 {15, "3552713678800500929355621337890625"},
102 {15, "17763568394002504646778106689453125"},
103 {16, "88817841970012523233890533447265625"},
104 {16, "444089209850062616169452667236328125"},
105 {16, "2220446049250313080847263336181640625"},
106 {16, "11102230246251565404236316680908203125"},
107 {17, "55511151231257827021181583404541015625"},
108 {17, "277555756156289135105907917022705078125"},
109 {17, "1387778780781445675529539585113525390625"},
110 {18, "6938893903907228377647697925567626953125"},
111 {18, "34694469519536141888238489627838134765625"},
112 {18, "173472347597680709441192448139190673828125"},
113 {19, "867361737988403547205962240695953369140625"},
114 };
115
116 // The maximum amount we can shift is the number of bits used in the
117 // accumulator, minus the number of bits needed to represent the base (in this
118 // case 4).
119 static constexpr uint32_t MAX_SHIFT_AMOUNT = sizeof(uint64_t) - 4;
120
121 // 800 is an arbitrary number of digits, but should be
122 // large enough for any practical number.
123 static constexpr uint32_t MAX_NUM_DIGITS = 800;
124
125 uint32_t num_digits = 0;
126 int32_t decimal_point = 0;
127 bool truncated = false;
128 uint8_t digits[MAX_NUM_DIGITS];
129
130private:
131 LIBC_INLINE bool should_round_up(int32_t round_to_digit,
132 RoundDirection round) {
133 if (round_to_digit < 0 ||
134 static_cast<uint32_t>(round_to_digit) >= this->num_digits) {
135 return false;
136 }
137
138 // The above condition handles all cases where all of the trailing digits
139 // are zero. In that case, if the rounding mode is up, then this number
140 // should be rounded up. Similarly, if the rounding mode is down, then it
141 // should always round down.
142 if (round == RoundDirection::Up) {
143 return true;
144 } else if (round == RoundDirection::Down) {
145 return false;
146 }
147 // Else round to nearest.
148
149 // If we're right in the middle and there are no extra digits
150 if (this->digits[round_to_digit] == 5 &&
151 static_cast<uint32_t>(round_to_digit + 1) == this->num_digits) {
152
153 // Round up if we've truncated (since that means the result is slightly
154 // higher than what's represented.)
155 if (this->truncated) {
156 return true;
157 }
158
159 // If this exactly halfway, round to even.
160 if (round_to_digit == 0)
161 // When the input is ".5".
162 return false;
163 return this->digits[round_to_digit - 1] % 2 != 0;
164 }
165 // If there are digits after round_to_digit, they must be non-zero since we
166 // trim trailing zeroes after all operations that change digits.
167 return this->digits[round_to_digit] >= 5;
168 }
169
170 // Takes an amount to left shift and returns the number of new digits needed
171 // to store the result based on LEFT_SHIFT_DIGIT_TABLE.
172 LIBC_INLINE uint32_t get_num_new_digits(uint32_t lshift_amount) {
173 const char *power_of_five =
174 LEFT_SHIFT_DIGIT_TABLE[lshift_amount].power_of_five;
175 uint32_t new_digits = LEFT_SHIFT_DIGIT_TABLE[lshift_amount].new_digits;
176 uint32_t digit_index = 0;
177 while (power_of_five[digit_index] != 0) {
178 if (digit_index >= this->num_digits) {
179 return new_digits - 1;
180 }
181 if (this->digits[digit_index] !=
182 internal::b36_char_to_int(power_of_five[digit_index])) {
183 return new_digits -
184 ((this->digits[digit_index] <
185 internal::b36_char_to_int(power_of_five[digit_index]))
186 ? 1
187 : 0);
188 }
189 ++digit_index;
190 }
191 return new_digits;
192 }
193
194 // Trim all trailing 0s
195 LIBC_INLINE void trim_trailing_zeroes() {
196 while (this->num_digits > 0 && this->digits[this->num_digits - 1] == 0) {
197 --this->num_digits;
198 }
199 if (this->num_digits == 0) {
200 this->decimal_point = 0;
201 }
202 }
203
204 // Perform a digitwise binary non-rounding right shift on this value by
205 // shift_amount. The shift_amount can't be more than MAX_SHIFT_AMOUNT to
206 // prevent overflow.
207 LIBC_INLINE void right_shift(uint32_t shift_amount) {
208 uint32_t read_index = 0;
209 uint32_t write_index = 0;
210
211 uint64_t accumulator = 0;
212
213 const uint64_t shift_mask = (uint64_t(1) << shift_amount) - 1;
214
215 // Warm Up phase: we don't have enough digits to start writing, so just
216 // read them into the accumulator.
217 while (accumulator >> shift_amount == 0) {
218 uint64_t read_digit = 0;
219 // If there are still digits to read, read the next one, else the digit is
220 // assumed to be 0.
221 if (read_index < this->num_digits) {
222 read_digit = this->digits[read_index];
223 }
224 accumulator = accumulator * 10 + read_digit;
225 ++read_index;
226 }
227
228 // Shift the decimal point by the number of digits it took to fill the
229 // accumulator.
230 this->decimal_point -= read_index - 1;
231
232 // Middle phase: we have enough digits to write, as well as more digits to
233 // read. Keep reading until we run out of digits.
234 while (read_index < this->num_digits) {
235 uint64_t read_digit = this->digits[read_index];
236 uint64_t write_digit = accumulator >> shift_amount;
237 accumulator &= shift_mask;
238 this->digits[write_index] = static_cast<uint8_t>(write_digit);
239 accumulator = accumulator * 10 + read_digit;
240 ++read_index;
241 ++write_index;
242 }
243
244 // Cool Down phase: All of the readable digits have been read, so just write
245 // the remainder, while treating any more digits as 0.
246 while (accumulator > 0) {
247 uint64_t write_digit = accumulator >> shift_amount;
248 accumulator &= shift_mask;
249 if (write_index < MAX_NUM_DIGITS) {
250 this->digits[write_index] = static_cast<uint8_t>(write_digit);
251 ++write_index;
252 } else if (write_digit > 0) {
253 this->truncated = true;
254 }
255 accumulator = accumulator * 10;
256 }
257 this->num_digits = write_index;
258 this->trim_trailing_zeroes();
259 }
260
261 // Perform a digitwise binary non-rounding left shift on this value by
262 // shift_amount. The shift_amount can't be more than MAX_SHIFT_AMOUNT to
263 // prevent overflow.
264 LIBC_INLINE void left_shift(uint32_t shift_amount) {
265 uint32_t new_digits = this->get_num_new_digits(shift_amount);
266
267 int32_t read_index = this->num_digits - 1;
268 uint32_t write_index = this->num_digits + new_digits;
269
270 uint64_t accumulator = 0;
271
272 // No Warm Up phase. Since we're putting digits in at the top and taking
273 // digits from the bottom we don't have to wait for the accumulator to fill.
274
275 // Middle phase: while we have more digits to read, keep reading as well as
276 // writing.
277 while (read_index >= 0) {
278 accumulator += static_cast<uint64_t>(this->digits[read_index])
279 << shift_amount;
280 uint64_t next_accumulator = accumulator / 10;
281 uint64_t write_digit = accumulator - (10 * next_accumulator);
282 --write_index;
283 if (write_index < MAX_NUM_DIGITS) {
284 this->digits[write_index] = static_cast<uint8_t>(write_digit);
285 } else if (write_digit != 0) {
286 this->truncated = true;
287 }
288 accumulator = next_accumulator;
289 --read_index;
290 }
291
292 // Cool Down phase: there are no more digits to read, so just write the
293 // remaining digits in the accumulator.
294 while (accumulator > 0) {
295 uint64_t next_accumulator = accumulator / 10;
296 uint64_t write_digit = accumulator - (10 * next_accumulator);
297 --write_index;
298 if (write_index < MAX_NUM_DIGITS) {
299 this->digits[write_index] = static_cast<uint8_t>(write_digit);
300 } else if (write_digit != 0) {
301 this->truncated = true;
302 }
303 accumulator = next_accumulator;
304 }
305
306 this->num_digits += new_digits;
307 if (this->num_digits > MAX_NUM_DIGITS) {
308 this->num_digits = MAX_NUM_DIGITS;
309 }
310 this->decimal_point += new_digits;
311 this->trim_trailing_zeroes();
312 }
313
314public:
315 // num_string is assumed to be a string of numeric characters. It doesn't
316 // handle leading spaces.
317 LIBC_INLINE
318 HighPrecisionDecimal(
319 const char *__restrict num_string,
320 const size_t num_len = cpp::numeric_limits<size_t>::max()) {
321 bool saw_dot = false;
322 size_t num_cur = 0;
323 // This counts the digits in the number, even if there isn't space to store
324 // them all.
325 uint32_t total_digits = 0;
326 while (num_cur < num_len &&
327 (isdigit(num_string[num_cur]) || num_string[num_cur] == '.')) {
328 if (num_string[num_cur] == '.') {
329 if (saw_dot) {
330 break;
331 }
332 this->decimal_point = total_digits;
333 saw_dot = true;
334 } else {
335 if (num_string[num_cur] == '0' && this->num_digits == 0) {
336 --this->decimal_point;
337 ++num_cur;
338 continue;
339 }
340 ++total_digits;
341 if (this->num_digits < MAX_NUM_DIGITS) {
342 this->digits[this->num_digits] = static_cast<uint8_t>(
343 internal::b36_char_to_int(num_string[num_cur]));
344 ++this->num_digits;
345 } else if (num_string[num_cur] != '0') {
346 this->truncated = true;
347 }
348 }
349 ++num_cur;
350 }
351
352 if (!saw_dot)
353 this->decimal_point = total_digits;
354
355 if (num_cur < num_len &&
356 (num_string[num_cur] == 'e' || num_string[num_cur] == 'E')) {
357 ++num_cur;
358 if (isdigit(num_string[num_cur]) || num_string[num_cur] == '+' ||
359 num_string[num_cur] == '-') {
360 auto result =
361 strtointeger<int32_t>(num_string + num_cur, 10, num_len - num_cur);
362 if (result.has_error()) {
363 // TODO: handle error
364 }
365 int32_t add_to_exponent = result.value;
366
367 // Here we do this operation as int64 to avoid overflow.
368 int64_t temp_exponent = static_cast<int64_t>(this->decimal_point) +
369 static_cast<int64_t>(add_to_exponent);
370
371 // Theoretically these numbers should be MAX_BIASED_EXPONENT for long
372 // double, but that should be ~16,000 which is much less than 1 << 30.
373 if (temp_exponent > (1 << 30)) {
374 temp_exponent = (1 << 30);
375 } else if (temp_exponent < -(1 << 30)) {
376 temp_exponent = -(1 << 30);
377 }
378 this->decimal_point = static_cast<int32_t>(temp_exponent);
379 }
380 }
381
382 this->trim_trailing_zeroes();
383 }
384
385 // Binary shift left (shift_amount > 0) or right (shift_amount < 0)
386 LIBC_INLINE void shift(int shift_amount) {
387 if (shift_amount == 0) {
388 return;
389 }
390 // Left
391 else if (shift_amount > 0) {
392 while (static_cast<uint32_t>(shift_amount) > MAX_SHIFT_AMOUNT) {
393 this->left_shift(MAX_SHIFT_AMOUNT);
394 shift_amount -= MAX_SHIFT_AMOUNT;
395 }
396 this->left_shift(shift_amount);
397 }
398 // Right
399 else {
400 while (static_cast<uint32_t>(shift_amount) < -MAX_SHIFT_AMOUNT) {
401 this->right_shift(MAX_SHIFT_AMOUNT);
402 shift_amount += MAX_SHIFT_AMOUNT;
403 }
404 this->right_shift(-shift_amount);
405 }
406 }
407
408 // Round the number represented to the closest value of unsigned int type T.
409 // This is done ignoring overflow.
410 template <class T>
411 LIBC_INLINE T
412 round_to_integer_type(RoundDirection round = RoundDirection::Nearest) {
413 T result = 0;
414 uint32_t cur_digit = 0;
415
416 while (static_cast<int32_t>(cur_digit) < this->decimal_point &&
417 cur_digit < this->num_digits) {
418 result = result * 10 + (this->digits[cur_digit]);
419 ++cur_digit;
420 }
421
422 // If there are implicit 0s at the end of the number, include those.
423 while (static_cast<int32_t>(cur_digit) < this->decimal_point) {
424 result *= 10;
425 ++cur_digit;
426 }
427 return result + static_cast<unsigned int>(
428 this->should_round_up(this->decimal_point, round));
429 }
430
431 // Extra functions for testing.
432
433 LIBC_INLINE uint8_t *get_digits() { return this->digits; }
434 LIBC_INLINE uint32_t get_num_digits() { return this->num_digits; }
435 LIBC_INLINE int32_t get_decimal_point() { return this->decimal_point; }
436 LIBC_INLINE void set_truncated(bool trunc) { this->truncated = trunc; }
437};
438
439} // namespace internal
440} // namespace LIBC_NAMESPACE_DECL
441
442#endif // LLVM_LIBC_SRC___SUPPORT_HIGH_PRECISION_DECIMAL_H
lib/libcxx/libc/src/__support/libc_assert.h created+88
...@@ -0,0 +1,88 @@
1//===-- Definition of a libc internal assert macro --------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_LIBC_ASSERT_H
10#define LLVM_LIBC_SRC___SUPPORT_LIBC_ASSERT_H
11
12#include "src/__support/macros/config.h"
13#if defined(LIBC_COPT_USE_C_ASSERT) || !defined(LIBC_FULL_BUILD)
14
15// The build is configured to just use the public <assert.h> API
16// for libc's internal assertions.
17
18#include <assert.h>
19
20#define LIBC_ASSERT(COND) assert(COND)
21
22#else // Not LIBC_COPT_USE_C_ASSERT
23
24#include "src/__support/OSUtil/exit.h"
25#include "src/__support/OSUtil/io.h"
26#include "src/__support/integer_to_string.h"
27#include "src/__support/macros/attributes.h" // For LIBC_INLINE
28#include "src/__support/macros/optimization.h" // For LIBC_UNLIKELY
29
30namespace LIBC_NAMESPACE_DECL {
31
32// This is intended to be removed in a future patch to use a similar design to
33// below, but it's necessary for the external assert.
34LIBC_INLINE void report_assertion_failure(const char *assertion,
35 const char *filename, unsigned line,
36 const char *funcname) {
37 const IntegerToString<unsigned> line_buffer(line);
38 write_to_stderr(filename);
39 write_to_stderr(":");
40 write_to_stderr(line_buffer.view());
41 write_to_stderr(": Assertion failed: '");
42 write_to_stderr(assertion);
43 write_to_stderr("' in function: '");
44 write_to_stderr(funcname);
45 write_to_stderr("'\n");
46}
47
48} // namespace LIBC_NAMESPACE_DECL
49
50#ifdef LIBC_ASSERT
51#error "Unexpected: LIBC_ASSERT macro already defined"
52#endif
53
54// The public "assert" macro calls abort on failure. Should it be same here?
55// The libc internal assert can fire from anywhere inside the libc. So, to
56// avoid potential chicken-and-egg problems, it is simple to do an exit
57// on assertion failure instead of calling abort. We also don't want to use
58// __builtin_trap as it could potentially be implemented using illegal
59// instructions which can be very misleading when debugging.
60#ifdef NDEBUG
61#define LIBC_ASSERT(COND) \
62 do { \
63 } while (false)
64#else
65
66// Convert __LINE__ to a string using macros. The indirection is necessary
67// because otherwise it will turn "__LINE__" into a string, not its value. The
68// value is evaluated in the indirection step.
69#define __LIBC_MACRO_TO_STR(x) #x
70#define __LIBC_MACRO_TO_STR_INDIR(y) __LIBC_MACRO_TO_STR(y)
71#define __LIBC_LINE_STR__ __LIBC_MACRO_TO_STR_INDIR(__LINE__)
72
73#define LIBC_ASSERT(COND) \
74 do { \
75 if (LIBC_UNLIKELY(!(COND))) { \
76 LIBC_NAMESPACE::write_to_stderr(__FILE__ ":" __LIBC_LINE_STR__ \
77 ": Assertion failed: '" #COND \
78 "' in function: '"); \
79 LIBC_NAMESPACE::write_to_stderr(__PRETTY_FUNCTION__); \
80 LIBC_NAMESPACE::write_to_stderr("'\n"); \
81 LIBC_NAMESPACE::internal::exit(0xFF); \
82 } \
83 } while (false)
84#endif // NDEBUG
85
86#endif // LIBC_COPT_USE_C_ASSERT
87
88#endif // LLVM_LIBC_SRC___SUPPORT_LIBC_ASSERT_H
lib/libcxx/libc/src/__support/macros/attributes.h created+51
...@@ -0,0 +1,51 @@
1//===-- Portable attributes -------------------------------------*- C++ -*-===//
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// This header file defines macros for declaring attributes for functions,
9// types, and variables.
10//
11// These macros are used within llvm-libc and allow the compiler to optimize,
12// where applicable, certain function calls.
13//
14// Most macros here are exposing GCC or Clang features, and are stubbed out for
15// other compilers.
16
17#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H
18#define LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H
19
20#include "properties/architectures.h"
21
22#ifndef __has_attribute
23#define __has_attribute(x) 0
24#endif
25
26#define LIBC_INLINE inline
27#define LIBC_INLINE_VAR inline
28#define LIBC_INLINE_ASM __asm__ __volatile__
29#define LIBC_UNUSED __attribute__((unused))
30
31#ifdef LIBC_TARGET_ARCH_IS_GPU
32#define LIBC_THREAD_LOCAL
33#else
34#define LIBC_THREAD_LOCAL thread_local
35#endif
36
37#if __cplusplus >= 202002L
38#define LIBC_CONSTINIT constinit
39#elif __has_attribute(__require_constant_initialization__)
40#define LIBC_CONSTINIT __attribute__((__require_constant_initialization__))
41#else
42#define LIBC_CONSTINIT
43#endif
44
45#if defined(__clang__) && __has_attribute(preferred_type)
46#define LIBC_PREFERED_TYPE(TYPE) [[clang::preferred_type(TYPE)]]
47#else
48#define LIBC_PREFERED_TYPE(TYPE)
49#endif
50
51#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H
lib/libcxx/libc/src/__support/macros/config.h created+46
...@@ -0,0 +1,46 @@
1//===-- Portable attributes -------------------------------------*- C++ -*-===//
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// This header file defines a set of macros for checking the presence of
9// important compiler and platform features. Such macros can be used to
10// produce portable code by parameterizing compilation based on the presence or
11// lack of a given feature.
12
13#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H
14#define LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H
15
16// Workaround for compilers that do not support builtin detection.
17// FIXME: This is only required for the GPU portion which should be moved.
18#ifndef __has_builtin
19#define __has_builtin(b) 0
20#endif
21
22// Compiler feature-detection.
23// clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension
24#ifdef __has_feature
25#define LIBC_HAS_FEATURE(f) __has_feature(f)
26#else
27#define LIBC_HAS_FEATURE(f) 0
28#endif
29
30#ifdef __clang__
31// Declare a LIBC_NAMESPACE with hidden visibility. `namespace
32// LIBC_NAMESPACE_DECL {` should be used around all declarations and definitions
33// for libc internals as opposed to just `namespace LIBC_NAMESPACE {`. This
34// ensures that all declarations within this namespace have hidden
35// visibility, which optimizes codegen for uses of symbols defined in other
36// translation units in ways that can be necessary for correctness by avoiding
37// dynamic relocations. This does not affect the public C symbols which are
38// controlled independently via `LLVM_LIBC_FUNCTION_ATTR`.
39#define LIBC_NAMESPACE_DECL [[gnu::visibility("hidden")]] LIBC_NAMESPACE
40#else
41// TODO(#98548): GCC emits a warning when using the visibility attribute which
42// needs to be diagnosed and addressed.
43#define LIBC_NAMESPACE_DECL LIBC_NAMESPACE
44#endif
45
46#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H
lib/libcxx/libc/src/__support/macros/null_check.h created+28
...@@ -0,0 +1,28 @@
1//===-- Safe nullptr check --------------------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_MACROS_NULL_CHECK_H
10#define LLVM_LIBC_SRC___SUPPORT_MACROS_NULL_CHECK_H
11
12#include "src/__support/macros/config.h"
13#include "src/__support/macros/optimization.h"
14#include "src/__support/macros/sanitizer.h"
15
16#if defined(LIBC_ADD_NULL_CHECKS) && !defined(LIBC_HAS_SANITIZER)
17#define LIBC_CRASH_ON_NULLPTR(ptr) \
18 do { \
19 if (LIBC_UNLIKELY((ptr) == nullptr)) \
20 __builtin_trap(); \
21 } while (0)
22#else
23#define LIBC_CRASH_ON_NULLPTR(ptr) \
24 do { \
25 } while (0)
26#endif
27
28#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_NULL_CHECK_H
lib/libcxx/libc/src/__support/macros/optimization.h created+61
...@@ -0,0 +1,61 @@
1//===-- Portable optimization macros ----------------------------*- C++ -*-===//
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// This header file defines portable macros for performance optimization.
9
10#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_OPTIMIZATION_H
11#define LLVM_LIBC_SRC___SUPPORT_MACROS_OPTIMIZATION_H
12
13#include "src/__support/macros/attributes.h" // LIBC_INLINE
14#include "src/__support/macros/config.h"
15#include "src/__support/macros/properties/compiler.h" // LIBC_COMPILER_IS_CLANG
16
17// We use a template to implement likely/unlikely to make sure that we don't
18// accidentally pass an integer.
19namespace LIBC_NAMESPACE_DECL {
20namespace details {
21template <typename T>
22LIBC_INLINE constexpr bool expects_bool_condition(T value, T expected) {
23 return __builtin_expect(value, expected);
24}
25} // namespace details
26} // namespace LIBC_NAMESPACE_DECL
27#define LIBC_LIKELY(x) LIBC_NAMESPACE::details::expects_bool_condition(x, true)
28#define LIBC_UNLIKELY(x) \
29 LIBC_NAMESPACE::details::expects_bool_condition(x, false)
30
31#if defined(LIBC_COMPILER_IS_CLANG)
32#define LIBC_LOOP_NOUNROLL _Pragma("nounroll")
33#elif defined(LIBC_COMPILER_IS_GCC)
34#define LIBC_LOOP_NOUNROLL _Pragma("GCC unroll 0")
35#else
36#error "Unhandled compiler"
37#endif
38
39// Defining optimization options for math functions.
40// TODO: Exporting this to public generated headers?
41#define LIBC_MATH_SKIP_ACCURATE_PASS 0x01
42#define LIBC_MATH_SMALL_TABLES 0x02
43#define LIBC_MATH_NO_ERRNO 0x04
44#define LIBC_MATH_NO_EXCEPT 0x08
45#define LIBC_MATH_FAST \
46 (LIBC_MATH_SKIP_ACCURATE_PASS | LIBC_MATH_SMALL_TABLES | \
47 LIBC_MATH_NO_ERRNO | LIBC_MATH_NO_EXCEPT)
48
49#ifndef LIBC_MATH
50#define LIBC_MATH 0
51#endif // LIBC_MATH
52
53#if (LIBC_MATH & LIBC_MATH_SKIP_ACCURATE_PASS)
54#define LIBC_MATH_HAS_SKIP_ACCURATE_PASS
55#endif
56
57#if (LIBC_MATH & LIBC_MATH_SMALL_TABLES)
58#define LIBC_MATH_HAS_SMALL_TABLES
59#endif
60
61#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_OPTIMIZATION_H
lib/libcxx/libc/src/__support/macros/properties/architectures.h created+64
...@@ -0,0 +1,64 @@
1//===-- Compile time architecture detection ---------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_ARCHITECTURES_H
10#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_ARCHITECTURES_H
11
12#if defined(__AMDGPU__)
13#define LIBC_TARGET_ARCH_IS_AMDGPU
14#endif
15
16#if defined(__NVPTX__)
17#define LIBC_TARGET_ARCH_IS_NVPTX
18#endif
19
20#if defined(LIBC_TARGET_ARCH_IS_NVPTX) || defined(LIBC_TARGET_ARCH_IS_AMDGPU)
21#define LIBC_TARGET_ARCH_IS_GPU
22#endif
23
24#if defined(__pnacl__) || defined(__CLR_VER) || defined(LIBC_TARGET_ARCH_IS_GPU)
25#define LIBC_TARGET_ARCH_IS_VM
26#endif
27
28#if (defined(_M_IX86) || defined(__i386__)) && !defined(LIBC_TARGET_ARCH_IS_VM)
29#define LIBC_TARGET_ARCH_IS_X86_32
30#endif
31
32#if (defined(_M_X64) || defined(__x86_64__)) && !defined(LIBC_TARGET_ARCH_IS_VM)
33#define LIBC_TARGET_ARCH_IS_X86_64
34#endif
35
36#if defined(LIBC_TARGET_ARCH_IS_X86_32) || defined(LIBC_TARGET_ARCH_IS_X86_64)
37#define LIBC_TARGET_ARCH_IS_X86
38#endif
39
40#if (defined(__arm__) || defined(_M_ARM))
41#define LIBC_TARGET_ARCH_IS_ARM
42#endif
43
44#if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64)
45#define LIBC_TARGET_ARCH_IS_AARCH64
46#endif
47
48#if defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(LIBC_TARGET_ARCH_IS_ARM)
49#define LIBC_TARGET_ARCH_IS_ANY_ARM
50#endif
51
52#if defined(__riscv) && (__riscv_xlen == 64)
53#define LIBC_TARGET_ARCH_IS_RISCV64
54#endif
55
56#if defined(__riscv) && (__riscv_xlen == 32)
57#define LIBC_TARGET_ARCH_IS_RISCV32
58#endif
59
60#if defined(LIBC_TARGET_ARCH_IS_RISCV64) || defined(LIBC_TARGET_ARCH_IS_RISCV32)
61#define LIBC_TARGET_ARCH_IS_ANY_RISCV
62#endif
63
64#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_ARCHITECTURES_H
lib/libcxx/libc/src/__support/macros/properties/compiler.h created+43
...@@ -0,0 +1,43 @@
1//===-- Compile time compiler detection -------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H
10#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H
11
12// Example usage of compiler version checks
13// #if defined(LIBC_COMPILER_CLANG_VER)
14// # if LIBC_COMPILER_CLANG_VER < 1500
15// # warning "Libc only supports Clang 15 and later"
16// # endif
17// #elif defined(LIBC_COMPILER_GCC_VER)
18// # if LIBC_COMPILER_GCC_VER < 1500
19// # warning "Libc only supports GCC 15 and later"
20// # endif
21// #elif defined(LIBC_COMPILER_MSC_VER)
22// # if LIBC_COMPILER_MSC_VER < 1930
23// # warning "Libc only supports Visual Studio 2022 RTW (17.0) and later"
24// # endif
25// #endif
26
27#if defined(__clang__)
28#define LIBC_COMPILER_IS_CLANG
29#define LIBC_COMPILER_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
30#endif
31
32#if defined(__GNUC__) && !defined(__clang__)
33#define LIBC_COMPILER_IS_GCC
34#define LIBC_COMPILER_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
35#endif
36
37#if defined(_MSC_VER)
38#define LIBC_COMPILER_IS_MSC
39// https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros
40#define LIBC_COMPILER_MSC_VER (_MSC_VER)
41#endif
42
43#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H
lib/libcxx/libc/src/__support/macros/properties/complex_types.h created+30
...@@ -0,0 +1,30 @@
1//===-- Complex Types support -----------------------------------*- C++ -*-===//
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// Complex Types detection and support.
9
10#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CTYPES_H
11#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CTYPES_H
12
13#include "include/llvm-libc-types/cfloat128.h"
14#include "include/llvm-libc-types/cfloat16.h"
15#include "types.h"
16
17// -- cfloat16 support --------------------------------------------------------
18// LIBC_TYPES_HAS_CFLOAT16 and 'cfloat16' type is provided by
19// "include/llvm-libc-types/cfloat16.h"
20
21// -- cfloat128 support -------------------------------------------------------
22// LIBC_TYPES_HAS_CFLOAT128 and 'cfloat128' type are provided by
23// "include/llvm-libc-types/cfloat128.h"
24
25#if defined(LIBC_TYPES_HAS_CFLOAT128) && \
26 !defined(LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE)
27#define LIBC_TYPES_CFLOAT128_IS_NOT_COMPLEX_LONG_DOUBLE
28#endif
29
30#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CTYPES_H
lib/libcxx/libc/src/__support/macros/properties/cpu_features.h created+60
...@@ -0,0 +1,60 @@
1//===-- Compile time cpu feature detection ----------------------*- C++ -*-===//
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// This file lists target cpu features by introspecting compiler enabled
9// preprocessor definitions.
10//===----------------------------------------------------------------------===//
11
12#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CPU_FEATURES_H
13#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CPU_FEATURES_H
14
15#include "architectures.h"
16
17#if defined(__ARM_FEATURE_FP16_SCALAR_ARITHMETIC)
18#define LIBC_TARGET_CPU_HAS_FULLFP16
19#endif
20
21#if defined(__SSE2__)
22#define LIBC_TARGET_CPU_HAS_SSE2
23#endif
24
25#if defined(__SSE4_2__)
26#define LIBC_TARGET_CPU_HAS_SSE4_2
27#endif
28
29#if defined(__AVX__)
30#define LIBC_TARGET_CPU_HAS_AVX
31#endif
32
33#if defined(__AVX2__)
34#define LIBC_TARGET_CPU_HAS_AVX2
35#endif
36
37#if defined(__AVX512F__)
38#define LIBC_TARGET_CPU_HAS_AVX512F
39#endif
40
41#if defined(__AVX512BW__)
42#define LIBC_TARGET_CPU_HAS_AVX512BW
43#endif
44
45#if defined(__ARM_FEATURE_FMA) || (defined(__AVX2__) && defined(__FMA__)) || \
46 defined(__NVPTX__) || defined(__AMDGPU__) || defined(__LIBC_RISCV_USE_FMA)
47#define LIBC_TARGET_CPU_HAS_FMA
48#endif
49
50#if defined(LIBC_TARGET_ARCH_IS_AARCH64) || \
51 (defined(LIBC_TARGET_ARCH_IS_X86_64) && \
52 defined(LIBC_TARGET_CPU_HAS_SSE4_2))
53#define LIBC_TARGET_CPU_HAS_NEAREST_INT
54#endif
55
56#if defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(LIBC_TARGET_ARCH_IS_GPU)
57#define LIBC_TARGET_CPU_HAS_FAST_FLOAT16_OPS
58#endif
59
60#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CPU_FEATURES_H
lib/libcxx/libc/src/__support/macros/properties/os.h created+32
...@@ -0,0 +1,32 @@
1//===-- Target OS detection -------------------------------------*- C++ -*-===//
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#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_OS_H
9#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_OS_H
10
11#if (defined(__freebsd__) || defined(__FreeBSD__))
12#define LIBC_TARGET_OS_IS_FREEBSD
13#endif
14
15#if defined(__ANDROID__)
16#define LIBC_TARGET_OS_IS_ANDROID
17#endif
18
19#if defined(__linux__) && !defined(LIBC_TARGET_OS_IS_FREEBSD) && \
20 !defined(LIBC_TARGET_OS_IS_ANDROID)
21#define LIBC_TARGET_OS_IS_LINUX
22#endif
23
24#if (defined(_WIN64) || defined(_WIN32))
25#define LIBC_TARGET_OS_IS_WINDOWS
26#endif
27
28#if defined(__Fuchsia__)
29#define LIBC_TARGET_OS_IS_FUCHSIA
30#endif
31
32#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_OS_H
lib/libcxx/libc/src/__support/macros/properties/types.h created+61
...@@ -0,0 +1,61 @@
1//===-- Types support -------------------------------------------*- C++ -*-===//
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// Types detection and support.
9
10#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_TYPES_H
11#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_TYPES_H
12
13#include "hdr/float_macros.h" // LDBL_MANT_DIG
14#include "include/llvm-libc-macros/float16-macros.h" // LIBC_TYPES_HAS_FLOAT16
15#include "include/llvm-libc-types/float128.h" // float128
16#include "src/__support/macros/properties/architectures.h"
17#include "src/__support/macros/properties/compiler.h"
18#include "src/__support/macros/properties/cpu_features.h"
19#include "src/__support/macros/properties/os.h"
20
21#include <stdint.h> // UINT64_MAX, __SIZEOF_INT128__
22
23// 'long double' properties.
24#if (LDBL_MANT_DIG == 53)
25#define LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64
26#elif (LDBL_MANT_DIG == 64)
27#define LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
28#elif (LDBL_MANT_DIG == 113)
29#define LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128
30#elif (LDBL_MANT_DIG == 106)
31#define LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
32#endif
33
34#if defined(LIBC_TYPES_HAS_FLOAT128) && \
35 !defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128)
36#define LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
37#endif
38
39// int64 / uint64 support
40#if defined(UINT64_MAX)
41#define LIBC_TYPES_HAS_INT64
42#endif // UINT64_MAX
43
44// int128 / uint128 support
45#if defined(__SIZEOF_INT128__) && !defined(LIBC_TARGET_OS_IS_WINDOWS)
46#define LIBC_TYPES_HAS_INT128
47#endif // defined(__SIZEOF_INT128__)
48
49// -- float16 support ---------------------------------------------------------
50// LIBC_TYPES_HAS_FLOAT16 is provided by
51// "include/llvm-libc-macros/float16-macros.h"
52#ifdef LIBC_TYPES_HAS_FLOAT16
53// Type alias for internal use.
54using float16 = _Float16;
55#endif // LIBC_TYPES_HAS_FLOAT16
56
57// -- float128 support --------------------------------------------------------
58// LIBC_TYPES_HAS_FLOAT128 and 'float128' type are provided by
59// "include/llvm-libc-types/float128.h"
60
61#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_TYPES_H
lib/libcxx/libc/src/__support/macros/sanitizer.h created+59
...@@ -0,0 +1,59 @@
1//===-- Convenient sanitizer macros -----------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_MACROS_SANITIZER_H
10#define LLVM_LIBC_SRC___SUPPORT_MACROS_SANITIZER_H
11
12#include "src/__support/macros/config.h" //LIBC_HAS_FEATURE
13
14//-----------------------------------------------------------------------------
15// Functions to unpoison memory
16//-----------------------------------------------------------------------------
17
18#if LIBC_HAS_FEATURE(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
19#define LIBC_HAS_ADDRESS_SANITIZER
20#endif
21
22#if LIBC_HAS_FEATURE(memory_sanitizer)
23#define LIBC_HAS_MEMORY_SANITIZER
24#endif
25
26#if LIBC_HAS_FEATURE(undefined_behavior_sanitizer)
27#define LIBC_HAS_UNDEFINED_BEHAVIOR_SANITIZER
28#endif
29
30#if defined(LIBC_HAS_ADDRESS_SANITIZER) || \
31 defined(LIBC_HAS_MEMORY_SANITIZER) || \
32 defined(LIBC_HAS_UNDEFINED_BEHAVIOR_SANITIZER)
33#define LIBC_HAS_SANITIZER
34#endif
35
36#ifdef LIBC_HAS_MEMORY_SANITIZER
37// Only perform MSAN unpoison in non-constexpr context.
38#include <sanitizer/msan_interface.h>
39#define MSAN_UNPOISON(addr, size) \
40 do { \
41 if (!__builtin_is_constant_evaluated()) \
42 __msan_unpoison(addr, size); \
43 } while (0)
44#else
45#define MSAN_UNPOISON(ptr, size)
46#endif
47
48#ifdef LIBC_HAS_ADDRESS_SANITIZER
49#include <sanitizer/asan_interface.h>
50#define ASAN_POISON_MEMORY_REGION(addr, size) \
51 __asan_poison_memory_region((addr), (size))
52#define ASAN_UNPOISON_MEMORY_REGION(addr, size) \
53 __asan_unpoison_memory_region((addr), (size))
54#else
55#define ASAN_POISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size))
56#define ASAN_UNPOISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size))
57#endif
58
59#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_SANITIZER_H
lib/libcxx/libc/src/__support/math_extras.h created+161
...@@ -0,0 +1,161 @@
1//===-- Mimics llvm/Support/MathExtras.h ------------------------*- C++ -*-===//
2// Provides useful math functions.
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 LLVM_LIBC_SRC___SUPPORT_MATH_EXTRAS_H
11#define LLVM_LIBC_SRC___SUPPORT_MATH_EXTRAS_H
12
13#include "src/__support/CPP/bit.h" // countl_one, countr_zero
14#include "src/__support/CPP/limits.h" // CHAR_BIT, numeric_limits
15#include "src/__support/CPP/type_traits.h" // is_unsigned_v, is_constant_evaluated
16#include "src/__support/macros/attributes.h" // LIBC_INLINE
17#include "src/__support/macros/config.h"
18
19namespace LIBC_NAMESPACE_DECL {
20
21// Create a bitmask with the count right-most bits set to 1, and all other bits
22// set to 0. Only unsigned types are allowed.
23template <typename T, size_t count>
24LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T>
25mask_trailing_ones() {
26 constexpr unsigned T_BITS = CHAR_BIT * sizeof(T);
27 static_assert(count <= T_BITS && "Invalid bit index");
28 return count == 0 ? 0 : (T(-1) >> (T_BITS - count));
29}
30
31// Create a bitmask with the count left-most bits set to 1, and all other bits
32// set to 0. Only unsigned types are allowed.
33template <typename T, size_t count>
34LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T>
35mask_leading_ones() {
36 return T(~mask_trailing_ones<T, CHAR_BIT * sizeof(T) - count>());
37}
38
39// Create a bitmask with the count right-most bits set to 0, and all other bits
40// set to 1. Only unsigned types are allowed.
41template <typename T, size_t count>
42LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T>
43mask_trailing_zeros() {
44 return mask_leading_ones<T, CHAR_BIT * sizeof(T) - count>();
45}
46
47// Create a bitmask with the count left-most bits set to 0, and all other bits
48// set to 1. Only unsigned types are allowed.
49template <typename T, size_t count>
50LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T>
51mask_leading_zeros() {
52 return mask_trailing_ones<T, CHAR_BIT * sizeof(T) - count>();
53}
54
55// Returns whether 'a + b' overflows, the result is stored in 'res'.
56template <typename T>
57[[nodiscard]] LIBC_INLINE constexpr bool add_overflow(T a, T b, T &res) {
58 return __builtin_add_overflow(a, b, &res);
59}
60
61// Returns whether 'a - b' overflows, the result is stored in 'res'.
62template <typename T>
63[[nodiscard]] LIBC_INLINE constexpr bool sub_overflow(T a, T b, T &res) {
64 return __builtin_sub_overflow(a, b, &res);
65}
66
67#define RETURN_IF(TYPE, BUILTIN) \
68 if constexpr (cpp::is_same_v<T, TYPE>) \
69 return BUILTIN(a, b, carry_in, carry_out);
70
71// Returns the result of 'a + b' taking into account 'carry_in'.
72// The carry out is stored in 'carry_out' it not 'nullptr', dropped otherwise.
73// We keep the pass by pointer interface for consistency with the intrinsic.
74template <typename T>
75[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T>
76add_with_carry(T a, T b, T carry_in, T &carry_out) {
77 if constexpr (!cpp::is_constant_evaluated()) {
78#if __has_builtin(__builtin_addcb)
79 RETURN_IF(unsigned char, __builtin_addcb)
80#elif __has_builtin(__builtin_addcs)
81 RETURN_IF(unsigned short, __builtin_addcs)
82#elif __has_builtin(__builtin_addc)
83 RETURN_IF(unsigned int, __builtin_addc)
84#elif __has_builtin(__builtin_addcl)
85 RETURN_IF(unsigned long, __builtin_addcl)
86#elif __has_builtin(__builtin_addcll)
87 RETURN_IF(unsigned long long, __builtin_addcll)
88#endif
89 }
90 T sum = {};
91 T carry1 = add_overflow(a, b, sum);
92 T carry2 = add_overflow(sum, carry_in, sum);
93 carry_out = carry1 | carry2;
94 return sum;
95}
96
97// Returns the result of 'a - b' taking into account 'carry_in'.
98// The carry out is stored in 'carry_out' it not 'nullptr', dropped otherwise.
99// We keep the pass by pointer interface for consistency with the intrinsic.
100template <typename T>
101[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T>
102sub_with_borrow(T a, T b, T carry_in, T &carry_out) {
103 if constexpr (!cpp::is_constant_evaluated()) {
104#if __has_builtin(__builtin_subcb)
105 RETURN_IF(unsigned char, __builtin_subcb)
106#elif __has_builtin(__builtin_subcs)
107 RETURN_IF(unsigned short, __builtin_subcs)
108#elif __has_builtin(__builtin_subc)
109 RETURN_IF(unsigned int, __builtin_subc)
110#elif __has_builtin(__builtin_subcl)
111 RETURN_IF(unsigned long, __builtin_subcl)
112#elif __has_builtin(__builtin_subcll)
113 RETURN_IF(unsigned long long, __builtin_subcll)
114#endif
115 }
116 T sub = {};
117 T carry1 = sub_overflow(a, b, sub);
118 T carry2 = sub_overflow(sub, carry_in, sub);
119 carry_out = carry1 | carry2;
120 return sub;
121}
122
123#undef RETURN_IF
124
125template <typename T>
126[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
127first_leading_zero(T value) {
128 return value == cpp::numeric_limits<T>::max() ? 0
129 : cpp::countl_one(value) + 1;
130}
131
132template <typename T>
133[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
134first_leading_one(T value) {
135 return first_leading_zero(static_cast<T>(~value));
136}
137
138template <typename T>
139[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
140first_trailing_zero(T value) {
141 return value == cpp::numeric_limits<T>::max()
142 ? 0
143 : cpp::countr_zero(static_cast<T>(~value)) + 1;
144}
145
146template <typename T>
147[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
148first_trailing_one(T value) {
149 return value == cpp::numeric_limits<T>::max() ? 0
150 : cpp::countr_zero(value) + 1;
151}
152
153template <typename T>
154[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int>
155count_zeros(T value) {
156 return cpp::popcount<T>(static_cast<T>(~value));
157}
158
159} // namespace LIBC_NAMESPACE_DECL
160
161#endif // LLVM_LIBC_SRC___SUPPORT_MATH_EXTRAS_H
lib/libcxx/libc/src/__support/number_pair.h created+26
...@@ -0,0 +1,26 @@
1//===-- Utilities for pairs of numbers. -------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_NUMBER_PAIR_H
10#define LLVM_LIBC_SRC___SUPPORT_NUMBER_PAIR_H
11
12#include "CPP/type_traits.h"
13#include "src/__support/macros/config.h"
14
15#include <stddef.h>
16
17namespace LIBC_NAMESPACE_DECL {
18
19template <typename T> struct NumberPair {
20 T lo = T(0);
21 T hi = T(0);
22};
23
24} // namespace LIBC_NAMESPACE_DECL
25
26#endif // LLVM_LIBC_SRC___SUPPORT_NUMBER_PAIR_H
lib/libcxx/libc/src/__support/sign.h created+43
...@@ -0,0 +1,43 @@
1//===-- A simple sign type --------------------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_SIGN_H
10#define LLVM_LIBC_SRC___SUPPORT_SIGN_H
11
12#include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR
13
14namespace LIBC_NAMESPACE_DECL {
15
16// A type to interact with signed arithmetic types.
17struct Sign {
18 LIBC_INLINE constexpr bool is_pos() const { return !is_negative; }
19 LIBC_INLINE constexpr bool is_neg() const { return is_negative; }
20
21 LIBC_INLINE friend constexpr bool operator==(Sign a, Sign b) {
22 return a.is_negative == b.is_negative;
23 }
24
25 LIBC_INLINE friend constexpr bool operator!=(Sign a, Sign b) {
26 return !(a == b);
27 }
28
29 static const Sign POS;
30 static const Sign NEG;
31
32private:
33 LIBC_INLINE constexpr explicit Sign(bool is_negative)
34 : is_negative(is_negative) {}
35
36 bool is_negative;
37};
38
39LIBC_INLINE_VAR constexpr Sign Sign::NEG = Sign(true);
40LIBC_INLINE_VAR constexpr Sign Sign::POS = Sign(false);
41
42} // namespace LIBC_NAMESPACE_DECL
43#endif // LLVM_LIBC_SRC___SUPPORT_SIGN_H
lib/libcxx/libc/src/__support/str_to_float.h created+1275
...@@ -0,0 +1,1275 @@
1//===-- String to float conversion utils ------------------------*- C++ -*-===//
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// -----------------------------------------------------------------------------
10// **** WARNING ****
11// This file is shared with libc++. You should also be careful when adding
12// dependencies to this file, since it needs to build for all libc++ targets.
13// -----------------------------------------------------------------------------
14
15#ifndef LLVM_LIBC_SRC___SUPPORT_STR_TO_FLOAT_H
16#define LLVM_LIBC_SRC___SUPPORT_STR_TO_FLOAT_H
17
18#include "src/__support/CPP/bit.h"
19#include "src/__support/CPP/limits.h"
20#include "src/__support/CPP/optional.h"
21#include "src/__support/CPP/string_view.h"
22#include "src/__support/FPUtil/FPBits.h"
23#include "src/__support/FPUtil/rounding_mode.h"
24#include "src/__support/common.h"
25#include "src/__support/ctype_utils.h"
26#include "src/__support/detailed_powers_of_ten.h"
27#include "src/__support/high_precision_decimal.h"
28#include "src/__support/macros/config.h"
29#include "src/__support/macros/null_check.h"
30#include "src/__support/macros/optimization.h"
31#include "src/__support/str_to_integer.h"
32#include "src/__support/str_to_num_result.h"
33#include "src/__support/uint128.h"
34#include "src/errno/libc_errno.h" // For ERANGE
35
36#include <stdint.h>
37
38namespace LIBC_NAMESPACE_DECL {
39namespace internal {
40
41// -----------------------------------------------------------------------------
42// **** WARNING ****
43// This interface is shared with libc++, if you change this interface you need
44// to update it in both libc and libc++.
45// -----------------------------------------------------------------------------
46template <class T> struct ExpandedFloat {
47 typename fputil::FPBits<T>::StorageType mantissa;
48 int32_t exponent;
49};
50
51// -----------------------------------------------------------------------------
52// **** WARNING ****
53// This interface is shared with libc++, if you change this interface you need
54// to update it in both libc and libc++.
55// -----------------------------------------------------------------------------
56template <class T> struct FloatConvertReturn {
57 ExpandedFloat<T> num = {0, 0};
58 int error = 0;
59};
60
61LIBC_INLINE uint64_t low64(const UInt128 &num) {
62 return static_cast<uint64_t>(num & 0xffffffffffffffff);
63}
64
65LIBC_INLINE uint64_t high64(const UInt128 &num) {
66 return static_cast<uint64_t>(num >> 64);
67}
68
69template <class T> LIBC_INLINE void set_implicit_bit(fputil::FPBits<T> &) {
70 return;
71}
72
73#if defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80)
74template <>
75LIBC_INLINE void
76set_implicit_bit<long double>(fputil::FPBits<long double> &result) {
77 result.set_implicit_bit(result.get_biased_exponent() != 0);
78}
79#endif // LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
80
81// This Eisel-Lemire implementation is based on the algorithm described in the
82// paper Number Parsing at a Gigabyte per Second, Software: Practice and
83// Experience 51 (8), 2021 (https://arxiv.org/abs/2101.11408), as well as the
84// description by Nigel Tao
85// (https://nigeltao.github.io/blog/2020/eisel-lemire.html) and the golang
86// implementation, also by Nigel Tao
87// (https://github.com/golang/go/blob/release-branch.go1.16/src/strconv/eisel_lemire.go#L25)
88// for some optimizations as well as handling 32 bit floats.
89template <class T>
90LIBC_INLINE cpp::optional<ExpandedFloat<T>>
91eisel_lemire(ExpandedFloat<T> init_num,
92 RoundDirection round = RoundDirection::Nearest) {
93 using FPBits = typename fputil::FPBits<T>;
94 using StorageType = typename FPBits::StorageType;
95
96 StorageType mantissa = init_num.mantissa;
97 int32_t exp10 = init_num.exponent;
98
99 if (sizeof(T) > 8) { // This algorithm cannot handle anything longer than a
100 // double, so we skip straight to the fallback.
101 return cpp::nullopt;
102 }
103
104 // Exp10 Range
105 if (exp10 < DETAILED_POWERS_OF_TEN_MIN_EXP_10 ||
106 exp10 > DETAILED_POWERS_OF_TEN_MAX_EXP_10) {
107 return cpp::nullopt;
108 }
109
110 // Normalization
111 uint32_t clz = cpp::countl_zero<StorageType>(mantissa);
112 mantissa <<= clz;
113
114 int32_t exp2 =
115 exp10_to_exp2(exp10) + FPBits::STORAGE_LEN + FPBits::EXP_BIAS - clz;
116
117 // Multiplication
118 const uint64_t *power_of_ten =
119 DETAILED_POWERS_OF_TEN[exp10 - DETAILED_POWERS_OF_TEN_MIN_EXP_10];
120
121 UInt128 first_approx =
122 static_cast<UInt128>(mantissa) * static_cast<UInt128>(power_of_ten[1]);
123
124 // Wider Approximation
125 UInt128 final_approx;
126 // The halfway constant is used to check if the bits that will be shifted away
127 // intially are all 1. For doubles this is 64 (bitstype size) - 52 (final
128 // mantissa size) - 3 (we shift away the last two bits separately for
129 // accuracy, and the most significant bit is ignored.) = 9 bits. Similarly,
130 // it's 6 bits for floats in this case.
131 const uint64_t halfway_constant =
132 (uint64_t(1) << (FPBits::STORAGE_LEN - (FPBits::FRACTION_LEN + 3))) - 1;
133 if ((high64(first_approx) & halfway_constant) == halfway_constant &&
134 low64(first_approx) + mantissa < mantissa) {
135 UInt128 low_bits =
136 static_cast<UInt128>(mantissa) * static_cast<UInt128>(power_of_ten[0]);
137 UInt128 second_approx =
138 first_approx + static_cast<UInt128>(high64(low_bits));
139
140 if ((high64(second_approx) & halfway_constant) == halfway_constant &&
141 low64(second_approx) + 1 == 0 &&
142 low64(low_bits) + mantissa < mantissa) {
143 return cpp::nullopt;
144 }
145 final_approx = second_approx;
146 } else {
147 final_approx = first_approx;
148 }
149
150 // Shifting to 54 bits for doubles and 25 bits for floats
151 StorageType msb = static_cast<StorageType>(high64(final_approx) >>
152 (FPBits::STORAGE_LEN - 1));
153 StorageType final_mantissa = static_cast<StorageType>(
154 high64(final_approx) >>
155 (msb + FPBits::STORAGE_LEN - (FPBits::FRACTION_LEN + 3)));
156 exp2 -= static_cast<uint32_t>(1 ^ msb); // same as !msb
157
158 if (round == RoundDirection::Nearest) {
159 // Half-way ambiguity
160 if (low64(final_approx) == 0 &&
161 (high64(final_approx) & halfway_constant) == 0 &&
162 (final_mantissa & 3) == 1) {
163 return cpp::nullopt;
164 }
165
166 // Round to even.
167 final_mantissa += final_mantissa & 1;
168
169 } else if (round == RoundDirection::Up) {
170 // If any of the bits being rounded away are non-zero, then round up.
171 if (low64(final_approx) > 0 ||
172 (high64(final_approx) & halfway_constant) > 0) {
173 // Add two since the last current lowest bit is about to be shifted away.
174 final_mantissa += 2;
175 }
176 }
177 // else round down, which has no effect.
178
179 // From 54 to 53 bits for doubles and 25 to 24 bits for floats
180 final_mantissa >>= 1;
181 if ((final_mantissa >> (FPBits::FRACTION_LEN + 1)) > 0) {
182 final_mantissa >>= 1;
183 ++exp2;
184 }
185
186 // The if block is equivalent to (but has fewer branches than):
187 // if exp2 <= 0 || exp2 >= 0x7FF { etc }
188 if (static_cast<uint32_t>(exp2) - 1 >= (1 << FPBits::EXP_LEN) - 2) {
189 return cpp::nullopt;
190 }
191
192 ExpandedFloat<T> output;
193 output.mantissa = final_mantissa;
194 output.exponent = exp2;
195 return output;
196}
197
198// TODO: Re-enable eisel-lemire for long double is double double once it's
199// properly supported.
200#if !defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64) && \
201 !defined(LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE)
202template <>
203LIBC_INLINE cpp::optional<ExpandedFloat<long double>>
204eisel_lemire<long double>(ExpandedFloat<long double> init_num,
205 RoundDirection round) {
206 using FPBits = typename fputil::FPBits<long double>;
207 using StorageType = typename FPBits::StorageType;
208
209 UInt128 mantissa = init_num.mantissa;
210 int32_t exp10 = init_num.exponent;
211
212 // Exp10 Range
213 // This doesn't reach very far into the range for long doubles, since it's
214 // sized for doubles and their 11 exponent bits, and not for long doubles and
215 // their 15 exponent bits (max exponent of ~300 for double vs ~5000 for long
216 // double). This is a known tradeoff, and was made because a proper long
217 // double table would be approximately 16 times larger. This would have
218 // significant memory and storage costs all the time to speed up a relatively
219 // uncommon path. In addition the exp10_to_exp2 function only approximates
220 // multiplying by log(10)/log(2), and that approximation may not be accurate
221 // out to the full long double range.
222 if (exp10 < DETAILED_POWERS_OF_TEN_MIN_EXP_10 ||
223 exp10 > DETAILED_POWERS_OF_TEN_MAX_EXP_10) {
224 return cpp::nullopt;
225 }
226
227 // Normalization
228 uint32_t clz = cpp::countl_zero(mantissa) -
229 ((sizeof(UInt128) - sizeof(StorageType)) * CHAR_BIT);
230 mantissa <<= clz;
231
232 int32_t exp2 =
233 exp10_to_exp2(exp10) + FPBits::STORAGE_LEN + FPBits::EXP_BIAS - clz;
234
235 // Multiplication
236 const uint64_t *power_of_ten =
237 DETAILED_POWERS_OF_TEN[exp10 - DETAILED_POWERS_OF_TEN_MIN_EXP_10];
238
239 // Since the input mantissa is more than 64 bits, we have to multiply with the
240 // full 128 bits of the power of ten to get an approximation with the same
241 // number of significant bits. This means that we only get the one
242 // approximation, and that approximation is 256 bits long.
243 UInt128 approx_upper = static_cast<UInt128>(high64(mantissa)) *
244 static_cast<UInt128>(power_of_ten[1]);
245
246 UInt128 approx_middle_a = static_cast<UInt128>(high64(mantissa)) *
247 static_cast<UInt128>(power_of_ten[0]);
248 UInt128 approx_middle_b = static_cast<UInt128>(low64(mantissa)) *
249 static_cast<UInt128>(power_of_ten[1]);
250
251 UInt128 approx_middle = approx_middle_a + approx_middle_b;
252
253 // Handle overflow in the middle
254 approx_upper += (approx_middle < approx_middle_a) ? UInt128(1) << 64 : 0;
255
256 UInt128 approx_lower = static_cast<UInt128>(low64(mantissa)) *
257 static_cast<UInt128>(power_of_ten[0]);
258
259 UInt128 final_approx_lower =
260 approx_lower + (static_cast<UInt128>(low64(approx_middle)) << 64);
261 UInt128 final_approx_upper = approx_upper + high64(approx_middle) +
262 (final_approx_lower < approx_lower ? 1 : 0);
263
264 // The halfway constant is used to check if the bits that will be shifted away
265 // intially are all 1. For 80 bit floats this is 128 (bitstype size) - 64
266 // (final mantissa size) - 3 (we shift away the last two bits separately for
267 // accuracy, and the most significant bit is ignored.) = 61 bits. Similarly,
268 // it's 12 bits for 128 bit floats in this case.
269 constexpr UInt128 HALFWAY_CONSTANT =
270 (UInt128(1) << (FPBits::STORAGE_LEN - (FPBits::FRACTION_LEN + 3))) - 1;
271
272 if ((final_approx_upper & HALFWAY_CONSTANT) == HALFWAY_CONSTANT &&
273 final_approx_lower + mantissa < mantissa) {
274 return cpp::nullopt;
275 }
276
277 // Shifting to 65 bits for 80 bit floats and 113 bits for 128 bit floats
278 uint32_t msb =
279 static_cast<uint32_t>(final_approx_upper >> (FPBits::STORAGE_LEN - 1));
280 UInt128 final_mantissa = final_approx_upper >> (msb + FPBits::STORAGE_LEN -
281 (FPBits::FRACTION_LEN + 3));
282 exp2 -= static_cast<uint32_t>(1 ^ msb); // same as !msb
283
284 if (round == RoundDirection::Nearest) {
285 // Half-way ambiguity
286 if (final_approx_lower == 0 &&
287 (final_approx_upper & HALFWAY_CONSTANT) == 0 &&
288 (final_mantissa & 3) == 1) {
289 return cpp::nullopt;
290 }
291 // Round to even.
292 final_mantissa += final_mantissa & 1;
293
294 } else if (round == RoundDirection::Up) {
295 // If any of the bits being rounded away are non-zero, then round up.
296 if (final_approx_lower > 0 || (final_approx_upper & HALFWAY_CONSTANT) > 0) {
297 // Add two since the last current lowest bit is about to be shifted away.
298 final_mantissa += 2;
299 }
300 }
301 // else round down, which has no effect.
302
303 // From 65 to 64 bits for 80 bit floats and 113 to 112 bits for 128 bit
304 // floats
305 final_mantissa >>= 1;
306 if ((final_mantissa >> (FPBits::FRACTION_LEN + 1)) > 0) {
307 final_mantissa >>= 1;
308 ++exp2;
309 }
310
311 // The if block is equivalent to (but has fewer branches than):
312 // if exp2 <= 0 || exp2 >= MANTISSA_MAX { etc }
313 if (exp2 - 1 >= (1 << FPBits::EXP_LEN) - 2) {
314 return cpp::nullopt;
315 }
316
317 ExpandedFloat<long double> output;
318 output.mantissa = static_cast<StorageType>(final_mantissa);
319 output.exponent = exp2;
320 return output;
321}
322#endif // !defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64) &&
323 // !defined(LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE)
324
325// The nth item in POWERS_OF_TWO represents the greatest power of two less than
326// 10^n. This tells us how much we can safely shift without overshooting.
327constexpr uint8_t POWERS_OF_TWO[19] = {
328 0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59,
329};
330constexpr int32_t NUM_POWERS_OF_TWO =
331 sizeof(POWERS_OF_TWO) / sizeof(POWERS_OF_TWO[0]);
332
333// Takes a mantissa and base 10 exponent and converts it into its closest
334// floating point type T equivalent. This is the fallback algorithm used when
335// the Eisel-Lemire algorithm fails, it's slower but more accurate. It's based
336// on the Simple Decimal Conversion algorithm by Nigel Tao, described at this
337// link: https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html
338template <class T>
339LIBC_INLINE FloatConvertReturn<T> simple_decimal_conversion(
340 const char *__restrict numStart,
341 const size_t num_len = cpp::numeric_limits<size_t>::max(),
342 RoundDirection round = RoundDirection::Nearest) {
343 using FPBits = typename fputil::FPBits<T>;
344 using StorageType = typename FPBits::StorageType;
345
346 int32_t exp2 = 0;
347 HighPrecisionDecimal hpd = HighPrecisionDecimal(numStart, num_len);
348
349 FloatConvertReturn<T> output;
350
351 if (hpd.get_num_digits() == 0) {
352 output.num = {0, 0};
353 return output;
354 }
355
356 // If the exponent is too large and can't be represented in this size of
357 // float, return inf.
358 if (hpd.get_decimal_point() > 0 &&
359 exp10_to_exp2(hpd.get_decimal_point() - 1) > FPBits::EXP_BIAS) {
360 output.num = {0, fputil::FPBits<T>::MAX_BIASED_EXPONENT};
361 output.error = ERANGE;
362 return output;
363 }
364 // If the exponent is too small even for a subnormal, return 0.
365 if (hpd.get_decimal_point() < 0 &&
366 exp10_to_exp2(-hpd.get_decimal_point()) >
367 (FPBits::EXP_BIAS + static_cast<int32_t>(FPBits::FRACTION_LEN))) {
368 output.num = {0, 0};
369 output.error = ERANGE;
370 return output;
371 }
372
373 // Right shift until the number is smaller than 1.
374 while (hpd.get_decimal_point() > 0) {
375 int32_t shift_amount = 0;
376 if (hpd.get_decimal_point() >= NUM_POWERS_OF_TWO) {
377 shift_amount = 60;
378 } else {
379 shift_amount = POWERS_OF_TWO[hpd.get_decimal_point()];
380 }
381 exp2 += shift_amount;
382 hpd.shift(-shift_amount);
383 }
384
385 // Left shift until the number is between 1/2 and 1
386 while (hpd.get_decimal_point() < 0 ||
387 (hpd.get_decimal_point() == 0 && hpd.get_digits()[0] < 5)) {
388 int32_t shift_amount = 0;
389
390 if (-hpd.get_decimal_point() >= NUM_POWERS_OF_TWO) {
391 shift_amount = 60;
392 } else if (hpd.get_decimal_point() != 0) {
393 shift_amount = POWERS_OF_TWO[-hpd.get_decimal_point()];
394 } else { // This handles the case of the number being between .1 and .5
395 shift_amount = 1;
396 }
397 exp2 -= shift_amount;
398 hpd.shift(shift_amount);
399 }
400
401 // Left shift once so that the number is between 1 and 2
402 --exp2;
403 hpd.shift(1);
404
405 // Get the biased exponent
406 exp2 += FPBits::EXP_BIAS;
407
408 // Handle the exponent being too large (and return inf).
409 if (exp2 >= FPBits::MAX_BIASED_EXPONENT) {
410 output.num = {0, FPBits::MAX_BIASED_EXPONENT};
411 output.error = ERANGE;
412 return output;
413 }
414
415 // Shift left to fill the mantissa
416 hpd.shift(FPBits::FRACTION_LEN);
417 StorageType final_mantissa = hpd.round_to_integer_type<StorageType>();
418
419 // Handle subnormals
420 if (exp2 <= 0) {
421 // Shift right until there is a valid exponent
422 while (exp2 < 0) {
423 hpd.shift(-1);
424 ++exp2;
425 }
426 // Shift right one more time to compensate for the left shift to get it
427 // between 1 and 2.
428 hpd.shift(-1);
429 final_mantissa = hpd.round_to_integer_type<StorageType>(round);
430
431 // Check if by shifting right we've caused this to round to a normal number.
432 if ((final_mantissa >> FPBits::FRACTION_LEN) != 0) {
433 ++exp2;
434 }
435 }
436
437 // Check if rounding added a bit, and shift down if that's the case.
438 if (final_mantissa == StorageType(2) << FPBits::FRACTION_LEN) {
439 final_mantissa >>= 1;
440 ++exp2;
441
442 // Check if this rounding causes exp2 to go out of range and make the result
443 // INF. If this is the case, then finalMantissa and exp2 are already the
444 // correct values for an INF result.
445 if (exp2 >= FPBits::MAX_BIASED_EXPONENT) {
446 output.error = ERANGE;
447 }
448 }
449
450 if (exp2 == 0) {
451 output.error = ERANGE;
452 }
453
454 output.num = {final_mantissa, exp2};
455 return output;
456}
457
458// This class is used for templating the constants for Clinger's Fast Path,
459// described as a method of approximation in
460// Clinger WD. How to Read Floating Point Numbers Accurately. SIGPLAN Not 1990
461// Jun;25(6):92–101. https://doi.org/10.1145/93548.93557.
462// As well as the additions by Gay that extend the useful range by the number of
463// exact digits stored by the float type, described in
464// Gay DM, Correctly rounded binary-decimal and decimal-binary conversions;
465// 1990. AT&T Bell Laboratories Numerical Analysis Manuscript 90-10.
466template <class T> class ClingerConsts;
467
468template <> class ClingerConsts<float> {
469public:
470 static constexpr float POWERS_OF_TEN_ARRAY[] = {1e0, 1e1, 1e2, 1e3, 1e4, 1e5,
471 1e6, 1e7, 1e8, 1e9, 1e10};
472 static constexpr int32_t EXACT_POWERS_OF_TEN = 10;
473 static constexpr int32_t DIGITS_IN_MANTISSA = 7;
474 static constexpr float MAX_EXACT_INT = 16777215.0;
475};
476
477template <> class ClingerConsts<double> {
478public:
479 static constexpr double POWERS_OF_TEN_ARRAY[] = {
480 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
481 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22};
482 static constexpr int32_t EXACT_POWERS_OF_TEN = 22;
483 static constexpr int32_t DIGITS_IN_MANTISSA = 15;
484 static constexpr double MAX_EXACT_INT = 9007199254740991.0;
485};
486
487#if defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64)
488template <> class ClingerConsts<long double> {
489public:
490 static constexpr long double POWERS_OF_TEN_ARRAY[] = {
491 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
492 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22};
493 static constexpr int32_t EXACT_POWERS_OF_TEN =
494 ClingerConsts<double>::EXACT_POWERS_OF_TEN;
495 static constexpr int32_t DIGITS_IN_MANTISSA =
496 ClingerConsts<double>::DIGITS_IN_MANTISSA;
497 static constexpr long double MAX_EXACT_INT =
498 ClingerConsts<double>::MAX_EXACT_INT;
499};
500#elif defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80)
501template <> class ClingerConsts<long double> {
502public:
503 static constexpr long double POWERS_OF_TEN_ARRAY[] = {
504 1e0L, 1e1L, 1e2L, 1e3L, 1e4L, 1e5L, 1e6L, 1e7L, 1e8L, 1e9L,
505 1e10L, 1e11L, 1e12L, 1e13L, 1e14L, 1e15L, 1e16L, 1e17L, 1e18L, 1e19L,
506 1e20L, 1e21L, 1e22L, 1e23L, 1e24L, 1e25L, 1e26L, 1e27L};
507 static constexpr int32_t EXACT_POWERS_OF_TEN = 27;
508 static constexpr int32_t DIGITS_IN_MANTISSA = 21;
509 static constexpr long double MAX_EXACT_INT = 18446744073709551615.0L;
510};
511#elif defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128)
512template <> class ClingerConsts<long double> {
513public:
514 static constexpr long double POWERS_OF_TEN_ARRAY[] = {
515 1e0L, 1e1L, 1e2L, 1e3L, 1e4L, 1e5L, 1e6L, 1e7L, 1e8L, 1e9L,
516 1e10L, 1e11L, 1e12L, 1e13L, 1e14L, 1e15L, 1e16L, 1e17L, 1e18L, 1e19L,
517 1e20L, 1e21L, 1e22L, 1e23L, 1e24L, 1e25L, 1e26L, 1e27L, 1e28L, 1e29L,
518 1e30L, 1e31L, 1e32L, 1e33L, 1e34L, 1e35L, 1e36L, 1e37L, 1e38L, 1e39L,
519 1e40L, 1e41L, 1e42L, 1e43L, 1e44L, 1e45L, 1e46L, 1e47L, 1e48L};
520 static constexpr int32_t EXACT_POWERS_OF_TEN = 48;
521 static constexpr int32_t DIGITS_IN_MANTISSA = 33;
522 static constexpr long double MAX_EXACT_INT =
523 10384593717069655257060992658440191.0L;
524};
525#elif defined(LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE)
526// TODO: Add proper double double type support here, currently using constants
527// for double since it should be safe.
528template <> class ClingerConsts<long double> {
529public:
530 static constexpr double POWERS_OF_TEN_ARRAY[] = {
531 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,
532 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22};
533 static constexpr int32_t EXACT_POWERS_OF_TEN = 22;
534 static constexpr int32_t DIGITS_IN_MANTISSA = 15;
535 static constexpr double MAX_EXACT_INT = 9007199254740991.0;
536};
537#else
538#error "Unknown long double type"
539#endif
540
541// Take an exact mantissa and exponent and attempt to convert it using only
542// exact floating point arithmetic. This only handles numbers with low
543// exponents, but handles them quickly. This is an implementation of Clinger's
544// Fast Path, as described above.
545template <class T>
546LIBC_INLINE cpp::optional<ExpandedFloat<T>>
547clinger_fast_path(ExpandedFloat<T> init_num,
548 RoundDirection round = RoundDirection::Nearest) {
549 using FPBits = typename fputil::FPBits<T>;
550 using StorageType = typename FPBits::StorageType;
551
552 StorageType mantissa = init_num.mantissa;
553 int32_t exp10 = init_num.exponent;
554
555 if ((mantissa >> FPBits::FRACTION_LEN) > 0) {
556 return cpp::nullopt;
557 }
558
559 FPBits result;
560 T float_mantissa;
561 if constexpr (is_big_int_v<StorageType> || sizeof(T) > sizeof(uint64_t)) {
562 float_mantissa =
563 (static_cast<T>(uint64_t(mantissa >> 64)) * static_cast<T>(0x1.0p64)) +
564 static_cast<T>(uint64_t(mantissa));
565 } else {
566 float_mantissa = static_cast<T>(mantissa);
567 }
568
569 if (exp10 == 0) {
570 result = FPBits(float_mantissa);
571 }
572 if (exp10 > 0) {
573 if (exp10 > ClingerConsts<T>::EXACT_POWERS_OF_TEN +
574 ClingerConsts<T>::DIGITS_IN_MANTISSA) {
575 return cpp::nullopt;
576 }
577 if (exp10 > ClingerConsts<T>::EXACT_POWERS_OF_TEN) {
578 float_mantissa = float_mantissa *
579 ClingerConsts<T>::POWERS_OF_TEN_ARRAY
580 [exp10 - ClingerConsts<T>::EXACT_POWERS_OF_TEN];
581 exp10 = ClingerConsts<T>::EXACT_POWERS_OF_TEN;
582 }
583 if (float_mantissa > ClingerConsts<T>::MAX_EXACT_INT) {
584 return cpp::nullopt;
585 }
586 result =
587 FPBits(float_mantissa * ClingerConsts<T>::POWERS_OF_TEN_ARRAY[exp10]);
588 } else if (exp10 < 0) {
589 if (-exp10 > ClingerConsts<T>::EXACT_POWERS_OF_TEN) {
590 return cpp::nullopt;
591 }
592 result =
593 FPBits(float_mantissa / ClingerConsts<T>::POWERS_OF_TEN_ARRAY[-exp10]);
594 }
595
596 // If the rounding mode is not nearest, then the sign of the number may affect
597 // the result. To make sure the rounding mode is respected properly, the
598 // calculation is redone with a negative result, and the rounding mode is used
599 // to select the correct result.
600 if (round != RoundDirection::Nearest) {
601 FPBits negative_result;
602 // I'm 99% sure this will break under fast math optimizations.
603 negative_result = FPBits((-float_mantissa) *
604 ClingerConsts<T>::POWERS_OF_TEN_ARRAY[exp10]);
605
606 // If the results are equal, then we don't need to use the rounding mode.
607 if (result.get_val() != -negative_result.get_val()) {
608 FPBits lower_result;
609 FPBits higher_result;
610
611 if (result.get_val() < -negative_result.get_val()) {
612 lower_result = result;
613 higher_result = negative_result;
614 } else {
615 lower_result = negative_result;
616 higher_result = result;
617 }
618
619 if (round == RoundDirection::Up) {
620 result = higher_result;
621 } else {
622 result = lower_result;
623 }
624 }
625 }
626
627 ExpandedFloat<T> output;
628 output.mantissa = result.get_explicit_mantissa();
629 output.exponent = result.get_biased_exponent();
630 return output;
631}
632
633// The upper bound is the highest base-10 exponent that could possibly give a
634// non-inf result for this size of float. The value is
635// log10(2^(exponent bias)).
636// The generic approximation uses the fact that log10(2^x) ~= x/3
637template <typename T> LIBC_INLINE constexpr int32_t get_upper_bound() {
638 return fputil::FPBits<T>::EXP_BIAS / 3;
639}
640
641template <> LIBC_INLINE constexpr int32_t get_upper_bound<float>() {
642 return 39;
643}
644
645template <> LIBC_INLINE constexpr int32_t get_upper_bound<double>() {
646 return 309;
647}
648
649// The lower bound is the largest negative base-10 exponent that could possibly
650// give a non-zero result for this size of float. The value is
651// log10(2^(exponent bias + final mantissa width + intermediate mantissa width))
652// The intermediate mantissa is the integer that's been parsed from the string,
653// and the final mantissa is the fractional part of the output number. A very
654// low base 10 exponent with a very high intermediate mantissa can cancel each
655// other out, and subnormal numbers allow for the result to be at the very low
656// end of the final mantissa.
657template <typename T> LIBC_INLINE constexpr int32_t get_lower_bound() {
658 using FPBits = typename fputil::FPBits<T>;
659 return -((FPBits::EXP_BIAS +
660 static_cast<int32_t>(FPBits::FRACTION_LEN + FPBits::STORAGE_LEN)) /
661 3);
662}
663
664template <> LIBC_INLINE constexpr int32_t get_lower_bound<float>() {
665 return -(39 + 6 + 10);
666}
667
668template <> LIBC_INLINE constexpr int32_t get_lower_bound<double>() {
669 return -(309 + 15 + 20);
670}
671
672// -----------------------------------------------------------------------------
673// **** WARNING ****
674// This interface is shared with libc++, if you change this interface you need
675// to update it in both libc and libc++.
676// -----------------------------------------------------------------------------
677// Takes a mantissa and base 10 exponent and converts it into its closest
678// floating point type T equivalient. First we try the Eisel-Lemire algorithm,
679// then if that fails then we fall back to a more accurate algorithm for
680// accuracy. The resulting mantissa and exponent are placed in outputMantissa
681// and outputExp2.
682template <class T>
683LIBC_INLINE FloatConvertReturn<T> decimal_exp_to_float(
684 ExpandedFloat<T> init_num, bool truncated, RoundDirection round,
685 const char *__restrict numStart,
686 const size_t num_len = cpp::numeric_limits<size_t>::max()) {
687 using FPBits = typename fputil::FPBits<T>;
688 using StorageType = typename FPBits::StorageType;
689
690 StorageType mantissa = init_num.mantissa;
691 int32_t exp10 = init_num.exponent;
692
693 FloatConvertReturn<T> output;
694 cpp::optional<ExpandedFloat<T>> opt_output;
695
696 // If the exponent is too large and can't be represented in this size of
697 // float, return inf. These bounds are relatively loose, but are mostly
698 // serving as a first pass. Some close numbers getting through is okay.
699 if (exp10 > get_upper_bound<T>()) {
700 output.num = {0, FPBits::MAX_BIASED_EXPONENT};
701 output.error = ERANGE;
702 return output;
703 }
704 // If the exponent is too small even for a subnormal, return 0.
705 if (exp10 < get_lower_bound<T>()) {
706 output.num = {0, 0};
707 output.error = ERANGE;
708 return output;
709 }
710
711 // Clinger's Fast Path and Eisel-Lemire can't set errno, but they can fail.
712 // For this reason the "error" field in their return values is used to
713 // represent whether they've failed as opposed to the errno value. Any
714 // non-zero value represents a failure.
715
716#ifndef LIBC_COPT_STRTOFLOAT_DISABLE_CLINGER_FAST_PATH
717 if (!truncated) {
718 opt_output = clinger_fast_path<T>(init_num, round);
719 // If the algorithm succeeded the error will be 0, else it will be a
720 // non-zero number.
721 if (opt_output.has_value()) {
722 return {opt_output.value(), 0};
723 }
724 }
725#endif // LIBC_COPT_STRTOFLOAT_DISABLE_CLINGER_FAST_PATH
726
727#ifndef LIBC_COPT_STRTOFLOAT_DISABLE_EISEL_LEMIRE
728 // Try Eisel-Lemire
729 opt_output = eisel_lemire<T>(init_num, round);
730 if (opt_output.has_value()) {
731 if (!truncated) {
732 return {opt_output.value(), 0};
733 }
734 // If the mantissa is truncated, then the result may be off by the LSB, so
735 // check if rounding the mantissa up changes the result. If not, then it's
736 // safe, else use the fallback.
737 auto second_output = eisel_lemire<T>({mantissa + 1, exp10}, round);
738 if (second_output.has_value()) {
739 if (opt_output->mantissa == second_output->mantissa &&
740 opt_output->exponent == second_output->exponent) {
741 return {opt_output.value(), 0};
742 }
743 }
744 }
745#endif // LIBC_COPT_STRTOFLOAT_DISABLE_EISEL_LEMIRE
746
747#ifndef LIBC_COPT_STRTOFLOAT_DISABLE_SIMPLE_DECIMAL_CONVERSION
748 output = simple_decimal_conversion<T>(numStart, num_len, round);
749#else
750#warning "Simple decimal conversion is disabled, result may not be correct."
751#endif // LIBC_COPT_STRTOFLOAT_DISABLE_SIMPLE_DECIMAL_CONVERSION
752
753 return output;
754}
755
756// -----------------------------------------------------------------------------
757// **** WARNING ****
758// This interface is shared with libc++, if you change this interface you need
759// to update it in both libc and libc++.
760// -----------------------------------------------------------------------------
761// Takes a mantissa and base 2 exponent and converts it into its closest
762// floating point type T equivalient. Since the exponent is already in the right
763// form, this is mostly just shifting and rounding. This is used for hexadecimal
764// numbers since a base 16 exponent multiplied by 4 is the base 2 exponent.
765template <class T>
766LIBC_INLINE FloatConvertReturn<T> binary_exp_to_float(ExpandedFloat<T> init_num,
767 bool truncated,
768 RoundDirection round) {
769 using FPBits = typename fputil::FPBits<T>;
770 using StorageType = typename FPBits::StorageType;
771
772 StorageType mantissa = init_num.mantissa;
773 int32_t exp2 = init_num.exponent;
774
775 FloatConvertReturn<T> output;
776
777 // This is the number of leading zeroes a properly normalized float of type T
778 // should have.
779 constexpr int32_t INF_EXP = (1 << FPBits::EXP_LEN) - 1;
780
781 // Normalization step 1: Bring the leading bit to the highest bit of
782 // StorageType.
783 uint32_t amount_to_shift_left = cpp::countl_zero<StorageType>(mantissa);
784 mantissa <<= amount_to_shift_left;
785
786 // Keep exp2 representing the exponent of the lowest bit of StorageType.
787 exp2 -= amount_to_shift_left;
788
789 // biased_exponent represents the biased exponent of the most significant bit.
790 int32_t biased_exponent = exp2 + FPBits::STORAGE_LEN + FPBits::EXP_BIAS - 1;
791
792 // Handle numbers that're too large and get squashed to inf
793 if (biased_exponent >= INF_EXP) {
794 // This indicates an overflow, so we make the result INF and set errno.
795 output.num = {0, (1 << FPBits::EXP_LEN) - 1};
796 output.error = ERANGE;
797 return output;
798 }
799
800 uint32_t amount_to_shift_right =
801 FPBits::STORAGE_LEN - FPBits::FRACTION_LEN - 1;
802
803 // Handle subnormals.
804 if (biased_exponent <= 0) {
805 amount_to_shift_right += 1 - biased_exponent;
806 biased_exponent = 0;
807
808 if (amount_to_shift_right > FPBits::STORAGE_LEN) {
809 // Return 0 if the exponent is too small.
810 output.num = {0, 0};
811 output.error = ERANGE;
812 return output;
813 }
814 }
815
816 StorageType round_bit_mask = StorageType(1) << (amount_to_shift_right - 1);
817 StorageType sticky_mask = round_bit_mask - 1;
818 bool round_bit = static_cast<bool>(mantissa & round_bit_mask);
819 bool sticky_bit = static_cast<bool>(mantissa & sticky_mask) || truncated;
820
821 if (amount_to_shift_right < FPBits::STORAGE_LEN) {
822 // Shift the mantissa and clear the implicit bit.
823 mantissa >>= amount_to_shift_right;
824 mantissa &= FPBits::FRACTION_MASK;
825 } else {
826 mantissa = 0;
827 }
828 bool least_significant_bit = static_cast<bool>(mantissa & StorageType(1));
829
830 // TODO: check that this rounding behavior is correct.
831
832 if (round == RoundDirection::Nearest) {
833 // Perform rounding-to-nearest, tie-to-even.
834 if (round_bit && (least_significant_bit || sticky_bit)) {
835 ++mantissa;
836 }
837 } else if (round == RoundDirection::Up) {
838 if (round_bit || sticky_bit) {
839 ++mantissa;
840 }
841 } else /* (round == RoundDirection::Down)*/ {
842 if (round_bit && sticky_bit) {
843 ++mantissa;
844 }
845 }
846
847 if (mantissa > FPBits::FRACTION_MASK) {
848 // Rounding causes the exponent to increase.
849 ++biased_exponent;
850
851 if (biased_exponent == INF_EXP) {
852 output.error = ERANGE;
853 }
854 }
855
856 if (biased_exponent == 0) {
857 output.error = ERANGE;
858 }
859
860 output.num = {mantissa & FPBits::FRACTION_MASK, biased_exponent};
861 return output;
862}
863
864// checks if the next 4 characters of the string pointer are the start of a
865// hexadecimal floating point number. Does not advance the string pointer.
866LIBC_INLINE bool is_float_hex_start(const char *__restrict src,
867 const char decimalPoint) {
868 if (!(src[0] == '0' && tolower(src[1]) == 'x')) {
869 return false;
870 }
871 size_t first_digit = 2;
872 if (src[2] == decimalPoint) {
873 ++first_digit;
874 }
875 return isalnum(src[first_digit]) && b36_char_to_int(src[first_digit]) < 16;
876}
877
878// Takes the start of a string representing a decimal float, as well as the
879// local decimalPoint. It returns if it suceeded in parsing any digits, and if
880// the return value is true then the outputs are pointer to the end of the
881// number, and the mantissa and exponent for the closest float T representation.
882// If the return value is false, then it is assumed that there is no number
883// here.
884template <class T>
885LIBC_INLINE StrToNumResult<ExpandedFloat<T>>
886decimal_string_to_float(const char *__restrict src, const char DECIMAL_POINT,
887 RoundDirection round) {
888 using FPBits = typename fputil::FPBits<T>;
889 using StorageType = typename FPBits::StorageType;
890
891 constexpr uint32_t BASE = 10;
892 constexpr char EXPONENT_MARKER = 'e';
893
894 bool truncated = false;
895 bool seen_digit = false;
896 bool after_decimal = false;
897 StorageType mantissa = 0;
898 int32_t exponent = 0;
899
900 size_t index = 0;
901
902 StrToNumResult<ExpandedFloat<T>> output({0, 0});
903
904 // The goal for the first step of parsing is to convert the number in src to
905 // the format mantissa * (base ^ exponent)
906
907 // The loop fills the mantissa with as many digits as it can hold
908 const StorageType bitstype_max_div_by_base =
909 cpp::numeric_limits<StorageType>::max() / BASE;
910 while (true) {
911 if (isdigit(src[index])) {
912 uint32_t digit = b36_char_to_int(src[index]);
913 seen_digit = true;
914
915 if (mantissa < bitstype_max_div_by_base) {
916 mantissa = (mantissa * BASE) + digit;
917 if (after_decimal) {
918 --exponent;
919 }
920 } else {
921 if (digit > 0)
922 truncated = true;
923 if (!after_decimal)
924 ++exponent;
925 }
926
927 ++index;
928 continue;
929 }
930 if (src[index] == DECIMAL_POINT) {
931 if (after_decimal) {
932 break; // this means that src[index] points to a second decimal point,
933 // ending the number.
934 }
935 after_decimal = true;
936 ++index;
937 continue;
938 }
939 // The character is neither a digit nor a decimal point.
940 break;
941 }
942
943 if (!seen_digit)
944 return output;
945
946 // TODO: When adding max length argument, handle the case of a trailing
947 // EXPONENT MARKER, see scanf for more details.
948 if (tolower(src[index]) == EXPONENT_MARKER) {
949 bool has_sign = false;
950 if (src[index + 1] == '+' || src[index + 1] == '-') {
951 has_sign = true;
952 }
953 if (isdigit(src[index + 1 + static_cast<size_t>(has_sign)])) {
954 ++index;
955 auto result = strtointeger<int32_t>(src + index, 10);
956 if (result.has_error())
957 output.error = result.error;
958 int32_t add_to_exponent = result.value;
959 index += result.parsed_len;
960
961 // Here we do this operation as int64 to avoid overflow.
962 int64_t temp_exponent = static_cast<int64_t>(exponent) +
963 static_cast<int64_t>(add_to_exponent);
964
965 // If the result is in the valid range, then we use it. The valid range is
966 // also within the int32 range, so this prevents overflow issues.
967 if (temp_exponent > FPBits::MAX_BIASED_EXPONENT) {
968 exponent = FPBits::MAX_BIASED_EXPONENT;
969 } else if (temp_exponent < -FPBits::MAX_BIASED_EXPONENT) {
970 exponent = -FPBits::MAX_BIASED_EXPONENT;
971 } else {
972 exponent = static_cast<int32_t>(temp_exponent);
973 }
974 }
975 }
976
977 output.parsed_len = index;
978 if (mantissa == 0) { // if we have a 0, then also 0 the exponent.
979 output.value = {0, 0};
980 } else {
981 auto temp =
982 decimal_exp_to_float<T>({mantissa, exponent}, truncated, round, src);
983 output.value = temp.num;
984 output.error = temp.error;
985 }
986 return output;
987}
988
989// Takes the start of a string representing a hexadecimal float, as well as the
990// local decimal point. It returns if it suceeded in parsing any digits, and if
991// the return value is true then the outputs are pointer to the end of the
992// number, and the mantissa and exponent for the closest float T representation.
993// If the return value is false, then it is assumed that there is no number
994// here.
995template <class T>
996LIBC_INLINE StrToNumResult<ExpandedFloat<T>>
997hexadecimal_string_to_float(const char *__restrict src,
998 const char DECIMAL_POINT, RoundDirection round) {
999 using FPBits = typename fputil::FPBits<T>;
1000 using StorageType = typename FPBits::StorageType;
1001
1002 constexpr uint32_t BASE = 16;
1003 constexpr char EXPONENT_MARKER = 'p';
1004
1005 bool truncated = false;
1006 bool seen_digit = false;
1007 bool after_decimal = false;
1008 StorageType mantissa = 0;
1009 int32_t exponent = 0;
1010
1011 size_t index = 0;
1012
1013 StrToNumResult<ExpandedFloat<T>> output({0, 0});
1014
1015 // The goal for the first step of parsing is to convert the number in src to
1016 // the format mantissa * (base ^ exponent)
1017
1018 // The loop fills the mantissa with as many digits as it can hold
1019 const StorageType bitstype_max_div_by_base =
1020 cpp::numeric_limits<StorageType>::max() / BASE;
1021 while (true) {
1022 if (isalnum(src[index])) {
1023 uint32_t digit = b36_char_to_int(src[index]);
1024 if (digit < BASE)
1025 seen_digit = true;
1026 else
1027 break;
1028
1029 if (mantissa < bitstype_max_div_by_base) {
1030 mantissa = (mantissa * BASE) + digit;
1031 if (after_decimal)
1032 --exponent;
1033 } else {
1034 if (digit > 0)
1035 truncated = true;
1036 if (!after_decimal)
1037 ++exponent;
1038 }
1039 ++index;
1040 continue;
1041 }
1042 if (src[index] == DECIMAL_POINT) {
1043 if (after_decimal) {
1044 break; // this means that src[index] points to a second decimal point,
1045 // ending the number.
1046 }
1047 after_decimal = true;
1048 ++index;
1049 continue;
1050 }
1051 // The character is neither a hexadecimal digit nor a decimal point.
1052 break;
1053 }
1054
1055 if (!seen_digit)
1056 return output;
1057
1058 // Convert the exponent from having a base of 16 to having a base of 2.
1059 exponent *= 4;
1060
1061 if (tolower(src[index]) == EXPONENT_MARKER) {
1062 bool has_sign = false;
1063 if (src[index + 1] == '+' || src[index + 1] == '-') {
1064 has_sign = true;
1065 }
1066 if (isdigit(src[index + 1 + static_cast<size_t>(has_sign)])) {
1067 ++index;
1068 auto result = strtointeger<int32_t>(src + index, 10);
1069 if (result.has_error())
1070 output.error = result.error;
1071
1072 int32_t add_to_exponent = result.value;
1073 index += result.parsed_len;
1074
1075 // Here we do this operation as int64 to avoid overflow.
1076 int64_t temp_exponent = static_cast<int64_t>(exponent) +
1077 static_cast<int64_t>(add_to_exponent);
1078
1079 // If the result is in the valid range, then we use it. The valid range is
1080 // also within the int32 range, so this prevents overflow issues.
1081 if (temp_exponent > FPBits::MAX_BIASED_EXPONENT) {
1082 exponent = FPBits::MAX_BIASED_EXPONENT;
1083 } else if (temp_exponent < -FPBits::MAX_BIASED_EXPONENT) {
1084 exponent = -FPBits::MAX_BIASED_EXPONENT;
1085 } else {
1086 exponent = static_cast<int32_t>(temp_exponent);
1087 }
1088 }
1089 }
1090 output.parsed_len = index;
1091 if (mantissa == 0) { // if we have a 0, then also 0 the exponent.
1092 output.value.exponent = 0;
1093 output.value.mantissa = 0;
1094 } else {
1095 auto temp = binary_exp_to_float<T>({mantissa, exponent}, truncated, round);
1096 output.error = temp.error;
1097 output.value = temp.num;
1098 }
1099 return output;
1100}
1101
1102template <class T>
1103LIBC_INLINE typename fputil::FPBits<T>::StorageType
1104nan_mantissa_from_ncharseq(const cpp::string_view ncharseq) {
1105 using FPBits = typename fputil::FPBits<T>;
1106 using StorageType = typename FPBits::StorageType;
1107
1108 StorageType nan_mantissa = 0;
1109
1110 if (ncharseq.data() != nullptr && isdigit(ncharseq[0])) {
1111 StrToNumResult<StorageType> strtoint_result =
1112 strtointeger<StorageType>(ncharseq.data(), 0);
1113 if (!strtoint_result.has_error())
1114 nan_mantissa = strtoint_result.value;
1115
1116 if (strtoint_result.parsed_len != static_cast<ptrdiff_t>(ncharseq.size()))
1117 nan_mantissa = 0;
1118 }
1119
1120 return nan_mantissa;
1121}
1122
1123// Takes a pointer to a string and a pointer to a string pointer. This function
1124// is used as the backend for all of the string to float functions.
1125// TODO: Add src_len member to match strtointeger.
1126// TODO: Next, move from char* and length to string_view
1127template <class T>
1128LIBC_INLINE StrToNumResult<T> strtofloatingpoint(const char *__restrict src) {
1129 using FPBits = typename fputil::FPBits<T>;
1130 using StorageType = typename FPBits::StorageType;
1131
1132 FPBits result = FPBits();
1133 bool seen_digit = false;
1134 char sign = '+';
1135
1136 int error = 0;
1137
1138 ptrdiff_t index = first_non_whitespace(src) - src;
1139
1140 if (src[index] == '+' || src[index] == '-') {
1141 sign = src[index];
1142 ++index;
1143 }
1144
1145 if (sign == '-') {
1146 result.set_sign(Sign::NEG);
1147 }
1148
1149 static constexpr char DECIMAL_POINT = '.';
1150 static const char *inf_string = "infinity";
1151 static const char *nan_string = "nan";
1152
1153 if (isdigit(src[index]) || src[index] == DECIMAL_POINT) { // regular number
1154 int base = 10;
1155 if (is_float_hex_start(src + index, DECIMAL_POINT)) {
1156 base = 16;
1157 index += 2;
1158 seen_digit = true;
1159 }
1160
1161 RoundDirection round_direction = RoundDirection::Nearest;
1162
1163 switch (fputil::quick_get_round()) {
1164 case FE_TONEAREST:
1165 round_direction = RoundDirection::Nearest;
1166 break;
1167 case FE_UPWARD:
1168 if (sign == '+') {
1169 round_direction = RoundDirection::Up;
1170 } else {
1171 round_direction = RoundDirection::Down;
1172 }
1173 break;
1174 case FE_DOWNWARD:
1175 if (sign == '+') {
1176 round_direction = RoundDirection::Down;
1177 } else {
1178 round_direction = RoundDirection::Up;
1179 }
1180 break;
1181 case FE_TOWARDZERO:
1182 round_direction = RoundDirection::Down;
1183 break;
1184 }
1185
1186 StrToNumResult<ExpandedFloat<T>> parse_result({0, 0});
1187 if (base == 16) {
1188 parse_result = hexadecimal_string_to_float<T>(src + index, DECIMAL_POINT,
1189 round_direction);
1190 } else { // base is 10
1191 parse_result = decimal_string_to_float<T>(src + index, DECIMAL_POINT,
1192 round_direction);
1193 }
1194 seen_digit = parse_result.parsed_len != 0;
1195 result.set_mantissa(parse_result.value.mantissa);
1196 result.set_biased_exponent(parse_result.value.exponent);
1197 index += parse_result.parsed_len;
1198 error = parse_result.error;
1199 } else if (tolower(src[index]) == 'n') { // NaN
1200 if (tolower(src[index + 1]) == nan_string[1] &&
1201 tolower(src[index + 2]) == nan_string[2]) {
1202 seen_digit = true;
1203 index += 3;
1204 StorageType nan_mantissa = 0;
1205 // this handles the case of `NaN(n-character-sequence)`, where the
1206 // n-character-sequence is made of 0 or more letters, numbers, or
1207 // underscore characters in any order.
1208 if (src[index] == '(') {
1209 size_t left_paren = index;
1210 ++index;
1211 while (isalnum(src[index]) || src[index] == '_')
1212 ++index;
1213 if (src[index] == ')') {
1214 ++index;
1215 nan_mantissa = nan_mantissa_from_ncharseq<T>(
1216 cpp::string_view(src + (left_paren + 1), index - left_paren - 2));
1217 } else {
1218 index = left_paren;
1219 }
1220 }
1221 result = FPBits(result.quiet_nan(result.sign(), nan_mantissa));
1222 }
1223 } else if (tolower(src[index]) == 'i') { // INF
1224 if (tolower(src[index + 1]) == inf_string[1] &&
1225 tolower(src[index + 2]) == inf_string[2]) {
1226 seen_digit = true;
1227 result = FPBits(result.inf(result.sign()));
1228 if (tolower(src[index + 3]) == inf_string[3] &&
1229 tolower(src[index + 4]) == inf_string[4] &&
1230 tolower(src[index + 5]) == inf_string[5] &&
1231 tolower(src[index + 6]) == inf_string[6] &&
1232 tolower(src[index + 7]) == inf_string[7]) {
1233 // if the string is "INFINITY" then consume 8 characters.
1234 index += 8;
1235 } else {
1236 index += 3;
1237 }
1238 }
1239 }
1240 if (!seen_digit) { // If there is nothing to actually parse, then return 0.
1241 return {T(0), 0, error};
1242 }
1243
1244 // This function only does something if T is long double and the platform uses
1245 // special 80 bit long doubles. Otherwise it should be inlined out.
1246 set_implicit_bit<T>(result);
1247
1248 return {result.get_val(), index, error};
1249}
1250
1251template <class T> LIBC_INLINE StrToNumResult<T> strtonan(const char *arg) {
1252 using FPBits = typename fputil::FPBits<T>;
1253 using StorageType = typename FPBits::StorageType;
1254
1255 LIBC_CRASH_ON_NULLPTR(arg);
1256
1257 FPBits result;
1258 int error = 0;
1259 StorageType nan_mantissa = 0;
1260
1261 ptrdiff_t index = 0;
1262 while (isalnum(arg[index]) || arg[index] == '_')
1263 ++index;
1264
1265 if (arg[index] == '\0')
1266 nan_mantissa = nan_mantissa_from_ncharseq<T>(cpp::string_view(arg, index));
1267
1268 result = FPBits::quiet_nan(Sign::POS, nan_mantissa);
1269 return {result.get_val(), 0, error};
1270}
1271
1272} // namespace internal
1273} // namespace LIBC_NAMESPACE_DECL
1274
1275#endif // LLVM_LIBC_SRC___SUPPORT_STR_TO_FLOAT_H
lib/libcxx/libc/src/__support/str_to_integer.h created+169
...@@ -0,0 +1,169 @@
1//===-- String to integer conversion utils ----------------------*- C++ -*-===//
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// -----------------------------------------------------------------------------
10// **** WARNING ****
11// This file is shared with libc++. You should also be careful when adding
12// dependencies to this file, since it needs to build for all libc++ targets.
13// -----------------------------------------------------------------------------
14
15#ifndef LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H
16#define LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H
17
18#include "src/__support/CPP/limits.h"
19#include "src/__support/CPP/type_traits.h"
20#include "src/__support/CPP/type_traits/make_unsigned.h"
21#include "src/__support/big_int.h"
22#include "src/__support/common.h"
23#include "src/__support/ctype_utils.h"
24#include "src/__support/macros/config.h"
25#include "src/__support/str_to_num_result.h"
26#include "src/__support/uint128.h"
27#include "src/errno/libc_errno.h" // For ERANGE
28
29namespace LIBC_NAMESPACE_DECL {
30namespace internal {
31
32// Returns a pointer to the first character in src that is not a whitespace
33// character (as determined by isspace())
34// TODO: Change from returning a pointer to returning a length.
35LIBC_INLINE const char *
36first_non_whitespace(const char *__restrict src,
37 size_t src_len = cpp::numeric_limits<size_t>::max()) {
38 size_t src_cur = 0;
39 while (src_cur < src_len && internal::isspace(src[src_cur])) {
40 ++src_cur;
41 }
42 return src + src_cur;
43}
44
45// checks if the next 3 characters of the string pointer are the start of a
46// hexadecimal number. Does not advance the string pointer.
47LIBC_INLINE bool
48is_hex_start(const char *__restrict src,
49 size_t src_len = cpp::numeric_limits<size_t>::max()) {
50 if (src_len < 3)
51 return false;
52 return *src == '0' && tolower(*(src + 1)) == 'x' && isalnum(*(src + 2)) &&
53 b36_char_to_int(*(src + 2)) < 16;
54}
55
56// Takes the address of the string pointer and parses the base from the start of
57// it.
58LIBC_INLINE int infer_base(const char *__restrict src, size_t src_len) {
59 // A hexadecimal number is defined as "the prefix 0x or 0X followed by a
60 // sequence of the decimal digits and the letters a (or A) through f (or F)
61 // with values 10 through 15 respectively." (C standard 6.4.4.1)
62 if (is_hex_start(src, src_len))
63 return 16;
64 // An octal number is defined as "the prefix 0 optionally followed by a
65 // sequence of the digits 0 through 7 only" (C standard 6.4.4.1) and so any
66 // number that starts with 0, including just 0, is an octal number.
67 if (src_len > 0 && src[0] == '0')
68 return 8;
69 // A decimal number is defined as beginning "with a nonzero digit and
70 // consist[ing] of a sequence of decimal digits." (C standard 6.4.4.1)
71 return 10;
72}
73
74// -----------------------------------------------------------------------------
75// **** WARNING ****
76// This interface is shared with libc++, if you change this interface you need
77// to update it in both libc and libc++.
78// -----------------------------------------------------------------------------
79// Takes a pointer to a string and the base to convert to. This function is used
80// as the backend for all of the string to int functions.
81template <class T>
82LIBC_INLINE StrToNumResult<T>
83strtointeger(const char *__restrict src, int base,
84 const size_t src_len = cpp::numeric_limits<size_t>::max()) {
85 using ResultType = make_integral_or_big_int_unsigned_t<T>;
86
87 ResultType result = 0;
88
89 bool is_number = false;
90 size_t src_cur = 0;
91 int error_val = 0;
92
93 if (src_len == 0)
94 return {0, 0, 0};
95
96 if (base < 0 || base == 1 || base > 36)
97 return {0, 0, EINVAL};
98
99 src_cur = first_non_whitespace(src, src_len) - src;
100
101 char result_sign = '+';
102 if (src[src_cur] == '+' || src[src_cur] == '-') {
103 result_sign = src[src_cur];
104 ++src_cur;
105 }
106
107 if (base == 0)
108 base = infer_base(src + src_cur, src_len - src_cur);
109
110 if (base == 16 && is_hex_start(src + src_cur, src_len - src_cur))
111 src_cur = src_cur + 2;
112
113 constexpr bool IS_UNSIGNED = cpp::is_unsigned_v<T>;
114 const bool is_positive = (result_sign == '+');
115
116 ResultType constexpr NEGATIVE_MAX =
117 !IS_UNSIGNED ? static_cast<ResultType>(cpp::numeric_limits<T>::max()) + 1
118 : cpp::numeric_limits<T>::max();
119 ResultType const abs_max =
120 (is_positive ? cpp::numeric_limits<T>::max() : NEGATIVE_MAX);
121 ResultType const abs_max_div_by_base =
122 static_cast<ResultType>(abs_max / base);
123
124 while (src_cur < src_len && isalnum(src[src_cur])) {
125 int cur_digit = b36_char_to_int(src[src_cur]);
126 if (cur_digit >= base)
127 break;
128
129 is_number = true;
130 ++src_cur;
131
132 // If the number has already hit the maximum value for the current type then
133 // the result cannot change, but we still need to advance src to the end of
134 // the number.
135 if (result == abs_max) {
136 error_val = ERANGE;
137 continue;
138 }
139
140 if (result > abs_max_div_by_base) {
141 result = abs_max;
142 error_val = ERANGE;
143 } else {
144 result = static_cast<ResultType>(result * base);
145 }
146 if (result > abs_max - cur_digit) {
147 result = abs_max;
148 error_val = ERANGE;
149 } else {
150 result = static_cast<ResultType>(result + cur_digit);
151 }
152 }
153
154 ptrdiff_t str_len = is_number ? (src_cur) : 0;
155
156 if (error_val == ERANGE) {
157 if (is_positive || IS_UNSIGNED)
158 return {cpp::numeric_limits<T>::max(), str_len, error_val};
159 else // T is signed and there is a negative overflow
160 return {cpp::numeric_limits<T>::min(), str_len, error_val};
161 }
162
163 return {static_cast<T>(is_positive ? result : -result), str_len, error_val};
164}
165
166} // namespace internal
167} // namespace LIBC_NAMESPACE_DECL
168
169#endif // LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H
lib/libcxx/libc/src/__support/str_to_num_result.h created+48
...@@ -0,0 +1,48 @@
1//===-- A data structure for str_to_number to return ------------*- C++ -*-===//
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// -----------------------------------------------------------------------------
10// **** WARNING ****
11// This file is shared with libc++. You should also be careful when adding
12// dependencies to this file, since it needs to build for all libc++ targets.
13// -----------------------------------------------------------------------------
14
15#ifndef LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H
16#define LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H
17
18#include "src/__support/macros/attributes.h" // LIBC_INLINE
19#include "src/__support/macros/config.h"
20
21#include <stddef.h>
22
23namespace LIBC_NAMESPACE_DECL {
24
25// -----------------------------------------------------------------------------
26// **** WARNING ****
27// This interface is shared with libc++, if you change this interface you need
28// to update it in both libc and libc++.
29// -----------------------------------------------------------------------------
30template <typename T> struct StrToNumResult {
31 T value;
32 int error;
33 ptrdiff_t parsed_len;
34
35 LIBC_INLINE constexpr StrToNumResult(T value)
36 : value(value), error(0), parsed_len(0) {}
37 LIBC_INLINE constexpr StrToNumResult(T value, ptrdiff_t parsed_len)
38 : value(value), error(0), parsed_len(parsed_len) {}
39 LIBC_INLINE constexpr StrToNumResult(T value, ptrdiff_t parsed_len, int error)
40 : value(value), error(error), parsed_len(parsed_len) {}
41
42 LIBC_INLINE constexpr bool has_error() { return error != 0; }
43
44 LIBC_INLINE constexpr operator T() { return value; }
45};
46} // namespace LIBC_NAMESPACE_DECL
47
48#endif // LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H
lib/libcxx/libc/src/__support/uint128.h created+23
...@@ -0,0 +1,23 @@
1//===-- 128-bit signed and unsigned int types -------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_UINT128_H
10#define LLVM_LIBC_SRC___SUPPORT_UINT128_H
11
12#include "big_int.h"
13#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
14
15#ifdef LIBC_TYPES_HAS_INT128
16using UInt128 = __uint128_t;
17using Int128 = __int128_t;
18#else
19using UInt128 = LIBC_NAMESPACE::UInt<128>;
20using Int128 = LIBC_NAMESPACE::Int<128>;
21#endif // LIBC_TYPES_HAS_INT128
22
23#endif // LLVM_LIBC_SRC___SUPPORT_UINT128_H
lib/libcxx/libc/src/errno/libc_errno.h created+47
...@@ -0,0 +1,47 @@
1//===-- Implementation header for libc_errno --------------------*- C++ -*-===//
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 LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
10#define LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
11
12#include "src/__support/macros/attributes.h"
13#include "src/__support/macros/config.h"
14#include "src/__support/macros/properties/architectures.h"
15
16#include "hdr/errno_macros.h"
17
18// This header is to be consumed by internal implementations, in which all of
19// them should refer to `libc_errno` instead of using `errno` directly from
20// <errno.h> header.
21
22// Unit and hermetic tests should:
23// - #include "src/errno/libc_errno.h"
24// - NOT #include <errno.h>
25// - Only use `libc_errno` in the code
26// - Depend on libc.src.errno.errno
27
28// Integration tests should:
29// - NOT #include "src/errno/libc_errno.h"
30// - #include <errno.h>
31// - Use regular `errno` in the code
32// - Still depend on libc.src.errno.errno
33
34namespace LIBC_NAMESPACE_DECL {
35
36extern "C" int *__llvm_libc_errno() noexcept;
37
38struct Errno {
39 void operator=(int);
40 operator int();
41};
42
43extern Errno libc_errno;
44
45} // namespace LIBC_NAMESPACE_DECL
46
47#endif // LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H
lib/libcxx/src/algorithm.cpp+2-3
...@@ -21,13 +21,12 @@ void __sort(RandomAccessIterator first, RandomAccessIterator last, Comp comp) {...@@ -21,13 +21,12 @@ void __sort(RandomAccessIterator first, RandomAccessIterator last, Comp comp) {
21 std::__introsort<_ClassicAlgPolicy,21 std::__introsort<_ClassicAlgPolicy,
22 ranges::less,22 ranges::less,
23 RandomAccessIterator,23 RandomAccessIterator,
24 __use_branchless_sort<ranges::less, RandomAccessIterator>::value>(24 __use_branchless_sort<ranges::less, RandomAccessIterator>>(first, last, ranges::less{}, depth_limit);
25 first, last, ranges::less{}, depth_limit);
26}25}
2726
28// clang-format off27// clang-format off
29template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);28template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
30#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS29#if _LIBCPP_HAS_WIDE_CHARACTERS
31template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);30template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
32#endif31#endif
33template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);32template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
lib/libcxx/src/any.cpp+1-1
...@@ -12,7 +12,7 @@ namespace std {...@@ -12,7 +12,7 @@ namespace std {
12const char* bad_any_cast::what() const noexcept { return "bad any cast"; }12const char* bad_any_cast::what() const noexcept { return "bad any cast"; }
13} // namespace std13} // namespace std
1414
15#include <experimental/__config>15#include <__config>
1616
17// Preserve std::experimental::any_bad_cast for ABI compatibility17// Preserve std::experimental::any_bad_cast for ABI compatibility
18// Even though it no longer exists in a header file18// Even though it no longer exists in a header file
lib/libcxx/src/atomic.cpp+2-2
...@@ -94,11 +94,11 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo...@@ -94,11 +94,11 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
9494
95static void95static void
96__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {96__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
97 _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAIT, __val, NULL, NULL);97 _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAIT, __val, nullptr, nullptr);
98}98}
9999
100static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {100static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {
101 _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, NULL, NULL);101 _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, nullptr, nullptr);
102}102}
103103
104#else // <- Add other operating systems here104#else // <- Add other operating systems here
lib/libcxx/src/barrier.cpp+1-5
...@@ -11,13 +11,11 @@...@@ -11,13 +11,11 @@
1111
12_LIBCPP_BEGIN_NAMESPACE_STD12_LIBCPP_BEGIN_NAMESPACE_STD
1313
14#if !defined(_LIBCPP_HAS_NO_TREE_BARRIER)
15
16class __barrier_algorithm_base {14class __barrier_algorithm_base {
17public:15public:
18 struct alignas(64) /* naturally-align the heap state */ __state_t {16 struct alignas(64) /* naturally-align the heap state */ __state_t {
19 struct {17 struct {
20 __atomic_base<__barrier_phase_t> __phase{0};18 atomic<__barrier_phase_t> __phase{0};
21 } __tickets[64];19 } __tickets[64];
22 };20 };
2321
...@@ -70,6 +68,4 @@ _LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(__barrier_algori...@@ -70,6 +68,4 @@ _LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(__barrier_algori
70 delete __barrier;68 delete __barrier;
71}69}
7270
73#endif // !defined(_LIBCPP_HAS_NO_TREE_BARRIER)
74
75_LIBCPP_END_NAMESPACE_STD71_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/call_once.cpp+5-5
...@@ -9,7 +9,7 @@...@@ -9,7 +9,7 @@
9#include <__mutex/once_flag.h>9#include <__mutex/once_flag.h>
10#include <__utility/exception_guard.h>10#include <__utility/exception_guard.h>
1111
12#ifndef _LIBCPP_HAS_NO_THREADS12#if _LIBCPP_HAS_THREADS
13# include <__thread/support.h>13# include <__thread/support.h>
14#endif14#endif
1515
...@@ -23,13 +23,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,13 +23,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
23// call into dispatch_once_f instead of here. Relevant radar this code needs to23// call into dispatch_once_f instead of here. Relevant radar this code needs to
24// keep in sync with: 7741191.24// keep in sync with: 7741191.
2525
26#ifndef _LIBCPP_HAS_NO_THREADS26#if _LIBCPP_HAS_THREADS
27static constinit __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;27static constinit __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;
28static constinit __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;28static constinit __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
29#endif29#endif
3030
31void __call_once(volatile once_flag::_State_type& flag, void* arg, void (*func)(void*)) {31void __call_once(volatile once_flag::_State_type& flag, void* arg, void (*func)(void*)) {
32#if defined(_LIBCPP_HAS_NO_THREADS)32#if !_LIBCPP_HAS_THREADS
3333
34 if (flag == once_flag::_Unset) {34 if (flag == once_flag::_Unset) {
35 auto guard = std::__make_exception_guard([&flag] { flag = once_flag::_Unset; });35 auto guard = std::__make_exception_guard([&flag] { flag = once_flag::_Unset; });
...@@ -39,7 +39,7 @@ void __call_once(volatile once_flag::_State_type& flag, void* arg, void (*func)(...@@ -39,7 +39,7 @@ void __call_once(volatile once_flag::_State_type& flag, void* arg, void (*func)(
39 guard.__complete();39 guard.__complete();
40 }40 }
4141
42#else // !_LIBCPP_HAS_NO_THREADS42#else // !_LIBCPP_HAS_THREADS
4343
44 __libcpp_mutex_lock(&mut);44 __libcpp_mutex_lock(&mut);
45 while (flag == once_flag::_Pending)45 while (flag == once_flag::_Pending)
...@@ -64,7 +64,7 @@ void __call_once(volatile once_flag::_State_type& flag, void* arg, void (*func)(...@@ -64,7 +64,7 @@ void __call_once(volatile once_flag::_State_type& flag, void* arg, void (*func)(
64 __libcpp_mutex_unlock(&mut);64 __libcpp_mutex_unlock(&mut);
65 }65 }
6666
67#endif // !_LIBCPP_HAS_NO_THREADS67#endif // !_LIBCPP_HAS_THREADS
68}68}
6969
70_LIBCPP_END_NAMESPACE_STD70_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/charconv.cpp+12
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
9#include <charconv>9#include <charconv>
10#include <string.h>10#include <string.h>
1111
12#include "include/from_chars_floating_point.h"
12#include "include/to_chars_floating_point.h"13#include "include/to_chars_floating_point.h"
1314
14_LIBCPP_BEGIN_NAMESPACE_STD15_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -74,4 +75,15 @@ to_chars_result to_chars(char* __first, char* __last, long double __value, chars...@@ -74,4 +75,15 @@ to_chars_result to_chars(char* __first, char* __last, long double __value, chars
74 __first, __last, static_cast<double>(__value), __fmt, __precision);75 __first, __last, static_cast<double>(__value), __fmt, __precision);
75}76}
7677
78template <class _Fp>
79__from_chars_result<_Fp> __from_chars_floating_point(
80 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt) {
81 return std::__from_chars_floating_point_impl<_Fp>(__first, __last, __fmt);
82}
83
84template __from_chars_result<float> __from_chars_floating_point(
85 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
86
87template __from_chars_result<double> __from_chars_floating_point(
88 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
77_LIBCPP_END_NAMESPACE_STD89_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/chrono.cpp+34-5
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12# define _LARGE_TIME_API12# define _LARGE_TIME_API
13#endif13#endif
1414
15#include <__system_error/system_error.h>15#include <__system_error/throw_system_error.h>
16#include <cerrno> // errno16#include <cerrno> // errno
17#include <chrono>17#include <chrono>
1818
...@@ -31,9 +31,14 @@...@@ -31,9 +31,14 @@
31# include <sys/time.h> // for gettimeofday and timeval31# include <sys/time.h> // for gettimeofday and timeval
32#endif32#endif
3333
34// OpenBSD does not have a fully conformant suite of POSIX timers, but34#if defined(__LLVM_LIBC__)
35# define _LIBCPP_HAS_TIMESPEC_GET
36#endif
37
38// OpenBSD and GPU do not have a fully conformant suite of POSIX timers, but
35// it does have clock_gettime and CLOCK_MONOTONIC which is all we need.39// it does have clock_gettime and CLOCK_MONOTONIC which is all we need.
36#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)40#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || defined(__AMDGPU__) || \
41 defined(__NVPTX__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
37# define _LIBCPP_HAS_CLOCK_GETTIME42# define _LIBCPP_HAS_CLOCK_GETTIME
38#endif43#endif
3944
...@@ -114,6 +119,15 @@ static system_clock::time_point __libcpp_system_clock_now() {...@@ -114,6 +119,15 @@ static system_clock::time_point __libcpp_system_clock_now() {
114 return system_clock::time_point(duration_cast<system_clock::duration>(d - nt_to_unix_epoch));119 return system_clock::time_point(duration_cast<system_clock::duration>(d - nt_to_unix_epoch));
115}120}
116121
122#elif defined(_LIBCPP_HAS_TIMESPEC_GET)
123
124static system_clock::time_point __libcpp_system_clock_now() {
125 struct timespec ts;
126 if (timespec_get(&ts, TIME_UTC) != TIME_UTC)
127 __throw_system_error(errno, "timespec_get(TIME_UTC) failed");
128 return system_clock::time_point(seconds(ts.tv_sec) + microseconds(ts.tv_nsec / 1000));
129}
130
117#elif defined(_LIBCPP_HAS_CLOCK_GETTIME)131#elif defined(_LIBCPP_HAS_CLOCK_GETTIME)
118132
119static system_clock::time_point __libcpp_system_clock_now() {133static system_clock::time_point __libcpp_system_clock_now() {
...@@ -133,7 +147,10 @@ static system_clock::time_point __libcpp_system_clock_now() {...@@ -133,7 +147,10 @@ static system_clock::time_point __libcpp_system_clock_now() {
133147
134#endif148#endif
135149
150_LIBCPP_DIAGNOSTIC_PUSH
151_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated")
136const bool system_clock::is_steady;152const bool system_clock::is_steady;
153_LIBCPP_DIAGNOSTIC_POP
137154
138system_clock::time_point system_clock::now() noexcept { return __libcpp_system_clock_now(); }155system_clock::time_point system_clock::now() noexcept { return __libcpp_system_clock_now(); }
139156
...@@ -151,7 +168,7 @@ system_clock::time_point system_clock::from_time_t(time_t t) noexcept { return s...@@ -151,7 +168,7 @@ system_clock::time_point system_clock::from_time_t(time_t t) noexcept { return s
151// instead.168// instead.
152//169//
153170
154#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK171#if _LIBCPP_HAS_MONOTONIC_CLOCK
155172
156# if defined(__APPLE__)173# if defined(__APPLE__)
157174
...@@ -212,6 +229,15 @@ static steady_clock::time_point __libcpp_steady_clock_now() noexcept {...@@ -212,6 +229,15 @@ static steady_clock::time_point __libcpp_steady_clock_now() noexcept {
212 return steady_clock::time_point(nanoseconds(_zx_clock_get_monotonic()));229 return steady_clock::time_point(nanoseconds(_zx_clock_get_monotonic()));
213}230}
214231
232# elif defined(_LIBCPP_HAS_TIMESPEC_GET)
233
234static steady_clock::time_point __libcpp_steady_clock_now() {
235 struct timespec ts;
236 if (timespec_get(&ts, TIME_MONOTONIC) != TIME_MONOTONIC)
237 __throw_system_error(errno, "timespec_get(TIME_MONOTONIC) failed");
238 return steady_clock::time_point(seconds(ts.tv_sec) + microseconds(ts.tv_nsec / 1000));
239}
240
215# elif defined(_LIBCPP_HAS_CLOCK_GETTIME)241# elif defined(_LIBCPP_HAS_CLOCK_GETTIME)
216242
217static steady_clock::time_point __libcpp_steady_clock_now() {243static steady_clock::time_point __libcpp_steady_clock_now() {
...@@ -225,11 +251,14 @@ static steady_clock::time_point __libcpp_steady_clock_now() {...@@ -225,11 +251,14 @@ static steady_clock::time_point __libcpp_steady_clock_now() {
225# error "Monotonic clock not implemented on this platform"251# error "Monotonic clock not implemented on this platform"
226# endif252# endif
227253
254_LIBCPP_DIAGNOSTIC_PUSH
255_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated")
228const bool steady_clock::is_steady;256const bool steady_clock::is_steady;
257_LIBCPP_DIAGNOSTIC_POP
229258
230steady_clock::time_point steady_clock::now() noexcept { return __libcpp_steady_clock_now(); }259steady_clock::time_point steady_clock::now() noexcept { return __libcpp_steady_clock_now(); }
231260
232#endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK261#endif // _LIBCPP_HAS_MONOTONIC_CLOCK
233262
234} // namespace chrono263} // namespace chrono
235264
lib/libcxx/src/condition_variable_destructor.cpp+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <__config>14#include <__config>
15#include <__thread/support.h>15#include <__thread/support.h>
1616
17#if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION)17#if _LIBCPP_ABI_VERSION == 1 || !_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
18# define NEEDS_CONDVAR_DESTRUCTOR18# define NEEDS_CONDVAR_DESTRUCTOR
19#endif19#endif
2020
lib/libcxx/src/exception.cpp+3
...@@ -6,6 +6,9 @@...@@ -6,6 +6,9 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#define _LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION
10#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
11
9#include <exception>12#include <exception>
10#include <new>13#include <new>
11#include <typeinfo>14#include <typeinfo>
lib/libcxx/src/experimental/include/tzdb/tzdb_list_private.h+6-6
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18// When threads are available, we use std::mutex over std::shared_mutex18// When threads are available, we use std::mutex over std::shared_mutex
19// due to the increased overhead of std::shared_mutex.19// due to the increased overhead of std::shared_mutex.
20// See shared_mutex_vs_mutex.bench.cpp20// See shared_mutex_vs_mutex.bench.cpp
21#ifndef _LIBCPP_HAS_NO_THREADS21#if _LIBCPP_HAS_THREADS
22# include <mutex>22# include <mutex>
23#endif23#endif
2424
...@@ -48,7 +48,7 @@ public:...@@ -48,7 +48,7 @@ public:
48 __impl() { __load_no_lock(); }48 __impl() { __load_no_lock(); }
4949
50 [[nodiscard]] const tzdb& __load() {50 [[nodiscard]] const tzdb& __load() {
51#ifndef _LIBCPP_HAS_NO_THREADS51#if _LIBCPP_HAS_THREADS
52 unique_lock __lock{__mutex_};52 unique_lock __lock{__mutex_};
53#endif53#endif
54 __load_no_lock();54 __load_no_lock();
...@@ -58,14 +58,14 @@ public:...@@ -58,14 +58,14 @@ public:
58 using const_iterator = tzdb_list::const_iterator;58 using const_iterator = tzdb_list::const_iterator;
5959
60 const tzdb& __front() const noexcept {60 const tzdb& __front() const noexcept {
61#ifndef _LIBCPP_HAS_NO_THREADS61#if _LIBCPP_HAS_THREADS
62 unique_lock __lock{__mutex_};62 unique_lock __lock{__mutex_};
63#endif63#endif
64 return __tzdb_.front();64 return __tzdb_.front();
65 }65 }
6666
67 const_iterator __erase_after(const_iterator __p) {67 const_iterator __erase_after(const_iterator __p) {
68#ifndef _LIBCPP_HAS_NO_THREADS68#if _LIBCPP_HAS_THREADS
69 unique_lock __lock{__mutex_};69 unique_lock __lock{__mutex_};
70#endif70#endif
7171
...@@ -74,7 +74,7 @@ public:...@@ -74,7 +74,7 @@ public:
74 }74 }
7575
76 const_iterator __begin() const noexcept {76 const_iterator __begin() const noexcept {
77#ifndef _LIBCPP_HAS_NO_THREADS77#if _LIBCPP_HAS_THREADS
78 unique_lock __lock{__mutex_};78 unique_lock __lock{__mutex_};
79#endif79#endif
80 return __tzdb_.begin();80 return __tzdb_.begin();
...@@ -89,7 +89,7 @@ private:...@@ -89,7 +89,7 @@ private:
89 // pre: The caller ensures the locking, if needed, is done.89 // pre: The caller ensures the locking, if needed, is done.
90 void __load_no_lock() { chrono::__init_tzdb(__tzdb_.emplace_front(), __rules_.emplace_front()); }90 void __load_no_lock() { chrono::__init_tzdb(__tzdb_.emplace_front(), __rules_.emplace_front()); }
9191
92#ifndef _LIBCPP_HAS_NO_THREADS92#if _LIBCPP_HAS_THREADS
93 mutable mutex __mutex_;93 mutable mutex __mutex_;
94#endif94#endif
95 forward_list<tzdb> __tzdb_;95 forward_list<tzdb> __tzdb_;
lib/libcxx/src/experimental/time_zone.cpp+4-4
...@@ -199,7 +199,7 @@ __format(const __tz::__continuation& __continuation, const string& __letters, se...@@ -199,7 +199,7 @@ __format(const __tz::__continuation& __continuation, const string& __letters, se
199 // active at the end. This should be determined separately.199 // active at the end. This should be determined separately.
200 return chrono::seconds{0};200 return chrono::seconds{0};
201 else201 else
202 static_assert(sizeof(_Tp) == 0); // TODO TZDB static_assert(false); after droping clang-16 support202 static_assert(false);
203203
204 std::__libcpp_unreachable();204 std::__libcpp_unreachable();
205 },205 },
...@@ -225,7 +225,7 @@ __format(const __tz::__continuation& __continuation, const string& __letters, se...@@ -225,7 +225,7 @@ __format(const __tz::__continuation& __continuation, const string& __letters, se
225 else if constexpr (same_as<_Tp, __tz::__constrained_weekday>)225 else if constexpr (same_as<_Tp, __tz::__constrained_weekday>)
226 return __value(__year, __month);226 return __value(__year, __month);
227 else227 else
228 static_assert(sizeof(_Tp) == 0); // TODO TZDB static_assert(false); after droping clang-16 support228 static_assert(false);
229229
230 std::__libcpp_unreachable();230 std::__libcpp_unreachable();
231 },231 },
...@@ -668,7 +668,7 @@ __first_rule(seconds __stdoff, const vector<__tz::__rule>& __rules) {...@@ -668,7 +668,7 @@ __first_rule(seconds __stdoff, const vector<__tz::__rule>& __rules) {
668 __continuation_end,668 __continuation_end,
669 __continuation.__stdoff + __save,669 __continuation.__stdoff + __save,
670 chrono::duration_cast<minutes>(__save),670 chrono::duration_cast<minutes>(__save),
671 __continuation.__format},671 chrono::__format(__continuation, __continuation.__format, __save)},
672 true};672 true};
673}673}
674674
...@@ -688,7 +688,7 @@ __get_sys_info(sys_seconds __time,...@@ -688,7 +688,7 @@ __get_sys_info(sys_seconds __time,
688 else if constexpr (same_as<_Tp, __tz::__save>)688 else if constexpr (same_as<_Tp, __tz::__save>)
689 return chrono::__get_sys_info_basic(__time, __continuation_begin, __continuation, __value.__time);689 return chrono::__get_sys_info_basic(__time, __continuation_begin, __continuation, __value.__time);
690 else690 else
691 static_assert(sizeof(_Tp) == 0); // TODO TZDB static_assert(false); after droping clang-16 support691 static_assert(false);
692692
693 std::__libcpp_unreachable();693 std::__libcpp_unreachable();
694 },694 },
lib/libcxx/src/experimental/tzdb.cpp+19-7
...@@ -8,12 +8,16 @@...@@ -8,12 +8,16 @@
88
9// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html9// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
1010
11#include <__assert>
11#include <algorithm>12#include <algorithm>
13#include <cctype>
12#include <chrono>14#include <chrono>
13#include <filesystem>15#include <filesystem>
14#include <fstream>16#include <fstream>
15#include <stdexcept>17#include <stdexcept>
16#include <string>18#include <string>
19#include <string_view>
20#include <vector>
1721
18#include "include/tzdb/time_zone_private.h"22#include "include/tzdb/time_zone_private.h"
19#include "include/tzdb/types_private.h"23#include "include/tzdb/types_private.h"
...@@ -51,8 +55,7 @@ _LIBCPP_WEAK string_view __libcpp_tzdb_directory() {...@@ -51,8 +55,7 @@ _LIBCPP_WEAK string_view __libcpp_tzdb_directory() {
51#if defined(__linux__)55#if defined(__linux__)
52 return "/usr/share/zoneinfo/";56 return "/usr/share/zoneinfo/";
53#else57#else
54// Zig patch: change this compilation error into a runtime crash.58 // zig patch: change this compilation error into a runtime crash
55//# error "unknown path to the IANA Time Zone Database"
56 abort();59 abort();
57#endif60#endif
58}61}
...@@ -96,14 +99,23 @@ static void __skip(istream& __input, string_view __suffix) {...@@ -96,14 +99,23 @@ static void __skip(istream& __input, string_view __suffix) {
96}99}
97100
98static void __matches(istream& __input, char __expected) {101static void __matches(istream& __input, char __expected) {
99 if (std::tolower(__input.get()) != __expected)102 _LIBCPP_ASSERT_INTERNAL(!std::isalpha(__expected) || std::islower(__expected), "lowercase characters only here!");
100 std::__throw_runtime_error((string("corrupt tzdb: expected character '") + __expected + '\'').c_str());103 char __c = __input.get();
104 if (std::tolower(__c) != __expected)
105 std::__throw_runtime_error(
106 (string("corrupt tzdb: expected character '") + __expected + "', got '" + __c + "' instead").c_str());
101}107}
102108
103static void __matches(istream& __input, string_view __expected) {109static void __matches(istream& __input, string_view __expected) {
104 for (auto __c : __expected)110 for (auto __c : __expected) {
105 if (std::tolower(__input.get()) != __c)111 _LIBCPP_ASSERT_INTERNAL(!std::isalpha(__c) || std::islower(__c), "lowercase strings only here!");
106 std::__throw_runtime_error((string("corrupt tzdb: expected string '") + string(__expected) + '\'').c_str());112 char __actual = __input.get();
113 if (std::tolower(__actual) != __c)
114 std::__throw_runtime_error(
115 (string("corrupt tzdb: expected character '") + __c + "' from string '" + string(__expected) + "', got '" +
116 __actual + "' instead")
117 .c_str());
118 }
107}119}
108120
109[[nodiscard]] static string __parse_string(istream& __input) {121[[nodiscard]] static string __parse_string(istream& __input) {
lib/libcxx/src/filesystem/directory_iterator.cpp+11-11
...@@ -47,9 +47,9 @@ public:...@@ -47,9 +47,9 @@ public:
47 }47 }
48 __stream_ = ::FindFirstFileW((root / "*").c_str(), &__data_);48 __stream_ = ::FindFirstFileW((root / "*").c_str(), &__data_);
49 if (__stream_ == INVALID_HANDLE_VALUE) {49 if (__stream_ == INVALID_HANDLE_VALUE) {
50 ec = detail::make_windows_error(GetLastError());50 ec = detail::get_last_error();
51 const bool ignore_permission_denied = bool(opts & directory_options::skip_permission_denied);51 const bool ignore_permission_denied = bool(opts & directory_options::skip_permission_denied);
52 if (ignore_permission_denied && ec.value() == static_cast<int>(errc::permission_denied))52 if (ignore_permission_denied && ec == errc::permission_denied)
53 ec.clear();53 ec.clear();
54 return;54 return;
55 }55 }
...@@ -77,13 +77,13 @@ public:...@@ -77,13 +77,13 @@ public:
77 bool assign() {77 bool assign() {
78 if (!wcscmp(__data_.cFileName, L".") || !wcscmp(__data_.cFileName, L".."))78 if (!wcscmp(__data_.cFileName, L".") || !wcscmp(__data_.cFileName, L".."))
79 return false;79 return false;
80 // FIXME: Cache more of this
81 // directory_entry::__cached_data cdata;
82 // cdata.__type_ = get_file_type(__data_);
83 // cdata.__size_ = get_file_size(__data_);
84 // cdata.__write_time_ = get_write_time(__data_);
85 __entry_.__assign_iter_entry(80 __entry_.__assign_iter_entry(
86 __root_ / __data_.cFileName, directory_entry::__create_iter_result(detail::get_file_type(__data_)));81 __root_ / __data_.cFileName,
82 directory_entry::__create_iter_cached_result(
83 detail::get_file_type(__data_),
84 detail::get_file_size(__data_),
85 detail::get_file_perm(__data_),
86 detail::get_write_time(__data_)));
87 return true;87 return true;
88 }88 }
8989
...@@ -91,7 +91,7 @@ private:...@@ -91,7 +91,7 @@ private:
91 error_code close() noexcept {91 error_code close() noexcept {
92 error_code ec;92 error_code ec;
93 if (!::FindClose(__stream_))93 if (!::FindClose(__stream_))
94 ec = detail::make_windows_error(GetLastError());94 ec = detail::get_last_error();
95 __stream_ = INVALID_HANDLE_VALUE;95 __stream_ = INVALID_HANDLE_VALUE;
96 return ec;96 return ec;
97 }97 }
...@@ -118,7 +118,7 @@ public:...@@ -118,7 +118,7 @@ public:
118 if ((__stream_ = ::opendir(root.c_str())) == nullptr) {118 if ((__stream_ = ::opendir(root.c_str())) == nullptr) {
119 ec = detail::capture_errno();119 ec = detail::capture_errno();
120 const bool allow_eacces = bool(opts & directory_options::skip_permission_denied);120 const bool allow_eacces = bool(opts & directory_options::skip_permission_denied);
121 if (allow_eacces && ec.value() == EACCES)121 if (allow_eacces && ec == errc::permission_denied)
122 ec.clear();122 ec.clear();
123 return;123 return;
124 }124 }
...@@ -307,7 +307,7 @@ bool recursive_directory_iterator::__try_recursion(error_code* ec) {...@@ -307,7 +307,7 @@ bool recursive_directory_iterator::__try_recursion(error_code* ec) {
307 }307 }
308 if (m_ec) {308 if (m_ec) {
309 const bool allow_eacess = bool(__imp_->__options_ & directory_options::skip_permission_denied);309 const bool allow_eacess = bool(__imp_->__options_ & directory_options::skip_permission_denied);
310 if (m_ec.value() == EACCES && allow_eacess) {310 if (m_ec == errc::permission_denied && allow_eacess) {
311 if (ec)311 if (ec)
312 ec->clear();312 ec->clear();
313 } else {313 } else {
lib/libcxx/src/filesystem/error.h+16-75
...@@ -32,80 +32,21 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM...@@ -32,80 +32,21 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
3232
33namespace detail {33namespace detail {
3434
35#if defined(_LIBCPP_WIN32API)35// On windows, libc functions use errno, but system functions use GetLastError.
3636// So, callers need to be careful which of these next functions they call!
37inline errc __win_err_to_errc(int err) {
38 constexpr struct {
39 DWORD win;
40 errc errc;
41 } win_error_mapping[] = {
42 {ERROR_ACCESS_DENIED, errc::permission_denied},
43 {ERROR_ALREADY_EXISTS, errc::file_exists},
44 {ERROR_BAD_NETPATH, errc::no_such_file_or_directory},
45 {ERROR_BAD_PATHNAME, errc::no_such_file_or_directory},
46 {ERROR_BAD_UNIT, errc::no_such_device},
47 {ERROR_BROKEN_PIPE, errc::broken_pipe},
48 {ERROR_BUFFER_OVERFLOW, errc::filename_too_long},
49 {ERROR_BUSY, errc::device_or_resource_busy},
50 {ERROR_BUSY_DRIVE, errc::device_or_resource_busy},
51 {ERROR_CANNOT_MAKE, errc::permission_denied},
52 {ERROR_CANTOPEN, errc::io_error},
53 {ERROR_CANTREAD, errc::io_error},
54 {ERROR_CANTWRITE, errc::io_error},
55 {ERROR_CURRENT_DIRECTORY, errc::permission_denied},
56 {ERROR_DEV_NOT_EXIST, errc::no_such_device},
57 {ERROR_DEVICE_IN_USE, errc::device_or_resource_busy},
58 {ERROR_DIR_NOT_EMPTY, errc::directory_not_empty},
59 {ERROR_DIRECTORY, errc::invalid_argument},
60 {ERROR_DISK_FULL, errc::no_space_on_device},
61 {ERROR_FILE_EXISTS, errc::file_exists},
62 {ERROR_FILE_NOT_FOUND, errc::no_such_file_or_directory},
63 {ERROR_HANDLE_DISK_FULL, errc::no_space_on_device},
64 {ERROR_INVALID_ACCESS, errc::permission_denied},
65 {ERROR_INVALID_DRIVE, errc::no_such_device},
66 {ERROR_INVALID_FUNCTION, errc::function_not_supported},
67 {ERROR_INVALID_HANDLE, errc::invalid_argument},
68 {ERROR_INVALID_NAME, errc::no_such_file_or_directory},
69 {ERROR_INVALID_PARAMETER, errc::invalid_argument},
70 {ERROR_LOCK_VIOLATION, errc::no_lock_available},
71 {ERROR_LOCKED, errc::no_lock_available},
72 {ERROR_NEGATIVE_SEEK, errc::invalid_argument},
73 {ERROR_NOACCESS, errc::permission_denied},
74 {ERROR_NOT_ENOUGH_MEMORY, errc::not_enough_memory},
75 {ERROR_NOT_READY, errc::resource_unavailable_try_again},
76 {ERROR_NOT_SAME_DEVICE, errc::cross_device_link},
77 {ERROR_NOT_SUPPORTED, errc::not_supported},
78 {ERROR_OPEN_FAILED, errc::io_error},
79 {ERROR_OPEN_FILES, errc::device_or_resource_busy},
80 {ERROR_OPERATION_ABORTED, errc::operation_canceled},
81 {ERROR_OUTOFMEMORY, errc::not_enough_memory},
82 {ERROR_PATH_NOT_FOUND, errc::no_such_file_or_directory},
83 {ERROR_READ_FAULT, errc::io_error},
84 {ERROR_REPARSE_TAG_INVALID, errc::invalid_argument},
85 {ERROR_RETRY, errc::resource_unavailable_try_again},
86 {ERROR_SEEK, errc::io_error},
87 {ERROR_SHARING_VIOLATION, errc::permission_denied},
88 {ERROR_TOO_MANY_OPEN_FILES, errc::too_many_files_open},
89 {ERROR_WRITE_FAULT, errc::io_error},
90 {ERROR_WRITE_PROTECT, errc::permission_denied},
91 };
92
93 for (const auto& pair : win_error_mapping)
94 if (pair.win == static_cast<DWORD>(err))
95 return pair.errc;
96 return errc::invalid_argument;
97}
98
99#endif // _LIBCPP_WIN32API
10037
101inline error_code capture_errno() {38inline error_code capture_errno() {
102 _LIBCPP_ASSERT_INTERNAL(errno != 0, "Expected errno to be non-zero");39 _LIBCPP_ASSERT_INTERNAL(errno != 0, "Expected errno to be non-zero");
103 return error_code(errno, generic_category());40 return error_code(errno, generic_category());
104}41}
10542
43inline error_code get_last_error() {
106#if defined(_LIBCPP_WIN32API)44#if defined(_LIBCPP_WIN32API)
107inline error_code make_windows_error(int err) { return make_error_code(__win_err_to_errc(err)); }45 return std::error_code(GetLastError(), std::system_category());
46#else
47 return capture_errno();
108#endif48#endif
49}
10950
110template <class T>51template <class T>
111T error_value();52T error_value();
...@@ -186,16 +127,16 @@ struct ErrorHandler {...@@ -186,16 +127,16 @@ struct ErrorHandler {
186 T report(const error_code& ec, const char* msg, ...) const {127 T report(const error_code& ec, const char* msg, ...) const {
187 va_list ap;128 va_list ap;
188 va_start(ap, msg);129 va_start(ap, msg);
189#ifndef _LIBCPP_HAS_NO_EXCEPTIONS130#if _LIBCPP_HAS_EXCEPTIONS
190 try {131 try {
191#endif // _LIBCPP_HAS_NO_EXCEPTIONS132#endif // _LIBCPP_HAS_EXCEPTIONS
192 report_impl(ec, msg, ap);133 report_impl(ec, msg, ap);
193#ifndef _LIBCPP_HAS_NO_EXCEPTIONS134#if _LIBCPP_HAS_EXCEPTIONS
194 } catch (...) {135 } catch (...) {
195 va_end(ap);136 va_end(ap);
196 throw;137 throw;
197 }138 }
198#endif // _LIBCPP_HAS_NO_EXCEPTIONS139#endif // _LIBCPP_HAS_EXCEPTIONS
199 va_end(ap);140 va_end(ap);
200 return error_value<T>();141 return error_value<T>();
201 }142 }
...@@ -206,16 +147,16 @@ struct ErrorHandler {...@@ -206,16 +147,16 @@ struct ErrorHandler {
206 T report(errc const& err, const char* msg, ...) const {147 T report(errc const& err, const char* msg, ...) const {
207 va_list ap;148 va_list ap;
208 va_start(ap, msg);149 va_start(ap, msg);
209#ifndef _LIBCPP_HAS_NO_EXCEPTIONS150#if _LIBCPP_HAS_EXCEPTIONS
210 try {151 try {
211#endif // _LIBCPP_HAS_NO_EXCEPTIONS152#endif // _LIBCPP_HAS_EXCEPTIONS
212 report_impl(make_error_code(err), msg, ap);153 report_impl(make_error_code(err), msg, ap);
213#ifndef _LIBCPP_HAS_NO_EXCEPTIONS154#if _LIBCPP_HAS_EXCEPTIONS
214 } catch (...) {155 } catch (...) {
215 va_end(ap);156 va_end(ap);
216 throw;157 throw;
217 }158 }
218#endif // _LIBCPP_HAS_NO_EXCEPTIONS159#endif // _LIBCPP_HAS_EXCEPTIONS
219 va_end(ap);160 va_end(ap);
220 return error_value<T>();161 return error_value<T>();
221 }162 }
...@@ -225,7 +166,7 @@ private:...@@ -225,7 +166,7 @@ private:
225 ErrorHandler& operator=(ErrorHandler const&) = delete;166 ErrorHandler& operator=(ErrorHandler const&) = delete;
226};167};
227168
228} // end namespace detail169} // namespace detail
229170
230_LIBCPP_END_NAMESPACE_FILESYSTEM171_LIBCPP_END_NAMESPACE_FILESYSTEM
231172
lib/libcxx/src/filesystem/file_descriptor.h+18-11
...@@ -97,11 +97,18 @@ inline uintmax_t get_file_size(const WIN32_FIND_DATAW& data) {...@@ -97,11 +97,18 @@ inline uintmax_t get_file_size(const WIN32_FIND_DATAW& data) {
97 return (static_cast<uint64_t>(data.nFileSizeHigh) << 32) + data.nFileSizeLow;97 return (static_cast<uint64_t>(data.nFileSizeHigh) << 32) + data.nFileSizeLow;
98}98}
99inline file_time_type get_write_time(const WIN32_FIND_DATAW& data) {99inline file_time_type get_write_time(const WIN32_FIND_DATAW& data) {
100 ULARGE_INTEGER tmp;100 using detail::fs_time;
101 const FILETIME& time = data.ftLastWriteTime;101 const FILETIME& time = data.ftLastWriteTime;
102 tmp.u.LowPart = time.dwLowDateTime;102 auto ts = filetime_to_timespec(time);
103 tmp.u.HighPart = time.dwHighDateTime;103 if (!fs_time::is_representable(ts))
104 return file_time_type(file_time_type::duration(tmp.QuadPart));104 return file_time_type::min();
105 return fs_time::convert_from_timespec(ts);
106}
107inline perms get_file_perm(const WIN32_FIND_DATAW& data) {
108 unsigned st_mode = 0555; // Read-only
109 if (!(data.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
110 st_mode |= 0222; // Write
111 return static_cast<perms>(st_mode) & perms::mask;
105}112}
106113
107#endif // !_LIBCPP_WIN32API114#endif // !_LIBCPP_WIN32API
...@@ -194,7 +201,7 @@ inline perms posix_get_perms(const StatT& st) noexcept { return static_cast<perm...@@ -194,7 +201,7 @@ inline perms posix_get_perms(const StatT& st) noexcept { return static_cast<perm
194inline file_status create_file_status(error_code& m_ec, path const& p, const StatT& path_stat, error_code* ec) {201inline file_status create_file_status(error_code& m_ec, path const& p, const StatT& path_stat, error_code* ec) {
195 if (ec)202 if (ec)
196 *ec = m_ec;203 *ec = m_ec;
197 if (m_ec && (m_ec.value() == ENOENT || m_ec.value() == ENOTDIR)) {204 if (m_ec && (m_ec == errc::no_such_file_or_directory || m_ec == errc::not_a_directory)) {
198 return file_status(file_type::not_found);205 return file_status(file_type::not_found);
199 } else if (m_ec) {206 } else if (m_ec) {
200 ErrorHandler<void> err("posix_stat", ec, &p);207 ErrorHandler<void> err("posix_stat", ec, &p);
...@@ -229,7 +236,7 @@ inline file_status create_file_status(error_code& m_ec, path const& p, const Sta...@@ -229,7 +236,7 @@ inline file_status create_file_status(error_code& m_ec, path const& p, const Sta
229inline file_status posix_stat(path const& p, StatT& path_stat, error_code* ec) {236inline file_status posix_stat(path const& p, StatT& path_stat, error_code* ec) {
230 error_code m_ec;237 error_code m_ec;
231 if (detail::stat(p.c_str(), &path_stat) == -1)238 if (detail::stat(p.c_str(), &path_stat) == -1)
232 m_ec = detail::capture_errno();239 m_ec = detail::get_last_error();
233 return create_file_status(m_ec, p, path_stat, ec);240 return create_file_status(m_ec, p, path_stat, ec);
234}241}
235242
...@@ -241,7 +248,7 @@ inline file_status posix_stat(path const& p, error_code* ec) {...@@ -241,7 +248,7 @@ inline file_status posix_stat(path const& p, error_code* ec) {
241inline file_status posix_lstat(path const& p, StatT& path_stat, error_code* ec) {248inline file_status posix_lstat(path const& p, StatT& path_stat, error_code* ec) {
242 error_code m_ec;249 error_code m_ec;
243 if (detail::lstat(p.c_str(), &path_stat) == -1)250 if (detail::lstat(p.c_str(), &path_stat) == -1)
244 m_ec = detail::capture_errno();251 m_ec = detail::get_last_error();
245 return create_file_status(m_ec, p, path_stat, ec);252 return create_file_status(m_ec, p, path_stat, ec);
246}253}
247254
...@@ -253,7 +260,7 @@ inline file_status posix_lstat(path const& p, error_code* ec) {...@@ -253,7 +260,7 @@ inline file_status posix_lstat(path const& p, error_code* ec) {
253// http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html260// http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html
254inline bool posix_ftruncate(const FileDescriptor& fd, off_t to_size, error_code& ec) {261inline bool posix_ftruncate(const FileDescriptor& fd, off_t to_size, error_code& ec) {
255 if (detail::ftruncate(fd.fd, to_size) == -1) {262 if (detail::ftruncate(fd.fd, to_size) == -1) {
256 ec = capture_errno();263 ec = get_last_error();
257 return true;264 return true;
258 }265 }
259 ec.clear();266 ec.clear();
...@@ -262,7 +269,7 @@ inline bool posix_ftruncate(const FileDescriptor& fd, off_t to_size, error_code&...@@ -262,7 +269,7 @@ inline bool posix_ftruncate(const FileDescriptor& fd, off_t to_size, error_code&
262269
263inline bool posix_fchmod(const FileDescriptor& fd, const StatT& st, error_code& ec) {270inline bool posix_fchmod(const FileDescriptor& fd, const StatT& st, error_code& ec) {
264 if (detail::fchmod(fd.fd, st.st_mode) == -1) {271 if (detail::fchmod(fd.fd, st.st_mode) == -1) {
265 ec = capture_errno();272 ec = get_last_error();
266 return true;273 return true;
267 }274 }
268 ec.clear();275 ec.clear();
...@@ -279,12 +286,12 @@ inline file_status FileDescriptor::refresh_status(error_code& ec) {...@@ -279,12 +286,12 @@ inline file_status FileDescriptor::refresh_status(error_code& ec) {
279 m_stat = {};286 m_stat = {};
280 error_code m_ec;287 error_code m_ec;
281 if (detail::fstat(fd, &m_stat) == -1)288 if (detail::fstat(fd, &m_stat) == -1)
282 m_ec = capture_errno();289 m_ec = get_last_error();
283 m_status = create_file_status(m_ec, name, m_stat, &ec);290 m_status = create_file_status(m_ec, name, m_stat, &ec);
284 return m_status;291 return m_status;
285}292}
286293
287} // end namespace detail294} // namespace detail
288295
289_LIBCPP_END_NAMESPACE_FILESYSTEM296_LIBCPP_END_NAMESPACE_FILESYSTEM
290297
lib/libcxx/src/filesystem/filesystem_clock.cpp+16-1
...@@ -7,6 +7,7 @@...@@ -7,6 +7,7 @@
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include <__config>9#include <__config>
10#include <__system_error/throw_system_error.h>
10#include <chrono>11#include <chrono>
11#include <filesystem>12#include <filesystem>
12#include <time.h>13#include <time.h>
...@@ -29,13 +30,21 @@...@@ -29,13 +30,21 @@
29# include <sys/time.h> // for gettimeofday and timeval30# include <sys/time.h> // for gettimeofday and timeval
30#endif31#endif
3132
32#if defined(__APPLE__) || defined(__gnu_hurd__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)33#if defined(__LLVM_LIBC__)
34# define _LIBCPP_HAS_TIMESPEC_GET
35#endif
36
37#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__AMDGPU__) || defined(__NVPTX__) || \
38 (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
33# define _LIBCPP_HAS_CLOCK_GETTIME39# define _LIBCPP_HAS_CLOCK_GETTIME
34#endif40#endif
3541
36_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM42_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
3743
44_LIBCPP_DIAGNOSTIC_PUSH
45_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated")
38const bool _FilesystemClock::is_steady;46const bool _FilesystemClock::is_steady;
47_LIBCPP_DIAGNOSTIC_POP
3948
40_FilesystemClock::time_point _FilesystemClock::now() noexcept {49_FilesystemClock::time_point _FilesystemClock::now() noexcept {
41 typedef chrono::duration<rep> __secs;50 typedef chrono::duration<rep> __secs;
...@@ -45,6 +54,12 @@ _FilesystemClock::time_point _FilesystemClock::now() noexcept {...@@ -45,6 +54,12 @@ _FilesystemClock::time_point _FilesystemClock::now() noexcept {
45 GetSystemTimeAsFileTime(&time);54 GetSystemTimeAsFileTime(&time);
46 detail::TimeSpec tp = detail::filetime_to_timespec(time);55 detail::TimeSpec tp = detail::filetime_to_timespec(time);
47 return time_point(__secs(tp.tv_sec) + chrono::duration_cast<duration>(__nsecs(tp.tv_nsec)));56 return time_point(__secs(tp.tv_sec) + chrono::duration_cast<duration>(__nsecs(tp.tv_nsec)));
57#elif defined(_LIBCPP_HAS_TIMESPEC_GET)
58 typedef chrono::duration<rep, nano> __nsecs;
59 struct timespec ts;
60 if (timespec_get(&ts, TIME_UTC) != TIME_UTC)
61 __throw_system_error(errno, "timespec_get(TIME_UTC) failed");
62 return time_point(__secs(ts.tv_sec) + chrono::duration_cast<duration>(__nsecs(ts.tv_nsec)));
48#elif defined(_LIBCPP_HAS_CLOCK_GETTIME)63#elif defined(_LIBCPP_HAS_CLOCK_GETTIME)
49 typedef chrono::duration<rep, nano> __nsecs;64 typedef chrono::duration<rep, nano> __nsecs;
50 struct timespec tp;65 struct timespec tp;
lib/libcxx/src/filesystem/format_string.h+5-5
...@@ -56,21 +56,21 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) string format_string(const cha...@@ -56,21 +56,21 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) string format_string(const cha
56 string ret;56 string ret;
57 va_list ap;57 va_list ap;
58 va_start(ap, msg);58 va_start(ap, msg);
59#ifndef _LIBCPP_HAS_NO_EXCEPTIONS59#if _LIBCPP_HAS_EXCEPTIONS
60 try {60 try {
61#endif // _LIBCPP_HAS_NO_EXCEPTIONS61#endif // _LIBCPP_HAS_EXCEPTIONS
62 ret = detail::vformat_string(msg, ap);62 ret = detail::vformat_string(msg, ap);
63#ifndef _LIBCPP_HAS_NO_EXCEPTIONS63#if _LIBCPP_HAS_EXCEPTIONS
64 } catch (...) {64 } catch (...) {
65 va_end(ap);65 va_end(ap);
66 throw;66 throw;
67 }67 }
68#endif // _LIBCPP_HAS_NO_EXCEPTIONS68#endif // _LIBCPP_HAS_EXCEPTIONS
69 va_end(ap);69 va_end(ap);
70 return ret;70 return ret;
71}71}
7272
73} // end namespace detail73} // namespace detail
7474
75_LIBCPP_END_NAMESPACE_FILESYSTEM75_LIBCPP_END_NAMESPACE_FILESYSTEM
7676
lib/libcxx/src/filesystem/int128_builtins.cpp+1-1
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <__config>16#include <__config>
17#include <climits>17#include <climits>
1818
19#if !defined(_LIBCPP_HAS_NO_INT128)19#if _LIBCPP_HAS_INT128
2020
21extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_EXPORTED_FROM_ABI __int128_t21extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_EXPORTED_FROM_ABI __int128_t
22__muloti4(__int128_t a, __int128_t b, int* overflow) {22__muloti4(__int128_t a, __int128_t b, int* overflow) {
lib/libcxx/src/filesystem/operations.cpp+181-60
...@@ -15,6 +15,7 @@...@@ -15,6 +15,7 @@
15#include <filesystem>15#include <filesystem>
16#include <iterator>16#include <iterator>
17#include <string_view>17#include <string_view>
18#include <system_error>
18#include <type_traits>19#include <type_traits>
19#include <vector>20#include <vector>
2021
...@@ -32,11 +33,24 @@...@@ -32,11 +33,24 @@
32# include <dirent.h>33# include <dirent.h>
33# include <sys/stat.h>34# include <sys/stat.h>
34# include <sys/statvfs.h>35# include <sys/statvfs.h>
36# include <sys/types.h>
35# include <unistd.h>37# include <unistd.h>
36#endif38#endif
37#include <fcntl.h> /* values for fchmodat */39#include <fcntl.h> /* values for fchmodat */
38#include <time.h>40#include <time.h>
3941
42// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc >= 2.27 and musl
43#if defined(__linux__)
44# if defined(_LIBCPP_GLIBC_PREREQ)
45# if _LIBCPP_GLIBC_PREREQ(2, 27)
46# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
47# endif
48# elif _LIBCPP_HAS_MUSL_LIBC
49# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
50# endif
51#elif defined(__FreeBSD__)
52# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
53#endif
40#if __has_include(<sys/sendfile.h>)54#if __has_include(<sys/sendfile.h>)
41# include <sys/sendfile.h>55# include <sys/sendfile.h>
42# define _LIBCPP_FILESYSTEM_USE_SENDFILE56# define _LIBCPP_FILESYSTEM_USE_SENDFILE
...@@ -44,10 +58,18 @@...@@ -44,10 +58,18 @@
44# include <copyfile.h>58# include <copyfile.h>
45# define _LIBCPP_FILESYSTEM_USE_COPYFILE59# define _LIBCPP_FILESYSTEM_USE_COPYFILE
46#else60#else
47# include <fstream>
48# define _LIBCPP_FILESYSTEM_USE_FSTREAM61# define _LIBCPP_FILESYSTEM_USE_FSTREAM
49#endif62#endif
5063
64// sendfile and copy_file_range need to fall back
65// to the fstream implementation for special files
66#if (defined(_LIBCPP_FILESYSTEM_USE_SENDFILE) || defined(_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE) || \
67 defined(_LIBCPP_FILESYSTEM_USE_FSTREAM)) && \
68 _LIBCPP_HAS_LOCALIZATION
69# include <fstream>
70# define _LIBCPP_FILESYSTEM_NEED_FSTREAM
71#endif
72
51#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB)73#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB)
52# pragma comment(lib, "rt")74# pragma comment(lib, "rt")
53#endif75#endif
...@@ -86,7 +108,7 @@ path __canonical(path const& orig_p, error_code* ec) {...@@ -86,7 +108,7 @@ path __canonical(path const& orig_p, error_code* ec) {
86#if (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112) || defined(_LIBCPP_WIN32API)108#if (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112) || defined(_LIBCPP_WIN32API)
87 std::unique_ptr<path::value_type, decltype(&::free)> hold(detail::realpath(p.c_str(), nullptr), &::free);109 std::unique_ptr<path::value_type, decltype(&::free)> hold(detail::realpath(p.c_str(), nullptr), &::free);
88 if (hold.get() == nullptr)110 if (hold.get() == nullptr)
89 return err.report(capture_errno());111 return err.report(detail::get_last_error());
90 return {hold.get()};112 return {hold.get()};
91#else113#else
92# if defined(__MVS__) && !defined(PATH_MAX)114# if defined(__MVS__) && !defined(PATH_MAX)
...@@ -96,7 +118,7 @@ path __canonical(path const& orig_p, error_code* ec) {...@@ -96,7 +118,7 @@ path __canonical(path const& orig_p, error_code* ec) {
96# endif118# endif
97 path::value_type* ret;119 path::value_type* ret;
98 if ((ret = detail::realpath(p.c_str(), buff)) == nullptr)120 if ((ret = detail::realpath(p.c_str(), buff)) == nullptr)
99 return err.report(capture_errno());121 return err.report(detail::get_last_error());
100 return {ret};122 return {ret};
101#endif123#endif
102}124}
...@@ -178,9 +200,89 @@ void __copy(const path& from, const path& to, copy_options options, error_code*...@@ -178,9 +200,89 @@ void __copy(const path& from, const path& to, copy_options options, error_code*
178namespace detail {200namespace detail {
179namespace {201namespace {
180202
203#if defined(_LIBCPP_FILESYSTEM_NEED_FSTREAM)
204bool copy_file_impl_fstream(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
205 ifstream in;
206 in.__open(read_fd.fd, ios::binary);
207 if (!in.is_open()) {
208 // This assumes that __open didn't reset the error code.
209 ec = capture_errno();
210 return false;
211 }
212 read_fd.fd = -1;
213 ofstream out;
214 out.__open(write_fd.fd, ios::binary);
215 if (!out.is_open()) {
216 ec = capture_errno();
217 return false;
218 }
219 write_fd.fd = -1;
220
221 if (in.good() && out.good()) {
222 using InIt = istreambuf_iterator<char>;
223 using OutIt = ostreambuf_iterator<char>;
224 InIt bin(in);
225 InIt ein;
226 OutIt bout(out);
227 copy(bin, ein, bout);
228 }
229 if (out.fail() || in.fail()) {
230 ec = make_error_code(errc::io_error);
231 return false;
232 }
233
234 ec.clear();
235 return true;
236}
237#endif
238
239#if defined(_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE)
240bool copy_file_impl_copy_file_range(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
241 size_t count = read_fd.get_stat().st_size;
242 // a zero-length file is either empty, or not copyable by this syscall
243 // return early to avoid the syscall cost
244 if (count == 0) {
245 ec = {EINVAL, generic_category()};
246 return false;
247 }
248 // do not modify the fd positions as copy_file_impl_sendfile may be called after a partial copy
249# if defined(__linux__)
250 loff_t off_in = 0;
251 loff_t off_out = 0;
252# else
253 off_t off_in = 0;
254 off_t off_out = 0;
255# endif
256
257 do {
258 ssize_t res;
259
260 if ((res = ::copy_file_range(read_fd.fd, &off_in, write_fd.fd, &off_out, count, 0)) == -1) {
261 ec = capture_errno();
262 return false;
263 }
264 count -= res;
265 } while (count > 0);
266
267 ec.clear();
268
269 return true;
270}
271#endif
272
181#if defined(_LIBCPP_FILESYSTEM_USE_SENDFILE)273#if defined(_LIBCPP_FILESYSTEM_USE_SENDFILE)
182bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {274bool copy_file_impl_sendfile(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
183 size_t count = read_fd.get_stat().st_size;275 size_t count = read_fd.get_stat().st_size;
276 // a zero-length file is either empty, or not copyable by this syscall
277 // return early to avoid the syscall cost
278 // however, we can't afford this luxury in the no-locale build,
279 // as we can't utilize the fstream impl to copy empty files
280# if _LIBCPP_HAS_LOCALIZATION
281 if (count == 0) {
282 ec = {EINVAL, generic_category()};
283 return false;
284 }
285# endif
184 do {286 do {
185 ssize_t res;287 ssize_t res;
186 if ((res = ::sendfile(write_fd.fd, read_fd.fd, nullptr, count)) == -1) {288 if ((res = ::sendfile(write_fd.fd, read_fd.fd, nullptr, count)) == -1) {
...@@ -194,6 +296,54 @@ bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_cod...@@ -194,6 +296,54 @@ bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_cod
194296
195 return true;297 return true;
196}298}
299#endif
300
301#if defined(_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE) || defined(_LIBCPP_FILESYSTEM_USE_SENDFILE)
302// If we have copy_file_range or sendfile, try both in succession (if available).
303// If both fail, fall back to using fstream.
304bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
305# if defined(_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE)
306 if (copy_file_impl_copy_file_range(read_fd, write_fd, ec)) {
307 return true;
308 }
309 // EINVAL: src and dst are the same file (this is not cheaply
310 // detectable from userspace)
311 // EINVAL: copy_file_range is unsupported for this file type by the
312 // underlying filesystem
313 // ENOTSUP: undocumented, can arise with old kernels and NFS
314 // EOPNOTSUPP: filesystem does not implement copy_file_range
315 // ETXTBSY: src or dst is an active swapfile (nonsensical, but allowed
316 // with normal copying)
317 // EXDEV: src and dst are on different filesystems that do not support
318 // cross-fs copy_file_range
319 // ENOENT: undocumented, can arise with CIFS
320 // ENOSYS: unsupported by kernel or blocked by seccomp
321 if (ec.value() != EINVAL && ec.value() != ENOTSUP && ec.value() != EOPNOTSUPP && ec.value() != ETXTBSY &&
322 ec.value() != EXDEV && ec.value() != ENOENT && ec.value() != ENOSYS) {
323 return false;
324 }
325 ec.clear();
326# endif
327
328# if defined(_LIBCPP_FILESYSTEM_USE_SENDFILE)
329 if (copy_file_impl_sendfile(read_fd, write_fd, ec)) {
330 return true;
331 }
332 // EINVAL: unsupported file type
333 if (ec.value() != EINVAL) {
334 return false;
335 }
336 ec.clear();
337# endif
338
339# if defined(_LIBCPP_FILESYSTEM_NEED_FSTREAM)
340 return copy_file_impl_fstream(read_fd, write_fd, ec);
341# else
342 // since iostreams are unavailable in the no-locale build, just fail after a failed sendfile
343 ec.assign(EINVAL, std::system_category());
344 return false;
345# endif
346}
197#elif defined(_LIBCPP_FILESYSTEM_USE_COPYFILE)347#elif defined(_LIBCPP_FILESYSTEM_USE_COPYFILE)
198bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {348bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
199 struct CopyFileState {349 struct CopyFileState {
...@@ -217,44 +367,14 @@ bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_cod...@@ -217,44 +367,14 @@ bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_cod
217}367}
218#elif defined(_LIBCPP_FILESYSTEM_USE_FSTREAM)368#elif defined(_LIBCPP_FILESYSTEM_USE_FSTREAM)
219bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {369bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
220 ifstream in;370 return copy_file_impl_fstream(read_fd, write_fd, ec);
221 in.__open(read_fd.fd, ios::binary);
222 if (!in.is_open()) {
223 // This assumes that __open didn't reset the error code.
224 ec = capture_errno();
225 return false;
226 }
227 read_fd.fd = -1;
228 ofstream out;
229 out.__open(write_fd.fd, ios::binary);
230 if (!out.is_open()) {
231 ec = capture_errno();
232 return false;
233 }
234 write_fd.fd = -1;
235
236 if (in.good() && out.good()) {
237 using InIt = istreambuf_iterator<char>;
238 using OutIt = ostreambuf_iterator<char>;
239 InIt bin(in);
240 InIt ein;
241 OutIt bout(out);
242 copy(bin, ein, bout);
243 }
244 if (out.fail() || in.fail()) {
245 ec = make_error_code(errc::io_error);
246 return false;
247 }
248
249 ec.clear();
250 return true;
251}371}
252#else372#else
253# error "Unknown implementation for copy_file_impl"373# error "Unknown implementation for copy_file_impl"
254#endif // copy_file_impl implementation374#endif // copy_file_impl implementation
255375
256} // end anonymous namespace376} // end anonymous namespace
257} // end namespace detail377} // namespace detail
258378
259bool __copy_file(const path& from, const path& to, copy_options options, error_code* ec) {379bool __copy_file(const path& from, const path& to, copy_options options, error_code* ec) {
260 using detail::FileDescriptor;380 using detail::FileDescriptor;
...@@ -393,9 +513,9 @@ bool __create_directory(const path& p, error_code* ec) {...@@ -393,9 +513,9 @@ bool __create_directory(const path& p, error_code* ec) {
393 if (detail::mkdir(p.c_str(), static_cast<int>(perms::all)) == 0)513 if (detail::mkdir(p.c_str(), static_cast<int>(perms::all)) == 0)
394 return true;514 return true;
395515
396 if (errno != EEXIST)516 error_code mec = detail::get_last_error();
397 return err.report(capture_errno());517 if (mec != errc::file_exists)
398 error_code mec = capture_errno();518 return err.report(mec);
399 error_code ignored_ec;519 error_code ignored_ec;
400 const file_status st = status(p, ignored_ec);520 const file_status st = status(p, ignored_ec);
401 if (!is_directory(st))521 if (!is_directory(st))
...@@ -417,10 +537,10 @@ bool __create_directory(path const& p, path const& attributes, error_code* ec) {...@@ -417,10 +537,10 @@ bool __create_directory(path const& p, path const& attributes, error_code* ec) {
417 if (detail::mkdir(p.c_str(), attr_stat.st_mode) == 0)537 if (detail::mkdir(p.c_str(), attr_stat.st_mode) == 0)
418 return true;538 return true;
419539
420 if (errno != EEXIST)540 mec = detail::get_last_error();
421 return err.report(capture_errno());541 if (mec != errc::file_exists)
542 return err.report(mec);
422543
423 mec = capture_errno();
424 error_code ignored_ec;544 error_code ignored_ec;
425 st = status(p, ignored_ec);545 st = status(p, ignored_ec);
426 if (!is_directory(st))546 if (!is_directory(st))
...@@ -431,19 +551,19 @@ bool __create_directory(path const& p, path const& attributes, error_code* ec) {...@@ -431,19 +551,19 @@ bool __create_directory(path const& p, path const& attributes, error_code* ec) {
431void __create_directory_symlink(path const& from, path const& to, error_code* ec) {551void __create_directory_symlink(path const& from, path const& to, error_code* ec) {
432 ErrorHandler<void> err("create_directory_symlink", ec, &from, &to);552 ErrorHandler<void> err("create_directory_symlink", ec, &from, &to);
433 if (detail::symlink_dir(from.c_str(), to.c_str()) == -1)553 if (detail::symlink_dir(from.c_str(), to.c_str()) == -1)
434 return err.report(capture_errno());554 return err.report(detail::get_last_error());
435}555}
436556
437void __create_hard_link(const path& from, const path& to, error_code* ec) {557void __create_hard_link(const path& from, const path& to, error_code* ec) {
438 ErrorHandler<void> err("create_hard_link", ec, &from, &to);558 ErrorHandler<void> err("create_hard_link", ec, &from, &to);
439 if (detail::link(from.c_str(), to.c_str()) == -1)559 if (detail::link(from.c_str(), to.c_str()) == -1)
440 return err.report(capture_errno());560 return err.report(detail::get_last_error());
441}561}
442562
443void __create_symlink(path const& from, path const& to, error_code* ec) {563void __create_symlink(path const& from, path const& to, error_code* ec) {
444 ErrorHandler<void> err("create_symlink", ec, &from, &to);564 ErrorHandler<void> err("create_symlink", ec, &from, &to);
445 if (detail::symlink_file(from.c_str(), to.c_str()) == -1)565 if (detail::symlink_file(from.c_str(), to.c_str()) == -1)
446 return err.report(capture_errno());566 return err.report(detail::get_last_error());
447}567}
448568
449path __current_path(error_code* ec) {569path __current_path(error_code* ec) {
...@@ -486,7 +606,7 @@ path __current_path(error_code* ec) {...@@ -486,7 +606,7 @@ path __current_path(error_code* ec) {
486606
487 unique_ptr<path::value_type, Deleter> hold(detail::getcwd(ptr, size), deleter);607 unique_ptr<path::value_type, Deleter> hold(detail::getcwd(ptr, size), deleter);
488 if (hold.get() == nullptr)608 if (hold.get() == nullptr)
489 return err.report(capture_errno(), "call to getcwd failed");609 return err.report(detail::get_last_error(), "call to getcwd failed");
490610
491 return {hold.get()};611 return {hold.get()};
492}612}
...@@ -494,7 +614,7 @@ path __current_path(error_code* ec) {...@@ -494,7 +614,7 @@ path __current_path(error_code* ec) {
494void __current_path(const path& p, error_code* ec) {614void __current_path(const path& p, error_code* ec) {
495 ErrorHandler<void> err("current_path", ec, &p);615 ErrorHandler<void> err("current_path", ec, &p);
496 if (detail::chdir(p.c_str()) == -1)616 if (detail::chdir(p.c_str()) == -1)
497 err.report(capture_errno());617 err.report(detail::get_last_error());
498}618}
499619
500bool __equivalent(const path& p1, const path& p2, error_code* ec) {620bool __equivalent(const path& p1, const path& p2, error_code* ec) {
...@@ -582,10 +702,10 @@ void __last_write_time(const path& p, file_time_type new_time, error_code* ec) {...@@ -582,10 +702,10 @@ void __last_write_time(const path& p, file_time_type new_time, error_code* ec) {
582 return err.report(errc::value_too_large);702 return err.report(errc::value_too_large);
583 detail::WinHandle h(p.c_str(), FILE_WRITE_ATTRIBUTES, 0);703 detail::WinHandle h(p.c_str(), FILE_WRITE_ATTRIBUTES, 0);
584 if (!h)704 if (!h)
585 return err.report(detail::make_windows_error(GetLastError()));705 return err.report(detail::get_last_error());
586 FILETIME last_write = timespec_to_filetime(ts);706 FILETIME last_write = timespec_to_filetime(ts);
587 if (!SetFileTime(h, nullptr, nullptr, &last_write))707 if (!SetFileTime(h, nullptr, nullptr, &last_write))
588 return err.report(detail::make_windows_error(GetLastError()));708 return err.report(detail::get_last_error());
589#else709#else
590 error_code m_ec;710 error_code m_ec;
591 array<TimeSpec, 2> tbuf;711 array<TimeSpec, 2> tbuf;
...@@ -643,7 +763,7 @@ void __permissions(const path& p, perms prms, perm_options opts, error_code* ec)...@@ -643,7 +763,7 @@ void __permissions(const path& p, perms prms, perm_options opts, error_code* ec)
643#if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_FDCWD)763#if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_FDCWD)
644 const int flags = set_sym_perms ? AT_SYMLINK_NOFOLLOW : 0;764 const int flags = set_sym_perms ? AT_SYMLINK_NOFOLLOW : 0;
645 if (detail::fchmodat(AT_FDCWD, p.c_str(), real_perms, flags) == -1) {765 if (detail::fchmodat(AT_FDCWD, p.c_str(), real_perms, flags) == -1) {
646 return err.report(capture_errno());766 return err.report(detail::get_last_error());
647 }767 }
648#else768#else
649 if (set_sym_perms)769 if (set_sym_perms)
...@@ -671,14 +791,14 @@ path __read_symlink(const path& p, error_code* ec) {...@@ -671,14 +791,14 @@ path __read_symlink(const path& p, error_code* ec) {
671#else791#else
672 StatT sb;792 StatT sb;
673 if (detail::lstat(p.c_str(), &sb) == -1) {793 if (detail::lstat(p.c_str(), &sb) == -1) {
674 return err.report(capture_errno());794 return err.report(detail::get_last_error());
675 }795 }
676 const size_t size = sb.st_size + 1;796 const size_t size = sb.st_size + 1;
677 auto buff = unique_ptr<path::value_type[]>(new path::value_type[size]);797 auto buff = unique_ptr<path::value_type[]>(new path::value_type[size]);
678#endif798#endif
679 detail::SSizeT ret;799 detail::SSizeT ret;
680 if ((ret = detail::readlink(p.c_str(), buff.get(), size)) == -1)800 if ((ret = detail::readlink(p.c_str(), buff.get(), size)) == -1)
681 return err.report(capture_errno());801 return err.report(detail::get_last_error());
682 // Note that `ret` returning `0` would work, resulting in a valid empty string being returned.802 // Note that `ret` returning `0` would work, resulting in a valid empty string being returned.
683 if (static_cast<size_t>(ret) >= size)803 if (static_cast<size_t>(ret) >= size)
684 return err.report(errc::value_too_large);804 return err.report(errc::value_too_large);
...@@ -689,8 +809,9 @@ path __read_symlink(const path& p, error_code* ec) {...@@ -689,8 +809,9 @@ path __read_symlink(const path& p, error_code* ec) {
689bool __remove(const path& p, error_code* ec) {809bool __remove(const path& p, error_code* ec) {
690 ErrorHandler<bool> err("remove", ec, &p);810 ErrorHandler<bool> err("remove", ec, &p);
691 if (detail::remove(p.c_str()) == -1) {811 if (detail::remove(p.c_str()) == -1) {
692 if (errno != ENOENT)812 error_code mec = detail::get_last_error();
693 err.report(capture_errno());813 if (mec != errc::no_such_file_or_directory)
814 err.report(mec);
694 return false;815 return false;
695 }816 }
696 return true;817 return true;
...@@ -732,7 +853,7 @@ uintmax_t remove_all_impl(path const& p, error_code& ec) {...@@ -732,7 +853,7 @@ uintmax_t remove_all_impl(path const& p, error_code& ec) {
732 return count;853 return count;
733}854}
734855
735} // end namespace856} // namespace
736857
737uintmax_t __remove_all(const path& p, error_code* ec) {858uintmax_t __remove_all(const path& p, error_code* ec) {
738 ErrorHandler<uintmax_t> err("remove_all", ec, &p);859 ErrorHandler<uintmax_t> err("remove_all", ec, &p);
...@@ -827,7 +948,7 @@ uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) {...@@ -827,7 +948,7 @@ uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) {
827 return 0;948 return 0;
828}949}
829950
830} // end namespace951} // namespace
831952
832uintmax_t __remove_all(const path& p, error_code* ec) {953uintmax_t __remove_all(const path& p, error_code* ec) {
833 ErrorHandler<uintmax_t> err("remove_all", ec, &p);954 ErrorHandler<uintmax_t> err("remove_all", ec, &p);
...@@ -843,13 +964,13 @@ uintmax_t __remove_all(const path& p, error_code* ec) {...@@ -843,13 +964,13 @@ uintmax_t __remove_all(const path& p, error_code* ec) {
843void __rename(const path& from, const path& to, error_code* ec) {964void __rename(const path& from, const path& to, error_code* ec) {
844 ErrorHandler<void> err("rename", ec, &from, &to);965 ErrorHandler<void> err("rename", ec, &from, &to);
845 if (detail::rename(from.c_str(), to.c_str()) == -1)966 if (detail::rename(from.c_str(), to.c_str()) == -1)
846 err.report(capture_errno());967 err.report(detail::get_last_error());
847}968}
848969
849void __resize_file(const path& p, uintmax_t size, error_code* ec) {970void __resize_file(const path& p, uintmax_t size, error_code* ec) {
850 ErrorHandler<void> err("resize_file", ec, &p);971 ErrorHandler<void> err("resize_file", ec, &p);
851 if (detail::truncate(p.c_str(), static_cast< ::off_t>(size)) == -1)972 if (detail::truncate(p.c_str(), static_cast< ::off_t>(size)) == -1)
852 return err.report(capture_errno());973 return err.report(detail::get_last_error());
853}974}
854975
855space_info __space(const path& p, error_code* ec) {976space_info __space(const path& p, error_code* ec) {
...@@ -857,7 +978,7 @@ space_info __space(const path& p, error_code* ec) {...@@ -857,7 +978,7 @@ space_info __space(const path& p, error_code* ec) {
857 space_info si;978 space_info si;
858 detail::StatVFS m_svfs = {};979 detail::StatVFS m_svfs = {};
859 if (detail::statvfs(p.c_str(), &m_svfs) == -1) {980 if (detail::statvfs(p.c_str(), &m_svfs) == -1) {
860 err.report(capture_errno());981 err.report(detail::get_last_error());
861 si.capacity = si.free = si.available = static_cast<uintmax_t>(-1);982 si.capacity = si.free = si.available = static_cast<uintmax_t>(-1);
862 return si;983 return si;
863 }984 }
...@@ -884,7 +1005,7 @@ path __temp_directory_path(error_code* ec) {...@@ -884,7 +1005,7 @@ path __temp_directory_path(error_code* ec) {
884 wchar_t buf[MAX_PATH];1005 wchar_t buf[MAX_PATH];
885 DWORD retval = GetTempPathW(MAX_PATH, buf);1006 DWORD retval = GetTempPathW(MAX_PATH, buf);
886 if (!retval)1007 if (!retval)
887 return err.report(detail::make_windows_error(GetLastError()));1008 return err.report(detail::get_last_error());
888 if (retval > MAX_PATH)1009 if (retval > MAX_PATH)
889 return err.report(errc::filename_too_long);1010 return err.report(errc::filename_too_long);
890 // GetTempPathW returns a path with a trailing slash, which we1011 // GetTempPathW returns a path with a trailing slash, which we
lib/libcxx/src/filesystem/path.cpp+6-2
...@@ -24,7 +24,10 @@ using parser::string_view_t;...@@ -24,7 +24,10 @@ using parser::string_view_t;
24// path definitions24// path definitions
25///////////////////////////////////////////////////////////////////////////////25///////////////////////////////////////////////////////////////////////////////
2626
27_LIBCPP_DIAGNOSTIC_PUSH
28_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated")
27constexpr path::value_type path::preferred_separator;29constexpr path::value_type path::preferred_separator;
30_LIBCPP_DIAGNOSTIC_POP
2831
29path& path::replace_extension(path const& replacement) {32path& path::replace_extension(path const& replacement) {
30 path p = extension();33 path p = extension();
...@@ -267,7 +270,7 @@ path path::lexically_relative(const path& base) const {...@@ -267,7 +270,7 @@ path path::lexically_relative(const path& base) const {
267 // Find the first mismatching element270 // Find the first mismatching element
268 auto PP = PathParser::CreateBegin(__pn_);271 auto PP = PathParser::CreateBegin(__pn_);
269 auto PPBase = PathParser::CreateBegin(base.__pn_);272 auto PPBase = PathParser::CreateBegin(base.__pn_);
270 while (PP && PPBase && PP.State_ == PPBase.State_ && *PP == *PPBase) {273 while (PP && PPBase && PP.State_ == PPBase.State_ && (*PP == *PPBase || PP.inRootDir())) {
271 ++PP;274 ++PP;
272 ++PPBase;275 ++PPBase;
273 }276 }
...@@ -368,7 +371,8 @@ size_t hash_value(const path& __p) noexcept {...@@ -368,7 +371,8 @@ size_t hash_value(const path& __p) noexcept {
368 size_t hash_value = 0;371 size_t hash_value = 0;
369 hash<string_view_t> hasher;372 hash<string_view_t> hasher;
370 while (PP) {373 while (PP) {
371 hash_value = __hash_combine(hash_value, hasher(*PP));374 string_view_t Part = PP.inRootDir() ? PATHSTR("/") : *PP;
375 hash_value = __hash_combine(hash_value, hasher(Part));
372 ++PP;376 ++PP;
373 }377 }
374 return hash_value;378 return hash_value;
lib/libcxx/src/filesystem/posix_compat.h+34-41
...@@ -11,9 +11,10 @@...@@ -11,9 +11,10 @@
11//11//
12// These generally behave like the proper posix functions, with these12// These generally behave like the proper posix functions, with these
13// exceptions:13// exceptions:
14// On Windows, they take paths in wchar_t* form, instead of char* form.14// - On Windows, they take paths in wchar_t* form, instead of char* form.
15// The symlink() function is split into two frontends, symlink_file()15// - The symlink() function is split into two frontends, symlink_file()
16// and symlink_dir().16// and symlink_dir().
17// - Errors should be retrieved with get_last_error, not errno.
17//18//
18// These are provided within an anonymous namespace within the detail19// These are provided within an anonymous namespace within the detail
19// namespace - callers need to include this header and call them as20// namespace - callers need to include this header and call them as
...@@ -122,11 +123,6 @@ namespace detail {...@@ -122,11 +123,6 @@ namespace detail {
122123
123# define O_NONBLOCK 0124# define O_NONBLOCK 0
124125
125inline int set_errno(int e = GetLastError()) {
126 errno = static_cast<int>(__win_err_to_errc(e));
127 return -1;
128}
129
130class WinHandle {126class WinHandle {
131public:127public:
132 WinHandle(const wchar_t* p, DWORD access, DWORD flags) {128 WinHandle(const wchar_t* p, DWORD access, DWORD flags) {
...@@ -153,7 +149,7 @@ private:...@@ -153,7 +149,7 @@ private:
153inline int stat_handle(HANDLE h, StatT* buf) {149inline int stat_handle(HANDLE h, StatT* buf) {
154 FILE_BASIC_INFO basic;150 FILE_BASIC_INFO basic;
155 if (!GetFileInformationByHandleEx(h, FileBasicInfo, &basic, sizeof(basic)))151 if (!GetFileInformationByHandleEx(h, FileBasicInfo, &basic, sizeof(basic)))
156 return set_errno();152 return -1;
157 memset(buf, 0, sizeof(*buf));153 memset(buf, 0, sizeof(*buf));
158 buf->st_mtim = filetime_to_timespec(basic.LastWriteTime);154 buf->st_mtim = filetime_to_timespec(basic.LastWriteTime);
159 buf->st_atim = filetime_to_timespec(basic.LastAccessTime);155 buf->st_atim = filetime_to_timespec(basic.LastAccessTime);
...@@ -168,18 +164,18 @@ inline int stat_handle(HANDLE h, StatT* buf) {...@@ -168,18 +164,18 @@ inline int stat_handle(HANDLE h, StatT* buf) {
168 if (basic.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {164 if (basic.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
169 FILE_ATTRIBUTE_TAG_INFO tag;165 FILE_ATTRIBUTE_TAG_INFO tag;
170 if (!GetFileInformationByHandleEx(h, FileAttributeTagInfo, &tag, sizeof(tag)))166 if (!GetFileInformationByHandleEx(h, FileAttributeTagInfo, &tag, sizeof(tag)))
171 return set_errno();167 return -1;
172 if (tag.ReparseTag == IO_REPARSE_TAG_SYMLINK)168 if (tag.ReparseTag == IO_REPARSE_TAG_SYMLINK)
173 buf->st_mode = (buf->st_mode & ~_S_IFMT) | _S_IFLNK;169 buf->st_mode = (buf->st_mode & ~_S_IFMT) | _S_IFLNK;
174 }170 }
175 FILE_STANDARD_INFO standard;171 FILE_STANDARD_INFO standard;
176 if (!GetFileInformationByHandleEx(h, FileStandardInfo, &standard, sizeof(standard)))172 if (!GetFileInformationByHandleEx(h, FileStandardInfo, &standard, sizeof(standard)))
177 return set_errno();173 return -1;
178 buf->st_nlink = standard.NumberOfLinks;174 buf->st_nlink = standard.NumberOfLinks;
179 buf->st_size = standard.EndOfFile.QuadPart;175 buf->st_size = standard.EndOfFile.QuadPart;
180 BY_HANDLE_FILE_INFORMATION info;176 BY_HANDLE_FILE_INFORMATION info;
181 if (!GetFileInformationByHandle(h, &info))177 if (!GetFileInformationByHandle(h, &info))
182 return set_errno();178 return -1;
183 buf->st_dev = info.dwVolumeSerialNumber;179 buf->st_dev = info.dwVolumeSerialNumber;
184 memcpy(&buf->st_ino.id[0], &info.nFileIndexHigh, 4);180 memcpy(&buf->st_ino.id[0], &info.nFileIndexHigh, 4);
185 memcpy(&buf->st_ino.id[4], &info.nFileIndexLow, 4);181 memcpy(&buf->st_ino.id[4], &info.nFileIndexLow, 4);
...@@ -189,7 +185,7 @@ inline int stat_handle(HANDLE h, StatT* buf) {...@@ -189,7 +185,7 @@ inline int stat_handle(HANDLE h, StatT* buf) {
189inline int stat_file(const wchar_t* path, StatT* buf, DWORD flags) {185inline int stat_file(const wchar_t* path, StatT* buf, DWORD flags) {
190 WinHandle h(path, FILE_READ_ATTRIBUTES, flags);186 WinHandle h(path, FILE_READ_ATTRIBUTES, flags);
191 if (!h)187 if (!h)
192 return set_errno();188 return -1;
193 int ret = stat_handle(h, buf);189 int ret = stat_handle(h, buf);
194 return ret;190 return ret;
195}191}
...@@ -206,7 +202,7 @@ inline int fstat(int fd, StatT* buf) {...@@ -206,7 +202,7 @@ inline int fstat(int fd, StatT* buf) {
206inline int mkdir(const wchar_t* path, int permissions) {202inline int mkdir(const wchar_t* path, int permissions) {
207 (void)permissions;203 (void)permissions;
208 if (!CreateDirectoryW(path, nullptr))204 if (!CreateDirectoryW(path, nullptr))
209 return set_errno();205 return -1;
210 return 0;206 return 0;
211}207}
212208
...@@ -219,10 +215,10 @@ inline int symlink_file_dir(const wchar_t* oldname, const wchar_t* newname, bool...@@ -219,10 +215,10 @@ inline int symlink_file_dir(const wchar_t* oldname, const wchar_t* newname, bool
219 return 0;215 return 0;
220 int e = GetLastError();216 int e = GetLastError();
221 if (e != ERROR_INVALID_PARAMETER)217 if (e != ERROR_INVALID_PARAMETER)
222 return set_errno(e);218 return -1;
223 if (CreateSymbolicLinkW(newname, oldname, flags))219 if (CreateSymbolicLinkW(newname, oldname, flags))
224 return 0;220 return 0;
225 return set_errno();221 return -1;
226}222}
227223
228inline int symlink_file(const wchar_t* oldname, const wchar_t* newname) {224inline int symlink_file(const wchar_t* oldname, const wchar_t* newname) {
...@@ -236,17 +232,17 @@ inline int symlink_dir(const wchar_t* oldname, const wchar_t* newname) {...@@ -236,17 +232,17 @@ inline int symlink_dir(const wchar_t* oldname, const wchar_t* newname) {
236inline int link(const wchar_t* oldname, const wchar_t* newname) {232inline int link(const wchar_t* oldname, const wchar_t* newname) {
237 if (CreateHardLinkW(newname, oldname, nullptr))233 if (CreateHardLinkW(newname, oldname, nullptr))
238 return 0;234 return 0;
239 return set_errno();235 return -1;
240}236}
241237
242inline int remove(const wchar_t* path) {238inline int remove(const wchar_t* path) {
243 detail::WinHandle h(path, DELETE, FILE_FLAG_OPEN_REPARSE_POINT);239 detail::WinHandle h(path, DELETE, FILE_FLAG_OPEN_REPARSE_POINT);
244 if (!h)240 if (!h)
245 return set_errno();241 return -1;
246 FILE_DISPOSITION_INFO info;242 FILE_DISPOSITION_INFO info;
247 info.DeleteFile = TRUE;243 info.DeleteFile = TRUE;
248 if (!SetFileInformationByHandle(h, FileDispositionInfo, &info, sizeof(info)))244 if (!SetFileInformationByHandle(h, FileDispositionInfo, &info, sizeof(info)))
249 return set_errno();245 return -1;
250 return 0;246 return 0;
251}247}
252248
...@@ -254,9 +250,9 @@ inline int truncate_handle(HANDLE h, off_t length) {...@@ -254,9 +250,9 @@ inline int truncate_handle(HANDLE h, off_t length) {
254 LARGE_INTEGER size_param;250 LARGE_INTEGER size_param;
255 size_param.QuadPart = length;251 size_param.QuadPart = length;
256 if (!SetFilePointerEx(h, size_param, 0, FILE_BEGIN))252 if (!SetFilePointerEx(h, size_param, 0, FILE_BEGIN))
257 return set_errno();253 return -1;
258 if (!SetEndOfFile(h))254 if (!SetEndOfFile(h))
259 return set_errno();255 return -1;
260 return 0;256 return 0;
261}257}
262258
...@@ -268,19 +264,19 @@ inline int ftruncate(int fd, off_t length) {...@@ -268,19 +264,19 @@ inline int ftruncate(int fd, off_t length) {
268inline int truncate(const wchar_t* path, off_t length) {264inline int truncate(const wchar_t* path, off_t length) {
269 detail::WinHandle h(path, GENERIC_WRITE, 0);265 detail::WinHandle h(path, GENERIC_WRITE, 0);
270 if (!h)266 if (!h)
271 return set_errno();267 return -1;
272 return truncate_handle(h, length);268 return truncate_handle(h, length);
273}269}
274270
275inline int rename(const wchar_t* from, const wchar_t* to) {271inline int rename(const wchar_t* from, const wchar_t* to) {
276 if (!(MoveFileExW(from, to, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH)))272 if (!(MoveFileExW(from, to, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH)))
277 return set_errno();273 return -1;
278 return 0;274 return 0;
279}275}
280276
281inline int chdir(const wchar_t* path) {277inline int chdir(const wchar_t* path) {
282 if (!SetCurrentDirectoryW(path))278 if (!SetCurrentDirectoryW(path))
283 return set_errno();279 return -1;
284 return 0;280 return 0;
285}281}
286282
...@@ -300,7 +296,7 @@ inline int statvfs(const wchar_t* p, StatVFS* buf) {...@@ -300,7 +296,7 @@ inline int statvfs(const wchar_t* p, StatVFS* buf) {
300 break;296 break;
301 path parent = dir.parent_path();297 path parent = dir.parent_path();
302 if (parent == dir) {298 if (parent == dir) {
303 errno = ENOENT;299 SetLastError(ERROR_PATH_NOT_FOUND);
304 return -1;300 return -1;
305 }301 }
306 dir = parent;302 dir = parent;
...@@ -308,7 +304,7 @@ inline int statvfs(const wchar_t* p, StatVFS* buf) {...@@ -308,7 +304,7 @@ inline int statvfs(const wchar_t* p, StatVFS* buf) {
308 ULARGE_INTEGER free_bytes_available_to_caller, total_number_of_bytes, total_number_of_free_bytes;304 ULARGE_INTEGER free_bytes_available_to_caller, total_number_of_bytes, total_number_of_free_bytes;
309 if (!GetDiskFreeSpaceExW(305 if (!GetDiskFreeSpaceExW(
310 dir.c_str(), &free_bytes_available_to_caller, &total_number_of_bytes, &total_number_of_free_bytes))306 dir.c_str(), &free_bytes_available_to_caller, &total_number_of_bytes, &total_number_of_free_bytes))
311 return set_errno();307 return -1;
312 buf->f_frsize = 1;308 buf->f_frsize = 1;
313 buf->f_blocks = total_number_of_bytes.QuadPart;309 buf->f_blocks = total_number_of_bytes.QuadPart;
314 buf->f_bfree = total_number_of_free_bytes.QuadPart;310 buf->f_bfree = total_number_of_free_bytes.QuadPart;
...@@ -330,7 +326,6 @@ inline wchar_t* getcwd([[maybe_unused]] wchar_t* in_buf, [[maybe_unused]] size_t...@@ -330,7 +326,6 @@ inline wchar_t* getcwd([[maybe_unused]] wchar_t* in_buf, [[maybe_unused]] size_t
330 retval = GetCurrentDirectoryW(buff_size, buff.get());326 retval = GetCurrentDirectoryW(buff_size, buff.get());
331 }327 }
332 if (!retval) {328 if (!retval) {
333 set_errno();
334 return nullptr;329 return nullptr;
335 }330 }
336 return buff.release();331 return buff.release();
...@@ -342,7 +337,6 @@ inline wchar_t* realpath(const wchar_t* path, [[maybe_unused]] wchar_t* resolved...@@ -342,7 +337,6 @@ inline wchar_t* realpath(const wchar_t* path, [[maybe_unused]] wchar_t* resolved
342337
343 WinHandle h(path, FILE_READ_ATTRIBUTES, 0);338 WinHandle h(path, FILE_READ_ATTRIBUTES, 0);
344 if (!h) {339 if (!h) {
345 set_errno();
346 return nullptr;340 return nullptr;
347 }341 }
348 size_t buff_size = MAX_PATH + 10;342 size_t buff_size = MAX_PATH + 10;
...@@ -354,7 +348,6 @@ inline wchar_t* realpath(const wchar_t* path, [[maybe_unused]] wchar_t* resolved...@@ -354,7 +348,6 @@ inline wchar_t* realpath(const wchar_t* path, [[maybe_unused]] wchar_t* resolved
354 retval = GetFinalPathNameByHandleW(h, buff.get(), buff_size, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);348 retval = GetFinalPathNameByHandleW(h, buff.get(), buff_size, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
355 }349 }
356 if (!retval) {350 if (!retval) {
357 set_errno();
358 return nullptr;351 return nullptr;
359 }352 }
360 wchar_t* ptr = buff.get();353 wchar_t* ptr = buff.get();
...@@ -376,20 +369,20 @@ using ModeT = int;...@@ -376,20 +369,20 @@ using ModeT = int;
376inline int fchmod_handle(HANDLE h, int perms) {369inline int fchmod_handle(HANDLE h, int perms) {
377 FILE_BASIC_INFO basic;370 FILE_BASIC_INFO basic;
378 if (!GetFileInformationByHandleEx(h, FileBasicInfo, &basic, sizeof(basic)))371 if (!GetFileInformationByHandleEx(h, FileBasicInfo, &basic, sizeof(basic)))
379 return set_errno();372 return -1;
380 DWORD orig_attributes = basic.FileAttributes;373 DWORD orig_attributes = basic.FileAttributes;
381 basic.FileAttributes &= ~FILE_ATTRIBUTE_READONLY;374 basic.FileAttributes &= ~FILE_ATTRIBUTE_READONLY;
382 if ((perms & 0222) == 0)375 if ((perms & 0222) == 0)
383 basic.FileAttributes |= FILE_ATTRIBUTE_READONLY;376 basic.FileAttributes |= FILE_ATTRIBUTE_READONLY;
384 if (basic.FileAttributes != orig_attributes && !SetFileInformationByHandle(h, FileBasicInfo, &basic, sizeof(basic)))377 if (basic.FileAttributes != orig_attributes && !SetFileInformationByHandle(h, FileBasicInfo, &basic, sizeof(basic)))
385 return set_errno();378 return -1;
386 return 0;379 return 0;
387}380}
388381
389inline int fchmodat(int /*fd*/, const wchar_t* path, int perms, int flag) {382inline int fchmodat(int /*fd*/, const wchar_t* path, int perms, int flag) {
390 DWORD attributes = GetFileAttributesW(path);383 DWORD attributes = GetFileAttributesW(path);
391 if (attributes == INVALID_FILE_ATTRIBUTES)384 if (attributes == INVALID_FILE_ATTRIBUTES)
392 return set_errno();385 return -1;
393 if (attributes & FILE_ATTRIBUTE_REPARSE_POINT && !(flag & AT_SYMLINK_NOFOLLOW)) {386 if (attributes & FILE_ATTRIBUTE_REPARSE_POINT && !(flag & AT_SYMLINK_NOFOLLOW)) {
394 // If the file is a symlink, and we are supposed to operate on the target387 // If the file is a symlink, and we are supposed to operate on the target
395 // of the symlink, we need to open a handle to it, without the388 // of the symlink, we need to open a handle to it, without the
...@@ -397,7 +390,7 @@ inline int fchmodat(int /*fd*/, const wchar_t* path, int perms, int flag) {...@@ -397,7 +390,7 @@ inline int fchmodat(int /*fd*/, const wchar_t* path, int perms, int flag) {
397 // symlink, and operate on it via the handle.390 // symlink, and operate on it via the handle.
398 detail::WinHandle h(path, FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES, 0);391 detail::WinHandle h(path, FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES, 0);
399 if (!h)392 if (!h)
400 return set_errno();393 return -1;
401 return fchmod_handle(h, perms);394 return fchmod_handle(h, perms);
402 } else {395 } else {
403 // For a non-symlink, or if operating on the symlink itself instead of396 // For a non-symlink, or if operating on the symlink itself instead of
...@@ -407,7 +400,7 @@ inline int fchmodat(int /*fd*/, const wchar_t* path, int perms, int flag) {...@@ -407,7 +400,7 @@ inline int fchmodat(int /*fd*/, const wchar_t* path, int perms, int flag) {
407 if ((perms & 0222) == 0)400 if ((perms & 0222) == 0)
408 attributes |= FILE_ATTRIBUTE_READONLY;401 attributes |= FILE_ATTRIBUTE_READONLY;
409 if (attributes != orig_attributes && !SetFileAttributesW(path, attributes))402 if (attributes != orig_attributes && !SetFileAttributesW(path, attributes))
410 return set_errno();403 return -1;
411 }404 }
412 return 0;405 return 0;
413}406}
...@@ -424,18 +417,18 @@ inline SSizeT readlink(const wchar_t* path, wchar_t* ret_buf, size_t bufsize) {...@@ -424,18 +417,18 @@ inline SSizeT readlink(const wchar_t* path, wchar_t* ret_buf, size_t bufsize) {
424 uint8_t buf[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];417 uint8_t buf[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
425 detail::WinHandle h(path, FILE_READ_ATTRIBUTES, FILE_FLAG_OPEN_REPARSE_POINT);418 detail::WinHandle h(path, FILE_READ_ATTRIBUTES, FILE_FLAG_OPEN_REPARSE_POINT);
426 if (!h)419 if (!h)
427 return set_errno();420 return -1;
428 DWORD out;421 DWORD out;
429 if (!DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, nullptr, 0, buf, sizeof(buf), &out, 0))422 if (!DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, nullptr, 0, buf, sizeof(buf), &out, 0))
430 return set_errno();423 return -1;
431 const auto* reparse = reinterpret_cast<LIBCPP_REPARSE_DATA_BUFFER*>(buf);424 const auto* reparse = reinterpret_cast<LIBCPP_REPARSE_DATA_BUFFER*>(buf);
432 size_t path_buf_offset = offsetof(LIBCPP_REPARSE_DATA_BUFFER, SymbolicLinkReparseBuffer.PathBuffer[0]);425 size_t path_buf_offset = offsetof(LIBCPP_REPARSE_DATA_BUFFER, SymbolicLinkReparseBuffer.PathBuffer[0]);
433 if (out < path_buf_offset) {426 if (out < path_buf_offset) {
434 errno = EINVAL;427 SetLastError(ERROR_REPARSE_TAG_INVALID);
435 return -1;428 return -1;
436 }429 }
437 if (reparse->ReparseTag != IO_REPARSE_TAG_SYMLINK) {430 if (reparse->ReparseTag != IO_REPARSE_TAG_SYMLINK) {
438 errno = EINVAL;431 SetLastError(ERROR_REPARSE_TAG_INVALID);
439 return -1;432 return -1;
440 }433 }
441 const auto& symlink = reparse->SymbolicLinkReparseBuffer;434 const auto& symlink = reparse->SymbolicLinkReparseBuffer;
...@@ -449,11 +442,11 @@ inline SSizeT readlink(const wchar_t* path, wchar_t* ret_buf, size_t bufsize) {...@@ -449,11 +442,11 @@ inline SSizeT readlink(const wchar_t* path, wchar_t* ret_buf, size_t bufsize) {
449 }442 }
450 // name_offset/length are expressed in bytes, not in wchar_t443 // name_offset/length are expressed in bytes, not in wchar_t
451 if (path_buf_offset + name_offset + name_length > out) {444 if (path_buf_offset + name_offset + name_length > out) {
452 errno = EINVAL;445 SetLastError(ERROR_REPARSE_TAG_INVALID);
453 return -1;446 return -1;
454 }447 }
455 if (name_length / sizeof(wchar_t) > bufsize) {448 if (name_length / sizeof(wchar_t) > bufsize) {
456 errno = ENOMEM;449 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
457 return -1;450 return -1;
458 }451 }
459 memcpy(ret_buf, &symlink.PathBuffer[name_offset / sizeof(wchar_t)], name_length);452 memcpy(ret_buf, &symlink.PathBuffer[name_offset / sizeof(wchar_t)], name_length);
...@@ -490,7 +483,7 @@ using SSizeT = ::ssize_t;...@@ -490,7 +483,7 @@ using SSizeT = ::ssize_t;
490483
491#endif484#endif
492485
493} // end namespace detail486} // namespace detail
494487
495_LIBCPP_END_NAMESPACE_FILESYSTEM488_LIBCPP_END_NAMESPACE_FILESYSTEM
496489
lib/libcxx/src/filesystem/time_utils.h+3-3
...@@ -299,7 +299,7 @@ inline TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; }...@@ -299,7 +299,7 @@ inline TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; }
299inline TimeSpec extract_atime(StatT const& st) { return st.st_atim; }299inline TimeSpec extract_atime(StatT const& st) { return st.st_atim; }
300#endif300#endif
301301
302#ifndef _LIBCPP_HAS_NO_FILESYSTEM302#if _LIBCPP_HAS_FILESYSTEM
303303
304# if !defined(_LIBCPP_WIN32API)304# if !defined(_LIBCPP_WIN32API)
305inline bool posix_utimes(const path& p, std::array<TimeSpec, 2> const& TS, error_code& ec) {305inline bool posix_utimes(const path& p, std::array<TimeSpec, 2> const& TS, error_code& ec) {
...@@ -342,9 +342,9 @@ inline file_time_type __extract_last_write_time(const path& p, const StatT& st,...@@ -342,9 +342,9 @@ inline file_time_type __extract_last_write_time(const path& p, const StatT& st,
342 return fs_time::convert_from_timespec(ts);342 return fs_time::convert_from_timespec(ts);
343}343}
344344
345#endif // !_LIBCPP_HAS_NO_FILESYSTEM345#endif // _LIBCPP_HAS_FILESYSTEM
346346
347} // end namespace detail347} // namespace detail
348348
349_LIBCPP_END_NAMESPACE_FILESYSTEM349_LIBCPP_END_NAMESPACE_FILESYSTEM
350350
lib/libcxx/src/future.cpp+2-2
...@@ -142,10 +142,10 @@ promise<void>::promise() : __state_(new __assoc_sub_state) {}...@@ -142,10 +142,10 @@ promise<void>::promise() : __state_(new __assoc_sub_state) {}
142142
143promise<void>::~promise() {143promise<void>::~promise() {
144 if (__state_) {144 if (__state_) {
145#ifndef _LIBCPP_HAS_NO_EXCEPTIONS145#if _LIBCPP_HAS_EXCEPTIONS
146 if (!__state_->__has_value() && __state_->use_count() > 1)146 if (!__state_->__has_value() && __state_->use_count() > 1)
147 __state_->set_exception(make_exception_ptr(future_error(future_errc::broken_promise)));147 __state_->set_exception(make_exception_ptr(future_error(future_errc::broken_promise)));
148#endif // _LIBCPP_HAS_NO_EXCEPTIONS148#endif // _LIBCPP_HAS_EXCEPTIONS
149 __state_->__release_shared();149 __state_->__release_shared();
150 }150 }
151}151}
lib/libcxx/src/include/atomic_support.h+5-5
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21# define _LIBCPP_HAS_ATOMIC_BUILTINS21# define _LIBCPP_HAS_ATOMIC_BUILTINS
22#endif22#endif
2323
24#if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)24#if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && _LIBCPP_HAS_THREADS
25# if defined(_LIBCPP_WARNING)25# if defined(_LIBCPP_WARNING)
26_LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported")26_LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported")
27# else27# else
...@@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3333
34namespace {34namespace {
3535
36#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)36#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && _LIBCPP_HAS_THREADS
3737
38enum __libcpp_atomic_order {38enum __libcpp_atomic_order {
39 _AO_Relaxed = __ATOMIC_RELAXED,39 _AO_Relaxed = __ATOMIC_RELAXED,
...@@ -80,7 +80,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_atomic_compare_exchange(...@@ -80,7 +80,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_atomic_compare_exchange(
80 return __atomic_compare_exchange_n(__val, __expected, __after, true, __success_order, __fail_order);80 return __atomic_compare_exchange_n(__val, __expected, __after, true, __success_order, __fail_order);
81}81}
8282
83#else // _LIBCPP_HAS_NO_THREADS83#else // _LIBCPP_HAS_THREADS
8484
85enum __libcpp_atomic_order { _AO_Relaxed, _AO_Consume, _AO_Acquire, _AO_Release, _AO_Acq_Rel, _AO_Seq };85enum __libcpp_atomic_order { _AO_Relaxed, _AO_Consume, _AO_Acquire, _AO_Release, _AO_Acq_Rel, _AO_Seq };
8686
...@@ -123,9 +123,9 @@ __libcpp_atomic_compare_exchange(_ValueType* __val, _ValueType* __expected, _Val...@@ -123,9 +123,9 @@ __libcpp_atomic_compare_exchange(_ValueType* __val, _ValueType* __expected, _Val
123 return false;123 return false;
124}124}
125125
126#endif // _LIBCPP_HAS_NO_THREADS126#endif // _LIBCPP_HAS_THREADS
127127
128} // end namespace128} // namespace
129129
130_LIBCPP_END_NAMESPACE_STD130_LIBCPP_END_NAMESPACE_STD
131131
lib/libcxx/src/include/config_elast.h+3-1
...@@ -21,6 +21,8 @@...@@ -21,6 +21,8 @@
21// where strerror/strerror_r can't handle out-of-range errno values.21// where strerror/strerror_r can't handle out-of-range errno values.
22#if defined(ELAST)22#if defined(ELAST)
23# define _LIBCPP_ELAST ELAST23# define _LIBCPP_ELAST ELAST
24#elif defined(__LLVM_LIBC__)
25// No _LIBCPP_ELAST needed for LLVM libc
24#elif defined(_NEWLIB_VERSION)26#elif defined(_NEWLIB_VERSION)
25# define _LIBCPP_ELAST __ELASTERROR27# define _LIBCPP_ELAST __ELASTERROR
26#elif defined(__NuttX__)28#elif defined(__NuttX__)
...@@ -31,7 +33,7 @@...@@ -31,7 +33,7 @@
31// No _LIBCPP_ELAST needed on WASI33// No _LIBCPP_ELAST needed on WASI
32#elif defined(__EMSCRIPTEN__)34#elif defined(__EMSCRIPTEN__)
33// No _LIBCPP_ELAST needed on Emscripten35// No _LIBCPP_ELAST needed on Emscripten
34#elif defined(__linux__) || defined(_LIBCPP_HAS_MUSL_LIBC)36#elif defined(__linux__) || _LIBCPP_HAS_MUSL_LIBC
35# define _LIBCPP_ELAST 409537# define _LIBCPP_ELAST 4095
36#elif defined(__APPLE__)38#elif defined(__APPLE__)
37// No _LIBCPP_ELAST needed on Apple39// No _LIBCPP_ELAST needed on Apple
lib/libcxx/src/include/from_chars_floating_point.h created+457
...@@ -0,0 +1,457 @@
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_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H
10#define _LIBCPP_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H
11
12// These headers are in the shared LLVM-libc header library.
13#include "shared/fp_bits.h"
14#include "shared/str_to_float.h"
15#include "shared/str_to_integer.h"
16
17#include <__assert>
18#include <__config>
19#include <cctype>
20#include <charconv>
21#include <concepts>
22#include <limits>
23
24// Included for the _Floating_type_traits class
25#include "to_chars_floating_point.h"
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29// Parses an infinity string.
30// Valid strings are case insensitive and contain INF or INFINITY.
31//
32// - __first is the first argument to std::from_chars. When the string is invalid
33// this value is returned as ptr in the result.
34// - __last is the last argument of std::from_chars.
35// - __value is the value argument of std::from_chars,
36// - __ptr is the current position is the input string. This is points beyond
37// the initial I character.
38// - __negative whether a valid string represents -inf or +inf.
39template <floating_point _Fp>
40__from_chars_result<_Fp>
41__from_chars_floating_point_inf(const char* const __first, const char* __last, const char* __ptr, bool __negative) {
42 if (__last - __ptr < 2) [[unlikely]]
43 return {_Fp{0}, 0, errc::invalid_argument};
44
45 if (std::tolower(__ptr[0]) != 'n' || std::tolower(__ptr[1]) != 'f') [[unlikely]]
46 return {_Fp{0}, 0, errc::invalid_argument};
47
48 __ptr += 2;
49
50 // At this point the result is valid and contains INF.
51 // When the remaining part contains INITY this will be consumed. Otherwise
52 // only INF is consumed. For example INFINITZ will consume INF and ignore
53 // INITZ.
54
55 if (__last - __ptr >= 5 //
56 && std::tolower(__ptr[0]) == 'i' //
57 && std::tolower(__ptr[1]) == 'n' //
58 && std::tolower(__ptr[2]) == 'i' //
59 && std::tolower(__ptr[3]) == 't' //
60 && std::tolower(__ptr[4]) == 'y')
61 __ptr += 5;
62
63 if constexpr (numeric_limits<_Fp>::has_infinity) {
64 if (__negative)
65 return {-std::numeric_limits<_Fp>::infinity(), __ptr - __first, std::errc{}};
66
67 return {std::numeric_limits<_Fp>::infinity(), __ptr - __first, std::errc{}};
68 } else {
69 return {_Fp{0}, __ptr - __first, errc::result_out_of_range};
70 }
71}
72
73// Parses a nan string.
74// Valid strings are case insensitive and contain INF or INFINITY.
75//
76// - __first is the first argument to std::from_chars. When the string is invalid
77// this value is returned as ptr in the result.
78// - __last is the last argument of std::from_chars.
79// - __value is the value argument of std::from_chars,
80// - __ptr is the current position is the input string. This is points beyond
81// the initial N character.
82// - __negative whether a valid string represents -nan or +nan.
83template <floating_point _Fp>
84__from_chars_result<_Fp>
85__from_chars_floating_point_nan(const char* const __first, const char* __last, const char* __ptr, bool __negative) {
86 if (__last - __ptr < 2) [[unlikely]]
87 return {_Fp{0}, 0, errc::invalid_argument};
88
89 if (std::tolower(__ptr[0]) != 'a' || std::tolower(__ptr[1]) != 'n') [[unlikely]]
90 return {_Fp{0}, 0, errc::invalid_argument};
91
92 __ptr += 2;
93
94 // At this point the result is valid and contains NAN. When the remaining
95 // part contains ( n-char-sequence_opt ) this will be consumed. Otherwise
96 // only NAN is consumed. For example NAN(abcd will consume NAN and ignore
97 // (abcd.
98 if (__last - __ptr >= 2 && __ptr[0] == '(') {
99 size_t __offset = 1;
100 do {
101 if (__ptr[__offset] == ')') {
102 __ptr += __offset + 1;
103 break;
104 }
105 if (__ptr[__offset] != '_' && !std::isalnum(__ptr[__offset]))
106 break;
107 ++__offset;
108 } while (__ptr + __offset != __last);
109 }
110
111 if (__negative)
112 return {-std::numeric_limits<_Fp>::quiet_NaN(), __ptr - __first, std::errc{}};
113
114 return {std::numeric_limits<_Fp>::quiet_NaN(), __ptr - __first, std::errc{}};
115}
116
117template <class _Tp>
118struct __fractional_constant_result {
119 size_t __offset{size_t(-1)};
120 _Tp __mantissa{0};
121 int __exponent{0};
122 bool __truncated{false};
123 bool __is_valid{false};
124};
125
126// Parses the hex constant part of the hexadecimal floating-point value.
127// - input start of buffer given to from_chars
128// - __n the number of elements in the buffer
129// - __offset where to start parsing. The input can have an optional sign, the
130// offset starts after this sign.
131template <class _Tp>
132__fractional_constant_result<_Tp> __parse_fractional_hex_constant(const char* __input, size_t __n, size_t __offset) {
133 __fractional_constant_result<_Tp> __result;
134
135 const _Tp __mantissa_truncate_threshold = numeric_limits<_Tp>::max() / 16;
136 bool __fraction = false;
137 for (; __offset < __n; ++__offset) {
138 if (std::isxdigit(__input[__offset])) {
139 __result.__is_valid = true;
140
141 uint32_t __digit = __input[__offset] - '0';
142 switch (std::tolower(__input[__offset])) {
143 case 'a':
144 __digit = 10;
145 break;
146 case 'b':
147 __digit = 11;
148 break;
149 case 'c':
150 __digit = 12;
151 break;
152 case 'd':
153 __digit = 13;
154 break;
155 case 'e':
156 __digit = 14;
157 break;
158 case 'f':
159 __digit = 15;
160 break;
161 }
162
163 if (__result.__mantissa < __mantissa_truncate_threshold) {
164 __result.__mantissa = (__result.__mantissa * 16) + __digit;
165 if (__fraction)
166 __result.__exponent -= 4;
167 } else {
168 if (__digit > 0)
169 __result.__truncated = true;
170 if (!__fraction)
171 __result.__exponent += 4;
172 }
173 } else if (__input[__offset] == '.') {
174 if (__fraction)
175 break; // this means that __input[__offset] points to a second decimal point, ending the number.
176
177 __fraction = true;
178 } else
179 break;
180 }
181
182 __result.__offset = __offset;
183 return __result;
184}
185
186struct __exponent_result {
187 size_t __offset{size_t(-1)};
188 int __value{0};
189 bool __present{false};
190};
191
192// When the exponent is not present the result of the struct contains
193// __offset, 0, false. This allows using the results unconditionally, the
194// __present is important for the scientific notation, where the value is
195// mandatory.
196__exponent_result __parse_exponent(const char* __input, size_t __n, size_t __offset, char __marker) {
197 if (__offset + 1 < __n && // an exponent always needs at least one digit.
198 std::tolower(__input[__offset]) == __marker && //
199 !std::isspace(__input[__offset + 1]) // leading whitespace is not allowed.
200 ) {
201 ++__offset;
202 LIBC_NAMESPACE::shared::StrToNumResult<int32_t> __e =
203 LIBC_NAMESPACE::shared::strtointeger<int32_t>(__input + __offset, 10, __n - __offset);
204 // __result.error contains the errno value, 0 or ERANGE these are not interesting.
205 // If the number of characters parsed is 0 it means there was no number.
206 if (__e.parsed_len != 0)
207 return {__offset + __e.parsed_len, __e.value, true};
208 else
209 --__offset; // the assumption of a valid exponent was not true, undo eating the exponent character.
210 }
211
212 return {__offset, 0, false};
213}
214
215// Here we do this operation as int64 to avoid overflow.
216int32_t __merge_exponents(int64_t __fractional, int64_t __exponent, int __max_biased_exponent) {
217 int64_t __sum = __fractional + __exponent;
218
219 if (__sum > __max_biased_exponent)
220 return __max_biased_exponent;
221
222 if (__sum < -__max_biased_exponent)
223 return -__max_biased_exponent;
224
225 return __sum;
226}
227
228template <class _Fp, class _Tp>
229__from_chars_result<_Fp>
230__calculate_result(_Tp __mantissa, int __exponent, bool __negative, __from_chars_result<_Fp> __result) {
231 auto __r = LIBC_NAMESPACE::shared::FPBits<_Fp>();
232 __r.set_mantissa(__mantissa);
233 __r.set_biased_exponent(__exponent);
234
235 // C17 7.12.1/6
236 // The result underflows if the magnitude of the mathematical result is so
237 // small that the mathematical result cannot be represented, without
238 // extraordinary roundoff error, in an object of the specified type.237) If
239 // the result underflows, the function returns an implementation-defined
240 // value whose magnitude is no greater than the smallest normalized positive
241 // number in the specified type; if the integer expression math_errhandling
242 // & MATH_ERRNO is nonzero, whether errno acquires the value ERANGE is
243 // implementation-defined; if the integer expression math_errhandling &
244 // MATH_ERREXCEPT is nonzero, whether the "underflow" floating-point
245 // exception is raised is implementation-defined.
246 //
247 // LLVM-LIBC sets ERAGNE for subnormal values
248 //
249 // [charconv.from.chars]/1
250 // ... If the parsed value is not in the range representable by the type of
251 // value, value is unmodified and the member ec of the return value is
252 // equal to errc::result_out_of_range. ...
253 //
254 // Undo the ERANGE for subnormal values.
255 if (__result.__ec == errc::result_out_of_range && __r.is_subnormal() && !__r.is_zero())
256 __result.__ec = errc{};
257
258 if (__negative)
259 __result.__value = -__r.get_val();
260 else
261 __result.__value = __r.get_val();
262
263 return __result;
264}
265
266// Implements from_chars for decimal floating-point values.
267// __first forwarded from from_chars
268// __last forwarded from from_chars
269// __value forwarded from from_chars
270// __fmt forwarded from from_chars
271// __ptr the start of the buffer to parse. This is after the optional sign character.
272// __negative should __value be set to a negative value?
273//
274// This function and __from_chars_floating_point_decimal are similar. However
275// the similar parts are all in helper functions. So the amount of code
276// duplication is minimal.
277template <floating_point _Fp>
278__from_chars_result<_Fp>
279__from_chars_floating_point_hex(const char* const __first, const char* __last, const char* __ptr, bool __negative) {
280 size_t __n = __last - __first;
281 ptrdiff_t __offset = __ptr - __first;
282
283 auto __fractional =
284 std::__parse_fractional_hex_constant<typename _Floating_type_traits<_Fp>::_Uint_type>(__first, __n, __offset);
285 if (!__fractional.__is_valid)
286 return {_Fp{0}, 0, errc::invalid_argument};
287
288 auto __parsed_exponent = std::__parse_exponent(__first, __n, __fractional.__offset, 'p');
289 __offset = __parsed_exponent.__offset;
290 int __exponent = std::__merge_exponents(
291 __fractional.__exponent, __parsed_exponent.__value, LIBC_NAMESPACE::shared::FPBits<_Fp>::MAX_BIASED_EXPONENT);
292
293 __from_chars_result<_Fp> __result{_Fp{0}, __offset, {}};
294 LIBC_NAMESPACE::shared::ExpandedFloat<_Fp> __expanded_float = {0, 0};
295 if (__fractional.__mantissa != 0) {
296 auto __temp = LIBC_NAMESPACE::shared::binary_exp_to_float<_Fp>(
297 {__fractional.__mantissa, __exponent},
298 __fractional.__truncated,
299 LIBC_NAMESPACE::shared::RoundDirection::Nearest);
300 __expanded_float = __temp.num;
301 if (__temp.error == ERANGE) {
302 __result.__ec = errc::result_out_of_range;
303 }
304 }
305
306 return std::__calculate_result<_Fp>(__expanded_float.mantissa, __expanded_float.exponent, __negative, __result);
307}
308
309// Parses the hex constant part of the decimal float value.
310// - input start of buffer given to from_chars
311// - __n the number of elements in the buffer
312// - __offset where to start parsing. The input can have an optional sign, the
313// offset starts after this sign.
314template <class _Tp>
315__fractional_constant_result<_Tp>
316__parse_fractional_decimal_constant(const char* __input, ptrdiff_t __n, ptrdiff_t __offset) {
317 __fractional_constant_result<_Tp> __result;
318
319 const _Tp __mantissa_truncate_threshold = numeric_limits<_Tp>::max() / 10;
320 bool __fraction = false;
321 for (; __offset < __n; ++__offset) {
322 if (std::isdigit(__input[__offset])) {
323 __result.__is_valid = true;
324
325 uint32_t __digit = __input[__offset] - '0';
326 if (__result.__mantissa < __mantissa_truncate_threshold) {
327 __result.__mantissa = (__result.__mantissa * 10) + __digit;
328 if (__fraction)
329 --__result.__exponent;
330 } else {
331 if (__digit > 0)
332 __result.__truncated = true;
333 if (!__fraction)
334 ++__result.__exponent;
335 }
336 } else if (__input[__offset] == '.') {
337 if (__fraction)
338 break; // this means that __input[__offset] points to a second decimal point, ending the number.
339
340 __fraction = true;
341 } else
342 break;
343 }
344
345 __result.__offset = __offset;
346 return __result;
347}
348
349// Implements from_chars for decimal floating-point values.
350// __first forwarded from from_chars
351// __last forwarded from from_chars
352// __value forwarded from from_chars
353// __fmt forwarded from from_chars
354// __ptr the start of the buffer to parse. This is after the optional sign character.
355// __negative should __value be set to a negative value?
356template <floating_point _Fp>
357__from_chars_result<_Fp> __from_chars_floating_point_decimal(
358 const char* const __first, const char* __last, chars_format __fmt, const char* __ptr, bool __negative) {
359 ptrdiff_t __n = __last - __first;
360 ptrdiff_t __offset = __ptr - __first;
361
362 auto __fractional =
363 std::__parse_fractional_decimal_constant<typename _Floating_type_traits<_Fp>::_Uint_type>(__first, __n, __offset);
364 if (!__fractional.__is_valid)
365 return {_Fp{0}, 0, errc::invalid_argument};
366
367 __offset = __fractional.__offset;
368
369 // LWG3456 Pattern used by std::from_chars is underspecified
370 // This changes fixed to ignore a possible exponent instead of making its
371 // existance an error.
372 int __exponent;
373 if (__fmt == chars_format::fixed) {
374 __exponent =
375 std::__merge_exponents(__fractional.__exponent, 0, LIBC_NAMESPACE::shared::FPBits<_Fp>::MAX_BIASED_EXPONENT);
376 } else {
377 auto __parsed_exponent = std::__parse_exponent(__first, __n, __offset, 'e');
378 if (__fmt == chars_format::scientific && !__parsed_exponent.__present) {
379 // [charconv.from.chars]/6.2 if fmt has chars_format::scientific set but not chars_format::fixed,
380 // the otherwise optional exponent part shall appear;
381 return {_Fp{0}, 0, errc::invalid_argument};
382 }
383
384 __offset = __parsed_exponent.__offset;
385 __exponent = std::__merge_exponents(
386 __fractional.__exponent, __parsed_exponent.__value, LIBC_NAMESPACE::shared::FPBits<_Fp>::MAX_BIASED_EXPONENT);
387 }
388
389 __from_chars_result<_Fp> __result{_Fp{0}, __offset, {}};
390 LIBC_NAMESPACE::shared::ExpandedFloat<_Fp> __expanded_float = {0, 0};
391 if (__fractional.__mantissa != 0) {
392 // This function expects to parse a positive value. This means it does not
393 // take a __first, __n as arguments, since __first points to '-' for
394 // negative values.
395 auto __temp = LIBC_NAMESPACE::shared::decimal_exp_to_float<_Fp>(
396 {__fractional.__mantissa, __exponent},
397 __fractional.__truncated,
398 LIBC_NAMESPACE::shared::RoundDirection::Nearest,
399 __ptr,
400 __last - __ptr);
401 __expanded_float = __temp.num;
402 if (__temp.error == ERANGE) {
403 __result.__ec = errc::result_out_of_range;
404 }
405 }
406
407 return std::__calculate_result(__expanded_float.mantissa, __expanded_float.exponent, __negative, __result);
408}
409
410template <floating_point _Fp>
411__from_chars_result<_Fp>
412__from_chars_floating_point_impl(const char* const __first, const char* __last, chars_format __fmt) {
413 if (__first == __last) [[unlikely]]
414 return {_Fp{0}, 0, errc::invalid_argument};
415
416 const char* __ptr = __first;
417 bool __negative = *__ptr == '-';
418 if (__negative) {
419 ++__ptr;
420 if (__ptr == __last) [[unlikely]]
421 return {_Fp{0}, 0, errc::invalid_argument};
422 }
423
424 // [charconv.from.chars]
425 // [Note 1: If the pattern allows for an optional sign, but the string has
426 // no digit characters following the sign, no characters match the pattern.
427 // -- end note]
428 // This is true for integrals, floating point allows -.0
429
430 // [charconv.from.chars]/6.2
431 // if fmt has chars_format::scientific set but not chars_format::fixed, the
432 // otherwise optional exponent part shall appear;
433 // Since INF/NAN do not have an exponent this value is not valid.
434 //
435 // LWG3456 Pattern used by std::from_chars is underspecified
436 // Does not address this point, but proposed option B does solve this issue,
437 // Both MSVC STL and libstdc++ implement this this behaviour.
438 switch (std::tolower(*__ptr)) {
439 case 'i':
440 return std::__from_chars_floating_point_inf<_Fp>(__first, __last, __ptr + 1, __negative);
441 case 'n':
442 if constexpr (numeric_limits<_Fp>::has_quiet_NaN)
443 // NOTE: The pointer passed here will be parsed in the default C locale.
444 // This is standard behavior (see https://eel.is/c++draft/charconv.from.chars), but may be unexpected.
445 return std::__from_chars_floating_point_nan<_Fp>(__first, __last, __ptr + 1, __negative);
446 return {_Fp{0}, 0, errc::invalid_argument};
447 }
448
449 if (__fmt == chars_format::hex)
450 return std::__from_chars_floating_point_hex<_Fp>(__first, __last, __ptr, __negative);
451
452 return std::__from_chars_floating_point_decimal<_Fp>(__first, __last, __fmt, __ptr, __negative);
453}
454
455_LIBCPP_END_NAMESPACE_STD
456
457#endif //_LIBCPP_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H
lib/libcxx/src/include/overridable_function.h+7-1
...@@ -96,7 +96,8 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no...@@ -96,7 +96,8 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no
96}96}
97_LIBCPP_END_NAMESPACE_STD97_LIBCPP_END_NAMESPACE_STD
9898
99#elif defined(_LIBCPP_OBJECT_FORMAT_ELF)99// The NVPTX linker cannot create '__start/__stop' sections.
100#elif defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__)
100101
101# define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1102# define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1
102# define _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE __attribute__((__section__("__lcxx_override")))103# define _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE __attribute__((__section__("__lcxx_override")))
...@@ -115,6 +116,11 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no...@@ -115,6 +116,11 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no
115 uintptr_t __end = reinterpret_cast<uintptr_t>(&__stop___lcxx_override);116 uintptr_t __end = reinterpret_cast<uintptr_t>(&__stop___lcxx_override);
116 uintptr_t __ptr = reinterpret_cast<uintptr_t>(__fptr);117 uintptr_t __ptr = reinterpret_cast<uintptr_t>(__fptr);
117118
119# if __has_feature(ptrauth_calls)
120 // We must pass a void* to ptrauth_strip since it only accepts a pointer type. See full explanation above.
121 __ptr = reinterpret_cast<uintptr_t>(ptrauth_strip(reinterpret_cast<void*>(__ptr), ptrauth_key_function_pointer));
122# endif
123
118 return __ptr < __start || __ptr > __end;124 return __ptr < __start || __ptr > __end;
119}125}
120_LIBCPP_END_NAMESPACE_STD126_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/include/refstring.h+1-1
...@@ -124,4 +124,4 @@ inline bool __libcpp_refstring::__uses_refcount() const {...@@ -124,4 +124,4 @@ inline bool __libcpp_refstring::__uses_refcount() const {
124124
125_LIBCPP_END_NAMESPACE_STD125_LIBCPP_END_NAMESPACE_STD
126126
127#endif //_LIBCPP_REFSTRING_H127#endif // _LIBCPP_REFSTRING_H
lib/libcxx/src/ios.cpp+5-5
...@@ -116,7 +116,7 @@ locale ios_base::getloc() const {...@@ -116,7 +116,7 @@ locale ios_base::getloc() const {
116}116}
117117
118// xalloc118// xalloc
119#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)119#if _LIBCPP_HAS_C_ATOMIC_IMP && _LIBCPP_HAS_THREADS
120atomic<int> ios_base::__xindex_{0};120atomic<int> ios_base::__xindex_{0};
121#else121#else
122int ios_base::__xindex_ = 0;122int ios_base::__xindex_ = 0;
...@@ -361,18 +361,18 @@ void ios_base::swap(ios_base& rhs) noexcept {...@@ -361,18 +361,18 @@ void ios_base::swap(ios_base& rhs) noexcept {
361361
362void ios_base::__set_badbit_and_consider_rethrow() {362void ios_base::__set_badbit_and_consider_rethrow() {
363 __rdstate_ |= badbit;363 __rdstate_ |= badbit;
364#ifndef _LIBCPP_HAS_NO_EXCEPTIONS364#if _LIBCPP_HAS_EXCEPTIONS
365 if (__exceptions_ & badbit)365 if (__exceptions_ & badbit)
366 throw;366 throw;
367#endif // _LIBCPP_HAS_NO_EXCEPTIONS367#endif // _LIBCPP_HAS_EXCEPTIONS
368}368}
369369
370void ios_base::__set_failbit_and_consider_rethrow() {370void ios_base::__set_failbit_and_consider_rethrow() {
371 __rdstate_ |= failbit;371 __rdstate_ |= failbit;
372#ifndef _LIBCPP_HAS_NO_EXCEPTIONS372#if _LIBCPP_HAS_EXCEPTIONS
373 if (__exceptions_ & failbit)373 if (__exceptions_ & failbit)
374 throw;374 throw;
375#endif // _LIBCPP_HAS_NO_EXCEPTIONS375#endif // _LIBCPP_HAS_EXCEPTIONS
376}376}
377377
378bool ios_base::sync_with_stdio(bool sync) {378bool ios_base::sync_with_stdio(bool sync) {
lib/libcxx/src/ios.instantiations.cpp+2-2
...@@ -23,7 +23,7 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<char>;...@@ -23,7 +23,7 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<char>;
23template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<char>;23template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<char>;
24template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_iostream<char>;24template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_iostream<char>;
2525
26#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS26#if _LIBCPP_HAS_WIDE_CHARACTERS
27template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<wchar_t>;27template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<wchar_t>;
28template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<wchar_t>;28template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<wchar_t>;
29template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<wchar_t>;29template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<wchar_t>;
...@@ -37,7 +37,7 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringstream<char>...@@ -37,7 +37,7 @@ template 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>;
3939
40#ifndef _LIBCPP_HAS_NO_FILESYSTEM40#if _LIBCPP_HAS_FILESYSTEM
41template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ifstream<char>;41template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ifstream<char>;
42template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ofstream<char>;42template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ofstream<char>;
43template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_filebuf<char>;43template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_filebuf<char>;
lib/libcxx/src/iostream.cpp+13-17
...@@ -11,10 +11,6 @@...@@ -11,10 +11,6 @@
11#include <new>11#include <new>
12#include <string>12#include <string>
1313
14#ifdef _LIBCPP_MSVCRT_LIKE
15# include <__locale_dir/locale_base_api/locale_guard.h>
16#endif
17
18#define _str(s) #s14#define _str(s) #s
19#define str(s) _str(s)15#define str(s) _str(s)
20#define _LIBCPP_ABI_NAMESPACE_STR str(_LIBCPP_ABI_NAMESPACE)16#define _LIBCPP_ABI_NAMESPACE_STR str(_LIBCPP_ABI_NAMESPACE)
...@@ -30,7 +26,7 @@ alignas(istream) _LIBCPP_EXPORTED_FROM_ABI char cin[sizeof(istream)]...@@ -30,7 +26,7 @@ alignas(istream) _LIBCPP_EXPORTED_FROM_ABI char cin[sizeof(istream)]
30alignas(__stdinbuf<char>) static char __cin[sizeof(__stdinbuf<char>)];26alignas(__stdinbuf<char>) static char __cin[sizeof(__stdinbuf<char>)];
31static mbstate_t mb_cin;27static mbstate_t mb_cin;
3228
33#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS29#if _LIBCPP_HAS_WIDE_CHARACTERS
34alignas(wistream) _LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)]30alignas(wistream) _LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)]
35# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)31# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
36 __asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR32 __asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
...@@ -39,7 +35,7 @@ alignas(wistream) _LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)]...@@ -39,7 +35,7 @@ alignas(wistream) _LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)]
39 ;35 ;
40alignas(__stdinbuf<wchar_t>) static char __wcin[sizeof(__stdinbuf<wchar_t>)];36alignas(__stdinbuf<wchar_t>) static char __wcin[sizeof(__stdinbuf<wchar_t>)];
41static mbstate_t mb_wcin;37static mbstate_t mb_wcin;
42#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS38#endif // _LIBCPP_HAS_WIDE_CHARACTERS
4339
44alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)]40alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)]
45#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)41#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
...@@ -50,7 +46,7 @@ alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)]...@@ -50,7 +46,7 @@ alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)]
50alignas(__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];46alignas(__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
51static mbstate_t mb_cout;47static mbstate_t mb_cout;
5248
53#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS49#if _LIBCPP_HAS_WIDE_CHARACTERS
54alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)]50alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)]
55# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)51# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
56 __asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR52 __asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
...@@ -59,7 +55,7 @@ alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)]...@@ -59,7 +55,7 @@ alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)]
59 ;55 ;
60alignas(__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];56alignas(__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
61static mbstate_t mb_wcout;57static mbstate_t mb_wcout;
62#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS58#endif // _LIBCPP_HAS_WIDE_CHARACTERS
6359
64alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)]60alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)]
65#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)61#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
...@@ -70,7 +66,7 @@ alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)]...@@ -70,7 +66,7 @@ alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)]
70alignas(__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];66alignas(__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
71static mbstate_t mb_cerr;67static mbstate_t mb_cerr;
7268
73#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS69#if _LIBCPP_HAS_WIDE_CHARACTERS
74alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)]70alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)]
75# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)71# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
76 __asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR72 __asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
...@@ -79,7 +75,7 @@ alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)]...@@ -79,7 +75,7 @@ alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)]
79 ;75 ;
80alignas(__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];76alignas(__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];
81static mbstate_t mb_wcerr;77static mbstate_t mb_wcerr;
82#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS78#endif // _LIBCPP_HAS_WIDE_CHARACTERS
8379
84alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)]80alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)]
85#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)81#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
...@@ -88,14 +84,14 @@ alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)]...@@ -88,14 +84,14 @@ alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)]
88#endif84#endif
89 ;85 ;
9086
91#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS87#if _LIBCPP_HAS_WIDE_CHARACTERS
92alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)]88alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)]
93# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)89# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
94 __asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR90 __asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
95 "@std@@@12@A")91 "@std@@@12@A")
96# endif92# endif
97 ;93 ;
98#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS94#endif // _LIBCPP_HAS_WIDE_CHARACTERS
9995
100// Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority96// Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority
101// attribute with a value that's reserved for the implementation (we're the implementation).97// attribute with a value that's reserved for the implementation (we're the implementation).
...@@ -107,12 +103,12 @@ alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)]...@@ -107,12 +103,12 @@ alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)]
107static void force_locale_initialization() {103static void force_locale_initialization() {
108#if defined(_LIBCPP_MSVCRT_LIKE)104#if defined(_LIBCPP_MSVCRT_LIKE)
109 static bool once = []() {105 static bool once = []() {
110 auto loc = newlocale(LC_ALL_MASK, "C", 0);106 auto loc = __locale::__newlocale(_LIBCPP_ALL_MASK, "C", 0);
111 {107 {
112 __libcpp_locale_guard g(loc); // forces initialization of locale TLS108 __locale::__locale_guard g(loc); // forces initialization of locale TLS
113 ((void)g);109 ((void)g);
114 }110 }
115 freelocale(loc);111 __locale::__freelocale(loc);
116 return true;112 return true;
117 }();113 }();
118 ((void)once);114 ((void)once);
...@@ -136,7 +132,7 @@ DoIOSInit::DoIOSInit() {...@@ -136,7 +132,7 @@ DoIOSInit::DoIOSInit() {
136 std::unitbuf(*cerr_ptr);132 std::unitbuf(*cerr_ptr);
137 cerr_ptr->tie(cout_ptr);133 cerr_ptr->tie(cout_ptr);
138134
139#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS135#if _LIBCPP_HAS_WIDE_CHARACTERS
140 wistream* wcin_ptr = ::new (wcin) wistream(::new (__wcin) __stdinbuf<wchar_t>(stdin, &mb_wcin));136 wistream* wcin_ptr = ::new (wcin) wistream(::new (__wcin) __stdinbuf<wchar_t>(stdin, &mb_wcin));
141 wostream* wcout_ptr = ::new (wcout) wostream(::new (__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout));137 wostream* wcout_ptr = ::new (wcout) wostream(::new (__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout));
142 wostream* wcerr_ptr = ::new (wcerr) wostream(::new (__wcerr) __stdoutbuf<wchar_t>(stderr, &mb_wcerr));138 wostream* wcerr_ptr = ::new (wcerr) wostream(::new (__wcerr) __stdoutbuf<wchar_t>(stderr, &mb_wcerr));
...@@ -154,7 +150,7 @@ DoIOSInit::~DoIOSInit() {...@@ -154,7 +150,7 @@ DoIOSInit::~DoIOSInit() {
154 ostream* clog_ptr = reinterpret_cast<ostream*>(clog);150 ostream* clog_ptr = reinterpret_cast<ostream*>(clog);
155 clog_ptr->flush();151 clog_ptr->flush();
156152
157#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS153#if _LIBCPP_HAS_WIDE_CHARACTERS
158 wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout);154 wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout);
159 wcout_ptr->flush();155 wcout_ptr->flush();
160 wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog);156 wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog);
lib/libcxx/src/legacy_pointer_safety.cpp deleted-23
...@@ -1,23 +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#include <__config>
10#include <memory>
11
12// Support for garbage collection was removed in C++23 by https://wg21.link/P2186R2. Libc++ implements
13// that removal as an extension in all Standard versions. However, we still define the functions that
14// were once part of the library's ABI for backwards compatibility.
15
16_LIBCPP_BEGIN_NAMESPACE_STD
17
18_LIBCPP_EXPORTED_FROM_ABI void declare_reachable(void*) {}
19_LIBCPP_EXPORTED_FROM_ABI void declare_no_pointers(char*, size_t) {}
20_LIBCPP_EXPORTED_FROM_ABI void undeclare_no_pointers(char*, size_t) {}
21_LIBCPP_EXPORTED_FROM_ABI void* __undeclare_reachable(void* p) { return p; }
22
23_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/locale.cpp+294-289
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
22#include <utility>22#include <utility>
23#include <vector>23#include <vector>
2424
25#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS25#if _LIBCPP_HAS_WIDE_CHARACTERS
26# include <cwctype>26# include <cwctype>
27#endif27#endif
2828
...@@ -34,7 +34,7 @@...@@ -34,7 +34,7 @@
34# define _CTYPE_DISABLE_MACROS34# define _CTYPE_DISABLE_MACROS
35#endif35#endif
3636
37#if !defined(_LIBCPP_MSVCRT) && !defined(__MINGW32__) && !defined(__BIONIC__) && !defined(__NuttX__)37#if __has_include("<langinfo.h>")
38# include <langinfo.h>38# include <langinfo.h>
39#endif39#endif
4040
...@@ -51,18 +51,18 @@ _LIBCPP_PUSH_MACROS...@@ -51,18 +51,18 @@ _LIBCPP_PUSH_MACROS
51_LIBCPP_BEGIN_NAMESPACE_STD51_LIBCPP_BEGIN_NAMESPACE_STD
5252
53struct __libcpp_unique_locale {53struct __libcpp_unique_locale {
54 __libcpp_unique_locale(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) {}54 __libcpp_unique_locale(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) {}
5555
56 ~__libcpp_unique_locale() {56 ~__libcpp_unique_locale() {
57 if (__loc_)57 if (__loc_)
58 freelocale(__loc_);58 __locale::__freelocale(__loc_);
59 }59 }
6060
61 explicit operator bool() const { return __loc_; }61 explicit operator bool() const { return __loc_; }
6262
63 locale_t& get() { return __loc_; }63 __locale::__locale_t& get() { return __loc_; }
6464
65 locale_t __loc_;65 __locale::__locale_t __loc_;
6666
67private:67private:
68 __libcpp_unique_locale(__libcpp_unique_locale const&);68 __libcpp_unique_locale(__libcpp_unique_locale const&);
...@@ -70,11 +70,11 @@ private:...@@ -70,11 +70,11 @@ private:
70};70};
7171
72#ifdef __cloc_defined72#ifdef __cloc_defined
73locale_t __cloc() {73__locale::__locale_t __cloc() {
74 // In theory this could create a race condition. In practice74 // In theory this could create a race condition. In practice
75 // the race condition is non-fatal since it will just create75 // the race condition is non-fatal since it will just create
76 // a little resource leak. Better approach would be appreciated.76 // a little resource leak. Better approach would be appreciated.
77 static locale_t result = newlocale(LC_ALL_MASK, "C", 0);77 static __locale::__locale_t result = __locale::__newlocale(_LIBCPP_ALL_MASK, "C", 0);
78 return result;78 return result;
79}79}
80#endif // __cloc_defined80#endif // __cloc_defined
...@@ -159,123 +159,123 @@ private:...@@ -159,123 +159,123 @@ private:
159locale::__imp::__imp(size_t refs) : facet(refs), facets_(N), name_("C") {159locale::__imp::__imp(size_t refs) : facet(refs), facets_(N), name_("C") {
160 facets_.clear();160 facets_.clear();
161 install(&make<std::collate<char> >(1u));161 install(&make<std::collate<char> >(1u));
162#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS162#if _LIBCPP_HAS_WIDE_CHARACTERS
163 install(&make<std::collate<wchar_t> >(1u));163 install(&make<std::collate<wchar_t> >(1u));
164#endif164#endif
165 install(&make<std::ctype<char> >(nullptr, false, 1u));165 install(&make<std::ctype<char> >(nullptr, false, 1u));
166#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS166#if _LIBCPP_HAS_WIDE_CHARACTERS
167 install(&make<std::ctype<wchar_t> >(1u));167 install(&make<std::ctype<wchar_t> >(1u));
168#endif168#endif
169 install(&make<codecvt<char, char, mbstate_t> >(1u));169 install(&make<codecvt<char, char, mbstate_t> >(1u));
170#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS170#if _LIBCPP_HAS_WIDE_CHARACTERS
171 install(&make<codecvt<wchar_t, char, mbstate_t> >(1u));171 install(&make<codecvt<wchar_t, char, mbstate_t> >(1u));
172#endif172#endif
173 _LIBCPP_SUPPRESS_DEPRECATED_PUSH173 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
174 install(&make<codecvt<char16_t, char, mbstate_t> >(1u));174 install(&make<codecvt<char16_t, char, mbstate_t> >(1u));
175 install(&make<codecvt<char32_t, char, mbstate_t> >(1u));175 install(&make<codecvt<char32_t, char, mbstate_t> >(1u));
176 _LIBCPP_SUPPRESS_DEPRECATED_POP176 _LIBCPP_SUPPRESS_DEPRECATED_POP
177#ifndef _LIBCPP_HAS_NO_CHAR8_T177#if _LIBCPP_HAS_CHAR8_T
178 install(&make<codecvt<char16_t, char8_t, mbstate_t> >(1u));178 install(&make<codecvt<char16_t, char8_t, mbstate_t> >(1u));
179 install(&make<codecvt<char32_t, char8_t, mbstate_t> >(1u));179 install(&make<codecvt<char32_t, char8_t, mbstate_t> >(1u));
180#endif180#endif
181 install(&make<numpunct<char> >(1u));181 install(&make<numpunct<char> >(1u));
182#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS182#if _LIBCPP_HAS_WIDE_CHARACTERS
183 install(&make<numpunct<wchar_t> >(1u));183 install(&make<numpunct<wchar_t> >(1u));
184#endif184#endif
185 install(&make<num_get<char> >(1u));185 install(&make<num_get<char> >(1u));
186#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS186#if _LIBCPP_HAS_WIDE_CHARACTERS
187 install(&make<num_get<wchar_t> >(1u));187 install(&make<num_get<wchar_t> >(1u));
188#endif188#endif
189 install(&make<num_put<char> >(1u));189 install(&make<num_put<char> >(1u));
190#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS190#if _LIBCPP_HAS_WIDE_CHARACTERS
191 install(&make<num_put<wchar_t> >(1u));191 install(&make<num_put<wchar_t> >(1u));
192#endif192#endif
193 install(&make<moneypunct<char, false> >(1u));193 install(&make<moneypunct<char, false> >(1u));
194 install(&make<moneypunct<char, true> >(1u));194 install(&make<moneypunct<char, true> >(1u));
195#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS195#if _LIBCPP_HAS_WIDE_CHARACTERS
196 install(&make<moneypunct<wchar_t, false> >(1u));196 install(&make<moneypunct<wchar_t, false> >(1u));
197 install(&make<moneypunct<wchar_t, true> >(1u));197 install(&make<moneypunct<wchar_t, true> >(1u));
198#endif198#endif
199 install(&make<money_get<char> >(1u));199 install(&make<money_get<char> >(1u));
200#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS200#if _LIBCPP_HAS_WIDE_CHARACTERS
201 install(&make<money_get<wchar_t> >(1u));201 install(&make<money_get<wchar_t> >(1u));
202#endif202#endif
203 install(&make<money_put<char> >(1u));203 install(&make<money_put<char> >(1u));
204#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS204#if _LIBCPP_HAS_WIDE_CHARACTERS
205 install(&make<money_put<wchar_t> >(1u));205 install(&make<money_put<wchar_t> >(1u));
206#endif206#endif
207 install(&make<time_get<char> >(1u));207 install(&make<time_get<char> >(1u));
208#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS208#if _LIBCPP_HAS_WIDE_CHARACTERS
209 install(&make<time_get<wchar_t> >(1u));209 install(&make<time_get<wchar_t> >(1u));
210#endif210#endif
211 install(&make<time_put<char> >(1u));211 install(&make<time_put<char> >(1u));
212#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS212#if _LIBCPP_HAS_WIDE_CHARACTERS
213 install(&make<time_put<wchar_t> >(1u));213 install(&make<time_put<wchar_t> >(1u));
214#endif214#endif
215 install(&make<std::messages<char> >(1u));215 install(&make<std::messages<char> >(1u));
216#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS216#if _LIBCPP_HAS_WIDE_CHARACTERS
217 install(&make<std::messages<wchar_t> >(1u));217 install(&make<std::messages<wchar_t> >(1u));
218#endif218#endif
219}219}
220220
221locale::__imp::__imp(const string& name, size_t refs) : facet(refs), facets_(N), name_(name) {221locale::__imp::__imp(const string& name, size_t refs) : facet(refs), facets_(N), name_(name) {
222#ifndef _LIBCPP_HAS_NO_EXCEPTIONS222#if _LIBCPP_HAS_EXCEPTIONS
223 try {223 try {
224#endif // _LIBCPP_HAS_NO_EXCEPTIONS224#endif // _LIBCPP_HAS_EXCEPTIONS
225 facets_ = locale::classic().__locale_->facets_;225 facets_ = locale::classic().__locale_->facets_;
226 for (unsigned i = 0; i < facets_.size(); ++i)226 for (unsigned i = 0; i < facets_.size(); ++i)
227 if (facets_[i])227 if (facets_[i])
228 facets_[i]->__add_shared();228 facets_[i]->__add_shared();
229 install(new collate_byname<char>(name_));229 install(new collate_byname<char>(name_));
230#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS230#if _LIBCPP_HAS_WIDE_CHARACTERS
231 install(new collate_byname<wchar_t>(name_));231 install(new collate_byname<wchar_t>(name_));
232#endif232#endif
233 install(new ctype_byname<char>(name_));233 install(new ctype_byname<char>(name_));
234#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS234#if _LIBCPP_HAS_WIDE_CHARACTERS
235 install(new ctype_byname<wchar_t>(name_));235 install(new ctype_byname<wchar_t>(name_));
236#endif236#endif
237 install(new codecvt_byname<char, char, mbstate_t>(name_));237 install(new codecvt_byname<char, char, mbstate_t>(name_));
238#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS238#if _LIBCPP_HAS_WIDE_CHARACTERS
239 install(new codecvt_byname<wchar_t, char, mbstate_t>(name_));239 install(new codecvt_byname<wchar_t, char, mbstate_t>(name_));
240#endif240#endif
241 _LIBCPP_SUPPRESS_DEPRECATED_PUSH241 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
242 install(new codecvt_byname<char16_t, char, mbstate_t>(name_));242 install(new codecvt_byname<char16_t, char, mbstate_t>(name_));
243 install(new codecvt_byname<char32_t, char, mbstate_t>(name_));243 install(new codecvt_byname<char32_t, char, mbstate_t>(name_));
244 _LIBCPP_SUPPRESS_DEPRECATED_POP244 _LIBCPP_SUPPRESS_DEPRECATED_POP
245#ifndef _LIBCPP_HAS_NO_CHAR8_T245#if _LIBCPP_HAS_CHAR8_T
246 install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name_));246 install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name_));
247 install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name_));247 install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name_));
248#endif248#endif
249 install(new numpunct_byname<char>(name_));249 install(new numpunct_byname<char>(name_));
250#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS250#if _LIBCPP_HAS_WIDE_CHARACTERS
251 install(new numpunct_byname<wchar_t>(name_));251 install(new numpunct_byname<wchar_t>(name_));
252#endif252#endif
253 install(new moneypunct_byname<char, false>(name_));253 install(new moneypunct_byname<char, false>(name_));
254 install(new moneypunct_byname<char, true>(name_));254 install(new moneypunct_byname<char, true>(name_));
255#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS255#if _LIBCPP_HAS_WIDE_CHARACTERS
256 install(new moneypunct_byname<wchar_t, false>(name_));256 install(new moneypunct_byname<wchar_t, false>(name_));
257 install(new moneypunct_byname<wchar_t, true>(name_));257 install(new moneypunct_byname<wchar_t, true>(name_));
258#endif258#endif
259 install(new time_get_byname<char>(name_));259 install(new time_get_byname<char>(name_));
260#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS260#if _LIBCPP_HAS_WIDE_CHARACTERS
261 install(new time_get_byname<wchar_t>(name_));261 install(new time_get_byname<wchar_t>(name_));
262#endif262#endif
263 install(new time_put_byname<char>(name_));263 install(new time_put_byname<char>(name_));
264#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS264#if _LIBCPP_HAS_WIDE_CHARACTERS
265 install(new time_put_byname<wchar_t>(name_));265 install(new time_put_byname<wchar_t>(name_));
266#endif266#endif
267 install(new messages_byname<char>(name_));267 install(new messages_byname<char>(name_));
268#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS268#if _LIBCPP_HAS_WIDE_CHARACTERS
269 install(new messages_byname<wchar_t>(name_));269 install(new messages_byname<wchar_t>(name_));
270#endif270#endif
271#ifndef _LIBCPP_HAS_NO_EXCEPTIONS271#if _LIBCPP_HAS_EXCEPTIONS
272 } catch (...) {272 } catch (...) {
273 for (unsigned i = 0; i < facets_.size(); ++i)273 for (unsigned i = 0; i < facets_.size(); ++i)
274 if (facets_[i])274 if (facets_[i])
275 facets_[i]->__release_shared();275 facets_[i]->__release_shared();
276 throw;276 throw;
277 }277 }
278#endif // _LIBCPP_HAS_NO_EXCEPTIONS278#endif // _LIBCPP_HAS_EXCEPTIONS
279}279}
280280
281locale::__imp::__imp(const __imp& other) : facets_(max<size_t>(N, other.facets_.size())), name_(other.name_) {281locale::__imp::__imp(const __imp& other) : facets_(max<size_t>(N, other.facets_.size())), name_(other.name_) {
...@@ -291,29 +291,29 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c)...@@ -291,29 +291,29 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c)
291 for (unsigned i = 0; i < facets_.size(); ++i)291 for (unsigned i = 0; i < facets_.size(); ++i)
292 if (facets_[i])292 if (facets_[i])
293 facets_[i]->__add_shared();293 facets_[i]->__add_shared();
294#ifndef _LIBCPP_HAS_NO_EXCEPTIONS294#if _LIBCPP_HAS_EXCEPTIONS
295 try {295 try {
296#endif // _LIBCPP_HAS_NO_EXCEPTIONS296#endif // _LIBCPP_HAS_EXCEPTIONS
297 if (c & locale::collate) {297 if (c & locale::collate) {
298 install(new collate_byname<char>(name));298 install(new collate_byname<char>(name));
299#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS299#if _LIBCPP_HAS_WIDE_CHARACTERS
300 install(new collate_byname<wchar_t>(name));300 install(new collate_byname<wchar_t>(name));
301#endif301#endif
302 }302 }
303 if (c & locale::ctype) {303 if (c & locale::ctype) {
304 install(new ctype_byname<char>(name));304 install(new ctype_byname<char>(name));
305#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS305#if _LIBCPP_HAS_WIDE_CHARACTERS
306 install(new ctype_byname<wchar_t>(name));306 install(new ctype_byname<wchar_t>(name));
307#endif307#endif
308 install(new codecvt_byname<char, char, mbstate_t>(name));308 install(new codecvt_byname<char, char, mbstate_t>(name));
309#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS309#if _LIBCPP_HAS_WIDE_CHARACTERS
310 install(new codecvt_byname<wchar_t, char, mbstate_t>(name));310 install(new codecvt_byname<wchar_t, char, mbstate_t>(name));
311#endif311#endif
312 _LIBCPP_SUPPRESS_DEPRECATED_PUSH312 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
313 install(new codecvt_byname<char16_t, char, mbstate_t>(name));313 install(new codecvt_byname<char16_t, char, mbstate_t>(name));
314 install(new codecvt_byname<char32_t, char, mbstate_t>(name));314 install(new codecvt_byname<char32_t, char, mbstate_t>(name));
315 _LIBCPP_SUPPRESS_DEPRECATED_POP315 _LIBCPP_SUPPRESS_DEPRECATED_POP
316#ifndef _LIBCPP_HAS_NO_CHAR8_T316#if _LIBCPP_HAS_CHAR8_T
317 install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name));317 install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name));
318 install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name));318 install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name));
319#endif319#endif
...@@ -321,41 +321,41 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c)...@@ -321,41 +321,41 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c)
321 if (c & locale::monetary) {321 if (c & locale::monetary) {
322 install(new moneypunct_byname<char, false>(name));322 install(new moneypunct_byname<char, false>(name));
323 install(new moneypunct_byname<char, true>(name));323 install(new moneypunct_byname<char, true>(name));
324#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS324#if _LIBCPP_HAS_WIDE_CHARACTERS
325 install(new moneypunct_byname<wchar_t, false>(name));325 install(new moneypunct_byname<wchar_t, false>(name));
326 install(new moneypunct_byname<wchar_t, true>(name));326 install(new moneypunct_byname<wchar_t, true>(name));
327#endif327#endif
328 }328 }
329 if (c & locale::numeric) {329 if (c & locale::numeric) {
330 install(new numpunct_byname<char>(name));330 install(new numpunct_byname<char>(name));
331#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS331#if _LIBCPP_HAS_WIDE_CHARACTERS
332 install(new numpunct_byname<wchar_t>(name));332 install(new numpunct_byname<wchar_t>(name));
333#endif333#endif
334 }334 }
335 if (c & locale::time) {335 if (c & locale::time) {
336 install(new time_get_byname<char>(name));336 install(new time_get_byname<char>(name));
337#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS337#if _LIBCPP_HAS_WIDE_CHARACTERS
338 install(new time_get_byname<wchar_t>(name));338 install(new time_get_byname<wchar_t>(name));
339#endif339#endif
340 install(new time_put_byname<char>(name));340 install(new time_put_byname<char>(name));
341#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS341#if _LIBCPP_HAS_WIDE_CHARACTERS
342 install(new time_put_byname<wchar_t>(name));342 install(new time_put_byname<wchar_t>(name));
343#endif343#endif
344 }344 }
345 if (c & locale::messages) {345 if (c & locale::messages) {
346 install(new messages_byname<char>(name));346 install(new messages_byname<char>(name));
347#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS347#if _LIBCPP_HAS_WIDE_CHARACTERS
348 install(new messages_byname<wchar_t>(name));348 install(new messages_byname<wchar_t>(name));
349#endif349#endif
350 }350 }
351#ifndef _LIBCPP_HAS_NO_EXCEPTIONS351#if _LIBCPP_HAS_EXCEPTIONS
352 } catch (...) {352 } catch (...) {
353 for (unsigned i = 0; i < facets_.size(); ++i)353 for (unsigned i = 0; i < facets_.size(); ++i)
354 if (facets_[i])354 if (facets_[i])
355 facets_[i]->__release_shared();355 facets_[i]->__release_shared();
356 throw;356 throw;
357 }357 }
358#endif // _LIBCPP_HAS_NO_EXCEPTIONS358#endif // _LIBCPP_HAS_EXCEPTIONS
359}359}
360360
361template <class F>361template <class F>
...@@ -370,18 +370,18 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)...@@ -370,18 +370,18 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)
370 for (unsigned i = 0; i < facets_.size(); ++i)370 for (unsigned i = 0; i < facets_.size(); ++i)
371 if (facets_[i])371 if (facets_[i])
372 facets_[i]->__add_shared();372 facets_[i]->__add_shared();
373#ifndef _LIBCPP_HAS_NO_EXCEPTIONS373#if _LIBCPP_HAS_EXCEPTIONS
374 try {374 try {
375#endif // _LIBCPP_HAS_NO_EXCEPTIONS375#endif // _LIBCPP_HAS_EXCEPTIONS
376 if (c & locale::collate) {376 if (c & locale::collate) {
377 install_from<std::collate<char> >(one);377 install_from<std::collate<char> >(one);
378#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS378#if _LIBCPP_HAS_WIDE_CHARACTERS
379 install_from<std::collate<wchar_t> >(one);379 install_from<std::collate<wchar_t> >(one);
380#endif380#endif
381 }381 }
382 if (c & locale::ctype) {382 if (c & locale::ctype) {
383 install_from<std::ctype<char> >(one);383 install_from<std::ctype<char> >(one);
384#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS384#if _LIBCPP_HAS_WIDE_CHARACTERS
385 install_from<std::ctype<wchar_t> >(one);385 install_from<std::ctype<wchar_t> >(one);
386#endif386#endif
387 install_from<std::codecvt<char, char, mbstate_t> >(one);387 install_from<std::codecvt<char, char, mbstate_t> >(one);
...@@ -389,68 +389,68 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)...@@ -389,68 +389,68 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)
389 install_from<std::codecvt<char16_t, char, mbstate_t> >(one);389 install_from<std::codecvt<char16_t, char, mbstate_t> >(one);
390 install_from<std::codecvt<char32_t, char, mbstate_t> >(one);390 install_from<std::codecvt<char32_t, char, mbstate_t> >(one);
391 _LIBCPP_SUPPRESS_DEPRECATED_POP391 _LIBCPP_SUPPRESS_DEPRECATED_POP
392#ifndef _LIBCPP_HAS_NO_CHAR8_T392#if _LIBCPP_HAS_CHAR8_T
393 install_from<std::codecvt<char16_t, char8_t, mbstate_t> >(one);393 install_from<std::codecvt<char16_t, char8_t, mbstate_t> >(one);
394 install_from<std::codecvt<char32_t, char8_t, mbstate_t> >(one);394 install_from<std::codecvt<char32_t, char8_t, mbstate_t> >(one);
395#endif395#endif
396#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS396#if _LIBCPP_HAS_WIDE_CHARACTERS
397 install_from<std::codecvt<wchar_t, char, mbstate_t> >(one);397 install_from<std::codecvt<wchar_t, char, mbstate_t> >(one);
398#endif398#endif
399 }399 }
400 if (c & locale::monetary) {400 if (c & locale::monetary) {
401 install_from<moneypunct<char, false> >(one);401 install_from<moneypunct<char, false> >(one);
402 install_from<moneypunct<char, true> >(one);402 install_from<moneypunct<char, true> >(one);
403#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS403#if _LIBCPP_HAS_WIDE_CHARACTERS
404 install_from<moneypunct<wchar_t, false> >(one);404 install_from<moneypunct<wchar_t, false> >(one);
405 install_from<moneypunct<wchar_t, true> >(one);405 install_from<moneypunct<wchar_t, true> >(one);
406#endif406#endif
407 install_from<money_get<char> >(one);407 install_from<money_get<char> >(one);
408#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS408#if _LIBCPP_HAS_WIDE_CHARACTERS
409 install_from<money_get<wchar_t> >(one);409 install_from<money_get<wchar_t> >(one);
410#endif410#endif
411 install_from<money_put<char> >(one);411 install_from<money_put<char> >(one);
412#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS412#if _LIBCPP_HAS_WIDE_CHARACTERS
413 install_from<money_put<wchar_t> >(one);413 install_from<money_put<wchar_t> >(one);
414#endif414#endif
415 }415 }
416 if (c & locale::numeric) {416 if (c & locale::numeric) {
417 install_from<numpunct<char> >(one);417 install_from<numpunct<char> >(one);
418#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS418#if _LIBCPP_HAS_WIDE_CHARACTERS
419 install_from<numpunct<wchar_t> >(one);419 install_from<numpunct<wchar_t> >(one);
420#endif420#endif
421 install_from<num_get<char> >(one);421 install_from<num_get<char> >(one);
422#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS422#if _LIBCPP_HAS_WIDE_CHARACTERS
423 install_from<num_get<wchar_t> >(one);423 install_from<num_get<wchar_t> >(one);
424#endif424#endif
425 install_from<num_put<char> >(one);425 install_from<num_put<char> >(one);
426#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS426#if _LIBCPP_HAS_WIDE_CHARACTERS
427 install_from<num_put<wchar_t> >(one);427 install_from<num_put<wchar_t> >(one);
428#endif428#endif
429 }429 }
430 if (c & locale::time) {430 if (c & locale::time) {
431 install_from<time_get<char> >(one);431 install_from<time_get<char> >(one);
432#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS432#if _LIBCPP_HAS_WIDE_CHARACTERS
433 install_from<time_get<wchar_t> >(one);433 install_from<time_get<wchar_t> >(one);
434#endif434#endif
435 install_from<time_put<char> >(one);435 install_from<time_put<char> >(one);
436#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS436#if _LIBCPP_HAS_WIDE_CHARACTERS
437 install_from<time_put<wchar_t> >(one);437 install_from<time_put<wchar_t> >(one);
438#endif438#endif
439 }439 }
440 if (c & locale::messages) {440 if (c & locale::messages) {
441 install_from<std::messages<char> >(one);441 install_from<std::messages<char> >(one);
442#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS442#if _LIBCPP_HAS_WIDE_CHARACTERS
443 install_from<std::messages<wchar_t> >(one);443 install_from<std::messages<wchar_t> >(one);
444#endif444#endif
445 }445 }
446#ifndef _LIBCPP_HAS_NO_EXCEPTIONS446#if _LIBCPP_HAS_EXCEPTIONS
447 } catch (...) {447 } catch (...) {
448 for (unsigned i = 0; i < facets_.size(); ++i)448 for (unsigned i = 0; i < facets_.size(); ++i)
449 if (facets_[i])449 if (facets_[i])
450 facets_[i]->__release_shared();450 facets_[i]->__release_shared();
451 throw;451 throw;
452 }452 }
453#endif // _LIBCPP_HAS_NO_EXCEPTIONS453#endif // _LIBCPP_HAS_EXCEPTIONS
454}454}
455455
456locale::__imp::__imp(const __imp& other, facet* f, long id)456locale::__imp::__imp(const __imp& other, facet* f, long id)
...@@ -570,7 +570,7 @@ locale locale::global(const locale& loc) {...@@ -570,7 +570,7 @@ locale locale::global(const locale& loc) {
570 locale r = g;570 locale r = g;
571 g = loc;571 g = loc;
572 if (g.name() != "*")572 if (g.name() != "*")
573 setlocale(LC_ALL, g.name().c_str());573 __locale::__setlocale(_LIBCPP_LC_ALL, g.name().c_str());
574 return r;574 return r;
575}575}
576576
...@@ -600,7 +600,7 @@ long locale::id::__get() {...@@ -600,7 +600,7 @@ long locale::id::__get() {
600// template <> class collate_byname<char>600// template <> class collate_byname<char>
601601
602collate_byname<char>::collate_byname(const char* n, size_t refs)602collate_byname<char>::collate_byname(const char* n, size_t refs)
603 : collate<char>(refs), __l_(newlocale(LC_ALL_MASK, n, 0)) {603 : collate<char>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, n, 0)) {
604 if (__l_ == 0)604 if (__l_ == 0)
605 __throw_runtime_error(605 __throw_runtime_error(
606 ("collate_byname<char>::collate_byname"606 ("collate_byname<char>::collate_byname"
...@@ -610,7 +610,7 @@ collate_byname<char>::collate_byname(const char* n, size_t refs)...@@ -610,7 +610,7 @@ collate_byname<char>::collate_byname(const char* n, size_t refs)
610}610}
611611
612collate_byname<char>::collate_byname(const string& name, size_t refs)612collate_byname<char>::collate_byname(const string& name, size_t refs)
613 : collate<char>(refs), __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) {613 : collate<char>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) {
614 if (__l_ == 0)614 if (__l_ == 0)
615 __throw_runtime_error(615 __throw_runtime_error(
616 ("collate_byname<char>::collate_byname"616 ("collate_byname<char>::collate_byname"
...@@ -619,13 +619,13 @@ collate_byname<char>::collate_byname(const string& name, size_t refs)...@@ -619,13 +619,13 @@ collate_byname<char>::collate_byname(const string& name, size_t refs)
619 .c_str());619 .c_str());
620}620}
621621
622collate_byname<char>::~collate_byname() { freelocale(__l_); }622collate_byname<char>::~collate_byname() { __locale::__freelocale(__l_); }
623623
624int collate_byname<char>::do_compare(624int collate_byname<char>::do_compare(
625 const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const {625 const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const {
626 string_type lhs(__lo1, __hi1);626 string_type lhs(__lo1, __hi1);
627 string_type rhs(__lo2, __hi2);627 string_type rhs(__lo2, __hi2);
628 int r = strcoll_l(lhs.c_str(), rhs.c_str(), __l_);628 int r = __locale::__strcoll(lhs.c_str(), rhs.c_str(), __l_);
629 if (r < 0)629 if (r < 0)
630 return -1;630 return -1;
631 if (r > 0)631 if (r > 0)
...@@ -635,16 +635,16 @@ int collate_byname<char>::do_compare(...@@ -635,16 +635,16 @@ int collate_byname<char>::do_compare(
635635
636collate_byname<char>::string_type collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) const {636collate_byname<char>::string_type collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) const {
637 const string_type in(lo, hi);637 const string_type in(lo, hi);
638 string_type out(strxfrm_l(0, in.c_str(), 0, __l_), char());638 string_type out(__locale::__strxfrm(0, in.c_str(), 0, __l_), char());
639 strxfrm_l(const_cast<char*>(out.c_str()), in.c_str(), out.size() + 1, __l_);639 __locale::__strxfrm(const_cast<char*>(out.c_str()), in.c_str(), out.size() + 1, __l_);
640 return out;640 return out;
641}641}
642642
643// template <> class collate_byname<wchar_t>643// template <> class collate_byname<wchar_t>
644644
645#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS645#if _LIBCPP_HAS_WIDE_CHARACTERS
646collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)646collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)
647 : collate<wchar_t>(refs), __l_(newlocale(LC_ALL_MASK, n, 0)) {647 : collate<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, n, 0)) {
648 if (__l_ == 0)648 if (__l_ == 0)
649 __throw_runtime_error(649 __throw_runtime_error(
650 ("collate_byname<wchar_t>::collate_byname(size_t refs)"650 ("collate_byname<wchar_t>::collate_byname(size_t refs)"
...@@ -654,7 +654,7 @@ collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)...@@ -654,7 +654,7 @@ collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)
654}654}
655655
656collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)656collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)
657 : collate<wchar_t>(refs), __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) {657 : collate<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) {
658 if (__l_ == 0)658 if (__l_ == 0)
659 __throw_runtime_error(659 __throw_runtime_error(
660 ("collate_byname<wchar_t>::collate_byname(size_t refs)"660 ("collate_byname<wchar_t>::collate_byname(size_t refs)"
...@@ -663,13 +663,13 @@ collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)...@@ -663,13 +663,13 @@ collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)
663 .c_str());663 .c_str());
664}664}
665665
666collate_byname<wchar_t>::~collate_byname() { freelocale(__l_); }666collate_byname<wchar_t>::~collate_byname() { __locale::__freelocale(__l_); }
667667
668int collate_byname<wchar_t>::do_compare(668int collate_byname<wchar_t>::do_compare(
669 const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const {669 const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const {
670 string_type lhs(__lo1, __hi1);670 string_type lhs(__lo1, __hi1);
671 string_type rhs(__lo2, __hi2);671 string_type rhs(__lo2, __hi2);
672 int r = wcscoll_l(lhs.c_str(), rhs.c_str(), __l_);672 int r = __locale::__wcscoll(lhs.c_str(), rhs.c_str(), __l_);
673 if (r < 0)673 if (r < 0)
674 return -1;674 return -1;
675 if (r > 0)675 if (r > 0)
...@@ -680,11 +680,11 @@ int collate_byname<wchar_t>::do_compare(...@@ -680,11 +680,11 @@ int collate_byname<wchar_t>::do_compare(
680collate_byname<wchar_t>::string_type680collate_byname<wchar_t>::string_type
681collate_byname<wchar_t>::do_transform(const char_type* lo, const char_type* hi) const {681collate_byname<wchar_t>::do_transform(const char_type* lo, const char_type* hi) const {
682 const string_type in(lo, hi);682 const string_type in(lo, hi);
683 string_type out(wcsxfrm_l(0, in.c_str(), 0, __l_), wchar_t());683 string_type out(__locale::__wcsxfrm(0, in.c_str(), 0, __l_), wchar_t());
684 wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size() + 1, __l_);684 __locale::__wcsxfrm(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size() + 1, __l_);
685 return out;685 return out;
686}686}
687#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS687#endif // _LIBCPP_HAS_WIDE_CHARACTERS
688688
689const ctype_base::mask ctype_base::space;689const ctype_base::mask ctype_base::space;
690const ctype_base::mask ctype_base::print;690const ctype_base::mask ctype_base::print;
...@@ -701,75 +701,76 @@ const ctype_base::mask ctype_base::graph;...@@ -701,75 +701,76 @@ const ctype_base::mask ctype_base::graph;
701701
702// template <> class ctype<wchar_t>;702// template <> class ctype<wchar_t>;
703703
704#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS704#if _LIBCPP_HAS_WIDE_CHARACTERS
705constinit locale::id ctype<wchar_t>::id;705constinit locale::id ctype<wchar_t>::id;
706706
707ctype<wchar_t>::~ctype() {}707ctype<wchar_t>::~ctype() {}
708708
709bool ctype<wchar_t>::do_is(mask m, char_type c) const {709bool ctype<wchar_t>::do_is(mask m, char_type c) const {
710 return isascii(c) ? (ctype<char>::classic_table()[c] & m) != 0 : false;710 return std::__libcpp_isascii(c) ? (ctype<char>::classic_table()[c] & m) != 0 : false;
711}711}
712712
713const wchar_t* ctype<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const {713const wchar_t* ctype<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const {
714 for (; low != high; ++low, ++vec)714 for (; low != high; ++low, ++vec)
715 *vec = static_cast<mask>(isascii(*low) ? ctype<char>::classic_table()[*low] : 0);715 *vec = static_cast<mask>(std::__libcpp_isascii(*low) ? ctype<char>::classic_table()[*low] : 0);
716 return low;716 return low;
717}717}
718718
719const wchar_t* ctype<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const {719const wchar_t* ctype<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const {
720 for (; low != high; ++low)720 for (; low != high; ++low)
721 if (isascii(*low) && (ctype<char>::classic_table()[*low] & m))721 if (std::__libcpp_isascii(*low) && (ctype<char>::classic_table()[*low] & m))
722 break;722 break;
723 return low;723 return low;
724}724}
725725
726const wchar_t* ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const {726const wchar_t* ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const {
727 for (; low != high; ++low)727 for (; low != high; ++low)
728 if (!(isascii(*low) && (ctype<char>::classic_table()[*low] & m)))728 if (!(std::__libcpp_isascii(*low) && (ctype<char>::classic_table()[*low] & m)))
729 break;729 break;
730 return low;730 return low;
731}731}
732732
733wchar_t ctype<wchar_t>::do_toupper(char_type c) const {733wchar_t ctype<wchar_t>::do_toupper(char_type c) const {
734# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE734# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
735 return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;735 return std::__libcpp_isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
736# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)736# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)
737 return isascii(c) ? ctype<char>::__classic_upper_table()[c] : c;737 return std::__libcpp_isascii(c) ? ctype<char>::__classic_upper_table()[c] : c;
738# else738# else
739 return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c - L'a' + L'A' : c;739 return (std::__libcpp_isascii(c) && __locale::__iswlower(c, _LIBCPP_GET_C_LOCALE)) ? c - L'a' + L'A' : c;
740# endif740# endif
741}741}
742742
743const wchar_t* ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const {743const wchar_t* ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const {
744 for (; low != high; ++low)744 for (; low != high; ++low)
745# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE745# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
746 *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;746 *low = std::__libcpp_isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
747# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)747# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)
748 *low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low] : *low;748 *low = std::__libcpp_isascii(*low) ? ctype<char>::__classic_upper_table()[*low] : *low;
749# else749# else
750 *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? (*low - L'a' + L'A') : *low;750 *low =
751 (std::__libcpp_isascii(*low) && __locale::__islower(*low, _LIBCPP_GET_C_LOCALE)) ? (*low - L'a' + L'A') : *low;
751# endif752# endif
752 return low;753 return low;
753}754}
754755
755wchar_t ctype<wchar_t>::do_tolower(char_type c) const {756wchar_t ctype<wchar_t>::do_tolower(char_type c) const {
756# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE757# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
757 return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;758 return std::__libcpp_isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
758# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)759# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)
759 return isascii(c) ? ctype<char>::__classic_lower_table()[c] : c;760 return std::__libcpp_isascii(c) ? ctype<char>::__classic_lower_table()[c] : c;
760# else761# else
761 return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c - L'A' + 'a' : c;762 return (std::__libcpp_isascii(c) && __locale::__isupper(c, _LIBCPP_GET_C_LOCALE)) ? c - L'A' + 'a' : c;
762# endif763# endif
763}764}
764765
765const wchar_t* ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const {766const wchar_t* ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const {
766 for (; low != high; ++low)767 for (; low != high; ++low)
767# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE768# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
768 *low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;769 *low = std::__libcpp_isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
769# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)770# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)
770 *low = isascii(*low) ? ctype<char>::__classic_lower_table()[*low] : *low;771 *low = std::__libcpp_isascii(*low) ? ctype<char>::__classic_lower_table()[*low] : *low;
771# else772# else
772 *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low - L'A' + L'a' : *low;773 *low = (std::__libcpp_isascii(*low) && __locale::__isupper(*low, _LIBCPP_GET_C_LOCALE)) ? *low - L'A' + L'a' : *low;
773# endif774# endif
774 return low;775 return low;
775}776}
...@@ -783,20 +784,20 @@ const char* ctype<wchar_t>::do_widen(const char* low, const char* high, char_typ...@@ -783,20 +784,20 @@ const char* ctype<wchar_t>::do_widen(const char* low, const char* high, char_typ
783}784}
784785
785char ctype<wchar_t>::do_narrow(char_type c, char dfault) const {786char ctype<wchar_t>::do_narrow(char_type c, char dfault) const {
786 if (isascii(c))787 if (std::__libcpp_isascii(c))
787 return static_cast<char>(c);788 return static_cast<char>(c);
788 return dfault;789 return dfault;
789}790}
790791
791const wchar_t* ctype<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const {792const wchar_t* ctype<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const {
792 for (; low != high; ++low, ++dest)793 for (; low != high; ++low, ++dest)
793 if (isascii(*low))794 if (std::__libcpp_isascii(*low))
794 *dest = static_cast<char>(*low);795 *dest = static_cast<char>(*low);
795 else796 else
796 *dest = dfault;797 *dest = dfault;
797 return low;798 return low;
798}799}
799#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS800#endif // _LIBCPP_HAS_WIDE_CHARACTERS
800801
801// template <> class ctype<char>;802// template <> class ctype<char>;
802803
...@@ -816,52 +817,56 @@ ctype<char>::~ctype() {...@@ -816,52 +817,56 @@ ctype<char>::~ctype() {
816817
817char ctype<char>::do_toupper(char_type c) const {818char ctype<char>::do_toupper(char_type c) const {
818#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE819#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
819 return isascii(c) ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(c)]) : c;820 return std::__libcpp_isascii(c) ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(c)]) : c;
820#elif defined(__NetBSD__)821#elif defined(__NetBSD__)
821 return static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]);822 return static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]);
822#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)823#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
823 return isascii(c) ? static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c;824 return std::__libcpp_isascii(c) ? static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c;
824#else825#else
825 return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c - 'a' + 'A' : c;826 return (std::__libcpp_isascii(c) && __locale::__islower(c, _LIBCPP_GET_C_LOCALE)) ? c - 'a' + 'A' : c;
826#endif827#endif
827}828}
828829
829const char* ctype<char>::do_toupper(char_type* low, const char_type* high) const {830const char* ctype<char>::do_toupper(char_type* low, const char_type* high) const {
830 for (; low != high; ++low)831 for (; low != high; ++low)
831#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE832#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
832 *low = isascii(*low) ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(*low)]) : *low;833 *low = std::__libcpp_isascii(*low)
834 ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(*low)])
835 : *low;
833#elif defined(__NetBSD__)836#elif defined(__NetBSD__)
834 *low = static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(*low)]);837 *low = static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(*low)]);
835#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)838#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
836 *low = isascii(*low) ? static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low;839 *low = std::__libcpp_isascii(*low) ? static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low;
837#else840#else
838 *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'a' + 'A' : *low;841 *low = (std::__libcpp_isascii(*low) && __locale::__islower(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'a' + 'A' : *low;
839#endif842#endif
840 return low;843 return low;
841}844}
842845
843char ctype<char>::do_tolower(char_type c) const {846char ctype<char>::do_tolower(char_type c) const {
844#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE847#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
845 return isascii(c) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(c)]) : c;848 return std::__libcpp_isascii(c) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(c)]) : c;
846#elif defined(__NetBSD__)849#elif defined(__NetBSD__)
847 return static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(c)]);850 return static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(c)]);
848#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)851#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
849 return isascii(c) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c;852 return std::__libcpp_isascii(c) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c;
850#else853#else
851 return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c - 'A' + 'a' : c;854 return (std::__libcpp_isascii(c) && __locale::__isupper(c, _LIBCPP_GET_C_LOCALE)) ? c - 'A' + 'a' : c;
852#endif855#endif
853}856}
854857
855const char* ctype<char>::do_tolower(char_type* low, const char_type* high) const {858const char* ctype<char>::do_tolower(char_type* low, const char_type* high) const {
856 for (; low != high; ++low)859 for (; low != high; ++low)
857#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE860#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
858 *low = isascii(*low) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(*low)]) : *low;861 *low = std::__libcpp_isascii(*low)
862 ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(*low)])
863 : *low;
859#elif defined(__NetBSD__)864#elif defined(__NetBSD__)
860 *low = static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(*low)]);865 *low = static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(*low)]);
861#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)866#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
862 *low = isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low;867 *low = std::__libcpp_isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low;
863#else868#else
864 *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'A' + 'a' : *low;869 *low = (std::__libcpp_isascii(*low) && __locale::__isupper(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'A' + 'a' : *low;
865#endif870#endif
866 return low;871 return low;
867}872}
...@@ -875,14 +880,14 @@ const char* ctype<char>::do_widen(const char* low, const char* high, char_type*...@@ -875,14 +880,14 @@ const char* ctype<char>::do_widen(const char* low, const char* high, char_type*
875}880}
876881
877char ctype<char>::do_narrow(char_type c, char dfault) const {882char ctype<char>::do_narrow(char_type c, char dfault) const {
878 if (isascii(c))883 if (std::__libcpp_isascii(c))
879 return static_cast<char>(c);884 return static_cast<char>(c);
880 return dfault;885 return dfault;
881}886}
882887
883const char* ctype<char>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const {888const char* ctype<char>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const {
884 for (; low != high; ++low, ++dest)889 for (; low != high; ++low, ++dest)
885 if (isascii(*low))890 if (std::__libcpp_isascii(*low))
886 *dest = *low;891 *dest = *low;
887 else892 else
888 *dest = dfault;893 *dest = dfault;
...@@ -1004,7 +1009,7 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept {...@@ -1004,7 +1009,7 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept {
1004# warning ctype<char>::classic_table() is not implemented1009# warning ctype<char>::classic_table() is not implemented
1005 printf("ctype<char>::classic_table() is not implemented\n");1010 printf("ctype<char>::classic_table() is not implemented\n");
1006 abort();1011 abort();
1007 return NULL;1012 return nullptr;
1008# endif1013# endif
1009}1014}
1010#endif1015#endif
...@@ -1042,7 +1047,7 @@ const unsigned short* ctype<char>::__classic_upper_table() _NOEXCEPT {...@@ -1042,7 +1047,7 @@ const unsigned short* ctype<char>::__classic_upper_table() _NOEXCEPT {
1042// template <> class ctype_byname<char>1047// template <> class ctype_byname<char>
10431048
1044ctype_byname<char>::ctype_byname(const char* name, size_t refs)1049ctype_byname<char>::ctype_byname(const char* name, size_t refs)
1045 : ctype<char>(0, false, refs), __l_(newlocale(LC_ALL_MASK, name, 0)) {1050 : ctype<char>(0, false, refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name, 0)) {
1046 if (__l_ == 0)1051 if (__l_ == 0)
1047 __throw_runtime_error(1052 __throw_runtime_error(
1048 ("ctype_byname<char>::ctype_byname"1053 ("ctype_byname<char>::ctype_byname"
...@@ -1052,7 +1057,7 @@ ctype_byname<char>::ctype_byname(const char* name, size_t refs)...@@ -1052,7 +1057,7 @@ ctype_byname<char>::ctype_byname(const char* name, size_t refs)
1052}1057}
10531058
1054ctype_byname<char>::ctype_byname(const string& name, size_t refs)1059ctype_byname<char>::ctype_byname(const string& name, size_t refs)
1055 : ctype<char>(0, false, refs), __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) {1060 : ctype<char>(0, false, refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) {
1056 if (__l_ == 0)1061 if (__l_ == 0)
1057 __throw_runtime_error(1062 __throw_runtime_error(
1058 ("ctype_byname<char>::ctype_byname"1063 ("ctype_byname<char>::ctype_byname"
...@@ -1061,33 +1066,33 @@ ctype_byname<char>::ctype_byname(const string& name, size_t refs)...@@ -1061,33 +1066,33 @@ ctype_byname<char>::ctype_byname(const string& name, size_t refs)
1061 .c_str());1066 .c_str());
1062}1067}
10631068
1064ctype_byname<char>::~ctype_byname() { freelocale(__l_); }1069ctype_byname<char>::~ctype_byname() { __locale::__freelocale(__l_); }
10651070
1066char ctype_byname<char>::do_toupper(char_type c) const {1071char ctype_byname<char>::do_toupper(char_type c) const {
1067 return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l_));1072 return static_cast<char>(__locale::__toupper(static_cast<unsigned char>(c), __l_));
1068}1073}
10691074
1070const char* ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const {1075const char* ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const {
1071 for (; low != high; ++low)1076 for (; low != high; ++low)
1072 *low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l_));1077 *low = static_cast<char>(__locale::__toupper(static_cast<unsigned char>(*low), __l_));
1073 return low;1078 return low;
1074}1079}
10751080
1076char ctype_byname<char>::do_tolower(char_type c) const {1081char ctype_byname<char>::do_tolower(char_type c) const {
1077 return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l_));1082 return static_cast<char>(__locale::__tolower(static_cast<unsigned char>(c), __l_));
1078}1083}
10791084
1080const char* ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const {1085const char* ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const {
1081 for (; low != high; ++low)1086 for (; low != high; ++low)
1082 *low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l_));1087 *low = static_cast<char>(__locale::__tolower(static_cast<unsigned char>(*low), __l_));
1083 return low;1088 return low;
1084}1089}
10851090
1086// template <> class ctype_byname<wchar_t>1091// template <> class ctype_byname<wchar_t>
10871092
1088#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1093#if _LIBCPP_HAS_WIDE_CHARACTERS
1089ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)1094ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
1090 : ctype<wchar_t>(refs), __l_(newlocale(LC_ALL_MASK, name, 0)) {1095 : ctype<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name, 0)) {
1091 if (__l_ == 0)1096 if (__l_ == 0)
1092 __throw_runtime_error(1097 __throw_runtime_error(
1093 ("ctype_byname<wchar_t>::ctype_byname"1098 ("ctype_byname<wchar_t>::ctype_byname"
...@@ -1097,7 +1102,7 @@ ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)...@@ -1097,7 +1102,7 @@ ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
1097}1102}
10981103
1099ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)1104ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)
1100 : ctype<wchar_t>(refs), __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) {1105 : ctype<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) {
1101 if (__l_ == 0)1106 if (__l_ == 0)
1102 __throw_runtime_error(1107 __throw_runtime_error(
1103 ("ctype_byname<wchar_t>::ctype_byname"1108 ("ctype_byname<wchar_t>::ctype_byname"
...@@ -1106,70 +1111,70 @@ ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)...@@ -1106,70 +1111,70 @@ ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)
1106 .c_str());1111 .c_str());
1107}1112}
11081113
1109ctype_byname<wchar_t>::~ctype_byname() { freelocale(__l_); }1114ctype_byname<wchar_t>::~ctype_byname() { __locale::__freelocale(__l_); }
11101115
1111bool ctype_byname<wchar_t>::do_is(mask m, char_type c) const {1116bool ctype_byname<wchar_t>::do_is(mask m, char_type c) const {
1117 wint_t ch = static_cast<wint_t>(c);
1112# ifdef _LIBCPP_WCTYPE_IS_MASK1118# ifdef _LIBCPP_WCTYPE_IS_MASK
1113 return static_cast<bool>(iswctype_l(c, m, __l_));1119 return static_cast<bool>(__locale::__iswctype(ch, m, __l_));
1114# else1120# else
1115 bool result = false;1121 bool result = false;
1116 wint_t ch = static_cast<wint_t>(c);
1117 if ((m & space) == space)1122 if ((m & space) == space)
1118 result |= (iswspace_l(ch, __l_) != 0);1123 result |= (__locale::__iswspace(ch, __l_) != 0);
1119 if ((m & print) == print)1124 if ((m & print) == print)
1120 result |= (iswprint_l(ch, __l_) != 0);1125 result |= (__locale::__iswprint(ch, __l_) != 0);
1121 if ((m & cntrl) == cntrl)1126 if ((m & cntrl) == cntrl)
1122 result |= (iswcntrl_l(ch, __l_) != 0);1127 result |= (__locale::__iswcntrl(ch, __l_) != 0);
1123 if ((m & upper) == upper)1128 if ((m & upper) == upper)
1124 result |= (iswupper_l(ch, __l_) != 0);1129 result |= (__locale::__iswupper(ch, __l_) != 0);
1125 if ((m & lower) == lower)1130 if ((m & lower) == lower)
1126 result |= (iswlower_l(ch, __l_) != 0);1131 result |= (__locale::__iswlower(ch, __l_) != 0);
1127 if ((m & alpha) == alpha)1132 if ((m & alpha) == alpha)
1128 result |= (iswalpha_l(ch, __l_) != 0);1133 result |= (__locale::__iswalpha(ch, __l_) != 0);
1129 if ((m & digit) == digit)1134 if ((m & digit) == digit)
1130 result |= (iswdigit_l(ch, __l_) != 0);1135 result |= (__locale::__iswdigit(ch, __l_) != 0);
1131 if ((m & punct) == punct)1136 if ((m & punct) == punct)
1132 result |= (iswpunct_l(ch, __l_) != 0);1137 result |= (__locale::__iswpunct(ch, __l_) != 0);
1133 if ((m & xdigit) == xdigit)1138 if ((m & xdigit) == xdigit)
1134 result |= (iswxdigit_l(ch, __l_) != 0);1139 result |= (__locale::__iswxdigit(ch, __l_) != 0);
1135 if ((m & blank) == blank)1140 if ((m & blank) == blank)
1136 result |= (iswblank_l(ch, __l_) != 0);1141 result |= (__locale::__iswblank(ch, __l_) != 0);
1137 return result;1142 return result;
1138# endif1143# endif
1139}1144}
11401145
1141const wchar_t* ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const {1146const wchar_t* ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const {
1142 for (; low != high; ++low, ++vec) {1147 for (; low != high; ++low, ++vec) {
1143 if (isascii(*low))1148 if (std::__libcpp_isascii(*low))
1144 *vec = static_cast<mask>(ctype<char>::classic_table()[*low]);1149 *vec = static_cast<mask>(ctype<char>::classic_table()[*low]);
1145 else {1150 else {
1146 *vec = 0;1151 *vec = 0;
1147 wint_t ch = static_cast<wint_t>(*low);1152 wint_t ch = static_cast<wint_t>(*low);
1148 if (iswspace_l(ch, __l_))1153 if (__locale::__iswspace(ch, __l_))
1149 *vec |= space;1154 *vec |= space;
1150# ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT1155# ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
1151 if (iswprint_l(ch, __l_))1156 if (__locale::__iswprint(ch, __l_))
1152 *vec |= print;1157 *vec |= print;
1153# endif1158# endif
1154 if (iswcntrl_l(ch, __l_))1159 if (__locale::__iswcntrl(ch, __l_))
1155 *vec |= cntrl;1160 *vec |= cntrl;
1156 if (iswupper_l(ch, __l_))1161 if (__locale::__iswupper(ch, __l_))
1157 *vec |= upper;1162 *vec |= upper;
1158 if (iswlower_l(ch, __l_))1163 if (__locale::__iswlower(ch, __l_))
1159 *vec |= lower;1164 *vec |= lower;
1160# ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA1165# ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
1161 if (iswalpha_l(ch, __l_))1166 if (__locale::__iswalpha(ch, __l_))
1162 *vec |= alpha;1167 *vec |= alpha;
1163# endif1168# endif
1164 if (iswdigit_l(ch, __l_))1169 if (__locale::__iswdigit(ch, __l_))
1165 *vec |= digit;1170 *vec |= digit;
1166 if (iswpunct_l(ch, __l_))1171 if (__locale::__iswpunct(ch, __l_))
1167 *vec |= punct;1172 *vec |= punct;
1168# ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT1173# ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
1169 if (iswxdigit_l(ch, __l_))1174 if (__locale::__iswxdigit(ch, __l_))
1170 *vec |= xdigit;1175 *vec |= xdigit;
1171# endif1176# endif
1172 if (iswblank_l(ch, __l_))1177 if (__locale::__iswblank(ch, __l_))
1173 *vec |= blank;1178 *vec |= blank;
1174 }1179 }
1175 }1180 }
...@@ -1179,29 +1184,29 @@ const wchar_t* ctype_byname<wchar_t>::do_is(const char_type* low, const char_typ...@@ -1179,29 +1184,29 @@ const wchar_t* ctype_byname<wchar_t>::do_is(const char_type* low, const char_typ
1179const wchar_t* ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const {1184const wchar_t* ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const {
1180 for (; low != high; ++low) {1185 for (; low != high; ++low) {
1181# ifdef _LIBCPP_WCTYPE_IS_MASK1186# ifdef _LIBCPP_WCTYPE_IS_MASK
1182 if (iswctype_l(*low, m, __l_))1187 if (__locale::__iswctype(static_cast<wint_t>(*low), m, __l_))
1183 break;1188 break;
1184# else1189# else
1185 wint_t ch = static_cast<wint_t>(*low);1190 wint_t ch = static_cast<wint_t>(*low);
1186 if ((m & space) == space && iswspace_l(ch, __l_))1191 if ((m & space) == space && __locale::__iswspace(ch, __l_))
1187 break;1192 break;
1188 if ((m & print) == print && iswprint_l(ch, __l_))1193 if ((m & print) == print && __locale::__iswprint(ch, __l_))
1189 break;1194 break;
1190 if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_))1195 if ((m & cntrl) == cntrl && __locale::__iswcntrl(ch, __l_))
1191 break;1196 break;
1192 if ((m & upper) == upper && iswupper_l(ch, __l_))1197 if ((m & upper) == upper && __locale::__iswupper(ch, __l_))
1193 break;1198 break;
1194 if ((m & lower) == lower && iswlower_l(ch, __l_))1199 if ((m & lower) == lower && __locale::__iswlower(ch, __l_))
1195 break;1200 break;
1196 if ((m & alpha) == alpha && iswalpha_l(ch, __l_))1201 if ((m & alpha) == alpha && __locale::__iswalpha(ch, __l_))
1197 break;1202 break;
1198 if ((m & digit) == digit && iswdigit_l(ch, __l_))1203 if ((m & digit) == digit && __locale::__iswdigit(ch, __l_))
1199 break;1204 break;
1200 if ((m & punct) == punct && iswpunct_l(ch, __l_))1205 if ((m & punct) == punct && __locale::__iswpunct(ch, __l_))
1201 break;1206 break;
1202 if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_))1207 if ((m & xdigit) == xdigit && __locale::__iswxdigit(ch, __l_))
1203 break;1208 break;
1204 if ((m & blank) == blank && iswblank_l(ch, __l_))1209 if ((m & blank) == blank && __locale::__iswblank(ch, __l_))
1205 break;1210 break;
1206# endif1211# endif
1207 }1212 }
...@@ -1210,30 +1215,30 @@ const wchar_t* ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, c...@@ -1210,30 +1215,30 @@ const wchar_t* ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, c
12101215
1211const wchar_t* ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const {1216const wchar_t* ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const {
1212 for (; low != high; ++low) {1217 for (; low != high; ++low) {
1218 wint_t ch = static_cast<wint_t>(*low);
1213# ifdef _LIBCPP_WCTYPE_IS_MASK1219# ifdef _LIBCPP_WCTYPE_IS_MASK
1214 if (!iswctype_l(*low, m, __l_))1220 if (!__locale::__iswctype(ch, m, __l_))
1215 break;1221 break;
1216# else1222# else
1217 wint_t ch = static_cast<wint_t>(*low);1223 if ((m & space) == space && __locale::__iswspace(ch, __l_))
1218 if ((m & space) == space && iswspace_l(ch, __l_))
1219 continue;1224 continue;
1220 if ((m & print) == print && iswprint_l(ch, __l_))1225 if ((m & print) == print && __locale::__iswprint(ch, __l_))
1221 continue;1226 continue;
1222 if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_))1227 if ((m & cntrl) == cntrl && __locale::__iswcntrl(ch, __l_))
1223 continue;1228 continue;
1224 if ((m & upper) == upper && iswupper_l(ch, __l_))1229 if ((m & upper) == upper && __locale::__iswupper(ch, __l_))
1225 continue;1230 continue;
1226 if ((m & lower) == lower && iswlower_l(ch, __l_))1231 if ((m & lower) == lower && __locale::__iswlower(ch, __l_))
1227 continue;1232 continue;
1228 if ((m & alpha) == alpha && iswalpha_l(ch, __l_))1233 if ((m & alpha) == alpha && __locale::__iswalpha(ch, __l_))
1229 continue;1234 continue;
1230 if ((m & digit) == digit && iswdigit_l(ch, __l_))1235 if ((m & digit) == digit && __locale::__iswdigit(ch, __l_))
1231 continue;1236 continue;
1232 if ((m & punct) == punct && iswpunct_l(ch, __l_))1237 if ((m & punct) == punct && __locale::__iswpunct(ch, __l_))
1233 continue;1238 continue;
1234 if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_))1239 if ((m & xdigit) == xdigit && __locale::__iswxdigit(ch, __l_))
1235 continue;1240 continue;
1236 if ((m & blank) == blank && iswblank_l(ch, __l_))1241 if ((m & blank) == blank && __locale::__iswblank(ch, __l_))
1237 continue;1242 continue;
1238 break;1243 break;
1239# endif1244# endif
...@@ -1241,44 +1246,44 @@ const wchar_t* ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low,...@@ -1241,44 +1246,44 @@ const wchar_t* ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low,
1241 return low;1246 return low;
1242}1247}
12431248
1244wchar_t ctype_byname<wchar_t>::do_toupper(char_type c) const { return towupper_l(c, __l_); }1249wchar_t ctype_byname<wchar_t>::do_toupper(char_type c) const { return __locale::__towupper(c, __l_); }
12451250
1246const wchar_t* ctype_byname<wchar_t>::do_toupper(char_type* low, const char_type* high) const {1251const wchar_t* ctype_byname<wchar_t>::do_toupper(char_type* low, const char_type* high) const {
1247 for (; low != high; ++low)1252 for (; low != high; ++low)
1248 *low = towupper_l(*low, __l_);1253 *low = __locale::__towupper(*low, __l_);
1249 return low;1254 return low;
1250}1255}
12511256
1252wchar_t ctype_byname<wchar_t>::do_tolower(char_type c) const { return towlower_l(c, __l_); }1257wchar_t ctype_byname<wchar_t>::do_tolower(char_type c) const { return __locale::__towlower(c, __l_); }
12531258
1254const wchar_t* ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const {1259const wchar_t* ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const {
1255 for (; low != high; ++low)1260 for (; low != high; ++low)
1256 *low = towlower_l(*low, __l_);1261 *low = __locale::__towlower(*low, __l_);
1257 return low;1262 return low;
1258}1263}
12591264
1260wchar_t ctype_byname<wchar_t>::do_widen(char c) const { return __libcpp_btowc_l(c, __l_); }1265wchar_t ctype_byname<wchar_t>::do_widen(char c) const { return __locale::__btowc(c, __l_); }
12611266
1262const char* ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const {1267const char* ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const {
1263 for (; low != high; ++low, ++dest)1268 for (; low != high; ++low, ++dest)
1264 *dest = __libcpp_btowc_l(*low, __l_);1269 *dest = __locale::__btowc(*low, __l_);
1265 return low;1270 return low;
1266}1271}
12671272
1268char ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const {1273char ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const {
1269 int r = __libcpp_wctob_l(c, __l_);1274 int r = __locale::__wctob(c, __l_);
1270 return (r != EOF) ? static_cast<char>(r) : dfault;1275 return (r != EOF) ? static_cast<char>(r) : dfault;
1271}1276}
12721277
1273const wchar_t*1278const wchar_t*
1274ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const {1279ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const {
1275 for (; low != high; ++low, ++dest) {1280 for (; low != high; ++low, ++dest) {
1276 int r = __libcpp_wctob_l(*low, __l_);1281 int r = __locale::__wctob(*low, __l_);
1277 *dest = (r != EOF) ? static_cast<char>(r) : dfault;1282 *dest = (r != EOF) ? static_cast<char>(r) : dfault;
1278 }1283 }
1279 return low;1284 return low;
1280}1285}
1281#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS1286#endif // _LIBCPP_HAS_WIDE_CHARACTERS
12821287
1283// template <> class codecvt<char, char, mbstate_t>1288// template <> class codecvt<char, char, mbstate_t>
12841289
...@@ -1331,13 +1336,13 @@ int codecvt<char, char, mbstate_t>::do_max_length() const noexcept { return 1; }...@@ -1331,13 +1336,13 @@ int codecvt<char, char, mbstate_t>::do_max_length() const noexcept { return 1; }
13311336
1332// template <> class codecvt<wchar_t, char, mbstate_t>1337// template <> class codecvt<wchar_t, char, mbstate_t>
13331338
1334#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1339#if _LIBCPP_HAS_WIDE_CHARACTERS
1335constinit locale::id codecvt<wchar_t, char, mbstate_t>::id;1340constinit locale::id codecvt<wchar_t, char, mbstate_t>::id;
13361341
1337codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs) : locale::facet(refs), __l_(_LIBCPP_GET_C_LOCALE) {}1342codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs) : locale::facet(refs), __l_(_LIBCPP_GET_C_LOCALE) {}
13381343
1339codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)1344codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)
1340 : locale::facet(refs), __l_(newlocale(LC_ALL_MASK, nm, 0)) {1345 : locale::facet(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) {
1341 if (__l_ == 0)1346 if (__l_ == 0)
1342 __throw_runtime_error(1347 __throw_runtime_error(
1343 ("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"1348 ("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"
...@@ -1348,7 +1353,7 @@ codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)...@@ -1348,7 +1353,7 @@ codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)
13481353
1349codecvt<wchar_t, char, mbstate_t>::~codecvt() {1354codecvt<wchar_t, char, mbstate_t>::~codecvt() {
1350 if (__l_ != _LIBCPP_GET_C_LOCALE)1355 if (__l_ != _LIBCPP_GET_C_LOCALE)
1351 freelocale(__l_);1356 __locale::__freelocale(__l_);
1352}1357}
13531358
1354codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_out(1359codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_out(
...@@ -1369,12 +1374,12 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_...@@ -1369,12 +1374,12 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_
1369 for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt) {1374 for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt) {
1370 // save state in case it is needed to recover to_nxt on error1375 // save state in case it is needed to recover to_nxt on error
1371 mbstate_t save_state = st;1376 mbstate_t save_state = st;
1372 size_t n = __libcpp_wcsnrtombs_l(1377 size_t n = __locale::__wcsnrtombs(
1373 to, &frm_nxt, static_cast<size_t>(fend - frm), static_cast<size_t>(to_end - to), &st, __l_);1378 to, &frm_nxt, static_cast<size_t>(fend - frm), static_cast<size_t>(to_end - to), &st, __l_);
1374 if (n == size_t(-1)) {1379 if (n == size_t(-1)) {
1375 // need to recover to_nxt1380 // need to recover to_nxt
1376 for (to_nxt = to; frm != frm_nxt; ++frm) {1381 for (to_nxt = to; frm != frm_nxt; ++frm) {
1377 n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l_);1382 n = __locale::__wcrtomb(to_nxt, *frm, &save_state, __l_);
1378 if (n == size_t(-1))1383 if (n == size_t(-1))
1379 break;1384 break;
1380 to_nxt += n;1385 to_nxt += n;
...@@ -1391,7 +1396,7 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_...@@ -1391,7 +1396,7 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_
1391 {1396 {
1392 // Try to write the terminating null1397 // Try to write the terminating null
1393 extern_type tmp[MB_LEN_MAX];1398 extern_type tmp[MB_LEN_MAX];
1394 n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_);1399 n = __locale::__wcrtomb(tmp, intern_type(), &st, __l_);
1395 if (n == size_t(-1)) // on error1400 if (n == size_t(-1)) // on error
1396 return error;1401 return error;
1397 if (n > static_cast<size_t>(to_end - to_nxt)) // is there room?1402 if (n > static_cast<size_t>(to_end - to_nxt)) // is there room?
...@@ -1426,12 +1431,12 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_...@@ -1426,12 +1431,12 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_
1426 for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt) {1431 for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt) {
1427 // save state in case it is needed to recover to_nxt on error1432 // save state in case it is needed to recover to_nxt on error
1428 mbstate_t save_state = st;1433 mbstate_t save_state = st;
1429 size_t n = __libcpp_mbsnrtowcs_l(1434 size_t n = __locale::__mbsnrtowcs(
1430 to, &frm_nxt, static_cast<size_t>(fend - frm), static_cast<size_t>(to_end - to), &st, __l_);1435 to, &frm_nxt, static_cast<size_t>(fend - frm), static_cast<size_t>(to_end - to), &st, __l_);
1431 if (n == size_t(-1)) {1436 if (n == size_t(-1)) {
1432 // need to recover to_nxt1437 // need to recover to_nxt
1433 for (to_nxt = to; frm != frm_nxt; ++to_nxt) {1438 for (to_nxt = to; frm != frm_nxt; ++to_nxt) {
1434 n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend - frm), &save_state, __l_);1439 n = __locale::__mbrtowc(to_nxt, frm, static_cast<size_t>(fend - frm), &save_state, __l_);
1435 switch (n) {1440 switch (n) {
1436 case 0:1441 case 0:
1437 ++frm;1442 ++frm;
...@@ -1458,7 +1463,7 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_...@@ -1458,7 +1463,7 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_
1458 if (fend != frm_end) // set up next null terminated sequence1463 if (fend != frm_end) // set up next null terminated sequence
1459 {1464 {
1460 // Try to write the terminating null1465 // Try to write the terminating null
1461 n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l_);1466 n = __locale::__mbrtowc(to_nxt, frm_nxt, 1, &st, __l_);
1462 if (n != 0) // on error1467 if (n != 0) // on error
1463 return error;1468 return error;
1464 ++to_nxt;1469 ++to_nxt;
...@@ -1476,7 +1481,7 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_...@@ -1476,7 +1481,7 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_
1476 state_type& st, extern_type* to, extern_type* to_end, extern_type*& to_nxt) const {1481 state_type& st, extern_type* to, extern_type* to_end, extern_type*& to_nxt) const {
1477 to_nxt = to;1482 to_nxt = to;
1478 extern_type tmp[MB_LEN_MAX];1483 extern_type tmp[MB_LEN_MAX];
1479 size_t n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_);1484 size_t n = __locale::__wcrtomb(tmp, intern_type(), &st, __l_);
1480 if (n == size_t(-1) || n == 0) // on error1485 if (n == size_t(-1) || n == 0) // on error
1481 return error;1486 return error;
1482 --n;1487 --n;
...@@ -1488,12 +1493,12 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_...@@ -1488,12 +1493,12 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_
1488}1493}
14891494
1490int codecvt<wchar_t, char, mbstate_t>::do_encoding() const noexcept {1495int codecvt<wchar_t, char, mbstate_t>::do_encoding() const noexcept {
1491 if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l_) != 0)1496 if (__locale::__mbtowc(nullptr, nullptr, MB_LEN_MAX, __l_) != 0)
1492 return -1;1497 return -1;
14931498
1494 // stateless encoding1499 // stateless encoding
1495 if (__l_ == 0 || __libcpp_mb_cur_max_l(__l_) == 1) // there are no known constant length encodings1500 if (__l_ == 0 || __locale::__mb_len_max(__l_) == 1) // there are no known constant length encodings
1496 return 1; // which take more than 1 char to form a wchar_t1501 return 1; // which take more than 1 char to form a wchar_t
1497 return 0;1502 return 0;
1498}1503}
14991504
...@@ -1503,7 +1508,7 @@ int codecvt<wchar_t, char, mbstate_t>::do_length(...@@ -1503,7 +1508,7 @@ int codecvt<wchar_t, char, mbstate_t>::do_length(
1503 state_type& st, const extern_type* frm, const extern_type* frm_end, size_t mx) const {1508 state_type& st, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
1504 int nbytes = 0;1509 int nbytes = 0;
1505 for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t) {1510 for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t) {
1506 size_t n = __libcpp_mbrlen_l(frm, static_cast<size_t>(frm_end - frm), &st, __l_);1511 size_t n = __locale::__mbrlen(frm, static_cast<size_t>(frm_end - frm), &st, __l_);
1507 switch (n) {1512 switch (n) {
1508 case 0:1513 case 0:
1509 ++nbytes;1514 ++nbytes;
...@@ -1522,9 +1527,9 @@ int codecvt<wchar_t, char, mbstate_t>::do_length(...@@ -1522,9 +1527,9 @@ int codecvt<wchar_t, char, mbstate_t>::do_length(
1522}1527}
15231528
1524int codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept {1529int codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept {
1525 return __l_ == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l_));1530 return __l_ == 0 ? 1 : static_cast<int>(__locale::__mb_len_max(__l_));
1526}1531}
1527#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS1532#endif // _LIBCPP_HAS_WIDE_CHARACTERS
15281533
1529// Valid UTF ranges1534// Valid UTF ranges
1530// UTF-32 UTF-16 UTF-8 # of code points1535// UTF-32 UTF-16 UTF-8 # of code points
...@@ -2815,7 +2820,7 @@ int codecvt<char16_t, char, mbstate_t>::do_length(...@@ -2815,7 +2820,7 @@ int codecvt<char16_t, char, mbstate_t>::do_length(
28152820
2816int codecvt<char16_t, char, mbstate_t>::do_max_length() const noexcept { return 4; }2821int codecvt<char16_t, char, mbstate_t>::do_max_length() const noexcept { return 4; }
28172822
2818#ifndef _LIBCPP_HAS_NO_CHAR8_T2823#if _LIBCPP_HAS_CHAR8_T
28192824
2820// template <> class codecvt<char16_t, char8_t, mbstate_t>2825// template <> class codecvt<char16_t, char8_t, mbstate_t>
28212826
...@@ -2949,7 +2954,7 @@ int codecvt<char32_t, char, mbstate_t>::do_length(...@@ -2949,7 +2954,7 @@ int codecvt<char32_t, char, mbstate_t>::do_length(
29492954
2950int codecvt<char32_t, char, mbstate_t>::do_max_length() const noexcept { return 4; }2955int codecvt<char32_t, char, mbstate_t>::do_max_length() const noexcept { return 4; }
29512956
2952#ifndef _LIBCPP_HAS_NO_CHAR8_T2957#if _LIBCPP_HAS_CHAR8_T
29532958
2954// template <> class codecvt<char32_t, char8_t, mbstate_t>2959// template <> class codecvt<char32_t, char8_t, mbstate_t>
29552960
...@@ -3020,7 +3025,7 @@ int codecvt<char32_t, char8_t, mbstate_t>::do_max_length() const noexcept { retu...@@ -3020,7 +3025,7 @@ int codecvt<char32_t, char8_t, mbstate_t>::do_max_length() const noexcept { retu
30203025
3021// __codecvt_utf8<wchar_t>3026// __codecvt_utf8<wchar_t>
30223027
3023#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS3028#if _LIBCPP_HAS_WIDE_CHARACTERS
3024__codecvt_utf8<wchar_t>::result __codecvt_utf8<wchar_t>::do_out(3029__codecvt_utf8<wchar_t>::result __codecvt_utf8<wchar_t>::do_out(
3025 state_type&,3030 state_type&,
3026 const intern_type* frm,3031 const intern_type* frm,
...@@ -3111,7 +3116,7 @@ int __codecvt_utf8<wchar_t>::do_max_length() const noexcept {...@@ -3111,7 +3116,7 @@ int __codecvt_utf8<wchar_t>::do_max_length() const noexcept {
3111 return 4;3116 return 4;
3112# endif3117# endif
3113}3118}
3114#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS3119#endif // _LIBCPP_HAS_WIDE_CHARACTERS
31153120
3116// __codecvt_utf8<char16_t>3121// __codecvt_utf8<char16_t>
31173122
...@@ -3249,7 +3254,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -3249,7 +3254,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
32493254
3250// __codecvt_utf16<wchar_t, false>3255// __codecvt_utf16<wchar_t, false>
32513256
3252#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS3257#if _LIBCPP_HAS_WIDE_CHARACTERS
3253__codecvt_utf16<wchar_t, false>::result __codecvt_utf16<wchar_t, false>::do_out(3258__codecvt_utf16<wchar_t, false>::result __codecvt_utf16<wchar_t, false>::do_out(
3254 state_type&,3259 state_type&,
3255 const intern_type* frm,3260 const intern_type* frm,
...@@ -3431,7 +3436,7 @@ int __codecvt_utf16<wchar_t, true>::do_max_length() const noexcept {...@@ -3431,7 +3436,7 @@ int __codecvt_utf16<wchar_t, true>::do_max_length() const noexcept {
3431 return 4;3436 return 4;
3432# endif3437# endif
3433}3438}
3434#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS3439#endif // _LIBCPP_HAS_WIDE_CHARACTERS
34353440
3436// __codecvt_utf16<char16_t, false>3441// __codecvt_utf16<char16_t, false>
34373442
...@@ -3703,7 +3708,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -3703,7 +3708,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
37033708
3704// __codecvt_utf8_utf16<wchar_t>3709// __codecvt_utf8_utf16<wchar_t>
37053710
3706#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS3711#if _LIBCPP_HAS_WIDE_CHARACTERS
3707__codecvt_utf8_utf16<wchar_t>::result __codecvt_utf8_utf16<wchar_t>::do_out(3712__codecvt_utf8_utf16<wchar_t>::result __codecvt_utf8_utf16<wchar_t>::do_out(
3708 state_type&,3713 state_type&,
3709 const intern_type* frm,3714 const intern_type* frm,
...@@ -3778,7 +3783,7 @@ int __codecvt_utf8_utf16<wchar_t>::do_max_length() const noexcept {...@@ -3778,7 +3783,7 @@ int __codecvt_utf8_utf16<wchar_t>::do_max_length() const noexcept {
3778 return 7;3783 return 7;
3779 return 4;3784 return 4;
3780}3785}
3781#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS3786#endif // _LIBCPP_HAS_WIDE_CHARACTERS
37823787
3783// __codecvt_utf8_utf16<char16_t>3788// __codecvt_utf8_utf16<char16_t>
37843789
...@@ -3930,22 +3935,22 @@ __widen_from_utf8<16>::~__widen_from_utf8() {}...@@ -3930,22 +3935,22 @@ __widen_from_utf8<16>::~__widen_from_utf8() {}
39303935
3931__widen_from_utf8<32>::~__widen_from_utf8() {}3936__widen_from_utf8<32>::~__widen_from_utf8() {}
39323937
3933#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS3938#if _LIBCPP_HAS_WIDE_CHARACTERS
3934static bool checked_string_to_wchar_convert(wchar_t& dest, const char* ptr, locale_t loc) {3939static bool checked_string_to_wchar_convert(wchar_t& dest, const char* ptr, __locale::__locale_t loc) {
3935 if (*ptr == '\0')3940 if (*ptr == '\0')
3936 return false;3941 return false;
3937 mbstate_t mb = {};3942 mbstate_t mb = {};
3938 wchar_t out;3943 wchar_t out;
3939 size_t ret = __libcpp_mbrtowc_l(&out, ptr, strlen(ptr), &mb, loc);3944 size_t ret = __locale::__mbrtowc(&out, ptr, strlen(ptr), &mb, loc);
3940 if (ret == static_cast<size_t>(-1) || ret == static_cast<size_t>(-2)) {3945 if (ret == static_cast<size_t>(-1) || ret == static_cast<size_t>(-2)) {
3941 return false;3946 return false;
3942 }3947 }
3943 dest = out;3948 dest = out;
3944 return true;3949 return true;
3945}3950}
3946#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS3951#endif // _LIBCPP_HAS_WIDE_CHARACTERS
39473952
3948#ifdef _LIBCPP_HAS_NO_WIDE_CHARACTERS3953#if !_LIBCPP_HAS_WIDE_CHARACTERS
3949static bool is_narrow_non_breaking_space(const char* ptr) {3954static bool is_narrow_non_breaking_space(const char* ptr) {
3950 // https://www.fileformat.info/info/unicode/char/202f/index.htm3955 // https://www.fileformat.info/info/unicode/char/202f/index.htm
3951 return ptr[0] == '\xe2' && ptr[1] == '\x80' && ptr[2] == '\xaf';3956 return ptr[0] == '\xe2' && ptr[1] == '\x80' && ptr[2] == '\xaf';
...@@ -3955,9 +3960,9 @@ static bool is_non_breaking_space(const char* ptr) {...@@ -3955,9 +3960,9 @@ static bool is_non_breaking_space(const char* ptr) {
3955 // https://www.fileformat.info/info/unicode/char/0a/index.htm3960 // https://www.fileformat.info/info/unicode/char/0a/index.htm
3956 return ptr[0] == '\xc2' && ptr[1] == '\xa0';3961 return ptr[0] == '\xc2' && ptr[1] == '\xa0';
3957}3962}
3958#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS3963#endif // _LIBCPP_HAS_WIDE_CHARACTERS
39593964
3960static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t __loc) {3965static bool checked_string_to_char_convert(char& dest, const char* ptr, __locale::__locale_t __loc) {
3961 if (*ptr == '\0')3966 if (*ptr == '\0')
3962 return false;3967 return false;
3963 if (!ptr[1]) {3968 if (!ptr[1]) {
...@@ -3965,14 +3970,14 @@ static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t...@@ -3965,14 +3970,14 @@ static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t
3965 return true;3970 return true;
3966 }3971 }
39673972
3968#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS3973#if _LIBCPP_HAS_WIDE_CHARACTERS
3969 // First convert the MBS into a wide char then attempt to narrow it using3974 // First convert the MBS into a wide char then attempt to narrow it using
3970 // wctob_l.3975 // wctob_l.
3971 wchar_t wout;3976 wchar_t wout;
3972 if (!checked_string_to_wchar_convert(wout, ptr, __loc))3977 if (!checked_string_to_wchar_convert(wout, ptr, __loc))
3973 return false;3978 return false;
3974 int res;3979 int res;
3975 if ((res = __libcpp_wctob_l(wout, __loc)) != char_traits<char>::eof()) {3980 if ((res = __locale::__wctob(wout, __loc)) != char_traits<char>::eof()) {
3976 dest = res;3981 dest = res;
3977 return true;3982 return true;
3978 }3983 }
...@@ -3986,7 +3991,7 @@ static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t...@@ -3986,7 +3991,7 @@ static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t
3986 default:3991 default:
3987 return false;3992 return false;
3988 }3993 }
3989#else // _LIBCPP_HAS_NO_WIDE_CHARACTERS3994#else // _LIBCPP_HAS_WIDE_CHARACTERS
3990 // FIXME: Work around specific multibyte sequences that we can reasonably3995 // FIXME: Work around specific multibyte sequences that we can reasonably
3991 // translate into a different single byte.3996 // translate into a different single byte.
3992 if (is_narrow_non_breaking_space(ptr) || is_non_breaking_space(ptr)) {3997 if (is_narrow_non_breaking_space(ptr) || is_non_breaking_space(ptr)) {
...@@ -3995,51 +4000,51 @@ static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t...@@ -3995,51 +4000,51 @@ static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t
3995 }4000 }
39964001
3997 return false;4002 return false;
3998#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS4003#endif // _LIBCPP_HAS_WIDE_CHARACTERS
3999 __libcpp_unreachable();4004 __libcpp_unreachable();
4000}4005}
40014006
4002// numpunct<char> && numpunct<wchar_t>4007// numpunct<char> && numpunct<wchar_t>
40034008
4004constinit locale::id numpunct<char>::id;4009constinit locale::id numpunct<char>::id;
4005#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4010#if _LIBCPP_HAS_WIDE_CHARACTERS
4006constinit locale::id numpunct<wchar_t>::id;4011constinit locale::id numpunct<wchar_t>::id;
4007#endif4012#endif
40084013
4009numpunct<char>::numpunct(size_t refs) : locale::facet(refs), __decimal_point_('.'), __thousands_sep_(',') {}4014numpunct<char>::numpunct(size_t refs) : locale::facet(refs), __decimal_point_('.'), __thousands_sep_(',') {}
40104015
4011#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4016#if _LIBCPP_HAS_WIDE_CHARACTERS
4012numpunct<wchar_t>::numpunct(size_t refs) : locale::facet(refs), __decimal_point_(L'.'), __thousands_sep_(L',') {}4017numpunct<wchar_t>::numpunct(size_t refs) : locale::facet(refs), __decimal_point_(L'.'), __thousands_sep_(L',') {}
4013#endif4018#endif
40144019
4015numpunct<char>::~numpunct() {}4020numpunct<char>::~numpunct() {}
40164021
4017#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4022#if _LIBCPP_HAS_WIDE_CHARACTERS
4018numpunct<wchar_t>::~numpunct() {}4023numpunct<wchar_t>::~numpunct() {}
4019#endif4024#endif
40204025
4021char numpunct< char >::do_decimal_point() const { return __decimal_point_; }4026char numpunct< char >::do_decimal_point() const { return __decimal_point_; }
4022#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4027#if _LIBCPP_HAS_WIDE_CHARACTERS
4023wchar_t numpunct<wchar_t>::do_decimal_point() const { return __decimal_point_; }4028wchar_t numpunct<wchar_t>::do_decimal_point() const { return __decimal_point_; }
4024#endif4029#endif
40254030
4026char numpunct< char >::do_thousands_sep() const { return __thousands_sep_; }4031char numpunct< char >::do_thousands_sep() const { return __thousands_sep_; }
4027#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4032#if _LIBCPP_HAS_WIDE_CHARACTERS
4028wchar_t numpunct<wchar_t>::do_thousands_sep() const { return __thousands_sep_; }4033wchar_t numpunct<wchar_t>::do_thousands_sep() const { return __thousands_sep_; }
4029#endif4034#endif
40304035
4031string numpunct< char >::do_grouping() const { return __grouping_; }4036string numpunct< char >::do_grouping() const { return __grouping_; }
4032#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4037#if _LIBCPP_HAS_WIDE_CHARACTERS
4033string numpunct<wchar_t>::do_grouping() const { return __grouping_; }4038string numpunct<wchar_t>::do_grouping() const { return __grouping_; }
4034#endif4039#endif
40354040
4036string numpunct< char >::do_truename() const { return "true"; }4041string numpunct< char >::do_truename() const { return "true"; }
4037#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4042#if _LIBCPP_HAS_WIDE_CHARACTERS
4038wstring numpunct<wchar_t>::do_truename() const { return L"true"; }4043wstring numpunct<wchar_t>::do_truename() const { return L"true"; }
4039#endif4044#endif
40404045
4041string numpunct< char >::do_falsename() const { return "false"; }4046string numpunct< char >::do_falsename() const { return "false"; }
4042#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4047#if _LIBCPP_HAS_WIDE_CHARACTERS
4043wstring numpunct<wchar_t>::do_falsename() const { return L"false"; }4048wstring numpunct<wchar_t>::do_falsename() const { return L"false"; }
4044#endif4049#endif
40454050
...@@ -4062,7 +4067,7 @@ void numpunct_byname<char>::__init(const char* nm) {...@@ -4062,7 +4067,7 @@ void numpunct_byname<char>::__init(const char* nm) {
4062 string(nm))4067 string(nm))
4063 .c_str());4068 .c_str());
40644069
4065 lconv* lc = __libcpp_localeconv_l(loc.get());4070 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());
4066 if (!checked_string_to_char_convert(__decimal_point_, lc->decimal_point, loc.get()))4071 if (!checked_string_to_char_convert(__decimal_point_, lc->decimal_point, loc.get()))
4067 __decimal_point_ = base::do_decimal_point();4072 __decimal_point_ = base::do_decimal_point();
4068 if (!checked_string_to_char_convert(__thousands_sep_, lc->thousands_sep, loc.get()))4073 if (!checked_string_to_char_convert(__thousands_sep_, lc->thousands_sep, loc.get()))
...@@ -4074,7 +4079,7 @@ void numpunct_byname<char>::__init(const char* nm) {...@@ -4074,7 +4079,7 @@ void numpunct_byname<char>::__init(const char* nm) {
40744079
4075// numpunct_byname<wchar_t>4080// numpunct_byname<wchar_t>
40764081
4077#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4082#if _LIBCPP_HAS_WIDE_CHARACTERS
4078numpunct_byname<wchar_t>::numpunct_byname(const char* nm, size_t refs) : numpunct<wchar_t>(refs) { __init(nm); }4083numpunct_byname<wchar_t>::numpunct_byname(const char* nm, size_t refs) : numpunct<wchar_t>(refs) { __init(nm); }
40794084
4080numpunct_byname<wchar_t>::numpunct_byname(const string& nm, size_t refs) : numpunct<wchar_t>(refs) {4085numpunct_byname<wchar_t>::numpunct_byname(const string& nm, size_t refs) : numpunct<wchar_t>(refs) {
...@@ -4093,14 +4098,14 @@ void numpunct_byname<wchar_t>::__init(const char* nm) {...@@ -4093,14 +4098,14 @@ void numpunct_byname<wchar_t>::__init(const char* nm) {
4093 string(nm))4098 string(nm))
4094 .c_str());4099 .c_str());
40954100
4096 lconv* lc = __libcpp_localeconv_l(loc.get());4101 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());
4097 checked_string_to_wchar_convert(__decimal_point_, lc->decimal_point, loc.get());4102 checked_string_to_wchar_convert(__decimal_point_, lc->decimal_point, loc.get());
4098 checked_string_to_wchar_convert(__thousands_sep_, lc->thousands_sep, loc.get());4103 checked_string_to_wchar_convert(__thousands_sep_, lc->thousands_sep, loc.get());
4099 __grouping_ = lc->grouping;4104 __grouping_ = lc->grouping;
4100 // localization for truename and falsename is not available4105 // localization for truename and falsename is not available
4101 }4106 }
4102}4107}
4103#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS4108#endif // _LIBCPP_HAS_WIDE_CHARACTERS
41044109
4105// num_get helpers4110// num_get helpers
41064111
...@@ -4240,7 +4245,7 @@ static string* init_weeks() {...@@ -4240,7 +4245,7 @@ static string* init_weeks() {
4240 return weeks;4245 return weeks;
4241}4246}
42424247
4243#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4248#if _LIBCPP_HAS_WIDE_CHARACTERS
4244static wstring* init_wweeks() {4249static wstring* init_wweeks() {
4245 static wstring weeks[14];4250 static wstring weeks[14];
4246 weeks[0] = L"Sunday";4251 weeks[0] = L"Sunday";
...@@ -4267,7 +4272,7 @@ const string* __time_get_c_storage<char>::__weeks() const {...@@ -4267,7 +4272,7 @@ const string* __time_get_c_storage<char>::__weeks() const {
4267 return weeks;4272 return weeks;
4268}4273}
42694274
4270#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4275#if _LIBCPP_HAS_WIDE_CHARACTERS
4271template <>4276template <>
4272const wstring* __time_get_c_storage<wchar_t>::__weeks() const {4277const wstring* __time_get_c_storage<wchar_t>::__weeks() const {
4273 static const wstring* weeks = init_wweeks();4278 static const wstring* weeks = init_wweeks();
...@@ -4304,7 +4309,7 @@ static string* init_months() {...@@ -4304,7 +4309,7 @@ static string* init_months() {
4304 return months;4309 return months;
4305}4310}
43064311
4307#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4312#if _LIBCPP_HAS_WIDE_CHARACTERS
4308static wstring* init_wmonths() {4313static wstring* init_wmonths() {
4309 static wstring months[24];4314 static wstring months[24];
4310 months[0] = L"January";4315 months[0] = L"January";
...@@ -4341,7 +4346,7 @@ const string* __time_get_c_storage<char>::__months() const {...@@ -4341,7 +4346,7 @@ const string* __time_get_c_storage<char>::__months() const {
4341 return months;4346 return months;
4342}4347}
43434348
4344#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4349#if _LIBCPP_HAS_WIDE_CHARACTERS
4345template <>4350template <>
4346const wstring* __time_get_c_storage<wchar_t>::__months() const {4351const wstring* __time_get_c_storage<wchar_t>::__months() const {
4347 static const wstring* months = init_wmonths();4352 static const wstring* months = init_wmonths();
...@@ -4356,7 +4361,7 @@ static string* init_am_pm() {...@@ -4356,7 +4361,7 @@ static string* init_am_pm() {
4356 return am_pm;4361 return am_pm;
4357}4362}
43584363
4359#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4364#if _LIBCPP_HAS_WIDE_CHARACTERS
4360static wstring* init_wam_pm() {4365static wstring* init_wam_pm() {
4361 static wstring am_pm[2];4366 static wstring am_pm[2];
4362 am_pm[0] = L"AM";4367 am_pm[0] = L"AM";
...@@ -4371,7 +4376,7 @@ const string* __time_get_c_storage<char>::__am_pm() const {...@@ -4371,7 +4376,7 @@ const string* __time_get_c_storage<char>::__am_pm() const {
4371 return am_pm;4376 return am_pm;
4372}4377}
43734378
4374#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4379#if _LIBCPP_HAS_WIDE_CHARACTERS
4375template <>4380template <>
4376const wstring* __time_get_c_storage<wchar_t>::__am_pm() const {4381const wstring* __time_get_c_storage<wchar_t>::__am_pm() const {
4377 static const wstring* am_pm = init_wam_pm();4382 static const wstring* am_pm = init_wam_pm();
...@@ -4385,7 +4390,7 @@ const string& __time_get_c_storage<char>::__x() const {...@@ -4385,7 +4390,7 @@ const string& __time_get_c_storage<char>::__x() const {
4385 return s;4390 return s;
4386}4391}
43874392
4388#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4393#if _LIBCPP_HAS_WIDE_CHARACTERS
4389template <>4394template <>
4390const wstring& __time_get_c_storage<wchar_t>::__x() const {4395const wstring& __time_get_c_storage<wchar_t>::__x() const {
4391 static wstring s(L"%m/%d/%y");4396 static wstring s(L"%m/%d/%y");
...@@ -4399,7 +4404,7 @@ const string& __time_get_c_storage<char>::__X() const {...@@ -4399,7 +4404,7 @@ const string& __time_get_c_storage<char>::__X() const {
4399 return s;4404 return s;
4400}4405}
44014406
4402#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4407#if _LIBCPP_HAS_WIDE_CHARACTERS
4403template <>4408template <>
4404const wstring& __time_get_c_storage<wchar_t>::__X() const {4409const wstring& __time_get_c_storage<wchar_t>::__X() const {
4405 static wstring s(L"%H:%M:%S");4410 static wstring s(L"%H:%M:%S");
...@@ -4413,7 +4418,7 @@ const string& __time_get_c_storage<char>::__c() const {...@@ -4413,7 +4418,7 @@ const string& __time_get_c_storage<char>::__c() const {
4413 return s;4418 return s;
4414}4419}
44154420
4416#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4421#if _LIBCPP_HAS_WIDE_CHARACTERS
4417template <>4422template <>
4418const wstring& __time_get_c_storage<wchar_t>::__c() const {4423const wstring& __time_get_c_storage<wchar_t>::__c() const {
4419 static wstring s(L"%a %b %d %H:%M:%S %Y");4424 static wstring s(L"%a %b %d %H:%M:%S %Y");
...@@ -4427,7 +4432,7 @@ const string& __time_get_c_storage<char>::__r() const {...@@ -4427,7 +4432,7 @@ const string& __time_get_c_storage<char>::__r() const {
4427 return s;4432 return s;
4428}4433}
44294434
4430#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4435#if _LIBCPP_HAS_WIDE_CHARACTERS
4431template <>4436template <>
4432const wstring& __time_get_c_storage<wchar_t>::__r() const {4437const wstring& __time_get_c_storage<wchar_t>::__r() const {
4433 static wstring s(L"%I:%M:%S %p");4438 static wstring s(L"%I:%M:%S %p");
...@@ -4437,17 +4442,17 @@ const wstring& __time_get_c_storage<wchar_t>::__r() const {...@@ -4437,17 +4442,17 @@ const wstring& __time_get_c_storage<wchar_t>::__r() const {
44374442
4438// time_get_byname4443// time_get_byname
44394444
4440__time_get::__time_get(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) {4445__time_get::__time_get(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) {
4441 if (__loc_ == 0)4446 if (__loc_ == 0)
4442 __throw_runtime_error(("time_get_byname failed to construct for " + string(nm)).c_str());4447 __throw_runtime_error(("time_get_byname failed to construct for " + string(nm)).c_str());
4443}4448}
44444449
4445__time_get::__time_get(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) {4450__time_get::__time_get(const string& nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm.c_str(), 0)) {
4446 if (__loc_ == 0)4451 if (__loc_ == 0)
4447 __throw_runtime_error(("time_get_byname failed to construct for " + nm).c_str());4452 __throw_runtime_error(("time_get_byname failed to construct for " + nm).c_str());
4448}4453}
44494454
4450__time_get::~__time_get() { freelocale(__loc_); }4455__time_get::~__time_get() { __locale::__freelocale(__loc_); }
44514456
4452_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")4457_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
44534458
...@@ -4467,7 +4472,7 @@ string __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) {...@@ -4467,7 +4472,7 @@ string __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) {
4467 char f[3] = {0};4472 char f[3] = {0};
4468 f[0] = '%';4473 f[0] = '%';
4469 f[1] = fmt;4474 f[1] = fmt;
4470 size_t n = strftime_l(buf, countof(buf), f, &t, __loc_);4475 size_t n = __locale::__strftime(buf, countof(buf), f, &t, __loc_);
4471 char* bb = buf;4476 char* bb = buf;
4472 char* be = buf + n;4477 char* be = buf + n;
4473 string result;4478 string result;
...@@ -4581,7 +4586,7 @@ string __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) {...@@ -4581,7 +4586,7 @@ string __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) {
45814586
4582_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-braces")4587_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-braces")
45834588
4584#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4589#if _LIBCPP_HAS_WIDE_CHARACTERS
4585template <>4590template <>
4586wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct) {4591wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct) {
4587 tm t = {0};4592 tm t = {0};
...@@ -4598,12 +4603,12 @@ wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& c...@@ -4598,12 +4603,12 @@ wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& c
4598 char f[3] = {0};4603 char f[3] = {0};
4599 f[0] = '%';4604 f[0] = '%';
4600 f[1] = fmt;4605 f[1] = fmt;
4601 strftime_l(buf, countof(buf), f, &t, __loc_);4606 __locale::__strftime(buf, countof(buf), f, &t, __loc_);
4602 wchar_t wbuf[100];4607 wchar_t wbuf[100];
4603 wchar_t* wbb = wbuf;4608 wchar_t* wbb = wbuf;
4604 mbstate_t mb = {0};4609 mbstate_t mb = {0};
4605 const char* bb = buf;4610 const char* bb = buf;
4606 size_t j = __libcpp_mbsrtowcs_l(wbb, &bb, countof(wbuf), &mb, __loc_);4611 size_t j = __locale::__mbsrtowcs(wbb, &bb, countof(wbuf), &mb, __loc_);
4607 if (j == size_t(-1))4612 if (j == size_t(-1))
4608 __throw_runtime_error("locale not supported");4613 __throw_runtime_error("locale not supported");
4609 wchar_t* wbe = wbb + j;4614 wchar_t* wbe = wbb + j;
...@@ -4715,7 +4720,7 @@ wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& c...@@ -4715,7 +4720,7 @@ wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& c
4715 }4720 }
4716 return result;4721 return result;
4717}4722}
4718#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS4723#endif // _LIBCPP_HAS_WIDE_CHARACTERS
47194724
4720template <>4725template <>
4721void __time_get_storage<char>::init(const ctype<char>& ct) {4726void __time_get_storage<char>::init(const ctype<char>& ct) {
...@@ -4724,25 +4729,25 @@ void __time_get_storage<char>::init(const ctype<char>& ct) {...@@ -4724,25 +4729,25 @@ void __time_get_storage<char>::init(const ctype<char>& ct) {
4724 // __weeks_4729 // __weeks_
4725 for (int i = 0; i < 7; ++i) {4730 for (int i = 0; i < 7; ++i) {
4726 t.tm_wday = i;4731 t.tm_wday = i;
4727 strftime_l(buf, countof(buf), "%A", &t, __loc_);4732 __locale::__strftime(buf, countof(buf), "%A", &t, __loc_);
4728 __weeks_[i] = buf;4733 __weeks_[i] = buf;
4729 strftime_l(buf, countof(buf), "%a", &t, __loc_);4734 __locale::__strftime(buf, countof(buf), "%a", &t, __loc_);
4730 __weeks_[i + 7] = buf;4735 __weeks_[i + 7] = buf;
4731 }4736 }
4732 // __months_4737 // __months_
4733 for (int i = 0; i < 12; ++i) {4738 for (int i = 0; i < 12; ++i) {
4734 t.tm_mon = i;4739 t.tm_mon = i;
4735 strftime_l(buf, countof(buf), "%B", &t, __loc_);4740 __locale::__strftime(buf, countof(buf), "%B", &t, __loc_);
4736 __months_[i] = buf;4741 __months_[i] = buf;
4737 strftime_l(buf, countof(buf), "%b", &t, __loc_);4742 __locale::__strftime(buf, countof(buf), "%b", &t, __loc_);
4738 __months_[i + 12] = buf;4743 __months_[i + 12] = buf;
4739 }4744 }
4740 // __am_pm_4745 // __am_pm_
4741 t.tm_hour = 1;4746 t.tm_hour = 1;
4742 strftime_l(buf, countof(buf), "%p", &t, __loc_);4747 __locale::__strftime(buf, countof(buf), "%p", &t, __loc_);
4743 __am_pm_[0] = buf;4748 __am_pm_[0] = buf;
4744 t.tm_hour = 13;4749 t.tm_hour = 13;
4745 strftime_l(buf, countof(buf), "%p", &t, __loc_);4750 __locale::__strftime(buf, countof(buf), "%p", &t, __loc_);
4746 __am_pm_[1] = buf;4751 __am_pm_[1] = buf;
4747 __c_ = __analyze('c', ct);4752 __c_ = __analyze('c', ct);
4748 __r_ = __analyze('r', ct);4753 __r_ = __analyze('r', ct);
...@@ -4750,7 +4755,7 @@ void __time_get_storage<char>::init(const ctype<char>& ct) {...@@ -4750,7 +4755,7 @@ void __time_get_storage<char>::init(const ctype<char>& ct) {
4750 __X_ = __analyze('X', ct);4755 __X_ = __analyze('X', ct);
4751}4756}
47524757
4753#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4758#if _LIBCPP_HAS_WIDE_CHARACTERS
4754template <>4759template <>
4755void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {4760void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {
4756 tm t = {0};4761 tm t = {0};
...@@ -4761,18 +4766,18 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {...@@ -4761,18 +4766,18 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {
4761 // __weeks_4766 // __weeks_
4762 for (int i = 0; i < 7; ++i) {4767 for (int i = 0; i < 7; ++i) {
4763 t.tm_wday = i;4768 t.tm_wday = i;
4764 strftime_l(buf, countof(buf), "%A", &t, __loc_);4769 __locale::__strftime(buf, countof(buf), "%A", &t, __loc_);
4765 mb = mbstate_t();4770 mb = mbstate_t();
4766 const char* bb = buf;4771 const char* bb = buf;
4767 size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);4772 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);
4768 if (j == size_t(-1) || j == 0)4773 if (j == size_t(-1) || j == 0)
4769 __throw_runtime_error("locale not supported");4774 __throw_runtime_error("locale not supported");
4770 wbe = wbuf + j;4775 wbe = wbuf + j;
4771 __weeks_[i].assign(wbuf, wbe);4776 __weeks_[i].assign(wbuf, wbe);
4772 strftime_l(buf, countof(buf), "%a", &t, __loc_);4777 __locale::__strftime(buf, countof(buf), "%a", &t, __loc_);
4773 mb = mbstate_t();4778 mb = mbstate_t();
4774 bb = buf;4779 bb = buf;
4775 j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);4780 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);
4776 if (j == size_t(-1) || j == 0)4781 if (j == size_t(-1) || j == 0)
4777 __throw_runtime_error("locale not supported");4782 __throw_runtime_error("locale not supported");
4778 wbe = wbuf + j;4783 wbe = wbuf + j;
...@@ -4781,18 +4786,18 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {...@@ -4781,18 +4786,18 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {
4781 // __months_4786 // __months_
4782 for (int i = 0; i < 12; ++i) {4787 for (int i = 0; i < 12; ++i) {
4783 t.tm_mon = i;4788 t.tm_mon = i;
4784 strftime_l(buf, countof(buf), "%B", &t, __loc_);4789 __locale::__strftime(buf, countof(buf), "%B", &t, __loc_);
4785 mb = mbstate_t();4790 mb = mbstate_t();
4786 const char* bb = buf;4791 const char* bb = buf;
4787 size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);4792 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);
4788 if (j == size_t(-1) || j == 0)4793 if (j == size_t(-1) || j == 0)
4789 __throw_runtime_error("locale not supported");4794 __throw_runtime_error("locale not supported");
4790 wbe = wbuf + j;4795 wbe = wbuf + j;
4791 __months_[i].assign(wbuf, wbe);4796 __months_[i].assign(wbuf, wbe);
4792 strftime_l(buf, countof(buf), "%b", &t, __loc_);4797 __locale::__strftime(buf, countof(buf), "%b", &t, __loc_);
4793 mb = mbstate_t();4798 mb = mbstate_t();
4794 bb = buf;4799 bb = buf;
4795 j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);4800 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);
4796 if (j == size_t(-1) || j == 0)4801 if (j == size_t(-1) || j == 0)
4797 __throw_runtime_error("locale not supported");4802 __throw_runtime_error("locale not supported");
4798 wbe = wbuf + j;4803 wbe = wbuf + j;
...@@ -4800,19 +4805,19 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {...@@ -4800,19 +4805,19 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {
4800 }4805 }
4801 // __am_pm_4806 // __am_pm_
4802 t.tm_hour = 1;4807 t.tm_hour = 1;
4803 strftime_l(buf, countof(buf), "%p", &t, __loc_);4808 __locale::__strftime(buf, countof(buf), "%p", &t, __loc_);
4804 mb = mbstate_t();4809 mb = mbstate_t();
4805 const char* bb = buf;4810 const char* bb = buf;
4806 size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);4811 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);
4807 if (j == size_t(-1))4812 if (j == size_t(-1))
4808 __throw_runtime_error("locale not supported");4813 __throw_runtime_error("locale not supported");
4809 wbe = wbuf + j;4814 wbe = wbuf + j;
4810 __am_pm_[0].assign(wbuf, wbe);4815 __am_pm_[0].assign(wbuf, wbe);
4811 t.tm_hour = 13;4816 t.tm_hour = 13;
4812 strftime_l(buf, countof(buf), "%p", &t, __loc_);4817 __locale::__strftime(buf, countof(buf), "%p", &t, __loc_);
4813 mb = mbstate_t();4818 mb = mbstate_t();
4814 bb = buf;4819 bb = buf;
4815 j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);4820 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);
4816 if (j == size_t(-1))4821 if (j == size_t(-1))
4817 __throw_runtime_error("locale not supported");4822 __throw_runtime_error("locale not supported");
4818 wbe = wbuf + j;4823 wbe = wbuf + j;
...@@ -4822,7 +4827,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {...@@ -4822,7 +4827,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {
4822 __x_ = __analyze('x', ct);4827 __x_ = __analyze('x', ct);
4823 __X_ = __analyze('X', ct);4828 __X_ = __analyze('X', ct);
4824}4829}
4825#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS4830#endif // _LIBCPP_HAS_WIDE_CHARACTERS
48264831
4827template <class CharT>4832template <class CharT>
4828struct _LIBCPP_HIDDEN __time_get_temp : public ctype_byname<CharT> {4833struct _LIBCPP_HIDDEN __time_get_temp : public ctype_byname<CharT> {
...@@ -4842,7 +4847,7 @@ __time_get_storage<char>::__time_get_storage(const string& __nm) : __time_get(__...@@ -4842,7 +4847,7 @@ __time_get_storage<char>::__time_get_storage(const string& __nm) : __time_get(__
4842 init(ct);4847 init(ct);
4843}4848}
48444849
4845#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4850#if _LIBCPP_HAS_WIDE_CHARACTERS
4846template <>4851template <>
4847__time_get_storage<wchar_t>::__time_get_storage(const char* __nm) : __time_get(__nm) {4852__time_get_storage<wchar_t>::__time_get_storage(const char* __nm) : __time_get(__nm) {
4848 const __time_get_temp<wchar_t> ct(__nm);4853 const __time_get_temp<wchar_t> ct(__nm);
...@@ -4854,7 +4859,7 @@ __time_get_storage<wchar_t>::__time_get_storage(const string& __nm) : __time_get...@@ -4854,7 +4859,7 @@ __time_get_storage<wchar_t>::__time_get_storage(const string& __nm) : __time_get
4854 const __time_get_temp<wchar_t> ct(__nm);4859 const __time_get_temp<wchar_t> ct(__nm);
4855 init(ct);4860 init(ct);
4856}4861}
4857#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS4862#endif // _LIBCPP_HAS_WIDE_CHARACTERS
48584863
4859template <>4864template <>
4860time_base::dateorder __time_get_storage<char>::__do_date_order() const {4865time_base::dateorder __time_get_storage<char>::__do_date_order() const {
...@@ -4937,7 +4942,7 @@ time_base::dateorder __time_get_storage<char>::__do_date_order() const {...@@ -4937,7 +4942,7 @@ time_base::dateorder __time_get_storage<char>::__do_date_order() const {
4937 return time_base::no_order;4942 return time_base::no_order;
4938}4943}
49394944
4940#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4945#if _LIBCPP_HAS_WIDE_CHARACTERS
4941template <>4946template <>
4942time_base::dateorder __time_get_storage<wchar_t>::__do_date_order() const {4947time_base::dateorder __time_get_storage<wchar_t>::__do_date_order() const {
4943 unsigned i;4948 unsigned i;
...@@ -5018,46 +5023,46 @@ time_base::dateorder __time_get_storage<wchar_t>::__do_date_order() const {...@@ -5018,46 +5023,46 @@ time_base::dateorder __time_get_storage<wchar_t>::__do_date_order() const {
5018 }5023 }
5019 return time_base::no_order;5024 return time_base::no_order;
5020}5025}
5021#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS5026#endif // _LIBCPP_HAS_WIDE_CHARACTERS
50225027
5023// time_put5028// time_put
50245029
5025__time_put::__time_put(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) {5030__time_put::__time_put(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) {
5026 if (__loc_ == 0)5031 if (__loc_ == 0)
5027 __throw_runtime_error(("time_put_byname failed to construct for " + string(nm)).c_str());5032 __throw_runtime_error(("time_put_byname failed to construct for " + string(nm)).c_str());
5028}5033}
50295034
5030__time_put::__time_put(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) {5035__time_put::__time_put(const string& nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm.c_str(), 0)) {
5031 if (__loc_ == 0)5036 if (__loc_ == 0)
5032 __throw_runtime_error(("time_put_byname failed to construct for " + nm).c_str());5037 __throw_runtime_error(("time_put_byname failed to construct for " + nm).c_str());
5033}5038}
50345039
5035__time_put::~__time_put() {5040__time_put::~__time_put() {
5036 if (__loc_ != _LIBCPP_GET_C_LOCALE)5041 if (__loc_ != _LIBCPP_GET_C_LOCALE)
5037 freelocale(__loc_);5042 __locale::__freelocale(__loc_);
5038}5043}
50395044
5040void __time_put::__do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const {5045void __time_put::__do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const {
5041 char fmt[] = {'%', __fmt, __mod, 0};5046 char fmt[] = {'%', __fmt, __mod, 0};
5042 if (__mod != 0)5047 if (__mod != 0)
5043 swap(fmt[1], fmt[2]);5048 swap(fmt[1], fmt[2]);
5044 size_t n = strftime_l(__nb, countof(__nb, __ne), fmt, __tm, __loc_);5049 size_t n = __locale::__strftime(__nb, countof(__nb, __ne), fmt, __tm, __loc_);
5045 __ne = __nb + n;5050 __ne = __nb + n;
5046}5051}
50475052
5048#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS5053#if _LIBCPP_HAS_WIDE_CHARACTERS
5049void __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const {5054void __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const {
5050 char __nar[100];5055 char __nar[100];
5051 char* __ne = __nar + 100;5056 char* __ne = __nar + 100;
5052 __do_put(__nar, __ne, __tm, __fmt, __mod);5057 __do_put(__nar, __ne, __tm, __fmt, __mod);
5053 mbstate_t mb = {0};5058 mbstate_t mb = {0};
5054 const char* __nb = __nar;5059 const char* __nb = __nar;
5055 size_t j = __libcpp_mbsrtowcs_l(__wb, &__nb, countof(__wb, __we), &mb, __loc_);5060 size_t j = __locale::__mbsrtowcs(__wb, &__nb, countof(__wb, __we), &mb, __loc_);
5056 if (j == size_t(-1))5061 if (j == size_t(-1))
5057 __throw_runtime_error("locale not supported");5062 __throw_runtime_error("locale not supported");
5058 __we = __wb + j;5063 __we = __wb + j;
5059}5064}
5060#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS5065#endif // _LIBCPP_HAS_WIDE_CHARACTERS
50615066
5062// moneypunct_byname5067// moneypunct_byname
50635068
...@@ -5428,7 +5433,7 @@ void moneypunct_byname<char, false>::init(const char* nm) {...@@ -5428,7 +5433,7 @@ void moneypunct_byname<char, false>::init(const char* nm) {
5428 if (!loc)5433 if (!loc)
5429 __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());5434 __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
54305435
5431 lconv* lc = __libcpp_localeconv_l(loc.get());5436 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());
5432 if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))5437 if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))
5433 __decimal_point_ = base::do_decimal_point();5438 __decimal_point_ = base::do_decimal_point();
5434 if (!checked_string_to_char_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get()))5439 if (!checked_string_to_char_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get()))
...@@ -5463,7 +5468,7 @@ void moneypunct_byname<char, true>::init(const char* nm) {...@@ -5463,7 +5468,7 @@ void moneypunct_byname<char, true>::init(const char* nm) {
5463 if (!loc)5468 if (!loc)
5464 __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());5469 __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
54655470
5466 lconv* lc = __libcpp_localeconv_l(loc.get());5471 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());
5467 if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))5472 if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))
5468 __decimal_point_ = base::do_decimal_point();5473 __decimal_point_ = base::do_decimal_point();
5469 if (!checked_string_to_char_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get()))5474 if (!checked_string_to_char_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get()))
...@@ -5511,14 +5516,14 @@ void moneypunct_byname<char, true>::init(const char* nm) {...@@ -5511,14 +5516,14 @@ void moneypunct_byname<char, true>::init(const char* nm) {
5511#endif // !_LIBCPP_MSVCRT5516#endif // !_LIBCPP_MSVCRT
5512}5517}
55135518
5514#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS5519#if _LIBCPP_HAS_WIDE_CHARACTERS
5515template <>5520template <>
5516void moneypunct_byname<wchar_t, false>::init(const char* nm) {5521void moneypunct_byname<wchar_t, false>::init(const char* nm) {
5517 typedef moneypunct<wchar_t, false> base;5522 typedef moneypunct<wchar_t, false> base;
5518 __libcpp_unique_locale loc(nm);5523 __libcpp_unique_locale loc(nm);
5519 if (!loc)5524 if (!loc)
5520 __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());5525 __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
5521 lconv* lc = __libcpp_localeconv_l(loc.get());5526 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());
5522 if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))5527 if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))
5523 __decimal_point_ = base::do_decimal_point();5528 __decimal_point_ = base::do_decimal_point();
5524 if (!checked_string_to_wchar_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get()))5529 if (!checked_string_to_wchar_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get()))
...@@ -5527,7 +5532,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {...@@ -5527,7 +5532,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {
5527 wchar_t wbuf[100];5532 wchar_t wbuf[100];
5528 mbstate_t mb = {0};5533 mbstate_t mb = {0};
5529 const char* bb = lc->currency_symbol;5534 const char* bb = lc->currency_symbol;
5530 size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());5535 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());
5531 if (j == size_t(-1))5536 if (j == size_t(-1))
5532 __throw_runtime_error("locale not supported");5537 __throw_runtime_error("locale not supported");
5533 wchar_t* wbe = wbuf + j;5538 wchar_t* wbe = wbuf + j;
...@@ -5541,7 +5546,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {...@@ -5541,7 +5546,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {
5541 else {5546 else {
5542 mb = mbstate_t();5547 mb = mbstate_t();
5543 bb = lc->positive_sign;5548 bb = lc->positive_sign;
5544 j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());5549 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());
5545 if (j == size_t(-1))5550 if (j == size_t(-1))
5546 __throw_runtime_error("locale not supported");5551 __throw_runtime_error("locale not supported");
5547 wbe = wbuf + j;5552 wbe = wbuf + j;
...@@ -5552,7 +5557,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {...@@ -5552,7 +5557,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {
5552 else {5557 else {
5553 mb = mbstate_t();5558 mb = mbstate_t();
5554 bb = lc->negative_sign;5559 bb = lc->negative_sign;
5555 j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());5560 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());
5556 if (j == size_t(-1))5561 if (j == size_t(-1))
5557 __throw_runtime_error("locale not supported");5562 __throw_runtime_error("locale not supported");
5558 wbe = wbuf + j;5563 wbe = wbuf + j;
...@@ -5573,7 +5578,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {...@@ -5573,7 +5578,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {
5573 if (!loc)5578 if (!loc)
5574 __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());5579 __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
55755580
5576 lconv* lc = __libcpp_localeconv_l(loc.get());5581 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());
5577 if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))5582 if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))
5578 __decimal_point_ = base::do_decimal_point();5583 __decimal_point_ = base::do_decimal_point();
5579 if (!checked_string_to_wchar_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get()))5584 if (!checked_string_to_wchar_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get()))
...@@ -5582,7 +5587,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {...@@ -5582,7 +5587,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {
5582 wchar_t wbuf[100];5587 wchar_t wbuf[100];
5583 mbstate_t mb = {0};5588 mbstate_t mb = {0};
5584 const char* bb = lc->int_curr_symbol;5589 const char* bb = lc->int_curr_symbol;
5585 size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());5590 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());
5586 if (j == size_t(-1))5591 if (j == size_t(-1))
5587 __throw_runtime_error("locale not supported");5592 __throw_runtime_error("locale not supported");
5588 wchar_t* wbe = wbuf + j;5593 wchar_t* wbe = wbuf + j;
...@@ -5600,7 +5605,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {...@@ -5600,7 +5605,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {
5600 else {5605 else {
5601 mb = mbstate_t();5606 mb = mbstate_t();
5602 bb = lc->positive_sign;5607 bb = lc->positive_sign;
5603 j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());5608 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());
5604 if (j == size_t(-1))5609 if (j == size_t(-1))
5605 __throw_runtime_error("locale not supported");5610 __throw_runtime_error("locale not supported");
5606 wbe = wbuf + j;5611 wbe = wbuf + j;
...@@ -5615,7 +5620,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {...@@ -5615,7 +5620,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {
5615 else {5620 else {
5616 mb = mbstate_t();5621 mb = mbstate_t();
5617 bb = lc->negative_sign;5622 bb = lc->negative_sign;
5618 j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());5623 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());
5619 if (j == size_t(-1))5624 if (j == size_t(-1))
5620 __throw_runtime_error("locale not supported");5625 __throw_runtime_error("locale not supported");
5621 wbe = wbuf + j;5626 wbe = wbuf + j;
...@@ -5641,7 +5646,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {...@@ -5641,7 +5646,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {
5641 __neg_format_, __curr_symbol_, true, lc->int_n_cs_precedes, lc->int_n_sep_by_space, lc->int_n_sign_posn, L' ');5646 __neg_format_, __curr_symbol_, true, lc->int_n_cs_precedes, lc->int_n_sep_by_space, lc->int_n_sign_posn, L' ');
5642# endif // !_LIBCPP_MSVCRT5647# endif // !_LIBCPP_MSVCRT
5643}5648}
5644#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS5649#endif // _LIBCPP_HAS_WIDE_CHARACTERS
56455650
5646void __do_nothing(void*) {}5651void __do_nothing(void*) {}
56475652
...@@ -5707,7 +5712,7 @@ template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_...@@ -5707,7 +5712,7 @@ template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_
5707 codecvt_byname<char16_t, char, mbstate_t>;5712 codecvt_byname<char16_t, char, mbstate_t>;
5708template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS5713template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
5709 codecvt_byname<char32_t, char, mbstate_t>;5714 codecvt_byname<char32_t, char, mbstate_t>;
5710#ifndef _LIBCPP_HAS_NO_CHAR8_T5715#if _LIBCPP_HAS_CHAR8_T
5711template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char16_t, char8_t, mbstate_t>;5716template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char16_t, char8_t, mbstate_t>;
5712template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, char8_t, mbstate_t>;5717template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, char8_t, mbstate_t>;
5713#endif5718#endif
lib/libcxx/src/memory.cpp+3-3
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
1313
14#include <memory>14#include <memory>
1515
16#ifndef _LIBCPP_HAS_NO_THREADS16#if _LIBCPP_HAS_THREADS
17# include <mutex>17# include <mutex>
18# include <thread>18# include <thread>
19# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)19# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
...@@ -96,7 +96,7 @@ __shared_weak_count* __shared_weak_count::lock() noexcept {...@@ -96,7 +96,7 @@ __shared_weak_count* __shared_weak_count::lock() noexcept {
9696
97const void* __shared_weak_count::__get_deleter(const type_info&) const noexcept { return nullptr; }97const void* __shared_weak_count::__get_deleter(const type_info&) const noexcept { return nullptr; }
9898
99#if !defined(_LIBCPP_HAS_NO_THREADS)99#if _LIBCPP_HAS_THREADS
100100
101static constexpr std::size_t __sp_mut_count = 32;101static constexpr std::size_t __sp_mut_count = 32;
102static constinit __libcpp_mutex_t mut_back[__sp_mut_count] = {102static constinit __libcpp_mutex_t mut_back[__sp_mut_count] = {
...@@ -128,7 +128,7 @@ __sp_mut& __get_sp_mut(const void* p) {...@@ -128,7 +128,7 @@ __sp_mut& __get_sp_mut(const void* p) {
128 return muts[hash<const void*>()(p) & (__sp_mut_count - 1)];128 return muts[hash<const void*>()(p) & (__sp_mut_count - 1)];
129}129}
130130
131#endif // !defined(_LIBCPP_HAS_NO_THREADS)131#endif // _LIBCPP_HAS_THREADS
132132
133void* align(size_t alignment, size_t size, void*& ptr, size_t& space) {133void* align(size_t alignment, size_t size, void*& ptr, size_t& space) {
134 void* r = nullptr;134 void* r = nullptr;
lib/libcxx/src/memory_resource.cpp+32-30
...@@ -6,12 +6,13 @@...@@ -6,12 +6,13 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include <cstddef>
9#include <memory>10#include <memory>
10#include <memory_resource>11#include <memory_resource>
1112
12#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER13#if _LIBCPP_HAS_ATOMIC_HEADER
13# include <atomic>14# include <atomic>
14#elif !defined(_LIBCPP_HAS_NO_THREADS)15#elif _LIBCPP_HAS_THREADS
15# include <mutex>16# include <mutex>
16# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)17# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
17# pragma comment(lib, "pthread")18# pragma comment(lib, "pthread")
...@@ -28,7 +29,7 @@ memory_resource::~memory_resource() = default;...@@ -28,7 +29,7 @@ memory_resource::~memory_resource() = default;
2829
29// new_delete_resource()30// new_delete_resource()
3031
31#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION32#if !_LIBCPP_HAS_ALIGNED_ALLOCATION
32static bool is_aligned_to(void* ptr, size_t align) {33static bool is_aligned_to(void* ptr, size_t align) {
33 void* p2 = ptr;34 void* p2 = ptr;
34 size_t space = 1;35 size_t space = 1;
...@@ -39,21 +40,23 @@ static bool is_aligned_to(void* ptr, size_t align) {...@@ -39,21 +40,23 @@ static bool is_aligned_to(void* ptr, size_t align) {
3940
40class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory_resource {41class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory_resource {
41 void* do_allocate(size_t bytes, size_t align) override {42 void* do_allocate(size_t bytes, size_t align) override {
42#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION43#if _LIBCPP_HAS_ALIGNED_ALLOCATION
43 return std::__libcpp_allocate(bytes, align);44 return std::__libcpp_allocate<std::byte>(__element_count(bytes), align);
44#else45#else
45 if (bytes == 0)46 if (bytes == 0)
46 bytes = 1;47 bytes = 1;
47 void* result = std::__libcpp_allocate(bytes, align);48 std::byte* result = std::__libcpp_allocate<std::byte>(__element_count(bytes), align);
48 if (!is_aligned_to(result, align)) {49 if (!is_aligned_to(result, align)) {
49 std::__libcpp_deallocate(result, bytes, align);50 std::__libcpp_deallocate<std::byte>(result, __element_count(bytes), align);
50 __throw_bad_alloc();51 __throw_bad_alloc();
51 }52 }
52 return result;53 return result;
53#endif54#endif
54 }55 }
5556
56 void do_deallocate(void* p, size_t bytes, size_t align) override { std::__libcpp_deallocate(p, bytes, align); }57 void do_deallocate(void* p, size_t bytes, size_t align) override {
58 std::__libcpp_deallocate<std::byte>(static_cast<std::byte*>(p), __element_count(bytes), align);
59 }
5760
58 bool do_is_equal(const memory_resource& other) const noexcept override { return &other == this; }61 bool do_is_equal(const memory_resource& other) const noexcept override { return &other == this; }
59};62};
...@@ -82,7 +85,7 @@ union ResourceInitHelper {...@@ -82,7 +85,7 @@ union ResourceInitHelper {
82// attribute with a value that's reserved for the implementation (we're the implementation).85// attribute with a value that's reserved for the implementation (we're the implementation).
83#include "memory_resource_init_helper.h"86#include "memory_resource_init_helper.h"
8487
85} // end namespace88} // namespace
8689
87memory_resource* new_delete_resource() noexcept { return &res_init.resources.new_delete_res; }90memory_resource* new_delete_resource() noexcept { return &res_init.resources.new_delete_res; }
8891
...@@ -91,7 +94,7 @@ memory_resource* null_memory_resource() noexcept { return &res_init.resources.nu...@@ -91,7 +94,7 @@ memory_resource* null_memory_resource() noexcept { return &res_init.resources.nu
91// default_memory_resource()94// default_memory_resource()
9295
93static memory_resource* __default_memory_resource(bool set = false, memory_resource* new_res = nullptr) noexcept {96static memory_resource* __default_memory_resource(bool set = false, memory_resource* new_res = nullptr) noexcept {
94#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER97#if _LIBCPP_HAS_ATOMIC_HEADER
95 static constinit atomic<memory_resource*> __res{&res_init.resources.new_delete_res};98 static constinit atomic<memory_resource*> __res{&res_init.resources.new_delete_res};
96 if (set) {99 if (set) {
97 new_res = new_res ? new_res : new_delete_resource();100 new_res = new_res ? new_res : new_delete_resource();
...@@ -100,7 +103,7 @@ static memory_resource* __default_memory_resource(bool set = false, memory_resou...@@ -100,7 +103,7 @@ static memory_resource* __default_memory_resource(bool set = false, memory_resou
100 } else {103 } else {
101 return std::atomic_load_explicit(&__res, memory_order_acquire);104 return std::atomic_load_explicit(&__res, memory_order_acquire);
102 }105 }
103#elif !defined(_LIBCPP_HAS_NO_THREADS)106#elif _LIBCPP_HAS_THREADS
104 static constinit memory_resource* res = &res_init.resources.new_delete_res;107 static constinit memory_resource* res = &res_init.resources.new_delete_res;
105 static mutex res_lock;108 static mutex res_lock;
106 if (set) {109 if (set) {
...@@ -412,6 +415,8 @@ bool synchronized_pool_resource::do_is_equal(const memory_resource& other) const...@@ -412,6 +415,8 @@ bool synchronized_pool_resource::do_is_equal(const memory_resource& other) const
412415
413// 23.12.6, mem.res.monotonic.buffer416// 23.12.6, mem.res.monotonic.buffer
414417
418constexpr size_t __default_growth_factor = 2;
419
415static void* align_down(size_t align, size_t size, void*& ptr, size_t& space) {420static void* align_down(size_t align, size_t size, void*& ptr, size_t& space) {
416 if (size > space)421 if (size > space)
417 return nullptr;422 return nullptr;
...@@ -428,23 +433,20 @@ static void* align_down(size_t align, size_t size, void*& ptr, size_t& space) {...@@ -428,23 +433,20 @@ static void* align_down(size_t align, size_t size, void*& ptr, size_t& space) {
428 return ptr;433 return ptr;
429}434}
430435
431void* monotonic_buffer_resource::__initial_descriptor::__try_allocate_from_chunk(size_t bytes, size_t align) {436template <bool is_initial, typename Chunk>
432 if (!__cur_)437void* __try_allocate_from_chunk(Chunk& self, size_t bytes, size_t align) {
433 return nullptr;438 if constexpr (is_initial) {
434 void* new_ptr = static_cast<void*>(__cur_);439 // only for __initial_descriptor.
435 size_t new_capacity = (__cur_ - __start_);440 // if __initial_descriptor.__cur_ equals nullptr, means no available buffer given when ctor.
436 void* aligned_ptr = align_down(align, bytes, new_ptr, new_capacity);441 // here we just return nullptr, let the caller do the next handling.
437 if (aligned_ptr != nullptr)442 if (!self.__cur_)
438 __cur_ = static_cast<char*>(new_ptr);443 return nullptr;
439 return aligned_ptr;444 }
440}445 void* new_ptr = static_cast<void*>(self.__cur_);
441446 size_t new_capacity = (self.__cur_ - self.__start_);
442void* monotonic_buffer_resource::__chunk_footer::__try_allocate_from_chunk(size_t bytes, size_t align) {
443 void* new_ptr = static_cast<void*>(__cur_);
444 size_t new_capacity = (__cur_ - __start_);
445 void* aligned_ptr = align_down(align, bytes, new_ptr, new_capacity);447 void* aligned_ptr = align_down(align, bytes, new_ptr, new_capacity);
446 if (aligned_ptr != nullptr)448 if (aligned_ptr != nullptr)
447 __cur_ = static_cast<char*>(new_ptr);449 self.__cur_ = static_cast<char*>(new_ptr);
448 return aligned_ptr;450 return aligned_ptr;
449}451}
450452
...@@ -461,10 +463,10 @@ void* monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) {...@@ -461,10 +463,10 @@ void* monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) {
461 return roundup(newsize, footer_align) + footer_size;463 return roundup(newsize, footer_align) + footer_size;
462 };464 };
463465
464 if (void* result = __initial_.__try_allocate_from_chunk(bytes, align))466 if (void* result = __try_allocate_from_chunk<true, __initial_descriptor>(__initial_, bytes, align))
465 return result;467 return result;
466 if (__chunks_ != nullptr) {468 if (__chunks_ != nullptr) {
467 if (void* result = __chunks_->__try_allocate_from_chunk(bytes, align))469 if (void* result = __try_allocate_from_chunk<false, __chunk_footer>(*__chunks_, bytes, align))
468 return result;470 return result;
469 }471 }
470472
...@@ -477,7 +479,7 @@ void* monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) {...@@ -477,7 +479,7 @@ void* monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) {
477 size_t previous_capacity = previous_allocation_size();479 size_t previous_capacity = previous_allocation_size();
478480
479 if (aligned_capacity <= previous_capacity) {481 if (aligned_capacity <= previous_capacity) {
480 size_t newsize = 2 * (previous_capacity - footer_size);482 size_t newsize = __default_growth_factor * (previous_capacity - footer_size);
481 aligned_capacity = roundup(newsize, footer_align) + footer_size;483 aligned_capacity = roundup(newsize, footer_align) + footer_size;
482 }484 }
483485
...@@ -490,7 +492,7 @@ void* monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) {...@@ -490,7 +492,7 @@ void* monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) {
490 footer->__align_ = align;492 footer->__align_ = align;
491 __chunks_ = footer;493 __chunks_ = footer;
492494
493 return __chunks_->__try_allocate_from_chunk(bytes, align);495 return __try_allocate_from_chunk<false, __chunk_footer>(*__chunks_, bytes, align);
494}496}
495497
496} // namespace pmr498} // namespace pmr
lib/libcxx/src/mutex_destructor.cpp+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19#include <__config>19#include <__config>
20#include <__thread/support.h>20#include <__thread/support.h>
2121
22#if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION)22#if _LIBCPP_ABI_VERSION == 1 || !_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
23# define NEEDS_MUTEX_DESTRUCTOR23# define NEEDS_MUTEX_DESTRUCTOR
24#endif24#endif
2525
lib/libcxx/src/new.cpp+6-6
...@@ -51,7 +51,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new(std...@@ -51,7 +51,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new(std
51}51}
5252
53_LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {53_LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {
54# ifdef _LIBCPP_HAS_NO_EXCEPTIONS54# if !_LIBCPP_HAS_EXCEPTIONS
55# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION55# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
56 _LIBCPP_ASSERT_SHIM(56 _LIBCPP_ASSERT_SHIM(
57 !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new)),57 !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new)),
...@@ -79,7 +79,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new[](s...@@ -79,7 +79,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new[](s
79}79}
8080
81_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {81_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {
82# ifdef _LIBCPP_HAS_NO_EXCEPTIONS82# if !_LIBCPP_HAS_EXCEPTIONS
83# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION83# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
84 _LIBCPP_ASSERT_SHIM(84 _LIBCPP_ASSERT_SHIM(
85 !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new[])),85 !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new[])),
...@@ -114,7 +114,7 @@ _LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept {...@@ -114,7 +114,7 @@ _LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept {
114114
115_LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); }115_LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); }
116116
117# if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)117# if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
118118
119static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignment) {119static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignment) {
120 if (size == 0)120 if (size == 0)
...@@ -145,7 +145,7 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {...@@ -145,7 +145,7 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {
145}145}
146146
147_LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {147_LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {
148# ifdef _LIBCPP_HAS_NO_EXCEPTIONS148# if !_LIBCPP_HAS_EXCEPTIONS
149# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION149# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
150 _LIBCPP_ASSERT_SHIM(150 _LIBCPP_ASSERT_SHIM(
151 !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new)),151 !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new)),
...@@ -174,7 +174,7 @@ operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {...@@ -174,7 +174,7 @@ operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {
174}174}
175175
176_LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {176_LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {
177# ifdef _LIBCPP_HAS_NO_EXCEPTIONS177# if !_LIBCPP_HAS_EXCEPTIONS
178# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION178# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
179 _LIBCPP_ASSERT_SHIM(179 _LIBCPP_ASSERT_SHIM(
180 !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new[])),180 !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new[])),
...@@ -220,7 +220,7 @@ _LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignmen...@@ -220,7 +220,7 @@ _LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignmen
220 ::operator delete[](ptr, alignment);220 ::operator delete[](ptr, alignment);
221}221}
222222
223# endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION223# endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
224// ------------------ END COPY ------------------224// ------------------ END COPY ------------------
225225
226#endif // !__GLIBCXX__ && !_LIBCPP_ABI_VCRUNTIME226#endif // !__GLIBCXX__ && !_LIBCPP_ABI_VCRUNTIME
lib/libcxx/src/new_helpers.cpp+1-1
...@@ -18,7 +18,7 @@ const nothrow_t nothrow{};...@@ -18,7 +18,7 @@ const nothrow_t nothrow{};
18#ifndef LIBSTDCXX18#ifndef LIBSTDCXX
1919
20void __throw_bad_alloc() {20void __throw_bad_alloc() {
21# ifndef _LIBCPP_HAS_NO_EXCEPTIONS21# if _LIBCPP_HAS_EXCEPTIONS
22 throw bad_alloc();22 throw bad_alloc();
23# else23# else
24 _LIBCPP_VERBOSE_ABORT("bad_alloc was thrown in -fno-exceptions mode");24 _LIBCPP_VERBOSE_ABORT("bad_alloc was thrown in -fno-exceptions mode");
lib/libcxx/src/optional.cpp+1-1
...@@ -17,7 +17,7 @@ const char* bad_optional_access::what() const noexcept { return "bad_optional_ac...@@ -17,7 +17,7 @@ const char* bad_optional_access::what() const noexcept { return "bad_optional_ac
1717
18} // namespace std18} // namespace std
1919
20#include <experimental/__config>20#include <__config>
2121
22// Preserve std::experimental::bad_optional_access for ABI compatibility22// Preserve std::experimental::bad_optional_access for ABI compatibility
23// Even though it no longer exists in a header file23// Even though it no longer exists in a header file
lib/libcxx/src/ostream.cpp+4-4
...@@ -7,7 +7,7 @@...@@ -7,7 +7,7 @@
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include <__config>9#include <__config>
10#ifndef _LIBCPP_HAS_NO_FILESYSTEM10#if _LIBCPP_HAS_FILESYSTEM
11# include <fstream>11# include <fstream>
12#endif12#endif
13#include <ostream>13#include <ostream>
...@@ -24,16 +24,16 @@ _LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os) {...@@ -24,16 +24,16 @@ _LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os) {
24 // Returning a nullptr means the stream is not considered a terminal and the24 // Returning a nullptr means the stream is not considered a terminal and the
25 // special terminal handling is not done. The terminal handling is mainly of25 // special terminal handling is not done. The terminal handling is mainly of
26 // importance on Windows.26 // importance on Windows.
27#ifndef _LIBCPP_HAS_NO_RTTI27#if _LIBCPP_HAS_RTTI
28 auto* __rdbuf = __os.rdbuf();28 auto* __rdbuf = __os.rdbuf();
29# ifndef _LIBCPP_HAS_NO_FILESYSTEM29# if _LIBCPP_HAS_FILESYSTEM
30 if (auto* __buffer = dynamic_cast<filebuf*>(__rdbuf))30 if (auto* __buffer = dynamic_cast<filebuf*>(__rdbuf))
31 return __buffer->__file_;31 return __buffer->__file_;
32# endif32# endif
3333
34 if (auto* __buffer = dynamic_cast<__stdoutbuf<char>*>(__rdbuf))34 if (auto* __buffer = dynamic_cast<__stdoutbuf<char>*>(__rdbuf))
35 return __buffer->__file_;35 return __buffer->__file_;
36#endif // _LIBCPP_HAS_NO_RTTI36#endif // _LIBCPP_HAS_RTTI
3737
38 return nullptr;38 return nullptr;
39}39}
lib/libcxx/src/print.cpp+3-3
...@@ -42,7 +42,7 @@ _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream) {...@@ -42,7 +42,7 @@ _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream) {
42 return GetConsoleMode(reinterpret_cast<void*>(__handle), &__mode);42 return GetConsoleMode(reinterpret_cast<void*>(__handle), &__mode);
43}43}
4444
45# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS45# if _LIBCPP_HAS_WIDE_CHARACTERS
46_LIBCPP_EXPORTED_FROM_ABI void46_LIBCPP_EXPORTED_FROM_ABI void
47__write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wstring_view __view) {47__write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wstring_view __view) {
48 // https://learn.microsoft.com/en-us/windows/console/writeconsole48 // https://learn.microsoft.com/en-us/windows/console/writeconsole
...@@ -51,10 +51,10 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst...@@ -51,10 +51,10 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst
51 __view.size(),51 __view.size(),
52 nullptr,52 nullptr,
53 nullptr) == 0) {53 nullptr) == 0) {
54 __throw_system_error(filesystem::detail::make_windows_error(GetLastError()), "failed to write formatted output");54 __throw_system_error(filesystem::detail::get_last_error(), "failed to write formatted output");
55 }55 }
56}56}
57# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS57# endif // _LIBCPP_HAS_WIDE_CHARACTERS
5858
59#elif __has_include(<unistd.h>) // !_LIBCPP_WIN32API59#elif __has_include(<unistd.h>) // !_LIBCPP_WIN32API
6060
lib/libcxx/src/random.cpp+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13# define _CRT_RAND_S13# define _CRT_RAND_S
14#endif // defined(_LIBCPP_USING_WIN32_RANDOM)14#endif // defined(_LIBCPP_USING_WIN32_RANDOM)
1515
16#include <__system_error/system_error.h>16#include <__system_error/throw_system_error.h>
17#include <limits>17#include <limits>
18#include <random>18#include <random>
1919
lib/libcxx/src/random_shuffle.cpp+4-4
...@@ -9,7 +9,7 @@...@@ -9,7 +9,7 @@
9#include <algorithm>9#include <algorithm>
10#include <random>10#include <random>
1111
12#ifndef _LIBCPP_HAS_NO_THREADS12#if _LIBCPP_HAS_THREADS
13# include <mutex>13# include <mutex>
14# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)14# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
15# pragma comment(lib, "pthread")15# pragma comment(lib, "pthread")
...@@ -18,13 +18,13 @@...@@ -18,13 +18,13 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#ifndef _LIBCPP_HAS_NO_THREADS21#if _LIBCPP_HAS_THREADS
22static constinit __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;22static constinit __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
23#endif23#endif
24unsigned __rs_default::__c_ = 0;24unsigned __rs_default::__c_ = 0;
2525
26__rs_default::__rs_default() {26__rs_default::__rs_default() {
27#ifndef _LIBCPP_HAS_NO_THREADS27#if _LIBCPP_HAS_THREADS
28 __libcpp_mutex_lock(&__rs_mut);28 __libcpp_mutex_lock(&__rs_mut);
29#endif29#endif
30 __c_ = 1;30 __c_ = 1;
...@@ -33,7 +33,7 @@ __rs_default::__rs_default() {...@@ -33,7 +33,7 @@ __rs_default::__rs_default() {
33__rs_default::__rs_default(const __rs_default&) { ++__c_; }33__rs_default::__rs_default(const __rs_default&) { ++__c_; }
3434
35__rs_default::~__rs_default() {35__rs_default::~__rs_default() {
36#ifndef _LIBCPP_HAS_NO_THREADS36#if _LIBCPP_HAS_THREADS
37 if (--__c_ == 0)37 if (--__c_ == 0)
38 __libcpp_mutex_unlock(&__rs_mut);38 __libcpp_mutex_unlock(&__rs_mut);
39#else39#else
lib/libcxx/src/regex.cpp+2-2
...@@ -323,8 +323,8 @@ const classnames ClassNames[] = {...@@ -323,8 +323,8 @@ const classnames ClassNames[] = {
323 {"xdigit", ctype_base::xdigit}};323 {"xdigit", ctype_base::xdigit}};
324324
325struct use_strcmp {325struct use_strcmp {
326 bool operator()(const collationnames& x, const char* y) { return strcmp(x.elem_, y) < 0; }326 bool operator()(const collationnames& x, const char* y) const { return strcmp(x.elem_, y) < 0; }
327 bool operator()(const classnames& x, const char* y) { return strcmp(x.elem_, y) < 0; }327 bool operator()(const classnames& x, const char* y) const { return strcmp(x.elem_, y) < 0; }
328};328};
329329
330} // namespace330} // namespace
lib/libcxx/src/ryu/d2s.cpp+1-1
...@@ -478,7 +478,7 @@ struct __floating_decimal_64 {...@@ -478,7 +478,7 @@ struct __floating_decimal_64 {
478 36893488u, 7378697u, 1475739u, 295147u, 59029u, 11805u, 2361u, 472u, 94u, 18u, 3u };478 36893488u, 7378697u, 1475739u, 295147u, 59029u, 11805u, 2361u, 472u, 94u, 18u, 3u };
479479
480 unsigned long _Trailing_zero_bits;480 unsigned long _Trailing_zero_bits;
481#ifdef _LIBCPP_HAS_BITSCAN64481#if _LIBCPP_HAS_BITSCAN64
482 (void) _BitScanForward64(&_Trailing_zero_bits, __v.__mantissa); // __v.__mantissa is guaranteed nonzero482 (void) _BitScanForward64(&_Trailing_zero_bits, __v.__mantissa); // __v.__mantissa is guaranteed nonzero
483#else // ^^^ 64-bit ^^^ / vvv 32-bit vvv483#else // ^^^ 64-bit ^^^ / vvv 32-bit vvv
484 const uint32_t _Low_mantissa = static_cast<uint32_t>(__v.__mantissa);484 const uint32_t _Low_mantissa = static_cast<uint32_t>(__v.__mantissa);
lib/libcxx/src/shared_mutex.cpp+11-5
...@@ -38,8 +38,10 @@ bool __shared_mutex_base::try_lock() {...@@ -38,8 +38,10 @@ bool __shared_mutex_base::try_lock() {
38}38}
3939
40void __shared_mutex_base::unlock() {40void __shared_mutex_base::unlock() {
41 lock_guard<mutex> _(__mut_);41 {
42 __state_ = 0;42 lock_guard<mutex> _(__mut_);
43 __state_ = 0;
44 }
43 __gate1_.notify_all();45 __gate1_.notify_all();
44}46}
4547
...@@ -67,16 +69,20 @@ bool __shared_mutex_base::try_lock_shared() {...@@ -67,16 +69,20 @@ bool __shared_mutex_base::try_lock_shared() {
67}69}
6870
69void __shared_mutex_base::unlock_shared() {71void __shared_mutex_base::unlock_shared() {
70 lock_guard<mutex> _(__mut_);72 unique_lock<mutex> lk(__mut_);
71 unsigned num_readers = (__state_ & __n_readers_) - 1;73 unsigned num_readers = (__state_ & __n_readers_) - 1;
72 __state_ &= ~__n_readers_;74 __state_ &= ~__n_readers_;
73 __state_ |= num_readers;75 __state_ |= num_readers;
74 if (__state_ & __write_entered_) {76 if (__state_ & __write_entered_) {
75 if (num_readers == 0)77 if (num_readers == 0) {
78 lk.unlock();
76 __gate2_.notify_one();79 __gate2_.notify_one();
80 }
77 } else {81 } else {
78 if (num_readers == __n_readers_ - 1)82 if (num_readers == __n_readers_ - 1) {
83 lk.unlock();
79 __gate1_.notify_one();84 __gate1_.notify_one();
85 }
80 }86 }
81}87}
8288
lib/libcxx/src/std_stream.h+3-3
...@@ -106,7 +106,7 @@ inline bool __do_getc(FILE* __fp, char* __pbuf) {...@@ -106,7 +106,7 @@ inline bool __do_getc(FILE* __fp, char* __pbuf) {
106 *__pbuf = static_cast<char>(__c);106 *__pbuf = static_cast<char>(__c);
107 return true;107 return true;
108}108}
109#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS109#if _LIBCPP_HAS_WIDE_CHARACTERS
110inline bool __do_getc(FILE* __fp, wchar_t* __pbuf) {110inline bool __do_getc(FILE* __fp, wchar_t* __pbuf) {
111 wint_t __c = getwc(__fp);111 wint_t __c = getwc(__fp);
112 if (__c == WEOF)112 if (__c == WEOF)
...@@ -121,7 +121,7 @@ inline bool __do_ungetc(int __c, FILE* __fp, char __dummy) {...@@ -121,7 +121,7 @@ inline bool __do_ungetc(int __c, FILE* __fp, char __dummy) {
121 return false;121 return false;
122 return true;122 return true;
123}123}
124#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS124#if _LIBCPP_HAS_WIDE_CHARACTERS
125inline bool __do_ungetc(std::wint_t __c, FILE* __fp, wchar_t __dummy) {125inline bool __do_ungetc(std::wint_t __c, FILE* __fp, wchar_t __dummy) {
126 if (ungetwc(__c, __fp) == WEOF)126 if (ungetwc(__c, __fp) == WEOF)
127 return false;127 return false;
...@@ -293,7 +293,7 @@ inline bool __do_fputc(char __c, FILE* __fp) {...@@ -293,7 +293,7 @@ inline bool __do_fputc(char __c, FILE* __fp) {
293 return false;293 return false;
294 return true;294 return true;
295}295}
296#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS296#if _LIBCPP_HAS_WIDE_CHARACTERS
297inline bool __do_fputc(wchar_t __c, FILE* __fp) {297inline bool __do_fputc(wchar_t __c, FILE* __fp) {
298 // fputwc works regardless of wide/narrow mode of stdout, while298 // fputwc works regardless of wide/narrow mode of stdout, while
299 // fwrite of wchar_t only works if the stream actually has been set299 // fwrite of wchar_t only works if the stream actually has been set
lib/libcxx/src/stdexcept.cpp+2-2
...@@ -19,8 +19,8 @@...@@ -19,8 +19,8 @@
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22_LIBCPP_NORETURN void __throw_runtime_error(const char* msg) {22void __throw_runtime_error(const char* msg) {
23#ifndef _LIBCPP_HAS_NO_EXCEPTIONS23#if _LIBCPP_HAS_EXCEPTIONS
24 throw runtime_error(msg);24 throw runtime_error(msg);
25#else25#else
26 _LIBCPP_VERBOSE_ABORT("runtime_error was thrown in -fno-exceptions mode with message \"%s\"", msg);26 _LIBCPP_VERBOSE_ABORT("runtime_error was thrown in -fno-exceptions mode with message \"%s\"", msg);
lib/libcxx/src/string.cpp+15-15
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14#include <stdexcept>14#include <stdexcept>
15#include <string>15#include <string>
1616
17#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS17#if _LIBCPP_HAS_WIDE_CHARACTERS
18# include <cwchar>18# include <cwchar>
19#endif19#endif
2020
...@@ -28,8 +28,8 @@ struct __basic_string_common;...@@ -28,8 +28,8 @@ struct __basic_string_common;
28// The struct isn't declared anymore in the headers. It's only here for ABI compatibility.28// The struct isn't declared anymore in the headers. It's only here for ABI compatibility.
29template <>29template <>
30struct __basic_string_common<true> {30struct __basic_string_common<true> {
31 _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const;31 [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const;
32 _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const;32 [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const;
33};33};
3434
35void __basic_string_common<true>::__throw_length_error() const { std::__throw_length_error("basic_string"); }35void __basic_string_common<true>::__throw_length_error() const { std::__throw_length_error("basic_string"); }
...@@ -40,12 +40,12 @@ void __basic_string_common<true>::__throw_out_of_range() const { std::__throw_ou...@@ -40,12 +40,12 @@ void __basic_string_common<true>::__throw_out_of_range() const { std::__throw_ou
40#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__;40#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__;
41#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION41#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
42_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)42_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)
43# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS43# if _LIBCPP_HAS_WIDE_CHARACTERS
44_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t)44_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t)
45# endif45# endif
46#else46#else
47_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)47_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)
48# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS48# if _LIBCPP_HAS_WIDE_CHARACTERS
49_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t)49_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t)
50# endif50# endif
51#endif51#endif
...@@ -115,7 +115,7 @@ inline unsigned long long as_integer(const string& func, const string& s, size_t...@@ -115,7 +115,7 @@ inline unsigned long long as_integer(const string& func, const string& s, size_t
115 return as_integer_helper<unsigned long long>(func, s, idx, base, strtoull);115 return as_integer_helper<unsigned long long>(func, s, idx, base, strtoull);
116}116}
117117
118#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS118#if _LIBCPP_HAS_WIDE_CHARACTERS
119// wstring119// wstring
120template <>120template <>
121inline int as_integer(const string& func, const wstring& s, size_t* idx, int base) {121inline int as_integer(const string& func, const wstring& s, size_t* idx, int base) {
...@@ -145,7 +145,7 @@ template <>...@@ -145,7 +145,7 @@ template <>
145inline unsigned long long as_integer(const string& func, const wstring& s, size_t* idx, int base) {145inline unsigned long long as_integer(const string& func, const wstring& s, size_t* idx, int base) {
146 return as_integer_helper<unsigned long long>(func, s, idx, base, wcstoull);146 return as_integer_helper<unsigned long long>(func, s, idx, base, wcstoull);
147}147}
148#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS148#endif // _LIBCPP_HAS_WIDE_CHARACTERS
149149
150// as_float150// as_float
151151
...@@ -184,7 +184,7 @@ inline long double as_float(const string& func, const string& s, size_t* idx) {...@@ -184,7 +184,7 @@ inline long double as_float(const string& func, const string& s, size_t* idx) {
184 return as_float_helper<long double>(func, s, idx, strtold);184 return as_float_helper<long double>(func, s, idx, strtold);
185}185}
186186
187#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS187#if _LIBCPP_HAS_WIDE_CHARACTERS
188template <>188template <>
189inline float as_float(const string& func, const wstring& s, size_t* idx) {189inline float as_float(const string& func, const wstring& s, size_t* idx) {
190 return as_float_helper<float>(func, s, idx, wcstof);190 return as_float_helper<float>(func, s, idx, wcstof);
...@@ -199,7 +199,7 @@ template <>...@@ -199,7 +199,7 @@ template <>
199inline long double as_float(const string& func, const wstring& s, size_t* idx) {199inline long double as_float(const string& func, const wstring& s, size_t* idx) {
200 return as_float_helper<long double>(func, s, idx, wcstold);200 return as_float_helper<long double>(func, s, idx, wcstold);
201}201}
202#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS202#endif // _LIBCPP_HAS_WIDE_CHARACTERS
203203
204} // unnamed namespace204} // unnamed namespace
205205
...@@ -223,7 +223,7 @@ double stod(const string& str, size_t* idx) { return as_float<double>("stod", st...@@ -223,7 +223,7 @@ double stod(const string& str, size_t* idx) { return as_float<double>("stod", st
223223
224long double stold(const string& str, size_t* idx) { return as_float<long double>("stold", str, idx); }224long double stold(const string& str, size_t* idx) { return as_float<long double>("stold", str, idx); }
225225
226#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS226#if _LIBCPP_HAS_WIDE_CHARACTERS
227int stoi(const wstring& str, size_t* idx, int base) { return as_integer<int>("stoi", str, idx, base); }227int stoi(const wstring& str, size_t* idx, int base) { return as_integer<int>("stoi", str, idx, base); }
228228
229long stol(const wstring& str, size_t* idx, int base) { return as_integer<long>("stol", str, idx, base); }229long stol(const wstring& str, size_t* idx, int base) { return as_integer<long>("stol", str, idx, base); }
...@@ -243,7 +243,7 @@ float stof(const wstring& str, size_t* idx) { return as_float<float>("stof", str...@@ -243,7 +243,7 @@ float stof(const wstring& str, size_t* idx) { return as_float<float>("stof", str
243double stod(const wstring& str, size_t* idx) { return as_float<double>("stod", str, idx); }243double stod(const wstring& str, size_t* idx) { return as_float<double>("stod", str, idx); }
244244
245long double stold(const wstring& str, size_t* idx) { return as_float<long double>("stold", str, idx); }245long double stold(const wstring& str, size_t* idx) { return as_float<long double>("stold", str, idx); }
246#endif // !_LIBCPP_HAS_NO_WIDE_CHARACTERS246#endif // _LIBCPP_HAS_WIDE_CHARACTERS
247247
248// to_string248// to_string
249249
...@@ -283,7 +283,7 @@ struct initial_string<string> {...@@ -283,7 +283,7 @@ struct initial_string<string> {
283 }283 }
284};284};
285285
286#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS286#if _LIBCPP_HAS_WIDE_CHARACTERS
287template <>287template <>
288struct initial_string<wstring> {288struct initial_string<wstring> {
289 wstring operator()() const {289 wstring operator()() const {
...@@ -302,7 +302,7 @@ inline wide_printf get_swprintf() {...@@ -302,7 +302,7 @@ inline wide_printf get_swprintf() {
302 return static_cast<int(__cdecl*)(wchar_t* __restrict, size_t, const wchar_t* __restrict, ...)>(_snwprintf);302 return static_cast<int(__cdecl*)(wchar_t* __restrict, size_t, const wchar_t* __restrict, ...)>(_snwprintf);
303# endif303# endif
304}304}
305#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS305#endif // _LIBCPP_HAS_WIDE_CHARACTERS
306306
307template <typename S, typename V>307template <typename S, typename V>
308S i_to_string(V v) {308S i_to_string(V v) {
...@@ -325,7 +325,7 @@ string to_string(unsigned val) { return i_to_string< string>(val); }...@@ -325,7 +325,7 @@ string to_string(unsigned val) { return i_to_string< string>(val); }
325string to_string(unsigned long val) { return i_to_string< string>(val); }325string to_string(unsigned long val) { return i_to_string< string>(val); }
326string to_string(unsigned long long val) { return i_to_string< string>(val); }326string to_string(unsigned long long val) { return i_to_string< string>(val); }
327327
328#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS328#if _LIBCPP_HAS_WIDE_CHARACTERS
329wstring to_wstring(int val) { return i_to_string<wstring>(val); }329wstring to_wstring(int val) { return i_to_string<wstring>(val); }
330wstring to_wstring(long val) { return i_to_string<wstring>(val); }330wstring to_wstring(long val) { return i_to_string<wstring>(val); }
331wstring to_wstring(long long val) { return i_to_string<wstring>(val); }331wstring to_wstring(long long val) { return i_to_string<wstring>(val); }
...@@ -338,7 +338,7 @@ string to_string(float val) { return as_string(snprintf, initial_string< string>...@@ -338,7 +338,7 @@ string to_string(float val) { return as_string(snprintf, initial_string< string>
338string to_string(double val) { return as_string(snprintf, initial_string< string>()(), "%f", val); }338string to_string(double val) { return as_string(snprintf, initial_string< string>()(), "%f", val); }
339string to_string(long double val) { return as_string(snprintf, initial_string< string>()(), "%Lf", val); }339string to_string(long double val) { return as_string(snprintf, initial_string< string>()(), "%Lf", val); }
340340
341#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS341#if _LIBCPP_HAS_WIDE_CHARACTERS
342wstring to_wstring(float val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); }342wstring to_wstring(float val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); }
343wstring to_wstring(double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); }343wstring to_wstring(double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); }
344wstring to_wstring(long double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%Lf", val); }344wstring to_wstring(long double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%Lf", val); }
lib/libcxx/src/support/ibm/mbsnrtowcs.cpp+2-2
...@@ -48,7 +48,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t mbsnrtowcs(...@@ -48,7 +48,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t mbsnrtowcs(
48 size_t dest_remaining = max_dest_chars - dest_converted;48 size_t dest_remaining = max_dest_chars - dest_converted;
4949
50 if (dst == nullptr) {50 if (dst == nullptr) {
51 result = mbrtowc(NULL, *src + source_converted, source_remaining, ps);51 result = mbrtowc(nullptr, *src + source_converted, source_remaining, ps);
52 } else if (dest_remaining >= source_remaining) {52 } else if (dest_remaining >= source_remaining) {
53 // dst has enough space to translate in-place.53 // dst has enough space to translate in-place.
54 result = mbrtowc(dst + dest_converted, *src + source_converted, source_remaining, ps);54 result = mbrtowc(dst + dest_converted, *src + source_converted, source_remaining, ps);
...@@ -86,7 +86,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t mbsnrtowcs(...@@ -86,7 +86,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t mbsnrtowcs(
8686
87 if (dst) {87 if (dst) {
88 if (result == terminated_sequence)88 if (result == terminated_sequence)
89 *src = NULL;89 *src = nullptr;
90 else90 else
91 *src += source_converted;91 *src += source_converted;
92 }92 }
lib/libcxx/src/support/ibm/wcsnrtombs.cpp+2-2
...@@ -41,7 +41,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t wcsnrtombs(...@@ -41,7 +41,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t wcsnrtombs(
41 size_t dest_remaining = dst_size_bytes - dest_converted;41 size_t dest_remaining = dst_size_bytes - dest_converted;
4242
43 if (dst == nullptr) {43 if (dst == nullptr) {
44 result = wcrtomb(NULL, c, ps);44 result = wcrtomb(nullptr, c, ps);
45 } else if (dest_remaining >= static_cast<size_t>(MB_CUR_MAX)) {45 } else if (dest_remaining >= static_cast<size_t>(MB_CUR_MAX)) {
46 // dst has enough space to translate in-place.46 // dst has enough space to translate in-place.
47 result = wcrtomb(dst + dest_converted, c, ps);47 result = wcrtomb(dst + dest_converted, c, ps);
...@@ -82,7 +82,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t wcsnrtombs(...@@ -82,7 +82,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t wcsnrtombs(
8282
83 if (c == L'\0') {83 if (c == L'\0') {
84 if (dst)84 if (dst)
85 *src = NULL;85 *src = nullptr;
86 return dest_converted;86 return dest_converted;
87 }87 }
88 }88 }
lib/libcxx/src/support/ibm/xlocale_zos.cpp+8-8
...@@ -20,12 +20,12 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) {...@@ -20,12 +20,12 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) {
20 std::string current_loc_name(setlocale(LC_ALL, 0));20 std::string current_loc_name(setlocale(LC_ALL, 0));
2121
22 // Check for errors.22 // Check for errors.
23 if (category_mask == LC_ALL_MASK && setlocale(LC_ALL, locale) == NULL) {23 if (category_mask == LC_ALL_MASK && setlocale(LC_ALL, locale) == nullptr) {
24 errno = EINVAL;24 errno = EINVAL;
25 return (locale_t)0;25 return (locale_t)0;
26 } else {26 } else {
27 for (int _Cat = 0; _Cat <= _LC_MAX; ++_Cat) {27 for (int _Cat = 0; _Cat <= _LC_MAX; ++_Cat) {
28 if ((_CATMASK(_Cat) & category_mask) != 0 && setlocale(_Cat, locale) == NULL) {28 if ((_CATMASK(_Cat) & category_mask) != 0 && setlocale(_Cat, locale) == nullptr) {
29 setlocale(LC_ALL, current_loc_name.c_str());29 setlocale(LC_ALL, current_loc_name.c_str());
30 errno = EINVAL;30 errno = EINVAL;
31 return (locale_t)0;31 return (locale_t)0;
...@@ -74,12 +74,12 @@ locale_t uselocale(locale_t newloc) {...@@ -74,12 +74,12 @@ locale_t uselocale(locale_t newloc) {
74 if (newloc) {74 if (newloc) {
75 // Set locales and check for errors.75 // Set locales and check for errors.
76 bool is_error =76 bool is_error =
77 (newloc->category_mask & LC_COLLATE_MASK && setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == NULL) ||77 (newloc->category_mask & LC_COLLATE_MASK && setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == nullptr) ||
78 (newloc->category_mask & LC_CTYPE_MASK && setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == NULL) ||78 (newloc->category_mask & LC_CTYPE_MASK && setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == nullptr) ||
79 (newloc->category_mask & LC_MONETARY_MASK && setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == NULL) ||79 (newloc->category_mask & LC_MONETARY_MASK && setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == nullptr) ||
80 (newloc->category_mask & LC_NUMERIC_MASK && setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == NULL) ||80 (newloc->category_mask & LC_NUMERIC_MASK && setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == nullptr) ||
81 (newloc->category_mask & LC_TIME_MASK && setlocale(LC_TIME, newloc->lc_time.c_str()) == NULL) ||81 (newloc->category_mask & LC_TIME_MASK && setlocale(LC_TIME, newloc->lc_time.c_str()) == nullptr) ||
82 (newloc->category_mask & LC_MESSAGES_MASK && setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == NULL);82 (newloc->category_mask & LC_MESSAGES_MASK && setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == nullptr);
8383
84 if (is_error) {84 if (is_error) {
85 setlocale(LC_ALL, current_loc_name.c_str());85 setlocale(LC_ALL, current_loc_name.c_str());
lib/libcxx/src/support/runtime/exception_fallback.ipp+10-13
...@@ -7,7 +7,7 @@...@@ -7,7 +7,7 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#include <cstdio>10#include <__verbose_abort>
1111
12namespace std {12namespace std {
1313
...@@ -21,7 +21,7 @@ unexpected_handler set_unexpected(unexpected_handler func) noexcept {...@@ -21,7 +21,7 @@ unexpected_handler set_unexpected(unexpected_handler func) noexcept {
2121
22unexpected_handler get_unexpected() noexcept { return __libcpp_atomic_load(&__unexpected_handler); }22unexpected_handler get_unexpected() noexcept { return __libcpp_atomic_load(&__unexpected_handler); }
2323
24_LIBCPP_NORETURN void unexpected() {24[[noreturn]] void unexpected() {
25 (*get_unexpected())();25 (*get_unexpected())();
26 // unexpected handler should not return26 // unexpected handler should not return
27 terminate();27 terminate();
...@@ -33,29 +33,26 @@ terminate_handler set_terminate(terminate_handler func) noexcept {...@@ -33,29 +33,26 @@ terminate_handler set_terminate(terminate_handler func) noexcept {
3333
34terminate_handler get_terminate() noexcept { return __libcpp_atomic_load(&__terminate_handler); }34terminate_handler get_terminate() noexcept { return __libcpp_atomic_load(&__terminate_handler); }
3535
36_LIBCPP_NORETURN void terminate() noexcept {36[[noreturn]] void terminate() noexcept {
37#ifndef _LIBCPP_HAS_NO_EXCEPTIONS37#if _LIBCPP_HAS_EXCEPTIONS
38 try {38 try {
39#endif // _LIBCPP_HAS_NO_EXCEPTIONS39#endif // _LIBCPP_HAS_EXCEPTIONS
40 (*get_terminate())();40 (*get_terminate())();
41 // handler should not return41 // handler should not return
42 fprintf(stderr, "terminate_handler unexpectedly returned\n");42 __libcpp_verbose_abort("terminate_handler unexpectedly returned\n");
43 ::abort();43#if _LIBCPP_HAS_EXCEPTIONS
44#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
45 } catch (...) {44 } catch (...) {
46 // handler should not throw exception45 // handler should not throw exception
47 fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");46 __libcpp_verbose_abort("terminate_handler unexpectedly threw an exception\n");
48 ::abort();
49 }47 }
50#endif // _LIBCPP_HAS_NO_EXCEPTIONS48#endif // _LIBCPP_HAS_EXCEPTIONS
51}49}
5250
53bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }51bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }
5452
55int uncaught_exceptions() noexcept {53int uncaught_exceptions() noexcept {
56#warning uncaught_exception not yet implemented54#warning uncaught_exception not yet implemented
57 fprintf(stderr, "uncaught_exceptions not yet implemented\n");55 __libcpp_verbose_abort("uncaught_exceptions not yet implemented\n");
58 ::abort();
59}56}
6057
61exception::~exception() noexcept {}58exception::~exception() noexcept {}
lib/libcxx/src/support/runtime/exception_msvc.ipp+9-12
...@@ -11,8 +11,7 @@...@@ -11,8 +11,7 @@
11# error this header can only be used when targeting the MSVC ABI11# error this header can only be used when targeting the MSVC ABI
12#endif12#endif
1313
14#include <stdio.h>14#include <__verbose_abort>
15#include <stdlib.h>
1615
17extern "C" {16extern "C" {
18typedef void(__cdecl* terminate_handler)();17typedef void(__cdecl* terminate_handler)();
...@@ -32,7 +31,7 @@ unexpected_handler set_unexpected(unexpected_handler func) noexcept { return ::s...@@ -32,7 +31,7 @@ unexpected_handler set_unexpected(unexpected_handler func) noexcept { return ::s
3231
33unexpected_handler get_unexpected() noexcept { return ::_get_unexpected(); }32unexpected_handler get_unexpected() noexcept { return ::_get_unexpected(); }
3433
35_LIBCPP_NORETURN void unexpected() {34[[noreturn]] void unexpected() {
36 (*get_unexpected())();35 (*get_unexpected())();
37 // unexpected handler should not return36 // unexpected handler should not return
38 terminate();37 terminate();
...@@ -42,21 +41,19 @@ terminate_handler set_terminate(terminate_handler func) noexcept { return ::set_...@@ -42,21 +41,19 @@ terminate_handler set_terminate(terminate_handler func) noexcept { return ::set_
4241
43terminate_handler get_terminate() noexcept { return ::_get_terminate(); }42terminate_handler get_terminate() noexcept { return ::_get_terminate(); }
4443
45_LIBCPP_NORETURN void terminate() noexcept {44[[noreturn]] void terminate() noexcept {
46#ifndef _LIBCPP_HAS_NO_EXCEPTIONS45#if _LIBCPP_HAS_EXCEPTIONS
47 try {46 try {
48#endif // _LIBCPP_HAS_NO_EXCEPTIONS47#endif // _LIBCPP_HAS_EXCEPTIONS
49 (*get_terminate())();48 (*get_terminate())();
50 // handler should not return49 // handler should not return
51 fprintf(stderr, "terminate_handler unexpectedly returned\n");50 __libcpp_verbose_abort("terminate_handler unexpectedly returned\n");
52 ::abort();51#if _LIBCPP_HAS_EXCEPTIONS
53#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
54 } catch (...) {52 } catch (...) {
55 // handler should not throw exception53 // handler should not throw exception
56 fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");54 __libcpp_verbose_abort("terminate_handler unexpectedly threw an exception\n");
57 ::abort();
58 }55 }
59#endif // _LIBCPP_HAS_NO_EXCEPTIONS56#endif // _LIBCPP_HAS_EXCEPTIONS
60}57}
6158
62bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }59bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }
lib/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp+2-2
...@@ -40,7 +40,7 @@ nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}...@@ -40,7 +40,7 @@ nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}
4040
41nested_exception::~nested_exception() noexcept {}41nested_exception::~nested_exception() noexcept {}
4242
43_LIBCPP_NORETURN void nested_exception::rethrow_nested() const {43void nested_exception::rethrow_nested() const {
44 if (__ptr_ == nullptr)44 if (__ptr_ == nullptr)
45 terminate();45 terminate();
46 rethrow_exception(__ptr_);46 rethrow_exception(__ptr_);
...@@ -55,7 +55,7 @@ exception_ptr current_exception() noexcept {...@@ -55,7 +55,7 @@ exception_ptr current_exception() noexcept {
55 return ptr;55 return ptr;
56}56}
5757
58_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) {58void rethrow_exception(exception_ptr p) {
59 __cxa_rethrow_primary_exception(p.__ptr_);59 __cxa_rethrow_primary_exception(p.__ptr_);
60 // if p.__ptr_ is NULL, above returns so we terminate60 // if p.__ptr_ is NULL, above returns so we terminate
61 terminate();61 terminate();
lib/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp+3-3
...@@ -31,7 +31,7 @@ struct exception_ptr {...@@ -31,7 +31,7 @@ struct exception_ptr {
3131
32} // namespace __exception_ptr32} // namespace __exception_ptr
3333
34_LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr);34[[noreturn]] void rethrow_exception(__exception_ptr::exception_ptr);
3535
36exception_ptr::~exception_ptr() noexcept { reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr(); }36exception_ptr::~exception_ptr() noexcept { reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr(); }
3737
...@@ -55,13 +55,13 @@ exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept...@@ -55,13 +55,13 @@ exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept
5555
56nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}56nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}
5757
58_LIBCPP_NORETURN void nested_exception::rethrow_nested() const {58[[noreturn]] void nested_exception::rethrow_nested() const {
59 if (__ptr_ == nullptr)59 if (__ptr_ == nullptr)
60 terminate();60 terminate();
61 rethrow_exception(__ptr_);61 rethrow_exception(__ptr_);
62}62}
6363
64_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) {64[[noreturn]] void rethrow_exception(exception_ptr p) {
65 rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p));65 rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p));
66}66}
6767
lib/libcxx/src/support/runtime/exception_pointer_msvc.ipp+2-2
...@@ -61,13 +61,13 @@ exception_ptr current_exception() noexcept {...@@ -61,13 +61,13 @@ exception_ptr current_exception() noexcept {
61 return __ret;61 return __ret;
62}62}
6363
64_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { __ExceptionPtrRethrow(&p); }64[[noreturn]] void rethrow_exception(exception_ptr p) { __ExceptionPtrRethrow(&p); }
6565
66nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}66nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}
6767
68nested_exception::~nested_exception() noexcept {}68nested_exception::~nested_exception() noexcept {}
6969
70_LIBCPP_NORETURN void nested_exception::rethrow_nested() const {70[[noreturn]] void nested_exception::rethrow_nested() const {
71 if (__ptr_ == nullptr)71 if (__ptr_ == nullptr)
72 terminate();72 terminate();
73 rethrow_exception(__ptr_);73 rethrow_exception(__ptr_);
lib/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp+10-18
...@@ -7,33 +7,28 @@...@@ -7,33 +7,28 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#include <stdio.h>10#include <__verbose_abort>
11#include <stdlib.h>
1211
13namespace std {12namespace std {
1413
15exception_ptr::~exception_ptr() noexcept {14exception_ptr::~exception_ptr() noexcept {
16#warning exception_ptr not yet implemented15#warning exception_ptr not yet implemented
17 fprintf(stderr, "exception_ptr not yet implemented\n");16 __libcpp_verbose_abort("exception_ptr not yet implemented\n");
18 ::abort();
19}17}
2018
21exception_ptr::exception_ptr(const exception_ptr& other) noexcept : __ptr_(other.__ptr_) {19exception_ptr::exception_ptr(const exception_ptr& other) noexcept : __ptr_(other.__ptr_) {
22#warning exception_ptr not yet implemented20#warning exception_ptr not yet implemented
23 fprintf(stderr, "exception_ptr not yet implemented\n");21 __libcpp_verbose_abort("exception_ptr not yet implemented\n");
24 ::abort();
25}22}
2623
27exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept {24exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept {
28#warning exception_ptr not yet implemented25#warning exception_ptr not yet implemented
29 fprintf(stderr, "exception_ptr not yet implemented\n");26 __libcpp_verbose_abort("exception_ptr not yet implemented\n");
30 ::abort();
31}27}
3228
33exception_ptr exception_ptr::__from_native_exception_pointer(void *__e) noexcept {29exception_ptr exception_ptr::__from_native_exception_pointer(void *__e) noexcept {
34#warning exception_ptr not yet implemented30#warning exception_ptr not yet implemented
35 fprintf(stderr, "exception_ptr not yet implemented\n");31 __libcpp_verbose_abort("exception_ptr not yet implemented\n");
36 ::abort();
37}32}
3833
39nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}34nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}
...@@ -44,10 +39,9 @@ nested_exception::~nested_exception() noexcept {}...@@ -44,10 +39,9 @@ nested_exception::~nested_exception() noexcept {}
4439
45#endif40#endif
4641
47_LIBCPP_NORETURN void nested_exception::rethrow_nested() const {42[[noreturn]] void nested_exception::rethrow_nested() const {
48#warning exception_ptr not yet implemented43#warning exception_ptr not yet implemented
49 fprintf(stderr, "exception_ptr not yet implemented\n");44 __libcpp_verbose_abort("exception_ptr not yet implemented\n");
50 ::abort();
51#if 045#if 0
52 if (__ptr_ == nullptr)46 if (__ptr_ == nullptr)
53 terminate();47 terminate();
...@@ -57,14 +51,12 @@ _LIBCPP_NORETURN void nested_exception::rethrow_nested() const {...@@ -57,14 +51,12 @@ _LIBCPP_NORETURN void nested_exception::rethrow_nested() const {
5751
58exception_ptr current_exception() noexcept {52exception_ptr current_exception() noexcept {
59#warning exception_ptr not yet implemented53#warning exception_ptr not yet implemented
60 fprintf(stderr, "exception_ptr not yet implemented\n");54 __libcpp_verbose_abort("exception_ptr not yet implemented\n");
61 ::abort();
62}55}
6356
64_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) {57[[noreturn]] void rethrow_exception(exception_ptr p) {
65#warning exception_ptr not yet implemented58#warning exception_ptr not yet implemented
66 fprintf(stderr, "exception_ptr not yet implemented\n");59 __libcpp_verbose_abort("exception_ptr not yet implemented\n");
67 ::abort();
68}60}
6961
70} // namespace std62} // namespace std
lib/libcxx/src/support/win32/locale_win32.cpp+133-80
...@@ -6,127 +6,180 @@...@@ -6,127 +6,180 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include <cstdarg> // va_start, va_end9#include <__locale_dir/support/windows.h>
10#include <locale>10#include <clocale> // std::localeconv() & friends
11#include <memory>11#include <cstdarg> // va_start & friends
12#include <type_traits>12#include <cstddef>
13#include <cstdio> // std::vsnprintf & friends
14#include <cstdlib> // std::strtof & friends
15#include <ctime> // std::strftime
16#include <cwchar> // wide char manipulation
1317
14#include <__locale_dir/locale_base_api/locale_guard.h>18_LIBCPP_BEGIN_NAMESPACE_STD
19namespace __locale {
1520
16int __libcpp_vasprintf(char** sptr, const char* __restrict fmt, va_list ap);21//
22// Locale management
23//
24// FIXME: base and mask currently unused. Needs manual work to construct the new locale
25__locale_t __newlocale(int /*mask*/, const char* locale, __locale_t /*base*/) {
26 return {::_create_locale(LC_ALL, locale), locale};
27}
28
29__lconv_t* __localeconv(__locale_t& loc) {
30 __locale_guard __current(loc);
31 lconv* lc = std::localeconv();
32 if (!lc)
33 return lc;
34 return loc.__store_lconv(lc);
35}
1736
18using std::__libcpp_locale_guard;37//
38// Strtonum functions
39//
40#if !defined(_LIBCPP_MSVCRT)
41float __strtof(const char* nptr, char** endptr, __locale_t loc) {
42 __locale_guard __current(loc);
43 return std::strtof(nptr, endptr);
44}
1945
20// FIXME: base and mask currently unused. Needs manual work to construct the new locale46long double __strtold(const char* nptr, char** endptr, __locale_t loc) {
21locale_t newlocale(int /*mask*/, const char* locale, locale_t /*base*/) {47 __locale_guard __current(loc);
22 return {_create_locale(LC_ALL, locale), locale};48 return std::strtold(nptr, endptr);
49}
50#endif
51
52//
53// Character manipulation functions
54//
55#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
56size_t __strftime(char* ret, size_t n, const char* format, const struct tm* tm, __locale_t loc) {
57 __locale_guard __current(loc);
58 return std::strftime(ret, n, format, tm);
23}59}
60#endif
2461
25decltype(MB_CUR_MAX) MB_CUR_MAX_L(locale_t __l) {62//
63// Other functions
64//
65decltype(MB_CUR_MAX) __mb_len_max(__locale_t __l) {
26#if defined(_LIBCPP_MSVCRT)66#if defined(_LIBCPP_MSVCRT)
27 return ___mb_cur_max_l_func(__l);67 return ::___mb_cur_max_l_func(__l);
28#else68#else
29 __libcpp_locale_guard __current(__l);69 __locale_guard __current(__l);
30 return MB_CUR_MAX;70 return MB_CUR_MAX;
31#endif71#endif
32}72}
3373
34lconv* localeconv_l(locale_t& loc) {74wint_t __btowc(int c, __locale_t loc) {
35 __libcpp_locale_guard __current(loc);75 __locale_guard __current(loc);
36 lconv* lc = localeconv();76 return std::btowc(c);
37 if (!lc)
38 return lc;
39 return loc.__store_lconv(lc);
40}77}
41size_t mbrlen_l(const char* __restrict s, size_t n, mbstate_t* __restrict ps, locale_t loc) {78
42 __libcpp_locale_guard __current(loc);79int __wctob(wint_t c, __locale_t loc) {
43 return mbrlen(s, n, ps);80 __locale_guard __current(loc);
44}81 return std::wctob(c);
45size_t
46mbsrtowcs_l(wchar_t* __restrict dst, const char** __restrict src, size_t len, mbstate_t* __restrict ps, locale_t loc) {
47 __libcpp_locale_guard __current(loc);
48 return mbsrtowcs(dst, src, len, ps);
49}82}
50size_t wcrtomb_l(char* __restrict s, wchar_t wc, mbstate_t* __restrict ps, locale_t loc) {83
51 __libcpp_locale_guard __current(loc);84size_t __wcsnrtombs(char* __restrict dst,
52 return wcrtomb(s, wc, ps);85 const wchar_t** __restrict src,
86 size_t nwc,
87 size_t len,
88 mbstate_t* __restrict ps,
89 __locale_t loc) {
90 __locale_guard __current(loc);
91 return ::wcsnrtombs(dst, src, nwc, len, ps);
53}92}
54size_t mbrtowc_l(wchar_t* __restrict pwc, const char* __restrict s, size_t n, mbstate_t* __restrict ps, locale_t loc) {93
55 __libcpp_locale_guard __current(loc);94size_t __wcrtomb(char* __restrict s, wchar_t wc, mbstate_t* __restrict ps, __locale_t loc) {
56 return mbrtowc(pwc, s, n, ps);95 __locale_guard __current(loc);
96 return std::wcrtomb(s, wc, ps);
57}97}
58size_t mbsnrtowcs_l(wchar_t* __restrict dst,98
99size_t __mbsnrtowcs(wchar_t* __restrict dst,
59 const char** __restrict src,100 const char** __restrict src,
60 size_t nms,101 size_t nms,
61 size_t len,102 size_t len,
62 mbstate_t* __restrict ps,103 mbstate_t* __restrict ps,
63 locale_t loc) {104 __locale_t loc) {
64 __libcpp_locale_guard __current(loc);105 __locale_guard __current(loc);
65 return mbsnrtowcs(dst, src, nms, len, ps);106 return ::mbsnrtowcs(dst, src, nms, len, ps);
66}107}
67size_t wcsnrtombs_l(char* __restrict dst,108
68 const wchar_t** __restrict src,109size_t
69 size_t nwc,110__mbrtowc(wchar_t* __restrict pwc, const char* __restrict s, size_t n, mbstate_t* __restrict ps, __locale_t loc) {
70 size_t len,111 __locale_guard __current(loc);
71 mbstate_t* __restrict ps,112 return std::mbrtowc(pwc, s, n, ps);
72 locale_t loc) {
73 __libcpp_locale_guard __current(loc);
74 return wcsnrtombs(dst, src, nwc, len, ps);
75}113}
76wint_t btowc_l(int c, locale_t loc) {114
77 __libcpp_locale_guard __current(loc);115size_t __mbrlen(const char* __restrict s, size_t n, mbstate_t* __restrict ps, __locale_t loc) {
78 return btowc(c);116 __locale_guard __current(loc);
117 return std::mbrlen(s, n, ps);
79}118}
80int wctob_l(wint_t c, locale_t loc) {119
81 __libcpp_locale_guard __current(loc);120size_t __mbsrtowcs(
82 return wctob(c);121 wchar_t* __restrict dst, const char** __restrict src, size_t len, mbstate_t* __restrict ps, __locale_t loc) {
122 __locale_guard __current(loc);
123 return std::mbsrtowcs(dst, src, len, ps);
83}124}
84125
85int snprintf_l(char* ret, size_t n, locale_t loc, const char* format, ...) {126int __snprintf(char* ret, size_t n, __locale_t loc, const char* format, ...) {
86 va_list ap;127 va_list ap;
87 va_start(ap, format);128 va_start(ap, format);
88#if defined(_LIBCPP_MSVCRT)129#if defined(_LIBCPP_MSVCRT)
89 // FIXME: Remove usage of internal CRT function and globals.130 // FIXME: Remove usage of internal CRT function and globals.
90 int result = __stdio_common_vsprintf(131 int result = ::__stdio_common_vsprintf(
91 _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, ret, n, format, loc, ap);132 _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, ret, n, format, loc, ap);
92#else133#else
93 __libcpp_locale_guard __current(loc);134 __locale_guard __current(loc);
94 _LIBCPP_DIAGNOSTIC_PUSH135 _LIBCPP_DIAGNOSTIC_PUSH
95 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")136 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
96 int result = vsnprintf(ret, n, format, ap);137 int result = std::vsnprintf(ret, n, format, ap);
97 _LIBCPP_DIAGNOSTIC_POP138 _LIBCPP_DIAGNOSTIC_POP
98#endif139#endif
99 va_end(ap);140 va_end(ap);
100 return result;141 return result;
101}142}
102143
103int asprintf_l(char** ret, locale_t loc, const char* format, ...) {144// Like sprintf, but when return value >= 0 it returns
145// a pointer to a malloc'd string in *sptr.
146// If return >= 0, use free to delete *sptr.
147int __libcpp_vasprintf(char** sptr, const char* __restrict format, va_list ap) {
148 *sptr = nullptr;
149 // Query the count required.
150 va_list ap_copy;
151 va_copy(ap_copy, ap);
152 _LIBCPP_DIAGNOSTIC_PUSH
153 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
154 int count = vsnprintf(nullptr, 0, format, ap_copy);
155 _LIBCPP_DIAGNOSTIC_POP
156 va_end(ap_copy);
157 if (count < 0)
158 return count;
159 size_t buffer_size = static_cast<size_t>(count) + 1;
160 char* p = static_cast<char*>(malloc(buffer_size));
161 if (!p)
162 return -1;
163 // If we haven't used exactly what was required, something is wrong.
164 // Maybe bug in vsnprintf. Report the error and return.
165 _LIBCPP_DIAGNOSTIC_PUSH
166 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
167 if (vsnprintf(p, buffer_size, format, ap) != count) {
168 _LIBCPP_DIAGNOSTIC_POP
169 free(p);
170 return -1;
171 }
172 // All good. This is returning memory to the caller not freeing it.
173 *sptr = p;
174 return count;
175}
176
177int __asprintf(char** ret, __locale_t loc, const char* format, ...) {
104 va_list ap;178 va_list ap;
105 va_start(ap, format);179 va_start(ap, format);
106 int result = vasprintf_l(ret, loc, format, ap);180 __locale_guard __current(loc);
107 va_end(ap);
108 return result;
109}
110int vasprintf_l(char** ret, locale_t loc, const char* format, va_list ap) {
111 __libcpp_locale_guard __current(loc);
112 return __libcpp_vasprintf(ret, format, ap);181 return __libcpp_vasprintf(ret, format, ap);
113}182}
114183
115#if !defined(_LIBCPP_MSVCRT)184} // namespace __locale
116float strtof_l(const char* nptr, char** endptr, locale_t loc) {185_LIBCPP_END_NAMESPACE_STD
117 __libcpp_locale_guard __current(loc);
118 return strtof(nptr, endptr);
119}
120
121long double strtold_l(const char* nptr, char** endptr, locale_t loc) {
122 __libcpp_locale_guard __current(loc);
123 return strtold(nptr, endptr);
124}
125#endif
126
127#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
128size_t strftime_l(char* ret, size_t n, const char* format, const struct tm* tm, locale_t loc) {
129 __libcpp_locale_guard __current(loc);
130 return strftime(ret, n, format, tm);
131}
132#endif
lib/libcxx/src/support/win32/support.cpp+4-37
...@@ -13,39 +13,6 @@...@@ -13,39 +13,6 @@
13#include <cstring> // strcpy, wcsncpy13#include <cstring> // strcpy, wcsncpy
14#include <cwchar> // mbstate_t14#include <cwchar> // mbstate_t
1515
16// Like sprintf, but when return value >= 0 it returns
17// a pointer to a malloc'd string in *sptr.
18// If return >= 0, use free to delete *sptr.
19int __libcpp_vasprintf(char** sptr, const char* __restrict format, va_list ap) {
20 *sptr = NULL;
21 // Query the count required.
22 va_list ap_copy;
23 va_copy(ap_copy, ap);
24 _LIBCPP_DIAGNOSTIC_PUSH
25 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
26 int count = vsnprintf(NULL, 0, format, ap_copy);
27 _LIBCPP_DIAGNOSTIC_POP
28 va_end(ap_copy);
29 if (count < 0)
30 return count;
31 size_t buffer_size = static_cast<size_t>(count) + 1;
32 char* p = static_cast<char*>(malloc(buffer_size));
33 if (!p)
34 return -1;
35 // If we haven't used exactly what was required, something is wrong.
36 // Maybe bug in vsnprintf. Report the error and return.
37 _LIBCPP_DIAGNOSTIC_PUSH
38 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
39 if (vsnprintf(p, buffer_size, format, ap) != count) {
40 _LIBCPP_DIAGNOSTIC_POP
41 free(p);
42 return -1;
43 }
44 // All good. This is returning memory to the caller not freeing it.
45 *sptr = p;
46 return count;
47}
48
49// Returns >= 0: the number of wide characters found in the16// Returns >= 0: the number of wide characters found in the
50// multi byte sequence src (of src_size_bytes), that fit in the buffer dst17// multi byte sequence src (of src_size_bytes), that fit in the buffer dst
51// (of max_dest_chars elements size). The count returned excludes the18// (of max_dest_chars elements size). The count returned excludes the
...@@ -81,7 +48,7 @@ size_t mbsnrtowcs(wchar_t* __restrict dst,...@@ -81,7 +48,7 @@ size_t mbsnrtowcs(wchar_t* __restrict dst,
81 // if result > 0, it's the size in bytes of that character.48 // if result > 0, it's the size in bytes of that character.
82 // othewise if result is zero it indicates the null character has been found.49 // othewise if result is zero it indicates the null character has been found.
83 // otherwise it's an error and errno may be set.50 // otherwise it's an error and errno may be set.
84 size_t char_size = mbrtowc(dst ? dst + dest_converted : NULL, *src + source_converted, source_remaining, ps);51 size_t char_size = mbrtowc(dst ? dst + dest_converted : nullptr, *src + source_converted, source_remaining, ps);
85 // Don't do anything to change errno from here on.52 // Don't do anything to change errno from here on.
86 if (char_size > 0) {53 if (char_size > 0) {
87 source_remaining -= char_size;54 source_remaining -= char_size;
...@@ -95,7 +62,7 @@ size_t mbsnrtowcs(wchar_t* __restrict dst,...@@ -95,7 +62,7 @@ size_t mbsnrtowcs(wchar_t* __restrict dst,
95 }62 }
96 if (dst) {63 if (dst) {
97 if (have_result && result == terminated_sequence)64 if (have_result && result == terminated_sequence)
98 *src = NULL;65 *src = nullptr;
99 else66 else
100 *src += source_converted;67 *src += source_converted;
101 }68 }
...@@ -141,7 +108,7 @@ size_t wcsnrtombs(char* __restrict dst,...@@ -141,7 +108,7 @@ size_t wcsnrtombs(char* __restrict dst,
141 if (dst)108 if (dst)
142 result = wcrtomb_s(&char_size, dst + dest_converted, dest_remaining, c, ps);109 result = wcrtomb_s(&char_size, dst + dest_converted, dest_remaining, c, ps);
143 else110 else
144 result = wcrtomb_s(&char_size, NULL, 0, c, ps);111 result = wcrtomb_s(&char_size, nullptr, 0, c, ps);
145 // If result is zero there is no error and char_size contains the112 // If result is zero there is no error and char_size contains the
146 // size of the multi-byte-sequence converted.113 // size of the multi-byte-sequence converted.
147 // Otherwise result indicates an errno type error.114 // Otherwise result indicates an errno type error.
...@@ -161,7 +128,7 @@ size_t wcsnrtombs(char* __restrict dst,...@@ -161,7 +128,7 @@ size_t wcsnrtombs(char* __restrict dst,
161 }128 }
162 if (dst) {129 if (dst) {
163 if (terminator_found)130 if (terminator_found)
164 *src = NULL;131 *src = nullptr;
165 else132 else
166 *src = *src + source_converted;133 *src = *src + source_converted;
167 }134 }
lib/libcxx/src/support/win32/thread_win32.cpp+1-1
...@@ -129,7 +129,7 @@ __libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter,...@@ -129,7 +129,7 @@ __libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter,
129129
130int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)(void)) {130int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)(void)) {
131 if (!InitOnceExecuteOnce(131 if (!InitOnceExecuteOnce(
132 (PINIT_ONCE)__flag, __libcpp_init_once_execute_once_thunk, reinterpret_cast<void*>(__init_routine), NULL))132 (PINIT_ONCE)__flag, __libcpp_init_once_execute_once_thunk, reinterpret_cast<void*>(__init_routine), nullptr))
133 return GetLastError();133 return GetLastError();
134 return 0;134 return 0;
135}135}
lib/libcxx/src/system_error.cpp+158-12
...@@ -8,25 +8,138 @@...@@ -8,25 +8,138 @@
88
9#include <__assert>9#include <__assert>
10#include <__config>10#include <__config>
11#include <__system_error/throw_system_error.h>
11#include <__verbose_abort>12#include <__verbose_abort>
12#include <cerrno>13#include <cerrno>
13#include <cstdio>14#include <cstdio>
14#include <cstdlib>15#include <cstdlib>
15#include <cstring>16#include <cstring>
17#include <optional>
16#include <string.h>18#include <string.h>
17#include <string>19#include <string>
18#include <system_error>20#include <system_error>
1921
20#include "include/config_elast.h"22#include "include/config_elast.h"
2123
22#if defined(__ANDROID__)24#if defined(_LIBCPP_WIN32API)
23# include <android/api-level.h>25# include <windows.h>
26# include <winerror.h>
24#endif27#endif
2528
26_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
2730
31#if defined(_LIBCPP_WIN32API)
32
28namespace {33namespace {
29#if !defined(_LIBCPP_HAS_NO_THREADS)34std::optional<errc> __win_err_to_errc(int err) {
35 switch (err) {
36 case ERROR_ACCESS_DENIED:
37 return errc::permission_denied;
38 case ERROR_ALREADY_EXISTS:
39 return errc::file_exists;
40 case ERROR_BAD_NETPATH:
41 return errc::no_such_file_or_directory;
42 case ERROR_BAD_PATHNAME:
43 return errc::no_such_file_or_directory;
44 case ERROR_BAD_UNIT:
45 return errc::no_such_device;
46 case ERROR_BROKEN_PIPE:
47 return errc::broken_pipe;
48 case ERROR_BUFFER_OVERFLOW:
49 return errc::filename_too_long;
50 case ERROR_BUSY:
51 return errc::device_or_resource_busy;
52 case ERROR_BUSY_DRIVE:
53 return errc::device_or_resource_busy;
54 case ERROR_CANNOT_MAKE:
55 return errc::permission_denied;
56 case ERROR_CANTOPEN:
57 return errc::io_error;
58 case ERROR_CANTREAD:
59 return errc::io_error;
60 case ERROR_CANTWRITE:
61 return errc::io_error;
62 case ERROR_CURRENT_DIRECTORY:
63 return errc::permission_denied;
64 case ERROR_DEV_NOT_EXIST:
65 return errc::no_such_device;
66 case ERROR_DEVICE_IN_USE:
67 return errc::device_or_resource_busy;
68 case ERROR_DIR_NOT_EMPTY:
69 return errc::directory_not_empty;
70 case ERROR_DIRECTORY:
71 return errc::invalid_argument;
72 case ERROR_DISK_FULL:
73 return errc::no_space_on_device;
74 case ERROR_FILE_EXISTS:
75 return errc::file_exists;
76 case ERROR_FILE_NOT_FOUND:
77 return errc::no_such_file_or_directory;
78 case ERROR_HANDLE_DISK_FULL:
79 return errc::no_space_on_device;
80 case ERROR_INVALID_ACCESS:
81 return errc::permission_denied;
82 case ERROR_INVALID_DRIVE:
83 return errc::no_such_device;
84 case ERROR_INVALID_FUNCTION:
85 return errc::function_not_supported;
86 case ERROR_INVALID_HANDLE:
87 return errc::invalid_argument;
88 case ERROR_INVALID_NAME:
89 return errc::no_such_file_or_directory;
90 case ERROR_INVALID_PARAMETER:
91 return errc::invalid_argument;
92 case ERROR_LOCK_VIOLATION:
93 return errc::no_lock_available;
94 case ERROR_LOCKED:
95 return errc::no_lock_available;
96 case ERROR_NEGATIVE_SEEK:
97 return errc::invalid_argument;
98 case ERROR_NOACCESS:
99 return errc::permission_denied;
100 case ERROR_NOT_ENOUGH_MEMORY:
101 return errc::not_enough_memory;
102 case ERROR_NOT_READY:
103 return errc::resource_unavailable_try_again;
104 case ERROR_NOT_SAME_DEVICE:
105 return errc::cross_device_link;
106 case ERROR_NOT_SUPPORTED:
107 return errc::not_supported;
108 case ERROR_OPEN_FAILED:
109 return errc::io_error;
110 case ERROR_OPEN_FILES:
111 return errc::device_or_resource_busy;
112 case ERROR_OPERATION_ABORTED:
113 return errc::operation_canceled;
114 case ERROR_OUTOFMEMORY:
115 return errc::not_enough_memory;
116 case ERROR_PATH_NOT_FOUND:
117 return errc::no_such_file_or_directory;
118 case ERROR_READ_FAULT:
119 return errc::io_error;
120 case ERROR_REPARSE_TAG_INVALID:
121 return errc::invalid_argument;
122 case ERROR_RETRY:
123 return errc::resource_unavailable_try_again;
124 case ERROR_SEEK:
125 return errc::io_error;
126 case ERROR_SHARING_VIOLATION:
127 return errc::permission_denied;
128 case ERROR_TOO_MANY_OPEN_FILES:
129 return errc::too_many_files_open;
130 case ERROR_WRITE_FAULT:
131 return errc::io_error;
132 case ERROR_WRITE_PROTECT:
133 return errc::permission_denied;
134 default:
135 return {};
136 }
137}
138} // namespace
139#endif
140
141namespace {
142#if _LIBCPP_HAS_THREADS
30143
31// GLIBC also uses 1024 as the maximum buffer size internally.144// GLIBC also uses 1024 as the maximum buffer size internally.
32constexpr size_t strerror_buff_size = 1024;145constexpr size_t strerror_buff_size = 1024;
...@@ -92,7 +205,7 @@ string do_strerror_r(int ev) {...@@ -92,7 +205,7 @@ string do_strerror_r(int ev) {
92}205}
93# endif206# endif
94207
95#endif // !defined(_LIBCPP_HAS_NO_THREADS)208#endif // _LIBCPP_HAS_THREADS
96209
97string make_error_str(const error_code& ec, string what_arg) {210string make_error_str(const error_code& ec, string what_arg) {
98 if (ec) {211 if (ec) {
...@@ -110,10 +223,10 @@ string make_error_str(const error_code& ec) {...@@ -110,10 +223,10 @@ string make_error_str(const error_code& ec) {
110 }223 }
111 return string();224 return string();
112}225}
113} // end namespace226} // namespace
114227
115string __do_message::message(int ev) const {228string __do_message::message(int ev) const {
116#if defined(_LIBCPP_HAS_NO_THREADS)229#if !_LIBCPP_HAS_THREADS
117 return string(::strerror(ev));230 return string(::strerror(ev));
118#else231#else
119 return do_strerror_r(ev);232 return do_strerror_r(ev);
...@@ -156,19 +269,52 @@ public:...@@ -156,19 +269,52 @@ public:
156const char* __system_error_category::name() const noexcept { return "system"; }269const char* __system_error_category::name() const noexcept { return "system"; }
157270
158string __system_error_category::message(int ev) const {271string __system_error_category::message(int ev) const {
159#ifdef _LIBCPP_ELAST272#ifdef _LIBCPP_WIN32API
273 std::string result;
274 char* str = nullptr;
275 unsigned long num_chars = ::FormatMessageA(
276 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
277 nullptr,
278 ev,
279 0,
280 reinterpret_cast<char*>(&str),
281 0,
282 nullptr);
283 auto is_whitespace = [](char ch) { return ch == '\n' || ch == '\r' || ch == ' '; };
284 while (num_chars > 0 && is_whitespace(str[num_chars - 1]))
285 --num_chars;
286
287 if (num_chars)
288 result = std::string(str, num_chars);
289 else
290 result = "Unknown error";
291
292 LocalFree(str);
293 return result;
294#else
295# ifdef _LIBCPP_ELAST
160 if (ev > _LIBCPP_ELAST)296 if (ev > _LIBCPP_ELAST)
161 return string("unspecified system_category error");297 return string("unspecified system_category error");
162#endif // _LIBCPP_ELAST298# endif // _LIBCPP_ELAST
163 return __do_message::message(ev);299 return __do_message::message(ev);
300#endif
164}301}
165302
166error_condition __system_error_category::default_error_condition(int ev) const noexcept {303error_condition __system_error_category::default_error_condition(int ev) const noexcept {
167#ifdef _LIBCPP_ELAST304#ifdef _LIBCPP_WIN32API
305 // Remap windows error codes to generic error codes if possible.
306 if (ev == 0)
307 return error_condition(0, generic_category());
308 if (auto maybe_errc = __win_err_to_errc(ev))
309 return error_condition(static_cast<int>(*maybe_errc), generic_category());
310 return error_condition(ev, system_category());
311#else
312# ifdef _LIBCPP_ELAST
168 if (ev > _LIBCPP_ELAST)313 if (ev > _LIBCPP_ELAST)
169 return error_condition(ev, system_category());314 return error_condition(ev, system_category());
170#endif // _LIBCPP_ELAST315# endif // _LIBCPP_ELAST
171 return error_condition(ev, generic_category());316 return error_condition(ev, generic_category());
317#endif
172}318}
173319
174const error_category& system_category() noexcept {320const error_category& system_category() noexcept {
...@@ -211,8 +357,8 @@ system_error::system_error(int ev, const error_category& ecat)...@@ -211,8 +357,8 @@ system_error::system_error(int ev, const error_category& ecat)
211system_error::~system_error() noexcept {}357system_error::~system_error() noexcept {}
212358
213void __throw_system_error(int ev, const char* what_arg) {359void __throw_system_error(int ev, const char* what_arg) {
214#ifndef _LIBCPP_HAS_NO_EXCEPTIONS360#if _LIBCPP_HAS_EXCEPTIONS
215 std::__throw_system_error(error_code(ev, system_category()), what_arg);361 std::__throw_system_error(error_code(ev, generic_category()), what_arg);
216#else362#else
217 // The above could also handle the no-exception case, but for size, avoid referencing system_category() unnecessarily.363 // The above could also handle the no-exception case, but for size, avoid referencing system_category() unnecessarily.
218 _LIBCPP_VERBOSE_ABORT(364 _LIBCPP_VERBOSE_ABORT(
lib/libcxx/src/vector.cpp+2-2
...@@ -17,8 +17,8 @@ struct __vector_base_common;...@@ -17,8 +17,8 @@ struct __vector_base_common;
1717
18template <>18template <>
19struct __vector_base_common<true> {19struct __vector_base_common<true> {
20 _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const;20 [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const;
21 _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const;21 [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const;
22};22};
2323
24void __vector_base_common<true>::__throw_length_error() const { std::__throw_length_error("vector"); }24void __vector_base_common<true>::__throw_length_error() const { std::__throw_length_error("vector"); }
lib/libcxx/src/verbose_abort.cpp+2-14
...@@ -13,13 +13,8 @@...@@ -13,13 +13,8 @@
13#include <cstdlib>13#include <cstdlib>
1414
15#ifdef __BIONIC__15#ifdef __BIONIC__
16# include <android/api-level.h>16# include <syslog.h>
17# if __ANDROID_API__ >= 21
18# include <syslog.h>
19extern "C" void android_set_abort_message(const char* msg);17extern "C" void android_set_abort_message(const char* msg);
20# else
21# include <assert.h>
22# endif // __ANDROID_API__ >= 21
23#endif // __BIONIC__18#endif // __BIONIC__
2419
25#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>)20#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>)
...@@ -28,7 +23,7 @@ extern "C" void android_set_abort_message(const char* msg);...@@ -28,7 +23,7 @@ extern "C" void android_set_abort_message(const char* msg);
2823
29_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
3025
31_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) {26_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT {
32 // Write message to stderr. We do this before formatting into a27 // Write message to stderr. We do this before formatting into a
33 // buffer so that we still get some information out if that fails.28 // buffer so that we still get some information out if that fails.
34 {29 {
...@@ -54,7 +49,6 @@ _LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) {...@@ -54,7 +49,6 @@ _LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) {
54#elif defined(__BIONIC__)49#elif defined(__BIONIC__)
55 vasprintf(&buffer, format, list);50 vasprintf(&buffer, format, list);
5651
57# if __ANDROID_API__ >= 21
58 // Show error in tombstone.52 // Show error in tombstone.
59 android_set_abort_message(buffer);53 android_set_abort_message(buffer);
6054
...@@ -62,12 +56,6 @@ _LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) {...@@ -62,12 +56,6 @@ _LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) {
62 openlog("libc++", 0, 0);56 openlog("libc++", 0, 0);
63 syslog(LOG_CRIT, "%s", buffer);57 syslog(LOG_CRIT, "%s", buffer);
64 closelog();58 closelog();
65# else
66 // The good error reporting wasn't available in Android until L. Since we're
67 // about to abort anyway, just call __assert2, which will log _somewhere_
68 // (tombstone and/or logcat) in older releases.
69 __assert2(__FILE__, __LINE__, __func__, buffer);
70# endif // __ANDROID_API__ >= 21
71#endif59#endif
72 va_end(list);60 va_end(list);
7361
src/Compilation.zig+1-23
...@@ -5776,29 +5776,7 @@ pub fn addCCArgs(...@@ -5776,29 +5776,7 @@ pub fn addCCArgs(
5776 comp.zig_lib_directory.path.?, "libcxxabi", "include",5776 comp.zig_lib_directory.path.?, "libcxxabi", "include",
5777 }));5777 }));
57785778
5779 if (target.abi.isMusl()) {5779 try libcxx.addCxxArgs(comp, arena, argv);
5780 try argv.append("-D_LIBCPP_HAS_MUSL_LIBC");
5781 }
5782
5783 try argv.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
5784 try argv.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS");
5785 try argv.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");
5786
5787 if (!comp.config.any_non_single_threaded) {
5788 try argv.append("-D_LIBCPP_HAS_NO_THREADS");
5789 }
5790
5791 // See the comment in libcxx.zig for more details about this.
5792 try argv.append("-D_LIBCPP_PSTL_BACKEND_SERIAL");
5793
5794 try argv.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{
5795 @intFromEnum(comp.libcxx_abi_version),
5796 }));
5797 try argv.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{
5798 @intFromEnum(comp.libcxx_abi_version),
5799 }));
5800
5801 try argv.append(libcxx.hardeningModeFlag(mod.optimize_mode));
5802 }5780 }
58035781
5804 // According to Rich Felker libc headers are supposed to go before C language headers.5782 // According to Rich Felker libc headers are supposed to go before C language headers.
src/libcxx.zig+72-90
...@@ -62,7 +62,6 @@ const libcxx_base_files = [_][]const u8{...@@ -62,7 +62,6 @@ const libcxx_base_files = [_][]const u8{
62 "src/ios.cpp",62 "src/ios.cpp",
63 "src/ios.instantiations.cpp",63 "src/ios.instantiations.cpp",
64 "src/iostream.cpp",64 "src/iostream.cpp",
65 "src/legacy_pointer_safety.cpp",
66 "src/locale.cpp",65 "src/locale.cpp",
67 "src/memory.cpp",66 "src/memory.cpp",
68 "src/memory_resource.cpp",67 "src/memory_resource.cpp",
...@@ -145,12 +144,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!...@@ -145,12 +144,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
145 const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" });144 const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" });
146 const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" });145 const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" });
147 const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" });146 const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" });
148 const abi_version_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{147 const cxx_libc_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "libc" });
149 @intFromEnum(comp.libcxx_abi_version),
150 });
151 const abi_namespace_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{
152 @intFromEnum(comp.libcxx_abi_version),
153 });
154148
155 const optimize_mode = comp.compilerRtOptMode();149 const optimize_mode = comp.compilerRtOptMode();
156 const strip = comp.compilerRtStrip();150 const strip = comp.compilerRtStrip();
...@@ -220,59 +214,27 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!...@@ -220,59 +214,27 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
220 var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxx_files.len);214 var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxx_files.len);
221215
222 for (libcxx_files) |cxx_src| {216 for (libcxx_files) |cxx_src| {
223 var cflags = std.ArrayList([]const u8).init(arena);217 // These don't compile on WASI due to e.g. `fchmod` usage.
224218 if (std.mem.startsWith(u8, cxx_src, "src/filesystem/") and target.os.tag == .wasi)
225 if ((target.os.tag == .windows and (target.abi == .msvc or target.abi == .itanium)) or target.os.tag == .wasi) {219 continue;
226 // Filesystem stuff isn't supported on WASI and Windows (MSVC).
227 if (std.mem.startsWith(u8, cxx_src, "src/filesystem/"))
228 continue;
229 }
230
231 if (std.mem.startsWith(u8, cxx_src, "src/support/win32/") and target.os.tag != .windows)220 if (std.mem.startsWith(u8, cxx_src, "src/support/win32/") and target.os.tag != .windows)
232 continue;221 continue;
233 if (std.mem.startsWith(u8, cxx_src, "src/support/ibm/") and target.os.tag != .zos)222 if (std.mem.startsWith(u8, cxx_src, "src/support/ibm/") and target.os.tag != .zos)
234 continue;223 continue;
235 if (!comp.config.any_non_single_threaded)224
236 try cflags.append("-D_LIBCPP_HAS_NO_THREADS");225 var cflags = std.ArrayList([]const u8).init(arena);
226
227 try addCxxArgs(comp, arena, &cflags);
237228
238 try cflags.append("-DNDEBUG");229 try cflags.append("-DNDEBUG");
239 try cflags.append(hardeningModeFlag(optimize_mode));230 try cflags.append("-DLIBC_NAMESPACE=__llvm_libc_common_utils");
240 try cflags.append("-D_LIBCPP_BUILDING_LIBRARY");231 try cflags.append("-D_LIBCPP_BUILDING_LIBRARY");
241 try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
242 try cflags.append("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER");
243 try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS");
244 try cflags.append("-DLIBCXX_BUILDING_LIBCXXABI");232 try cflags.append("-DLIBCXX_BUILDING_LIBCXXABI");
245 try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");233 try cflags.append("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER");
246
247 // See libcxx/include/__algorithm/pstl_backends/cpu_backends/backend.h
248 // for potentially enabling some fancy features here, which would
249 // require corresponding changes in libcxx.zig, as well as
250 // Compilation.addCCArgs. This option makes it use serial backend which
251 // is simple and works everywhere.
252 try cflags.append("-D_LIBCPP_PSTL_BACKEND_SERIAL");
253
254 try cflags.append(abi_version_arg);
255 try cflags.append(abi_namespace_arg);
256234
257 try cflags.append("-fvisibility=hidden");235 try cflags.append("-fvisibility=hidden");
258 try cflags.append("-fvisibility-inlines-hidden");236 try cflags.append("-fvisibility-inlines-hidden");
259237
260 if (target.abi.isMusl()) {
261 try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC");
262 }
263
264 if (target.isGnuLibC()) {
265 // glibc 2.16 introduced aligned_alloc
266 if (target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) {
267 try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION");
268 }
269 }
270
271 if (target.os.tag == .wasi) {
272 // WASI doesn't support exceptions yet.
273 try cflags.append("-fno-exceptions");
274 }
275
276 if (target.os.tag == .zos) {238 if (target.os.tag == .zos) {
277 try cflags.append("-fno-aligned-allocation");239 try cflags.append("-fno-aligned-allocation");
278 } else {240 } else {
...@@ -299,6 +261,9 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!...@@ -299,6 +261,9 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
299 try cache_exempt_flags.append("-I");261 try cache_exempt_flags.append("-I");
300 try cache_exempt_flags.append(cxx_src_include_path);262 try cache_exempt_flags.append(cxx_src_include_path);
301263
264 try cache_exempt_flags.append("-I");
265 try cache_exempt_flags.append(cxx_libc_include_path);
266
302 c_source_files.appendAssumeCapacity(.{267 c_source_files.appendAssumeCapacity(.{
303 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", cxx_src }),268 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", cxx_src }),
304 .extra_flags = cflags.items,269 .extra_flags = cflags.items,
...@@ -389,12 +354,6 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr...@@ -389,12 +354,6 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
389 const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" });354 const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" });
390 const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" });355 const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" });
391 const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" });356 const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" });
392 const abi_version_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{
393 @intFromEnum(comp.libcxx_abi_version),
394 });
395 const abi_namespace_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{
396 @intFromEnum(comp.libcxx_abi_version),
397 });
398357
399 const optimize_mode = comp.compilerRtOptMode();358 const optimize_mode = comp.compilerRtOptMode();
400 const strip = comp.compilerRtStrip();359 const strip = comp.compilerRtStrip();
...@@ -465,51 +424,26 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr...@@ -465,51 +424,26 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
465 var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxxabi_files.len);424 var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxxabi_files.len);
466425
467 for (libcxxabi_files) |cxxabi_src| {426 for (libcxxabi_files) |cxxabi_src| {
427 if (!comp.config.any_non_single_threaded and std.mem.startsWith(u8, cxxabi_src, "src/cxa_thread_atexit.cpp"))
428 continue;
429
468 var cflags = std.ArrayList([]const u8).init(arena);430 var cflags = std.ArrayList([]const u8).init(arena);
469431
470 if (target.os.tag == .wasi) {432 try addCxxArgs(comp, arena, &cflags);
471 // WASI doesn't support exceptions yet.
472 if (std.mem.startsWith(u8, cxxabi_src, "src/cxa_exception.cpp") or
473 std.mem.startsWith(u8, cxxabi_src, "src/cxa_personality.cpp"))
474 continue;
475 try cflags.append("-fno-exceptions");
476 }
477433
478 // WASM targets are single threaded.434 try cflags.append("-DNDEBUG");
435 try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY");
479 if (!comp.config.any_non_single_threaded) {436 if (!comp.config.any_non_single_threaded) {
480 if (std.mem.startsWith(u8, cxxabi_src, "src/cxa_thread_atexit.cpp")) {
481 continue;
482 }
483 try cflags.append("-D_LIBCXXABI_HAS_NO_THREADS");437 try cflags.append("-D_LIBCXXABI_HAS_NO_THREADS");
484 } else if (target.abi.isGnu()) {438 }
439 if (target.abi.isGnu()) {
485 if (target.os.tag != .linux or !(target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 18, .patch = 0 }) == .lt))440 if (target.os.tag != .linux or !(target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 18, .patch = 0 }) == .lt))
486 try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL");441 try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL");
487 }442 }
488443
489 try cflags.append("-DNDEBUG");
490 try cflags.append(hardeningModeFlag(optimize_mode));
491 try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY");
492 try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");
493 try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
494 try cflags.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS");
495
496 try cflags.append(abi_version_arg);
497 try cflags.append(abi_namespace_arg);
498
499 try cflags.append("-fvisibility=hidden");444 try cflags.append("-fvisibility=hidden");
500 try cflags.append("-fvisibility-inlines-hidden");445 try cflags.append("-fvisibility-inlines-hidden");
501446
502 if (target.abi.isMusl()) {
503 try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC");
504 }
505
506 if (target.isGnuLibC()) {
507 // glibc 2.16 introduced aligned_alloc
508 if (target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) {
509 try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION");
510 }
511 }
512
513 if (target_util.supports_fpic(target)) {447 if (target_util.supports_fpic(target)) {
514 try cflags.append("-fPIC");448 try cflags.append("-fPIC");
515 }449 }
...@@ -593,10 +527,58 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr...@@ -593,10 +527,58 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
593 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);527 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
594}528}
595529
596pub fn hardeningModeFlag(optimize_mode: std.builtin.OptimizeMode) []const u8 {530pub fn addCxxArgs(
597 return switch (optimize_mode) {531 comp: *const Compilation,
532 arena: std.mem.Allocator,
533 cflags: *std.ArrayList([]const u8),
534) error{OutOfMemory}!void {
535 const target = comp.getTarget();
536 const optimize_mode = comp.compilerRtOptMode();
537
538 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{
539 @intFromEnum(comp.libcxx_abi_version),
540 }));
541 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{
542 @intFromEnum(comp.libcxx_abi_version),
543 }));
544 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}THREADS", .{
545 if (!comp.config.any_non_single_threaded) "NO_" else "",
546 }));
547 try cflags.append("-D_LIBCPP_HAS_MONOTONIC_CLOCK");
548 try cflags.append("-D_LIBCPP_HAS_TERMINAL");
549 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}MUSL_LIBC", .{
550 if (!target.abi.isMusl()) "NO_" else "",
551 }));
552 try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");
553 try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
554 try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS");
555 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}FILESYSTEM", .{
556 if (target.os.tag == .wasi) "NO_" else "",
557 }));
558 try cflags.append("-D_LIBCPP_HAS_RANDOM_DEVICE");
559 try cflags.append("-D_LIBCPP_HAS_LOCALIZATION");
560 try cflags.append("-D_LIBCPP_HAS_UNICODE");
561 try cflags.append("-D_LIBCPP_HAS_WIDE_CHARACTERS");
562 try cflags.append("-D_LIBCPP_HAS_NO_STD_MODULES");
563 if (target.os.tag == .linux) {
564 try cflags.append("-D_LIBCPP_HAS_TIME_ZONE_DATABASE");
565 }
566 // See libcxx/include/__algorithm/pstl_backends/cpu_backends/backend.h
567 // for potentially enabling some fancy features here, which would
568 // require corresponding changes in libcxx.zig, as well as
569 // Compilation.addCCArgs. This option makes it use serial backend which
570 // is simple and works everywhere.
571 try cflags.append("-D_LIBCPP_PSTL_BACKEND_SERIAL");
572 try cflags.append(switch (optimize_mode) {
598 .Debug => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG",573 .Debug => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG",
599 .ReleaseFast, .ReleaseSmall => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE",574 .ReleaseFast, .ReleaseSmall => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE",
600 .ReleaseSafe => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST",575 .ReleaseSafe => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST",
601 };576 });
577 if (target.isGnuLibC()) {
578 // glibc 2.16 introduced aligned_alloc
579 if (target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) {
580 try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION");
581 }
582 }
583 try cflags.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS");
602}584}